Index: tests/CachedDecodingPixelRefTest.cpp |
diff --git a/tests/CachedDecodingPixelRefTest.cpp b/tests/CachedDecodingPixelRefTest.cpp |
index 2d8a0e70737a66c376987caf9c2adb055026f054..6c8a0e93f7e5c30932cddde12d749f4f65c06e13 100644 |
--- a/tests/CachedDecodingPixelRefTest.cpp |
+++ b/tests/CachedDecodingPixelRefTest.cpp |
@@ -66,7 +66,7 @@ static bool simple_bitmap_factory(SkBitmapFactory::DecodeProc proc, |
dst->setConfig(SkImageInfoToBitmapConfig(info), info.fWidth, |
info.fHeight, 0, info.fAlphaType); |
SkAutoTUnref<SkLazyPixelRef> ref(SkNEW_ARGS(SkLazyPixelRef, |
- (data, proc, NULL))); |
+ (info, data, proc, NULL))); |
dst->setPixelRef(ref); |
return true; |
} |
@@ -205,8 +205,18 @@ DEF_TEST(LazyCachedPixelRef, reporter) { |
} |
class TestPixelRef : public SkCachingPixelRef { |
+ static SkImageInfo cons_up_info() { |
+ SkImageInfo info; |
+ info.fWidth = 10; |
+ info.fHeight = 10; |
+ info.fColorType = kRGBA_8888_SkColorType; |
+ info.fAlphaType = kOpaque_SkAlphaType; |
+ return info; |
+ } |
public: |
- TestPixelRef(int x) : fX(x) { } |
+ TestPixelRef(int x) |
+ : INHERITED(cons_up_info()) |
+ , fX(x) { } |
virtual ~TestPixelRef() { } |
static bool Install(SkBitmap* destination, int x) { |
SkAutoTUnref<TestPixelRef> ref(SkNEW_ARGS(TestPixelRef, (x))); |
@@ -214,21 +224,9 @@ public: |
} |
SK_DECLARE_UNFLATTENABLE_OBJECT() |
protected: |
- virtual bool onDecodeInfo(SkImageInfo* info) SK_OVERRIDE { |
- if (fX == 0) { |
- return false; |
- } |
- SkASSERT(info); |
- info->fWidth = 10; |
- info->fHeight = 10; |
- info->fColorType = kRGBA_8888_SkColorType; |
- info->fAlphaType = kOpaque_SkAlphaType; |
- return true; |
- } |
- virtual bool onDecodePixels(const SkImageInfo& info, |
- void* pixels, |
+ virtual bool onDecodePixels(void* pixels, |
size_t rowBytes) SK_OVERRIDE { |
- return false; |
+ return fX != 0; |
} |
private: |
int fX; // controls where the failure happens |
@@ -237,13 +235,20 @@ private: |
DEF_TEST(CachingPixelRef, reporter) { |
SkBitmap lazy; |
- // test the error handling |
- REPORTER_ASSERT(reporter, !TestPixelRef::Install(&lazy, 0)); |
- // onDecodeInfo should succeed, allowing installation |
- REPORTER_ASSERT(reporter, TestPixelRef::Install(&lazy, 1)); |
- SkAutoLockPixels autoLockPixels(lazy); // now pixels are good. |
- // onDecodePixels should fail, so getting pixels will fail. |
- REPORTER_ASSERT(reporter, NULL == lazy.getPixels()); |
+ |
+ { |
+ REPORTER_ASSERT(reporter, TestPixelRef::Install(&lazy, 1)); |
+ SkAutoLockPixels autoLockPixels(lazy); // now pixels are good. |
+ // onDecodePixels should succeed. |
+ REPORTER_ASSERT(reporter, NULL != lazy.getPixels()); |
+ } |
+ { |
+ // onDecodeInfo should succeed, allowing installation |
+ REPORTER_ASSERT(reporter, TestPixelRef::Install(&lazy, 0)); |
+ SkAutoLockPixels autoLockPixels(lazy); // now pixels are bad. |
+ // onDecodePixels should fail. |
+ REPORTER_ASSERT(reporter, NULL == lazy.getPixels()); |
+ } |
} |
static void compare_with_SkDecodingImageGenerator(skiatest::Reporter* reporter, |