Test a GIF with an out of range transparent index
Bug: skia:8461 According to skbug.com/7069, we should allow GIFs to use a transparent index outside of the range of the color table. Add a test to verify support for this. The GIF is 2x2 with the following pixels: ------------------------------------------------- | black | white | ------------------------------------------------- | transparent | transparent | ------------------------------------------------- The color table only has 2 entries (black and white), and the transparent index is 2. Change-Id: I16574a61e2982b6628c3eca96cb7b3e1f57d3b2a Reviewed-on: https://skia-review.googlesource.com/c/161561 Reviewed-by: Nigel Tao <nigeltao@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com> Auto-Submit: Leon Scroggins <scroggo@google.com>
This commit is contained in:
parent
bdf12ad8d5
commit
f05626bf96
BIN
resources/images/out-of-palette.gif
Normal file
BIN
resources/images/out-of-palette.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 44 B |
@ -281,3 +281,45 @@ DEF_TEST(Codec_GifTruncated2, r) {
|
||||
// too early.
|
||||
REPORTER_ASSERT(r, codec->getFrameCount() == 0);
|
||||
}
|
||||
|
||||
DEF_TEST(Codec_gif_out_of_palette, r) {
|
||||
if (GetResourcePath().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const char* path = "images/out-of-palette.gif";
|
||||
auto data = GetResourceAsData(path);
|
||||
if (!data) {
|
||||
ERRORF(r, "failed to find %s", path);
|
||||
return;
|
||||
}
|
||||
|
||||
auto codec = SkCodec::MakeFromData(std::move(data));
|
||||
if (!codec) {
|
||||
ERRORF(r, "Could not create codec from %s", path);
|
||||
return;
|
||||
}
|
||||
|
||||
SkBitmap bm;
|
||||
bm.allocPixels(codec->getInfo());
|
||||
auto result = codec->getPixels(bm.pixmap());
|
||||
REPORTER_ASSERT(r, result == SkCodec::kSuccess, "Failed to decode %s with error %s",
|
||||
path, SkCodec::ResultToString(result));
|
||||
|
||||
struct {
|
||||
int x;
|
||||
int y;
|
||||
SkColor expected;
|
||||
} pixels[] = {
|
||||
{ 0, 0, SK_ColorBLACK },
|
||||
{ 1, 0, SK_ColorWHITE },
|
||||
{ 0, 1, SK_ColorTRANSPARENT },
|
||||
{ 1, 1, SK_ColorTRANSPARENT },
|
||||
};
|
||||
for (auto& pixel : pixels) {
|
||||
auto actual = bm.getColor(pixel.x, pixel.y);
|
||||
REPORTER_ASSERT(r, actual == pixel.expected,
|
||||
"pixel (%i,%i) mismatch! expected: %x actual: %x",
|
||||
pixel.x, pixel.y, pixel.expected, actual);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user