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

Unified Diff: src/lazy/SkLazyPixelRef.h

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: src/lazy/SkLazyPixelRef.h
diff --git a/src/lazy/SkLazyPixelRef.h b/src/lazy/SkLazyPixelRef.h
index f8a16d168914326b52726241358bab7d77b5c2d7..a48c55f0ce3083cac11ac776b2e53e6c526a500a 100644
--- a/src/lazy/SkLazyPixelRef.h
+++ b/src/lazy/SkLazyPixelRef.h
@@ -8,16 +8,12 @@
#ifndef SkLazyPixelRef_DEFINED
#define SkLazyPixelRef_DEFINED
-#include "SkBitmapFactory.h"
-#include "SkImage.h"
#include "SkImageCache.h"
+#include "SkImageGenerator.h"
+#include "SkImageInfo.h"
#include "SkPixelRef.h"
-#include "SkFlattenable.h"
-#include "SkScaledImageCache.h"
class SkColorTable;
-class SkData;
-class SkImageCache;
#ifdef SK_DEBUG
#define LAZY_CACHE_STATS 1
@@ -29,19 +25,12 @@ class SkImageCache;
* PixelRef which defers decoding until SkBitmap::lockPixels() is called.
*/
class SkLazyPixelRef : public SkPixelRef {
-
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. If NULL, use the global
- * SkScaledImageCache.
+ * Given a SkImageGenerator object, creates a new SkLazyPixelRef
+ * and installs it into destination SkBitmap.
*/
- SkLazyPixelRef(SkData*, SkBitmapFactory::DecodeProc, SkImageCache*);
-
- virtual ~SkLazyPixelRef();
+ static bool Install(SkImageGenerator*, SkImageCache*, SkBitmap* dst);
reed1 2013/11/25 18:06:56 Do we still support SkImageCache?
#ifdef SK_DEBUG
intptr_t getCacheId() const { return fCacheId; }
@@ -53,42 +42,45 @@ public:
static void ResetCacheStats() { gCacheHits = gCacheMisses = 0; }
#endif
- // No need to flatten this object. When flattening an SkBitmap, SkOrderedWriteBuffer will check
- // the encoded data and write that instead.
- // Future implementations of SkFlattenableWriteBuffer will need to special case for
- // onRefEncodedData as well.
+ // No need to flatten this object. When flattening an SkBitmap,
+ // SkOrderedWriteBuffer will check the encoded data and write that
+ // instead.
+ // Future implementations of SkFlattenableWriteBuffer will need to
+ // special case for onRefEncodedData as well.
SK_DECLARE_UNFLATTENABLE_OBJECT()
protected:
- virtual void* onLockPixels(SkColorTable**) SK_OVERRIDE;
+ virtual ~SkLazyPixelRef();
+ virtual void* onLockPixels(SkColorTable** colorTable) SK_OVERRIDE;
virtual void onUnlockPixels() SK_OVERRIDE;
virtual bool onLockPixelsAreWritable() const SK_OVERRIDE { return false; }
virtual SkData* onRefEncodedData() SK_OVERRIDE;
- virtual bool onImplementsDecodeInto() SK_OVERRIDE;
+ virtual bool onImplementsDecodeInto() SK_OVERRIDE { return true; }
virtual bool onDecodeInto(int pow2, SkBitmap*) SK_OVERRIDE;
private:
- bool fErrorInDecoding;
- SkData* fData;
- SkBitmapFactory::DecodeProc fDecodeProc;
- SkImageCache* fImageCache;
- union {
- SkImageCache::ID fCacheId;
- SkScaledImageCache::ID* fScaledCacheId;
- };
- size_t fRowBytes;
- SkImageInfo fLazilyCachedInfo;
+ bool fErrorInDecoding;
+ SkImageGenerator* fImageGenerator;
+ SkImageCache::ID fCacheId;
+ SkImageInfo fInfo;
+ size_t fSize;
+ size_t fRowBytes;
+ SkImageCache* fImageCache;
#if LAZY_CACHE_STATS
- static int32_t gCacheHits;
- static int32_t gCacheMisses;
+ static int32_t gCacheHits;
+ static int32_t gCacheMisses;
#endif
- // lazily initialized our cached info. Returns NULL on failure.
- const SkImage::Info* getCachedInfo();
- void* lockScaledImageCachePixels();
- void* lockImageCachePixels();
-
+ /**
+ * @param SkImageCache Object that handles allocating and freeing
+ * the pixel memory, as needed.
+ */
+ SkLazyPixelRef(SkImageGenerator*,
+ const SkImageInfo&,
+ size_t size,
+ size_t rowBytes,
+ SkImageCache*);
typedef SkPixelRef INHERITED;
};

Powered by Google App Engine
This is Rietveld 408576698