@@ -13,6 +13,7 @@ import android.graphics.Canvas
1313import android.graphics.Matrix
1414import android.graphics.Paint
1515import android.graphics.Shader
16+ import android.os.Build
1617import com.facebook.fresco.vito.renderer.util.ColorUtils
1718
1819typealias RenderCommand = (Canvas ) -> Unit
@@ -83,14 +84,21 @@ object ImageRenderer {
8384 shape.rect.right.toInt(),
8485 shape.rect.bottom.toInt())
8586 }
86- drawable.colorFilter = paint.colorFilter
87+ // Some drawable types (eg VectorDrawable) will always invalidate when colorFilter
88+ // is modified, so check the current value before we update it
89+ if (Build .VERSION .SDK_INT < 21 || drawable.colorFilter != paint.colorFilter) {
90+ drawable.colorFilter = paint.colorFilter
91+ }
8792 drawable.alpha = paint.alpha
8893 drawable.draw(canvas)
8994 }
9095 else -> {
9196 return { canvas ->
9297 drawable.setBounds(0 , 0 , width, height)
93- drawable.colorFilter = null // The Paint handles the color filter
98+ if (Build .VERSION .SDK_INT < 21 || drawable.colorFilter != null ) {
99+ // The Paint handles the color filter
100+ drawable.colorFilter = null
101+ }
94102 val bitmap = Bitmap .createBitmap(width, height, Bitmap .Config .ARGB_8888 )
95103 drawable.draw(Canvas (bitmap))
96104 paint.setBitmap(bitmap, imageTransformation)
0 commit comments