aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/lazy/SkDiscardablePixelRef.h
diff options
context:
space:
mode:
authorGravatar halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-05 18:31:42 +0000
committerGravatar halcanary@google.com <halcanary@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-05 18:31:42 +0000
commit2c7c7ee47d75e7815ea8db05e924ab55958cb402 (patch)
treee6b7221c8f6a6d3b9d548c923499f3cf23f79634 /src/lazy/SkDiscardablePixelRef.h
parent3e0446ccbfbeadd0d02d417cb68e950d6c92f8e1 (diff)
Big Cleanup: SkBitmapFactory, SkLazyPixelRef, SkImageCache
Removed SkBitmapFactory since no clients were using it. New cache selection mechanism can simply pass a SkDiscardableMemory::Factory into the SkDiscardablePixelRef if non-default SkDiscardableMemory should be used. Removed BitmapFactoryTest. SkDiscardableMemory::Factory interface. Android will need this functionality in the future inside their BitmapFactory. Removed SkLazyPixelRef, since it's functionality is now subsumed into SkDiscardablePixelRef. Removed LazyPixelRef test. Modified SkDiscardablePixelRef to optionally allow it to use a SkDiscardableMemory::Factory. This tiny change makes it a replacement for SkLazyPixelRef. This functioanlity is also necessary for moving Android over to SkDiscardablePixelRef from SkImageRef in a later CL. Added a test for this. SkDecodingImageGenerator::Install can optionally pass a factory in to SkDiscardablePixelRef. Removed SkImageCache, SkLruImageCache, and SkPurgeableImageCache. This functionality can be handled much more cleanly by SkDiscardableMemory. New SkDiscardableMemoryPool class to replace SkLruImageCache. In a later CL, we will replace SkImageRef_GlobalPool (used by android) as well. This is a concrete implementation of SkDiscardableMemory::Factory. Added a test for this. modified gm/factory.cpp to remove dependnce on SkBitmapFactory + SkLruImageCache. Now uses SkDecodingImageGenerator + SkDiscardablePixelRef + SkDiscardableMemoryPool. SkImageDecoder::Target replaces SkBitmapFactory::Target. The DecodeMemoryToTarget function may disappear in the future. Moved SkLazyCachingPixelRef::DecodeProc replaces SkBitmapFactory::DecodeProc. This is a short term change, since another CL changes SkLazyCachingPixelRef to use SkImageGenerator instead of DecodeProc. Modified DrawBitmapRectTest to use SkDiscardablePixelRef instead of SkLazyPixelRef. tools/LazyDecodeBitmap.cpp now uses SkDecodingImageGenerator + SkDiscardablePixelRef instead of a SkBitmapFactory. bench_pictures uses the Global SkDiscardableMemoryPool instead of a global gLruImageCache. R=reed@google.com, scroggo@google.com Review URL: https://codereview.chromium.org/103033002 git-svn-id: http://skia.googlecode.com/svn/trunk@12515 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/lazy/SkDiscardablePixelRef.h')
-rw-r--r--src/lazy/SkDiscardablePixelRef.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/lazy/SkDiscardablePixelRef.h b/src/lazy/SkDiscardablePixelRef.h
index bbe19b8b20..78dcd66791 100644
--- a/src/lazy/SkDiscardablePixelRef.h
+++ b/src/lazy/SkDiscardablePixelRef.h
@@ -8,16 +8,18 @@
#ifndef SkDiscardablePixelRef_DEFINED
#define SkDiscardablePixelRef_DEFINED
+#include "SkDiscardableMemory.h"
#include "SkPixelRef.h"
#include "SkImageGenerator.h"
#include "SkImageInfo.h"
-class SkDiscardableMemory;
-
/**
* An interface that allows a purgable PixelRef to re-decode an image.
*/
+typedef SkDiscardableMemory* (*SkDiscardableMemoryFactory)(size_t bytes);
+
+
class SkDiscardablePixelRef : public SkPixelRef {
public:
/**
@@ -30,8 +32,19 @@ public:
* installed into destination is destroyed, it will call
* SkDELETE() on the generator. Therefore, generator should be
* allocated with SkNEW() or SkNEW_ARGS().
+ *
+ * @param destination Upon success, this bitmap will be
+ * configured and have a pixelref installed.
+ *
+ * @param factory If not NULL, this object will be used as a
+ * source of discardable memory when decoding. If NULL, then
+ * SkDiscardableMemory::Create() will be called.
+ *
+ * @return true iff successful.
*/
- static bool Install(SkImageGenerator* generator, SkBitmap* destination);
+ static bool Install(SkImageGenerator* generator,
+ SkBitmap* destination,
+ SkDiscardableMemory::Factory* factory = NULL);
SK_DECLARE_UNFLATTENABLE_OBJECT()
@@ -47,6 +60,7 @@ protected:
private:
SkImageGenerator* const fGenerator;
+ SkDiscardableMemory::Factory* const fDMFactory;
const SkImageInfo fInfo;
const size_t fSize; // size of memory to be allocated
const size_t fRowBytes;
@@ -59,6 +73,7 @@ private:
SkDiscardablePixelRef(SkImageGenerator* generator,
const SkImageInfo& info,
size_t size,
- size_t rowBytes);
+ size_t rowBytes,
+ SkDiscardableMemory::Factory* factory);
};
#endif // SkDiscardablePixelRef_DEFINED