aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Leon Scroggins III <scroggo@google.com>2018-02-28 16:24:18 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-28 21:46:03 +0000
commit9e8a594905316d14aeb55ab5ab5f50e03cb847c6 (patch)
tree52fe46a142e298307fc1b75bc75d7821fdc3b2b3 /tests
parent84447e03ac2c8543d1e943cb6f754b910581e4bc (diff)
Support pngs with incorrect CMF bytes
Bug: chromium:807324 Though these pngs are technically incorrect, many such PNGs exist, and they are supported in Chromium. Ensure that users of SkCodec (e.g. Android, Flutter) display them as well. Change-Id: I2f1e573b4b7039cea81f96397cc0aa4cbc9461c3 Reviewed-on: https://skia-review.googlesource.com/111082 Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Derek Sollenberger <djsollen@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/CodecTest.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index e3362f5815..d8dab25a90 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -1566,3 +1566,38 @@ DEF_TEST(Codec_ossfuzz6274, r) {
}
}
}
+
+DEF_TEST(Codec_crbug807324, r) {
+ if (GetResourcePath().isEmpty()) {
+ return;
+ }
+
+ const char* file = "images/crbug807324.png";
+ auto image = GetResourceAsImage(file);
+ if (!image) {
+ ERRORF(r, "Missing %s", file);
+ return;
+ }
+
+ const int kWidth = image->width();
+ const int kHeight = image->height();
+
+ SkBitmap bm;
+ if (!bm.tryAllocPixels(SkImageInfo::MakeN32Premul(kWidth, kHeight))) {
+ ERRORF(r, "Could not allocate pixels (%i x %i)", kWidth, kHeight);
+ return;
+ }
+
+ bm.eraseColor(SK_ColorTRANSPARENT);
+
+ SkCanvas canvas(bm);
+ canvas.drawImage(image, 0, 0, nullptr);
+
+ for (int i = 0; i < kWidth; ++i)
+ for (int j = 0; j < kHeight; ++j) {
+ if (*bm.getAddr32(i, j) == SK_ColorTRANSPARENT) {
+ ERRORF(r, "image should not be transparent! %i, %i is 0", i, j);
+ return;
+ }
+ }
+}