| Index: src/lazy/SkCachingPixelRef.h
|
| diff --git a/src/lazy/SkCachingPixelRef.h b/src/lazy/SkCachingPixelRef.h
|
| index db968dfcdde27ce29cdab589be07413075d084be..81092dc78e9c429a87aa8ff80f45602ddda1d78f 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,61 +21,51 @@ 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();
|
| + /**
|
| + * Takes ownership of SkImageGenerator. If this method fails for
|
| + * whatever reason, it will return false and immediatetely delete
|
| + * the generator. If it succeeds, it will modify destination
|
| + * bitmap.
|
| + *
|
| + * If Install fails or when the SkCachingPixelRef that is
|
| + * installed into destination is destroyed, it will call
|
| + * SkDELETE() on the generator. Therefore, generator should be
|
| + * allocated with SkNEW() or SkNEW_ARGS().
|
| + */
|
| + static bool Install(SkImageGenerator* gen, SkBitmap* dst);
|
|
|
| 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* const fImageGenerator;
|
| + bool fErrorInDecoding;
|
| + void* fScaledCacheId;
|
| + const SkImageInfo fInfo;
|
| + const size_t fRowBytes;
|
|
|
| + SkCachingPixelRef(SkImageGenerator* imageGenerator,
|
| + const SkImageInfo& info,
|
| + size_t rowBytes);
|
| typedef SkPixelRef INHERITED;
|
| };
|
|
|
| #endif // SkCachingPixelRef_DEFINED
|
| +
|
|
|