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

Unified Diff: src/lazy/SkLazyPixelRef.h

Issue 37343002: Allow SkLazyPixelRef to use SkScaledImageCache (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: linted Created 7 years, 2 months 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: src/lazy/SkLazyPixelRef.h
diff --git a/src/lazy/SkLazyPixelRef.h b/src/lazy/SkLazyPixelRef.h
index 8f7a751e953693efd0b81cc9e0bafd24dba6154c..c7281d035aa19c4ce8783397931335b201fd73fa 100644
--- a/src/lazy/SkLazyPixelRef.h
+++ b/src/lazy/SkLazyPixelRef.h
@@ -33,8 +33,9 @@ public:
* Create a new SkLazyPixelRef.
* @param SkData Encoded data representing the pixels.
* @param DecodeProc Called to decode the pixels when needed. Must be non-NULL.
- * @param SkImageCache Object that handles allocating and freeing the pixel memory, as needed.
- * Must not be NULL.
+ * @param SkImageCache Object that handles allocating and freeing
+ * the pixel memory, as needed. If NULL, use the global
+ * SkScaledImageCache.
*/
SkLazyPixelRef(SkData*, SkBitmapFactory::DecodeProc, SkImageCache*);
@@ -64,14 +65,25 @@ protected:
virtual bool onImplementsDecodeInto() SK_OVERRIDE;
virtual bool onDecodeInto(int pow2, SkBitmap*) SK_OVERRIDE;
+ /**
+ * The allocator is used when (fImageCache==NULL) to allocate
+ * concrete PixelRefs as needed. If NULL, use the default allocator.
+ * This is passed directly into SkBitmap::allocPixels().
+ */
+ virtual void setAllocator(SkBitmap::Allocator * allocator = NULL) {
+ fAllocator = allocator;
scroggo 2013/10/23 15:27:49 SkBitmap::Allocator inherits from SkRefCnt. Typica
hal.canary 2013/10/23 16:11:52 I'll make that change, unless there is any reason
+ }
+
private:
bool fErrorInDecoding;
SkData* fData;
SkBitmapFactory::DecodeProc fDecodeProc;
SkImageCache* fImageCache;
+ // fCacheId is a (SkScaledImageCache::ID*) or a (SkImageCache::ID).
intptr_t fCacheId;
size_t fRowBytes;
SkImage::Info fLazilyCachedInfo;
+ SkBitmap::Allocator* fAllocator;
#if LAZY_CACHE_STATS
static int32_t gCacheHits;

Powered by Google App Engine
This is Rietveld 408576698