94 const char* file =
"images/alphabetAnim.gif";
97 ERRORF(r,
"Could not get %s", file);
107 {
true, {100, 100}, { 0, 0, 100, 100} },
108 {
true, {100, 100}, { 0, 0, 50, 50} },
109 {
true, {100, 100}, { 10, 10, 100, 100} },
110 {
true, {100, 100}, { 0, 0, 100, 100} },
113 {
false, {100, 100}, { 0, 100, 100, 0} },
114 {
false, {100, 100}, { 100, 0, 0, 100} },
117 {
false, {100, 100}, { 0, 1, 100, 101} },
118 {
false, {100, 100}, { 0, -1, 100, 99} },
119 {
false, {100, 100}, { -1, 0, 99, 100} },
120 {
false, {100, 100}, { 100, 100, 200, 200} },
123 {
true, { 50, 50}, { 0, 0, 50, 50} },
124 {
true, { 50, 50}, { 0, 0, 25, 25} },
125 {
true, {200, 200}, { 0, 1, 100, 101} },
128 {
false, { 50, 50}, { 0, 0, 75, 25} },
129 {
false, { 50, 50}, { 0, 0, 25, 75} },
132 for (
const auto& rec : gRecs) {
135 ERRORF(r,
"Could not create codec for %s", file);
139 auto info = codec->getInfo();
143 rec.cropRect,
nullptr);
222 for (
const char* file : {
"images/alphabetAnim.gif",
223 "images/colorTables.gif",
224 "images/stoplight.webp",
225 "images/required.webp",
229 ERRORF(r,
"Could not get %s", file);
235 ERRORF(r,
"Could not create codec for %s", file);
240 const int frameCount = codec->getFrameCount();
243 ERRORF(r,
"Could not create androidCodec for %s", file);
248 if (!animatedImage) {
249 ERRORF(r,
"Could not create animated image for %s", file);
252 animatedImage->setRepetitionCount(0);
254 std::vector<SkBitmap> expected(frameCount);
255 std::vector<sk_sp<SkPicture>> pictures(frameCount);
256 for (
int i = 0; i < frameCount; i++) {
262 pictures[i] = animatedImage->makePictureSnapshot();
265 const auto duration = animatedImage->decodeNextFrame();
269 if (i >= frameCount - 2) {
276 for (
int i = 0; i < frameCount; i++) {
278 test.allocPixels(imageInfo);
293 for (
const char* file : {
"images/alphabetAnim.gif",
294 "images/colorTables.gif",
295 "images/stoplight.webp",
296 "images/required.webp",
300 ERRORF(r,
"Could not get %s", file);
306 ERRORF(r,
"Could not create codec for %s", file);
310 std::vector<SkCodec::FrameInfo> frameInfos = codec->getFrameInfo();
311 std::vector<SkBitmap> frames(frameInfos.size());
326 const int defaultRepetitionCount = codec->getRepetitionCount();
328 for (
size_t i = 0; i < frameInfos.size(); ++i) {
329 auto info = codec->getInfo().makeAlphaType(frameInfos[i].fAlphaType);
330 auto& bm = frames[i];
334 options.fPriorFrame = frameInfos[i].fRequiredFrame;
336 bm.allocPixels(
info);
341 ERRORF(r,
"Failed to copy %s frame %i", file,
options.fPriorFrame);
355 ERRORF(r,
"Could not create androidCodec for %s", file);
360 if (!animatedImage) {
361 ERRORF(r,
"Could not create animated image for %s", file);
365 REPORTER_ASSERT(r, defaultRepetitionCount == animatedImage->getRepetitionCount());
370 test.allocPixels(imageInfo);
373 animatedImage->draw(&c);
379 REPORTER_ASSERT(r, animatedImage->currentFrameDuration() == frameInfos[0].fDuration);
381 if (!testDraw(animatedImage, 0)) {
382 ERRORF(r,
"Did not start with frame 0");
388 for (
size_t i = 1; i < frameInfos.size(); ++i) {
389 const int frameTime = animatedImage->decodeNextFrame();
390 REPORTER_ASSERT(r, frameTime == animatedImage->currentFrameDuration());
392 if (i == frameInfos.size() - 1 && defaultRepetitionCount == 0) {
400 if (!testDraw(animatedImage, i)) {
401 ERRORF(r,
"Did not update to %zu properly", i);
411 animatedImage->reset();
413 if (!testDraw(animatedImage, 0)) {
414 ERRORF(r,
"reset failed");
420 for (
int j = 0; j < (
int) frameInfos.size(); ++j) {
426 for (
int i = 0; i <= j; ++i) {
428 animatedImage->reset();
429 if (!testDraw(animatedImage, 0)) {
430 ERRORF(r,
"reset failed for image %s from frame %i",
436 animatedImage->decodeNextFrame();
437 if (!testDraw(animatedImage, i)) {
438 ERRORF(r,
"failed to match frame %i in %s on iteration %i",
451 for (
int loopCount : { 0, 1, 2, 5 }) {
454 animatedImage->setRepetitionCount(loopCount);
457 for (
int loops = 0; loops <= loopCount; loops++) {
462 for (
size_t i = 1; i <= frameInfos.size(); ++i) {
463 const int frameTime = animatedImage->decodeNextFrame();
465 if (loops != loopCount) {
466 ERRORF(r,
"%s animation stopped early: loops: %i\tloopCount: %i",
467 file, loops, loopCount);
470 if (i != frameInfos.size() - 1) {
471 ERRORF(r,
"%s animation stopped early: i: %zu\tsize: %zu",
472 file, i, frameInfos.size());
480 if (!animatedImage->isFinished()) {
481 ERRORF(r,
"%s animation should have finished with specified loop count (%i)",