Correct LottieWeb drawing params
The tiles are now centered in a 200 x 200 box.
Additionally, the frames drawn should now
match how the seeking happens (before, we would
try to draw frame *index* 300 when there were only
300 frames)
I renamed a variable in DmSrcSink because it initially
confused me as the purpose of it.
Bug: skia:
Change-Id: I8552a24727326cd8714dfd1c7794a0c4b0a418cb
Reviewed-on: https://skia-review.googlesource.com/150126
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index a4d623e..cd5822e 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -1186,25 +1186,26 @@
const auto t_rate = 1.0f / (kTileCount * kTileCount - 1);
- // Shuffled order to exercise non-linear frame progression.
- static constexpr int frames[] = { 4, 0, 3, 1, 2 };
- static_assert(SK_ARRAY_COUNT(frames) == kTileCount, "");
+ // Draw the frames in a shuffled order to exercise non-linear
+ // frame progression. The film strip will still be in order left-to-right,
+ // top-down, just not drawn in that order.
+ static constexpr int frameOrder[] = { 4, 0, 3, 1, 2 };
+ static_assert(SK_ARRAY_COUNT(frameOrder) == kTileCount, "");
for (int i = 0; i < kTileCount; ++i) {
- const SkScalar y = frames[i] * kTileSize;
+ const SkScalar y = frameOrder[i] * kTileSize;
for (int j = 0; j < kTileCount; ++j) {
- const SkScalar x = frames[j] * kTileSize;
+ const SkScalar x = frameOrder[j] * kTileSize;
SkRect dest = SkRect::MakeXYWH(x, y, kTileSize, kTileSize);
- const auto t = t_rate * (frames[i] * kTileCount + frames[j]);
+ const auto t = t_rate * (frameOrder[i] * kTileCount + frameOrder[j]);
{
SkAutoCanvasRestore acr(canvas, true);
canvas->clipRect(dest, true);
canvas->concat(SkMatrix::MakeRectToRect(SkRect::MakeSize(animation->size()),
dest,
SkMatrix::kCenter_ScaleToFit));
-
animation->seek(t);
animation->render(canvas);
}