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

Unified Diff: tests/CodexTest.cpp

Issue 1230033004: Allow creating multiple scanline decoders. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Progressive scanline decoder needs to handle rewind on first call. Created 5 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/CodexTest.cpp
diff --git a/tests/CodexTest.cpp b/tests/CodexTest.cpp
index 32968fdb7a91b06ce62066e4dec51e9d6a2a86bf..f4682055a42d8a67f17a578781774b6536d7e5cb 100644
--- a/tests/CodexTest.cpp
+++ b/tests/CodexTest.cpp
@@ -28,6 +28,19 @@ static void md5(const SkBitmap& bm, SkMD5::Digest* digest) {
md5.finish(*digest);
}
+/**
+ * Compute the digest for bm and compare it to a known good digest.
+ * @param r Reporter to assert that bm's digest matches goodDigest.
+ * @param goodDigest The known good digest to compare to.
+ * @param bm The bitmap to test.
+ */
+static void compare_to_good_digest(skiatest::Reporter* r, const SkMD5::Digest& goodDigest,
+ const SkBitmap& bm) {
+ SkMD5::Digest digest;
+ md5(bm, &digest);
+ REPORTER_ASSERT(r, digest == goodDigest);
+}
+
static void check(skiatest::Reporter* r,
const char path[],
SkISize size,
@@ -56,8 +69,8 @@ static void check(skiatest::Reporter* r,
codec->getPixels(info, bm.getPixels(), bm.rowBytes(), NULL, NULL, NULL);
REPORTER_ASSERT(r, result == SkCodec::kSuccess);
- SkMD5::Digest digest1, digest2;
- md5(bm, &digest1);
+ SkMD5::Digest digest;
+ md5(bm, &digest);
bm.eraseColor(SK_ColorYELLOW);
@@ -66,25 +79,26 @@ static void check(skiatest::Reporter* r,
REPORTER_ASSERT(r, result == SkCodec::kSuccess);
// verify that re-decoding gives the same result.
- md5(bm, &digest2);
- REPORTER_ASSERT(r, digest1 == digest2);
+ compare_to_good_digest(r, digest, bm);
- SkScanlineDecoder* scanlineDecoder = codec->getScanlineDecoder(info);
+ SkAutoTDelete<SkScanlineDecoder> scanlineDecoder(codec->getScanlineDecoder(info));
if (supportsScanlineDecoding) {
bm.eraseColor(SK_ColorYELLOW);
REPORTER_ASSERT(r, scanlineDecoder);
- // Regular decodes should be disabled after creating a scanline decoder
+ // Regular decodes should not be affected by creating a scanline decoder
result = codec->getPixels(info, bm.getPixels(), bm.rowBytes(), NULL, NULL, NULL);
- REPORTER_ASSERT(r, SkCodec::kInvalidParameters == result);
+ REPORTER_ASSERT(r, SkCodec::kSuccess == result);
+ compare_to_good_digest(r, digest, bm);
+
+ bm.eraseColor(SK_ColorYELLOW);
+
for (int y = 0; y < info.height(); y++) {
result = scanlineDecoder->getScanlines(bm.getAddr(0, y), 1, 0);
REPORTER_ASSERT(r, result == SkCodec::kSuccess);
}
// verify that scanline decoding gives the same result.
- SkMD5::Digest digest3;
- md5(bm, &digest3);
- REPORTER_ASSERT(r, digest3 == digest1);
+ compare_to_good_digest(r, digest, bm);
} else {
REPORTER_ASSERT(r, !scanlineDecoder);
}
« 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