Skip to content

Commit

Permalink
Avoid drawing placeholder when it shouldn't be used
Browse files Browse the repository at this point in the history
  • Loading branch information
sjudd committed Oct 2, 2023
1 parent 1863e67 commit b1c6076
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,15 @@ internal class GlideNode : DrawModifierNode, LayoutModifierNode, SemanticsModifi
override fun ContentDrawScope.draw() {
if (draw) {
val drawPlaceholder = transition.drawPlaceholder ?: DoNotTransition.drawPlaceholder
placeholder?.let { painter ->
drawContext.canvas.withSave {
placeholderPositionAndSize = drawOne(painter, placeholderPositionAndSize) { size ->
drawPlaceholder.invoke(this, painter, size, alpha, colorFilter)
// If we're only showing the placeholder, it should just be drawn as the primary image.
// If we've loaded a full image and we have a placeholder, then we should try to draw both so
// that the transition can decide what to do.
if (placeholder != primary && transition != DoNotTransition) {
placeholder?.let { painter ->
drawContext.canvas.withSave {
placeholderPositionAndSize = drawOne(painter, placeholderPositionAndSize) { size ->
drawPlaceholder.invoke(this, painter, size, alpha, colorFilter)
}
}
}
}
Expand Down

0 comments on commit b1c6076

Please sign in to comment.