@@ -31,7 +31,6 @@ package com.github.awxkee.avifcoil.decoder.animation
3131import android.graphics.Bitmap
3232import android.graphics.Canvas
3333import android.graphics.ColorFilter
34- import android.graphics.Matrix
3534import android.graphics.Paint
3635import android.graphics.Rect
3736import android.graphics.drawable.Animatable
@@ -78,39 +77,27 @@ public class AnimatedDrawable(
7877
7978 private val measuredTimesStore = mutableListOf<Int >()
8079
81- private var shouldClearCache = frameStore.framesCount > preheatFrames
82-
8380 private fun makeDecodingRunner (
8481 nextFrameIndex : Int
8582 ): Runnable = DecodeFrameRunnable (
8683 syncedFrames = syncedFrames,
8784 frameStore = frameStore,
8885 lock = lock,
8986 nextFrameIndex = nextFrameIndex,
90- measuredTimesStore = measuredTimesStore,
91- preheatFrames = preheatFrames,
92- shouldClearCache = shouldClearCache
87+ measuredTimesStore = measuredTimesStore
9388 )
9489
9590 private class DecodeFrameRunnable (
9691 private val syncedFrames : MutableList <SyncedFrame >,
9792 private val frameStore : AnimatedFrameStore ,
9893 private val lock : Any ,
9994 private val nextFrameIndex : Int ,
100- private val measuredTimesStore : MutableList <Int >,
101- private val preheatFrames : Int ,
102- private val shouldClearCache : Boolean
95+ private val measuredTimesStore : MutableList <Int >
10396 ) : Runnable {
10497 override fun run () {
10598 val measureTime = measureTimeMillis {
10699 val syncedNextFrame = syncedFrames.firstOrNull { it.frameIndex == nextFrameIndex }
107100 if (syncedNextFrame == null ) {
108- if (shouldClearCache) {
109- val firstFromNext = nextFrameIndex - preheatFrames
110- if (syncedFrames.firstOrNull { it.frameIndex == firstFromNext } != null ) {
111- syncedFrames.removeIf { it.frameIndex == firstFromNext }
112- }
113- }
114101 val nextFrame = frameStore.getFrame(nextFrameIndex)
115102 val nextFrameDuration = frameStore.getFrameDuration(nextFrameIndex)
116103 synchronized(lock) {
@@ -226,15 +213,13 @@ public class AnimatedDrawable(
226213 mHandlerThread.post(preheatRunnable)
227214 }
228215
229- private val matrix = Matrix ()
230216 private val paint = Paint (Paint .ANTI_ALIAS_FLAG )
231217
232218 private val rect = Rect ()
233219
234220 override fun draw (canvas : Canvas ) {
235221 val bmp = currentBitmap
236222 if (bmp != null ) {
237- matrix.reset()
238223 rect.set(0 , 0 , bmp.width, bmp.height)
239224 canvas.drawBitmap(bmp, rect, bounds, paint)
240225 }
@@ -245,11 +230,11 @@ public class AnimatedDrawable(
245230 }
246231
247232 override fun getIntrinsicHeight (): Int {
248- return frameStore .height
233+ return bounds .height()
249234 }
250235
251236 override fun getIntrinsicWidth (): Int {
252- return frameStore .width
237+ return bounds .width()
253238 }
254239
255240 override fun setColorFilter (colorFilter : ColorFilter ? ) {
0 commit comments