diff options
author | halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-11-21 15:32:08 +0000 |
---|---|---|
committer | halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-11-21 15:32:08 +0000 |
commit | ad04eb49f5d3f324e6b85411c776d7466c1fef92 (patch) | |
tree | 72ec9bb693a1da847d1b3f6d1958ea2f0638e5c2 /tests/CachedDecodingPixelRefTest.cpp | |
parent | 8b656c6db40a99af241e38eae853f887413040cc (diff) |
Add SkImageGenerator Interface
- Add SkDiscardablePixelRef class that uses SkDiscardableMemory and
a SkImageGenerator.
- Add SkDecodingImageGenerator class as an example of a
SkImageGenerator.
- Add DecodingImageGenerator unit test.
- Add SkBasicDiscardableMemory implmentation for unit tests only.
R=reed@google.com, scroggo@google.com
Review URL: https://codereview.chromium.org/74793011
git-svn-id: http://skia.googlecode.com/svn/trunk@12341 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/CachedDecodingPixelRefTest.cpp')
-rw-r--r-- | tests/CachedDecodingPixelRefTest.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/CachedDecodingPixelRefTest.cpp b/tests/CachedDecodingPixelRefTest.cpp index 9a005469da..2d8a0e7073 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,35 @@ 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); + if (!success) { + return; + } + + REPORTER_ASSERT(reporter, NULL == lazy.getPixels()); + { + SkAutoLockPixels autoLockPixels(lazy); // now pixels are good. + REPORTER_ASSERT(reporter, NULL != lazy.getPixels()); + if (NULL == lazy.getPixels()) { + return; + } + } + // pixels should be gone! + REPORTER_ASSERT(reporter, NULL == lazy.getPixels()); + { + SkAutoLockPixels autoLockPixels(lazy); // now pixels are good. + REPORTER_ASSERT(reporter, NULL != lazy.getPixels()); + } + compare_bitmaps(reporter, original, lazy, comparePixels); +} +DEF_TEST(DecodingImageGenerator, reporter) { + test_three_encodings(reporter, compare_with_SkDecodingImageGenerator); +} |