Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Sources/SkipUI/SkipUI/Graphics/Gradient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ public struct LinearGradient : ShapeStyle, Renderable {

@Composable override func asBrush(opacity: Double, animationContext: ComposeContext?) -> Brush? {
let stops = gradient.colorStops(opacity: opacity)
return LinearGradientShaderBrush(colorStops: stops, startPoint: startPoint, endPoint: endPoint)
return remember(gradient, startPoint, endPoint, opacity) {
Comment thread
dfabulich marked this conversation as resolved.
LinearGradientShaderBrush(colorStops: stops, startPoint: startPoint, endPoint: endPoint)
}
}

private struct LinearGradientShaderBrush: ShaderBrush {
Expand Down Expand Up @@ -207,7 +209,9 @@ public struct EllipticalGradient : ShapeStyle, Renderable {

@Composable override func asBrush(opacity: Double, animationContext: ComposeContext?) -> Brush? {
let stops = gradient.colorStops(opacity: opacity)
return RadialGradientShaderBrush(colorStops: stops, center: center, startFraction: startFraction, endFraction: endFraction)
return remember(gradient, center, startFraction, endFraction, opacity) {
RadialGradientShaderBrush(colorStops: stops, center: center, startFraction: startFraction, endFraction: endFraction)
}
}

private struct RadialGradientShaderBrush: ShaderBrush {
Expand Down Expand Up @@ -275,7 +279,9 @@ public struct RadialGradient : ShapeStyle, Renderable {
let start = with(density) { startRadius.dp.toPx() }
let end = with(density) { endRadius.dp.toPx() }
let stops = gradient.colorStops(opacity: opacity)
return RadialGradientShaderBrush(colorStops: stops, center: center, startRadius: start, endRadius: end)
return remember(gradient, center, start, end, opacity) {
RadialGradientShaderBrush(colorStops: stops, center: center, startRadius: start, endRadius: end)
}
}

private struct RadialGradientShaderBrush: ShaderBrush {
Expand Down