From 44be74a3157112c5018a87f5c2158522a1b68019 Mon Sep 17 00:00:00 2001 From: Chris Banes Date: Tue, 1 Jun 2021 17:19:48 +0100 Subject: [PATCH] [DrawablePainter] Stop pre-scaling the Canvas We no longer need to pre-scale the Canvas as the modifier is now responsible for scaling and positioning the canvas as appropriate. --- .../accompanist/imageloading/DrawablePainter.kt | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/imageloading-core/src/main/java/com/google/accompanist/imageloading/DrawablePainter.kt b/imageloading-core/src/main/java/com/google/accompanist/imageloading/DrawablePainter.kt index 8c194ef0d..125e4583f 100644 --- a/imageloading-core/src/main/java/com/google/accompanist/imageloading/DrawablePainter.kt +++ b/imageloading-core/src/main/java/com/google/accompanist/imageloading/DrawablePainter.kt @@ -129,18 +129,10 @@ class DrawablePainter( // Reading this ensures that we invalidate when invalidateDrawable() is called invalidateTick + // Update the Drawable's bounds + drawable.setBounds(0, 0, size.width.roundToInt(), size.height.roundToInt()) + canvas.withSave { - if (drawable.intrinsicWidth > 0 && drawable.intrinsicHeight > 0) { - // Painters are responsible for scaling content to meet the canvas size - canvas.scale( - sx = size.width / drawable.intrinsicWidth, - sy = size.height / drawable.intrinsicHeight - ) - } else { - // If the drawable has no intrinsic bounds, set its bounds to be the - // canvas size - drawable.setBounds(0, 0, size.width.roundToInt(), size.height.roundToInt()) - } drawable.draw(canvas.nativeCanvas) } }