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

Unified Diff: tests/CachedDecodingPixelRefTest.cpp

Issue 74793011: Add SkImageGenerator Interface (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: protected destructor Created 7 years, 1 month 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
Index: tests/CachedDecodingPixelRefTest.cpp
diff --git a/tests/CachedDecodingPixelRefTest.cpp b/tests/CachedDecodingPixelRefTest.cpp
index 9a005469da3bce52f138d6856fdec40feaae9f76..76882f0e0ded98458d14fc321abd2b72d06faf3c 100644
--- a/tests/CachedDecodingPixelRefTest.cpp
+++ b/tests/CachedDecodingPixelRefTest.cpp
@@ -8,6 +8,7 @@
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkData.h"
+#include "SkDecodingImageGenerator.h"
#include "SkForceLinking.h"
#include "SkImageDecoder.h"
#include "SkImagePriv.h"
@@ -244,3 +245,36 @@ DEF_TEST(CachingPixelRef, reporter) {
// onDecodePixels should fail, so getting pixels will fail.
REPORTER_ASSERT(reporter, NULL == lazy.getPixels());
}
+
+static void compare_with_SkDecodingImageGenerator(skiatest::Reporter* reporter,
+ SkData* encoded,
+ const SkBitmap& original,
+ bool comparePixels) {
+
+ SkBitmap lazy;
+ bool success = SkDecodingImageGenerator::Install(encoded, &lazy);
+ REPORTER_ASSERT(reporter, success);
scroggo 2013/11/19 22:19:27 If success is false, should we return false?
hal.canary 2013/11/20 00:07:10 We should return early, at least.
+
+ bool getPixelsSuccess;
+ REPORTER_ASSERT(reporter, NULL == lazy.getPixels());
+ {
+ SkAutoLockPixels autoLockPixels(lazy); // now pixels are good.
+ REPORTER_ASSERT(reporter, NULL != lazy.getPixels());
+ getPixelsSuccess = (NULL != lazy.getPixels());
+ }
+ if (!getPixelsSuccess) {
+ return;
+ }
+ // pixels should be gone!
+ REPORTER_ASSERT(reporter, NULL == lazy.getPixels());
+ {
+ SkAutoLockPixels autoLockPixels(lazy); // now pixels are good.
+ REPORTER_ASSERT(reporter, NULL != lazy.getPixels());
+ }
+ if (getPixelsSuccess) {
+ compare_bitmaps(reporter, original, lazy, comparePixels);
+ }
+}
+DEF_TEST(DecodingImageGenerator, reporter) {
+ test_three_encodings(reporter, compare_with_SkDecodingImageGenerator);
+}
« src/ports/SkDiscardableMemory_none.cpp ('K') | « src/ports/SkDiscardableMemory_none.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698