Respect repetition count in SkAnimatedImage
Bug: b/63908092
By default use the repetition count stored in the encoded data (if
any). Allow setting the repetition count manually, so that the
animation will stop after n+1 total cycles (unless -1 is used for
infinite).
If the animation is complete, make start reset it.
When the animation is not running, make update return max double (i.e.
no need to update any time soon).
Fix a bug where the first call to update returned -1.
Share write_bm with CodecAnimTest, for debugging.
Update Sample to check isRunning rather than keeping its own record
of whether the animation is running.
Change-Id: I883e4d7325f7a7b23a422fa9d756f9ea3018f0f8
Reviewed-on: https://skia-review.googlesource.com/97082
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
diff --git a/tests/CodecAnimTest.cpp b/tests/CodecAnimTest.cpp
index f707f1e..c5c65f8 100644
--- a/tests/CodecAnimTest.cpp
+++ b/tests/CodecAnimTest.cpp
@@ -8,11 +8,9 @@
#include "SkAndroidCodec.h"
#include "SkBitmap.h"
#include "SkCodec.h"
-#include "SkCommonFlags.h"
-#include "SkImageEncoder.h"
-#include "SkOSPath.h"
#include "SkStream.h"
+#include "CodecPriv.h"
#include "Resources.h"
#include "Test.h"
#include "sk_tool_utils.h"
@@ -20,19 +18,6 @@
#include <initializer_list>
#include <vector>
-static void write_bm(const char* name, const SkBitmap& bm) {
- if (FLAGS_writePath.isEmpty()) {
- return;
- }
-
- SkString filename = SkOSPath::Join(FLAGS_writePath[0], name);
- filename.appendf(".png");
- SkFILEWStream file(filename.c_str());
- if (!SkEncodeImage(&file, bm, SkEncodedImageFormat::kPNG, 100)) {
- SkDebugf("failed to write '%s'\n", filename.c_str());
- }
-}
-
DEF_TEST(Codec_trunc, r) {
sk_sp<SkData> data(GetResourceAsData("images/box.gif"));
if (!data) {