| Index: tests/ImageDecodingTest.cpp
|
| diff --git a/tests/ImageDecodingTest.cpp b/tests/ImageDecodingTest.cpp
|
| index 5c9d5c58992745568d1a5b366ddb0762d07747e1..f30a0b25b7c115eed29990fb780ad1d373b95360 100644
|
| --- a/tests/ImageDecodingTest.cpp
|
| +++ b/tests/ImageDecodingTest.cpp
|
| @@ -20,7 +20,7 @@ __SK_FORCE_IMAGE_DECODER_LINKING;
|
| * Interprets c as an unpremultiplied color, and returns the
|
| * premultiplied equivalent.
|
| */
|
| -SkPMColor SkPreMultiplyUnPMColor(SkPMColor c) {
|
| +static SkPMColor premultiply_unpmcolor(SkPMColor c) {
|
| U8CPU a = SkGetPackedA32(c);
|
| U8CPU r = SkGetPackedR32(c);
|
| U8CPU g = SkGetPackedG32(c);
|
| @@ -29,6 +29,31 @@ SkPMColor SkPreMultiplyUnPMColor(SkPMColor c) {
|
| }
|
|
|
| /**
|
| + * Return true if this stream format should be skipped, due
|
| + * to do being an opaque format or not a valid format.
|
| + */
|
| +static bool skip_image_format(SkImageDecoder::Format format) {
|
| + switch (format) {
|
| + case SkImageDecoder::kPNG_Format:
|
| + case SkImageDecoder::kWEBP_Format:
|
| + return false;
|
| + // Skip unknown since it will not be decoded anyway.
|
| + case SkImageDecoder::kUnknown_Format:
|
| + // Technically ICO and BMP supports alpha channels, but our image
|
| + // decoders do not, so skip them as well.
|
| + case SkImageDecoder::kICO_Format:
|
| + case SkImageDecoder::kBMP_Format:
|
| + // The rest of these are opaque.
|
| + case SkImageDecoder::kWBMP_Format:
|
| + case SkImageDecoder::kGIF_Format:
|
| + case SkImageDecoder::kJPEG_Format:
|
| + return true;
|
| + }
|
| + SkASSERT(false);
|
| + return true;
|
| +}
|
| +
|
| +/**
|
| * Test decoding an image in premultiplied mode and unpremultiplied mode and compare
|
| * them.
|
| */
|
| @@ -39,8 +64,8 @@ static void compare_unpremul(skiatest::Reporter* reporter, const SkString& filen
|
|
|
| SkFILEStream stream(filename.c_str());
|
|
|
| - // JPEG is always opaque, so requesting unpremultiplied does not change anything.
|
| - if (SkImageDecoder::GetStreamFormat(&stream) == SkImageDecoder::kJPEG_Format) {
|
| + SkImageDecoder::Format format = SkImageDecoder::GetStreamFormat(&stream);
|
| + if (skip_image_format(format)) {
|
| return;
|
| }
|
|
|
| @@ -89,7 +114,7 @@ static void compare_unpremul(skiatest::Reporter* reporter, const SkString& filen
|
| const SkPMColor c0 = *bm8888.getAddr32(i, j);
|
| // "c1" is the result of premultiplying the color of the unpremultiplied
|
| // bitmap at (i, j).
|
| - const SkPMColor c1 = SkPreMultiplyUnPMColor(*bm8888Unpremul.getAddr32(i, j));
|
| + const SkPMColor c1 = premultiply_unpmcolor(*bm8888Unpremul.getAddr32(i, j));
|
| // Compute the difference for each component.
|
| int da = SkAbs32(SkGetPackedA32(c0) - SkGetPackedA32(c1));
|
| int dr = SkAbs32(SkGetPackedR32(c0) - SkGetPackedR32(c1));
|
|
|