Chromium Code Reviews| Index: src/lazy/SkCachingPixelRef.h |
| diff --git a/src/lazy/SkCachingPixelRef.h b/src/lazy/SkCachingPixelRef.h |
| index db968dfcdde27ce29cdab589be07413075d084be..6f9951342aed2237d0db0858cee4ae0c2dd60b81 100644 |
| --- a/src/lazy/SkCachingPixelRef.h |
| +++ b/src/lazy/SkCachingPixelRef.h |
| @@ -8,7 +8,8 @@ |
| #ifndef SkCachingPixelRef_DEFINED |
| #define SkCachingPixelRef_DEFINED |
| -#include "SkImage.h" |
| +#include "SkImageInfo.h" |
| +#include "SkImageGenerator.h" |
| #include "SkPixelRef.h" |
| class SkColorTable; |
| @@ -20,60 +21,42 @@ class SkColorTable; |
| * or be destroyed before the next lock. If so, onLockPixels will |
| * attempt to re-decode. |
| * |
| - * Decoding is handled by the pure-virtual functions onDecodeInfo() |
| - * and onDecodePixels(). Subclasses of this class need only provide |
| - * those two functions. |
| + * Decoding is handled by the SkImageGenerator |
| */ |
| class SkCachingPixelRef : public SkPixelRef { |
| public: |
| - SkCachingPixelRef(); |
| - virtual ~SkCachingPixelRef(); |
| + /** |
| + * This created SkCachingPixelRef will take ownership of the |
|
scroggo
2013/12/02 18:26:01
Could you say that the SkCachingPixelRef is instal
|
| + * SkImageGenerator and destroy it. |
| + */ |
| + static bool Install(SkAutoTDelete<SkImageGenerator>* gen, SkBitmap* dst); |
|
scroggo
2013/12/02 18:26:01
Although I understand the motivation - it simplifi
hal.canary
2013/12/04 23:06:41
I ended up changing my mind on this. Let's keep t
|
| protected: |
| + virtual ~SkCachingPixelRef(); |
| virtual void* onLockPixels(SkColorTable** colorTable) SK_OVERRIDE; |
| virtual void onUnlockPixels() SK_OVERRIDE; |
| virtual bool onLockPixelsAreWritable() const SK_OVERRIDE { return false; } |
| - virtual bool onImplementsDecodeInto() SK_OVERRIDE { return true; } |
| - virtual bool onDecodeInto(int pow2, SkBitmap*) SK_OVERRIDE; |
| - |
| - /** |
| - * Configure the supplied bitmap for this pixelRef, based on |
| - * information provided by onDecodeInfo(). Does not set the |
| - * bitmap's pixelRef. */ |
| - bool configure(SkBitmap* bitmap); |
| - |
| - /** |
| - * Cache info from onDecodeInfo(). Returns false on failure. |
| - */ |
| - bool getInfo(SkImageInfo* info); |
| - /** |
| - * Return some information about the pixels, allowing this class |
| - * to allocate pixels. @return false if anything goes wrong. |
| - */ |
| - virtual bool onDecodeInfo(SkImageInfo* info) = 0; |
| - /** |
| - * Decode into the given pixels, a block of memory of size |
| - * (info.fHeight - 1) * rowBytes + (info.fWidth * bytesPerPixel) |
| - * |
| - * @param info Should be identical to the info returned by |
| - * onDecodeInfo so that the implementation can confirm |
| - * that the caller knows what it is asking for (config, |
| - * size). Thiscontract also allows the caller to specify |
| - * different output-configs, which the implementation can |
| - * decide to support or not. |
| - * |
| - * @return false if anything goes wrong. |
| - */ |
| - virtual bool onDecodePixels(const SkImageInfo& info, |
| - void* pixels, |
| - size_t rowBytes) = 0; |
| + virtual SkData* onRefEncodedData() SK_OVERRIDE { |
| + return fImageGenerator->refEncodedData(); |
| + } |
| + // 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() |
| private: |
| - bool fErrorInDecoding; |
| - void* fScaledCacheId; |
| - SkImageInfo fInfo; |
| - |
| + SkImageGenerator* fImageGenerator; |
| + bool fErrorInDecoding; |
| + void* fScaledCacheId; |
| + SkImageInfo fInfo; |
|
scroggo
2013/12/02 18:26:01
fInfo and fRowBytes can be const.
hal.canary
2013/12/04 23:06:41
Done.
|
| + size_t fRowBytes; |
| + |
| + SkCachingPixelRef(SkImageGenerator* imageGenerator, |
| + const SkImageInfo& info, |
| + size_t rowBytes); |
| typedef SkPixelRef INHERITED; |
| }; |