Take into account drawable bound left/top offset
diff --git a/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java b/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java
index 636dcea..366fde0 100644
--- a/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java
+++ b/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java
@@ -1419,6 +1419,7 @@
float scaleY = bounds.height() / (float) composition.getBounds().height();
renderingMatrix.preScale(scaleX, scaleY);
+ renderingMatrix.preTranslate(bounds.left, bounds.top);
}
compositionLayer.draw(canvas, renderingMatrix, alpha);
}
diff --git a/snapshot-tests/src/androidTest/java/com/airbnb/lottie/snapshots/LottieSnapshotTest.kt b/snapshot-tests/src/androidTest/java/com/airbnb/lottie/snapshots/LottieSnapshotTest.kt
index 879b65a..83c82cb 100644
--- a/snapshot-tests/src/androidTest/java/com/airbnb/lottie/snapshots/LottieSnapshotTest.kt
+++ b/snapshot-tests/src/androidTest/java/com/airbnb/lottie/snapshots/LottieSnapshotTest.kt
@@ -30,6 +30,7 @@
import com.airbnb.lottie.snapshots.tests.PartialFrameProgressTestCase
import com.airbnb.lottie.snapshots.tests.ProdAnimationsTestCase
import com.airbnb.lottie.snapshots.tests.ScaleTypesTestCase
+import com.airbnb.lottie.snapshots.tests.SeekBarTestCase
import com.airbnb.lottie.snapshots.tests.SoftwareRenderingDynamicPropertiesInvalidationTestCase
import com.airbnb.lottie.snapshots.tests.TextTestCase
import com.airbnb.lottie.snapshots.utils.BitmapPool
@@ -127,6 +128,7 @@
ProdAnimationsTestCase(),
ClipChildrenTestCase(),
SoftwareRenderingDynamicPropertiesInvalidationTestCase(),
+ SeekBarTestCase(),
)
withTimeout(TimeUnit.MINUTES.toMillis(45)) {
diff --git a/snapshot-tests/src/androidTest/java/com/airbnb/lottie/snapshots/tests/SeekBarTestCase.kt b/snapshot-tests/src/androidTest/java/com/airbnb/lottie/snapshots/tests/SeekBarTestCase.kt
new file mode 100644
index 0000000..4be13fa
--- /dev/null
+++ b/snapshot-tests/src/androidTest/java/com/airbnb/lottie/snapshots/tests/SeekBarTestCase.kt
@@ -0,0 +1,34 @@
+package com.airbnb.lottie.snapshots.tests
+
+import android.graphics.Canvas
+import android.view.LayoutInflater
+import android.view.View.MeasureSpec
+import com.airbnb.lottie.LottieCompositionFactory
+import com.airbnb.lottie.LottieDrawable
+import com.airbnb.lottie.model.LottieCompositionCache
+import com.airbnb.lottie.snapshots.SnapshotTestCase
+import com.airbnb.lottie.snapshots.SnapshotTestCaseContext
+import com.airbnb.lottie.snapshots.log
+import com.airbnb.lottie.snapshots.databinding.SeekBarBinding
+
+class SeekBarTestCase : SnapshotTestCase {
+ override suspend fun SnapshotTestCaseContext.run() {
+ val composition = LottieCompositionFactory.fromAssetSync(context, "Tests/Thumb.json").value!!
+ val drawable = LottieDrawable()
+ drawable.composition = composition
+ val binding = SeekBarBinding.inflate(LayoutInflater.from(context))
+ binding.seekBar.thumb = drawable
+
+ val widthSpec = MeasureSpec.makeMeasureSpec(512, MeasureSpec.EXACTLY)
+ val heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)
+ binding.root.measure(widthSpec, heightSpec)
+ binding.root.layout(0, 0, binding.root.measuredWidth, binding.root.measuredHeight)
+ log("Drawing seek bar ${binding.root.measuredWidth}x${binding.root.measuredHeight} -> ${binding.root.width}x${binding.root.height}")
+ val bitmap = bitmapPool.acquire(binding.root.measuredWidth, binding.root.measuredHeight)
+ val canvas = Canvas(bitmap)
+ binding.root.draw(canvas)
+ snapshotter.record(bitmap, "SeekBar", "ThumbDrawable")
+ LottieCompositionCache.getInstance().clear()
+ bitmapPool.release(bitmap)
+ }
+}
\ No newline at end of file
diff --git a/snapshot-tests/src/main/assets/Tests/Thumb.json b/snapshot-tests/src/main/assets/Tests/Thumb.json
new file mode 100644
index 0000000..50e3db7
--- /dev/null
+++ b/snapshot-tests/src/main/assets/Tests/Thumb.json
@@ -0,0 +1 @@
+{"v":"5.9.6","fr":29.9700012207031,"ip":0,"op":190.000007738859,"w":24,"h":24,"nm":"Thumb","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[12,12,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"sr","sy":1,"d":1,"pt":{"a":0,"k":5,"ix":3},"p":{"a":0,"k":[0,0],"ix":4},"r":{"a":0,"k":0,"ix":5},"ir":{"a":0,"k":5,"ix":6},"is":{"a":0,"k":0,"ix":8},"or":{"a":0,"k":12,"ix":7},"os":{"a":0,"k":0,"ix":9},"ix":1,"nm":"Polystar Path 1","mn":"ADBE Vector Shape - Star","hd":false},{"ty":"st","c":{"a":0,"k":[1,0.922702133656,0,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[1,0,0,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Polystar 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":190.000007738859,"st":0,"ct":1,"bm":0}],"markers":[]}
\ No newline at end of file
diff --git a/snapshot-tests/src/main/res/layout/seek_bar.xml b/snapshot-tests/src/main/res/layout/seek_bar.xml
new file mode 100644
index 0000000..7ea3ed1
--- /dev/null
+++ b/snapshot-tests/src/main/res/layout/seek_bar.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="512dp"
+ android:layout_height="64dp">
+
+ <SeekBar
+ android:id="@+id/seek_bar"
+ android:layout_gravity="center"
+ android:progress="50"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+</FrameLayout>
\ No newline at end of file