File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 33// SPDX-License-Identifier: AGPL-3.0-only
44//
55
6+ import SignalCoreKit
7+
68public class GradientView : UIView {
79
810 public override class var layerClass : AnyClass { CAGradientLayer . self }
@@ -38,17 +40,27 @@ public class GradientView: UIView {
3840 }
3941
4042 private func updateGradientColors( ) {
43+ guard gradientWithinPerformanceLimits ( ) else { return }
4144 gradientLayer. colors = colors. map { $0. cgColor }
4245 }
4346
4447 private func updateGradientLocations( ) {
48+ guard gradientWithinPerformanceLimits ( ) else { return }
4549 if let locations = locations, !locations. isEmpty {
4650 gradientLayer. locations = locations. map { NSNumber ( value: $0) }
4751 } else {
4852 gradientLayer. locations = nil
4953 }
5054 }
5155
56+ private func gradientWithinPerformanceLimits( ) -> Bool {
57+ if ( colors. count * 4 + ( locations? . count ?? 0 ) ) > 512 {
58+ owsFailDebug ( " Too many gradient points " )
59+ return false
60+ }
61+ return true
62+ }
63+
5264 /// Sets the `startPoint` and `endPoint` of the layer to reflect an angle in degrees
5365 /// where 0° starts at 12 o'clock and proceeds in a clockwise direction.
5466 public func setAngle( _ angle: UInt32 ) {
You can’t perform that action at this time.
0 commit comments