| Index: tests/CachedDecodingPixelRefTest.cpp
|
| diff --git a/tests/CachedDecodingPixelRefTest.cpp b/tests/CachedDecodingPixelRefTest.cpp
|
| index 2d8a0e70737a66c376987caf9c2adb055026f054..0c2130f3fcbc3c44e662022aefc3acc50ad4b30a 100644
|
| --- a/tests/CachedDecodingPixelRefTest.cpp
|
| +++ b/tests/CachedDecodingPixelRefTest.cpp
|
| @@ -16,6 +16,7 @@
|
| #include "SkLazyPixelRef.h"
|
| #include "SkScaledImageCache.h"
|
| #include "SkStream.h"
|
| +#include "SkLruImageCache.h"
|
|
|
| #include "Test.h"
|
| #include "TestClassDef.h"
|
| @@ -59,16 +60,11 @@ static SkData* create_data_from_bitmap(const SkBitmap& bm,
|
| static bool simple_bitmap_factory(SkBitmapFactory::DecodeProc proc,
|
| SkData* data,
|
| SkBitmap* dst) {
|
| - SkImageInfo info;
|
| - if (!proc(data->data(), data->size(), &info, NULL)) {
|
| - return false;
|
| - }
|
| - dst->setConfig(SkImageInfoToBitmapConfig(info), info.fWidth,
|
| - info.fHeight, 0, info.fAlphaType);
|
| - SkAutoTUnref<SkLazyPixelRef> ref(SkNEW_ARGS(SkLazyPixelRef,
|
| - (data, proc, NULL)));
|
| - dst->setPixelRef(ref);
|
| - return true;
|
| + SkBitmapFactory fact(proc);
|
| + size_t budget = 1000000;
|
| + SkAutoTUnref<SkImageCache> cache(SkNEW_ARGS(SkLruImageCache, (budget)));
|
| + fact.setImageCache(cache.get());
|
| + return fact.installPixelRef(data, dst);
|
| }
|
|
|
| static void compare_bitmaps(skiatest::Reporter* reporter,
|
| @@ -204,15 +200,17 @@ DEF_TEST(LazyCachedPixelRef, reporter) {
|
| test_three_encodings(reporter, compare_with_skLazyCachedPixelRef);
|
| }
|
|
|
| +namespace {
|
| class TestPixelRef : public SkCachingPixelRef {
|
| public:
|
| - TestPixelRef(int x) : fX(x) { }
|
| + explicit TestPixelRef(int x) : fX(x) { }
|
| virtual ~TestPixelRef() { }
|
| static bool Install(SkBitmap* destination, int x) {
|
| SkAutoTUnref<TestPixelRef> ref(SkNEW_ARGS(TestPixelRef, (x)));
|
| return ref->configure(destination) && destination->setPixelRef(ref);
|
| }
|
| SK_DECLARE_UNFLATTENABLE_OBJECT()
|
| +
|
| protected:
|
| virtual bool onDecodeInfo(SkImageInfo* info) SK_OVERRIDE {
|
| if (fX == 0) {
|
| @@ -230,10 +228,12 @@ protected:
|
| size_t rowBytes) SK_OVERRIDE {
|
| return false;
|
| }
|
| +
|
| private:
|
| int fX; // controls where the failure happens
|
| typedef SkCachingPixelRef INHERITED;
|
| };
|
| +} // namespace
|
|
|
| DEF_TEST(CachingPixelRef, reporter) {
|
| SkBitmap lazy;
|
| @@ -250,7 +250,6 @@ 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);
|
|
|