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

Unified Diff: tests/CodecTest.cpp

Issue 2161593003: Fix rewinding bug in SkJpegCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: GOOGLE 3 fix - doesn't affect Android Created 4 years, 5 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/SkJpegCodec.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 12d6ac8d3d2997a164da8219a4bd39f7923e349b..b8b957fe55cf7f6dca6640ac334ca2870a3c0b89 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -1012,3 +1012,32 @@ DEF_TEST(Codec_wbmp_max_size, r) {
REPORTER_ASSERT(r, !codec);
}
+
+DEF_TEST(Codec_jpeg_rewind, r) {
+ const char* path = "mandrill_512_q075.jpg";
+ SkAutoTDelete<SkStream> stream(resource(path));
+ if (!stream) {
+ SkDebugf("Missing resource '%s'\n", path);
+ return;
+ }
+ SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.release()));
+ if (!codec) {
+ ERRORF(r, "Unable to create codec '%s'.", path);
+ return;
+ }
+
+ const int width = codec->getInfo().width();
+ const int height = codec->getInfo().height();
+ size_t rowBytes = sizeof(SkPMColor) * width;
+ SkAutoMalloc pixelStorage(height * rowBytes);
+
+ // Perform a sampled decode.
+ SkAndroidCodec::AndroidOptions opts;
+ opts.fSampleSize = 12;
+ codec->getAndroidPixels(codec->getInfo().makeWH(width / 12, height / 12), pixelStorage.get(),
+ rowBytes, &opts);
+
+ // Rewind the codec and perform a full image decode.
+ SkCodec::Result result = codec->getPixels(codec->getInfo(), pixelStorage.get(), rowBytes);
+ REPORTER_ASSERT(r, SkCodec::kSuccess == result);
+}
« no previous file with comments | « src/codec/SkJpegCodec.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698