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

Unified Diff: tests/CachedDecodingPixelRefTest.cpp

Issue 83663006: Modify SkLazyPixelRef to use SkImageGenerator. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: reupload 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 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);

Powered by Google App Engine
This is Rietveld 408576698