Allow setting an SkColorSpace on SkAnimatedImage
Add a new constructor which merges the SkISize scaledSize with the
SkImageInfo. This allows passing an SkColorSpace to the decode.
Update the test to call the new API.
Bug: b/123301872
Change-Id: I9fd89198e97ac9b8e6dc9fcfe89ed38913a0fe69
Reviewed-on: https://skia-review.googlesource.com/c/189303
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
diff --git a/tests/AnimatedImageTest.cpp b/tests/AnimatedImageTest.cpp
index 5f5dadb..cb4e670 100644
--- a/tests/AnimatedImageTest.cpp
+++ b/tests/AnimatedImageTest.cpp
@@ -47,10 +47,10 @@
}
// Force the drawable follow its special case that requires scaling.
- auto size = codec->getInfo().dimensions();
- size.set(size.width() - 5, size.height() - 5);
- auto rect = SkIRect::MakeSize(size);
- auto image = SkAnimatedImage::Make(std::move(codec), size, rect, nullptr);
+ auto info = codec->getInfo();
+ info = info.makeWH(info.width() - 5, info.height() - 5);
+ auto rect = info.bounds();
+ auto image = SkAnimatedImage::Make(std::move(codec), info, rect, nullptr);
if (!image) {
ERRORF(r, "Failed to create animated image for %s", file);
return;
@@ -59,12 +59,12 @@
// Clear a bitmap to non-transparent and draw to it. pixels that are transparent
// in the image should not replace the original non-transparent color.
SkBitmap bm;
- bm.allocPixels(SkImageInfo::MakeN32Premul(size.width(), size.height()));
+ bm.allocPixels(SkImageInfo::MakeN32Premul(info.width(), info.height()));
bm.eraseColor(SK_ColorBLUE);
SkCanvas canvas(bm);
image->draw(&canvas);
- for (int i = 0; i < size.width(); ++i)
- for (int j = 0; j < size.height(); ++j) {
+ for (int i = 0; i < info.width(); ++i)
+ for (int j = 0; j < info.height(); ++j) {
if (*bm.getAddr32(i, j) == SK_ColorTRANSPARENT) {
ERRORF(r, "Erased color underneath!");
return;