diff --git a/coil-base/src/main/java/coil/RealImageLoader.kt b/coil-base/src/main/java/coil/RealImageLoader.kt index 9e2d63fd75..eef8bcdcf1 100644 --- a/coil-base/src/main/java/coil/RealImageLoader.kt +++ b/coil-base/src/main/java/coil/RealImageLoader.kt @@ -328,8 +328,8 @@ internal class RealImageLoader( val multiple = DecodeUtils.computeSizeMultiplier( srcWidth = bitmap.width, srcHeight = bitmap.height, - destWidth = size.width, - destHeight = size.height, + dstWidth = size.width, + dstHeight = size.height, scale = scale ) if (multiple != 1.0 && !requestService.allowInexactSize(request)) { diff --git a/coil-base/src/main/java/coil/decode/BitmapFactoryDecoder.kt b/coil-base/src/main/java/coil/decode/BitmapFactoryDecoder.kt index 4cb7dd1949..689f42c72e 100644 --- a/coil-base/src/main/java/coil/decode/BitmapFactoryDecoder.kt +++ b/coil-base/src/main/java/coil/decode/BitmapFactoryDecoder.kt @@ -95,8 +95,8 @@ internal class BitmapFactoryDecoder(private val context: Context) : Decoder { val rawScale = DecodeUtils.computeSizeMultiplier( srcWidth = srcWidth / inSampleSize.toDouble(), srcHeight = srcHeight / inSampleSize.toDouble(), - destWidth = width.toDouble(), - destHeight = height.toDouble(), + dstWidth = width.toDouble(), + dstHeight = height.toDouble(), scale = options.scale ) diff --git a/coil-base/src/main/java/coil/decode/DecodeUtils.kt b/coil-base/src/main/java/coil/decode/DecodeUtils.kt index 39822f80a2..61edbdd1f7 100644 --- a/coil-base/src/main/java/coil/decode/DecodeUtils.kt +++ b/coil-base/src/main/java/coil/decode/DecodeUtils.kt @@ -43,18 +43,18 @@ object DecodeUtils { /** * Calculate the [BitmapFactory.Options.inSampleSize] given the source dimensions of the image - * ([srcWidth] and [srcHeight]), the output dimensions ([destWidth], [destHeight]), and the [scale]. + * ([srcWidth] and [srcHeight]), the output dimensions ([dstWidth], [dstHeight]), and the [scale]. */ @JvmStatic fun calculateInSampleSize( @Px srcWidth: Int, @Px srcHeight: Int, - @Px destWidth: Int, - @Px destHeight: Int, + @Px dstWidth: Int, + @Px dstHeight: Int, scale: Scale ): Int { - val widthInSampleSize = Integer.highestOneBit(srcWidth / destWidth).coerceAtLeast(1) - val heightInSampleSize = Integer.highestOneBit(srcHeight / destHeight).coerceAtLeast(1) + val widthInSampleSize = Integer.highestOneBit(srcWidth / dstWidth).coerceAtLeast(1) + val heightInSampleSize = Integer.highestOneBit(srcHeight / dstHeight).coerceAtLeast(1) return when (scale) { Scale.FILL -> min(widthInSampleSize, heightInSampleSize) Scale.FIT -> max(widthInSampleSize, heightInSampleSize) @@ -69,12 +69,12 @@ object DecodeUtils { fun computeSizeMultiplier( @Px srcWidth: Int, @Px srcHeight: Int, - @Px destWidth: Int, - @Px destHeight: Int, + @Px dstWidth: Int, + @Px dstHeight: Int, scale: Scale ): Double { - val widthPercent = destWidth / srcWidth.toDouble() - val heightPercent = destHeight / srcHeight.toDouble() + val widthPercent = dstWidth / srcWidth.toDouble() + val heightPercent = dstHeight / srcHeight.toDouble() return when (scale) { Scale.FILL -> max(widthPercent, heightPercent) Scale.FIT -> min(widthPercent, heightPercent) @@ -86,12 +86,12 @@ object DecodeUtils { fun computeSizeMultiplier( @Px srcWidth: Float, @Px srcHeight: Float, - @Px destWidth: Float, - @Px destHeight: Float, + @Px dstWidth: Float, + @Px dstHeight: Float, scale: Scale ): Float { - val widthPercent = destWidth / srcWidth - val heightPercent = destHeight / srcHeight + val widthPercent = dstWidth / srcWidth + val heightPercent = dstHeight / srcHeight return when (scale) { Scale.FILL -> max(widthPercent, heightPercent) Scale.FIT -> min(widthPercent, heightPercent) @@ -103,12 +103,12 @@ object DecodeUtils { fun computeSizeMultiplier( @Px srcWidth: Double, @Px srcHeight: Double, - @Px destWidth: Double, - @Px destHeight: Double, + @Px dstWidth: Double, + @Px dstHeight: Double, scale: Scale ): Double { - val widthPercent = destWidth / srcWidth - val heightPercent = destHeight / srcHeight + val widthPercent = dstWidth / srcWidth + val heightPercent = dstHeight / srcHeight return when (scale) { Scale.FILL -> max(widthPercent, heightPercent) Scale.FIT -> min(widthPercent, heightPercent) diff --git a/coil-base/src/main/java/coil/decode/DrawableDecoderService.kt b/coil-base/src/main/java/coil/decode/DrawableDecoderService.kt index 30828d699d..7c90c19c14 100644 --- a/coil-base/src/main/java/coil/decode/DrawableDecoderService.kt +++ b/coil-base/src/main/java/coil/decode/DrawableDecoderService.kt @@ -56,8 +56,8 @@ internal class DrawableDecoderService(private val bitmapPool: BitmapPool) { val multiplier = DecodeUtils.computeSizeMultiplier( srcWidth = intrinsicWidth, srcHeight = intrinsicHeight, - destWidth = size.width, - destHeight = size.height, + dstWidth = size.width, + dstHeight = size.height, scale = Scale.FIT ) width = (multiplier * intrinsicWidth).roundToInt() diff --git a/coil-base/src/main/java/coil/drawable/CrossfadeDrawable.kt b/coil-base/src/main/java/coil/drawable/CrossfadeDrawable.kt index 0c8c9f554a..f62bd2f9ff 100644 --- a/coil-base/src/main/java/coil/drawable/CrossfadeDrawable.kt +++ b/coil-base/src/main/java/coil/drawable/CrossfadeDrawable.kt @@ -246,13 +246,7 @@ class CrossfadeDrawable( val targetWidth = targetBounds.width() val targetHeight = targetBounds.height() - val multiplier = DecodeUtils.computeSizeMultiplier( - srcWidth = width, - srcHeight = height, - destWidth = targetWidth, - destHeight = targetHeight, - scale = scale - ) + val multiplier = DecodeUtils.computeSizeMultiplier(width, height, targetWidth, targetHeight, scale) val dx = ((targetWidth - multiplier * width) / 2).roundToInt() val dy = ((targetHeight - multiplier * height) / 2).roundToInt() diff --git a/coil-base/src/main/java/coil/transform/RoundedCornersTransformation.kt b/coil-base/src/main/java/coil/transform/RoundedCornersTransformation.kt index 25ebe3febb..cad1d260f9 100644 --- a/coil-base/src/main/java/coil/transform/RoundedCornersTransformation.kt +++ b/coil-base/src/main/java/coil/transform/RoundedCornersTransformation.kt @@ -54,8 +54,8 @@ class RoundedCornersTransformation( val multiplier = DecodeUtils.computeSizeMultiplier( srcWidth = input.width, srcHeight = input.height, - destWidth = size.width, - destHeight = size.height, + dstWidth = size.width, + dstHeight = size.height, scale = Scale.FILL ) outputWidth = (size.width / multiplier).roundToInt() diff --git a/coil-gif/src/main/java/coil/decode/ImageDecoderDecoder.kt b/coil-gif/src/main/java/coil/decode/ImageDecoderDecoder.kt index 74e5a67cdb..122f0ee3a3 100644 --- a/coil-gif/src/main/java/coil/decode/ImageDecoderDecoder.kt +++ b/coil-gif/src/main/java/coil/decode/ImageDecoderDecoder.kt @@ -56,8 +56,8 @@ class ImageDecoderDecoder : Decoder { val multiplier = DecodeUtils.computeSizeMultiplier( srcWidth = infoSize.width, srcHeight = infoSize.height, - destWidth = size.width, - destHeight = size.height, + dstWidth = size.width, + dstHeight = size.height, scale = options.scale ) if (multiplier < 1) { diff --git a/coil-gif/src/main/java/coil/drawable/ScaleDrawable.kt b/coil-gif/src/main/java/coil/drawable/ScaleDrawable.kt index b57e5cbf25..78b0b54a08 100644 --- a/coil-gif/src/main/java/coil/drawable/ScaleDrawable.kt +++ b/coil-gif/src/main/java/coil/drawable/ScaleDrawable.kt @@ -76,13 +76,7 @@ class ScaleDrawable( val targetWidth = bounds.width() val targetHeight = bounds.height() - val multiplier = DecodeUtils.computeSizeMultiplier( - srcWidth = width, - srcHeight = height, - destWidth = targetWidth, - destHeight = targetHeight, - scale = scale - ) + val multiplier = DecodeUtils.computeSizeMultiplier(width, height, targetWidth, targetHeight, scale) val left = ((targetWidth - multiplier * width) / 2).roundToInt() val top = ((targetHeight - multiplier * height) / 2).roundToInt() diff --git a/coil-svg/src/main/java/coil/decode/SvgDecoder.kt b/coil-svg/src/main/java/coil/decode/SvgDecoder.kt index 1a450275a2..6037c4b3b1 100644 --- a/coil-svg/src/main/java/coil/decode/SvgDecoder.kt +++ b/coil-svg/src/main/java/coil/decode/SvgDecoder.kt @@ -46,8 +46,8 @@ class SvgDecoder(private val context: Context) : Decoder { val multiplier = DecodeUtils.computeSizeMultiplier( srcWidth = svgWidth, srcHeight = svgHeight, - destWidth = size.width.toFloat(), - destHeight = size.height.toFloat(), + dstWidth = size.width.toFloat(), + dstHeight = size.height.toFloat(), scale = options.scale ) bitmapWidth = (multiplier * svgWidth).toInt()