Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(588)

Unified Diff: tests/CodecTest.cpp

Issue 2401133002: Fix an assert statement in SkPngCodec (Closed)
Patch Set: Set fFirstRow and fLastRow Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/codec/SkPngCodec.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/CodecTest.cpp
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index 32482413f11d65da9723b90135d99b7599465685..a8f8781ef91f99442d700fb8fe4e0a33b00dbb88 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -1302,3 +1302,33 @@ DEF_TEST(Codec_fallBack, r) {
}
}
}
+
+// This test verifies that we fixed an assert statement that fired when reusing a png codec
+// after scaling.
+DEF_TEST(Codec_reusePng, r) {
+ std::unique_ptr<SkStream> stream(GetResourceAsStream("plane.png"));
+ if (!stream) {
+ return;
+ }
+
+ std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.release()));
+ if (!codec) {
+ ERRORF(r, "Failed to create codec\n");
+ return;
+ }
+
+ SkAndroidCodec::AndroidOptions opts;
+ opts.fSampleSize = 5;
+ auto size = codec->getSampledDimensions(opts.fSampleSize);
+ auto info = codec->getInfo().makeWH(size.fWidth, size.fHeight).makeColorType(kN32_SkColorType);
+ SkBitmap bm;
+ bm.allocPixels(info);
+ auto result = codec->getAndroidPixels(info, bm.getPixels(), bm.rowBytes(), &opts);
+ REPORTER_ASSERT(r, result == SkCodec::kSuccess);
+
+ info = codec->getInfo().makeColorType(kN32_SkColorType);
+ bm.allocPixels(info);
+ opts.fSampleSize = 1;
+ result = codec->getAndroidPixels(info, bm.getPixels(), bm.rowBytes(), &opts);
+ REPORTER_ASSERT(r, result == SkCodec::kSuccess);
+}
« no previous file with comments | « src/codec/SkPngCodec.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698