diff options
author | scroggo <scroggo@google.com> | 2015-11-23 07:20:57 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-23 07:20:57 -0800 |
commit | 3389e00136188800b98ca69488c0418c374fd78b (patch) | |
tree | 6cbb5b6bc005e618daca29be3873f7211780ebbc /include/core/SkImageDecoder.h | |
parent | a98419be092cce2a7ef27a09b6fd8065ff709cff (diff) |
Add SkPngChunkReader.
This class allows a client of SkCodec to read chunks in the data
stream that are not recognized by libpng. This is used by Android
to specify ninepatch data.
Taken from SkImageDecoder::Peeker. Modify the name of the class
and its method to be more specific to their use. Make
SkImageDecoder::Peeker a subclass of the new class, to help stage
the change in Android.
Add a test to verify that it works.
BUG=skia:4574
BUG=skia:3257
Review URL: https://codereview.chromium.org/1040453002
Diffstat (limited to 'include/core/SkImageDecoder.h')
-rw-r--r-- | include/core/SkImageDecoder.h | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/include/core/SkImageDecoder.h b/include/core/SkImageDecoder.h index 144878c166..30323b59ee 100644 --- a/include/core/SkImageDecoder.h +++ b/include/core/SkImageDecoder.h @@ -10,11 +10,14 @@ #include "SkBitmap.h" #include "SkImage.h" +#include "SkPngChunkReader.h" #include "SkRect.h" #include "SkRefCnt.h" #include "SkTRegistry.h" #include "SkTypes.h" +//#define SK_LEGACY_PEEKER + class SkStream; class SkStreamRewindable; @@ -126,23 +129,20 @@ public: */ bool getRequireUnpremultipliedColors() const { return fRequireUnpremultipliedColors; } - /** \class Peeker - - Base class for optional callbacks to retrieve meta/chunk data out of - an image as it is being decoded. - */ - class Peeker : public SkRefCnt { +#ifdef SK_LEGACY_PEEKER + // Android subclasses SkImageDecoder::Peeker, which has been changed into SkPngChunkReader. + // Temporarily use this class until Android can be updated to directly inherit from + // SkPngChunkReader. + class Peeker : public SkPngChunkReader { public: - /** Return true to continue decoding, or false to indicate an error, which - will cause the decoder to not return the image. - */ + bool readChunk(const char tag[], const void* data, size_t length) final { + return this->peek(tag, data, length); + } virtual bool peek(const char tag[], const void* data, size_t length) = 0; - private: - typedef SkRefCnt INHERITED; }; - - Peeker* getPeeker() const { return fPeeker; } - Peeker* setPeeker(Peeker*); +#endif + SkPngChunkReader* getPeeker() const { return fPeeker; } + SkPngChunkReader* setPeeker(SkPngChunkReader*); /** * By default, the codec will try to comply with the "pref" colortype @@ -229,8 +229,8 @@ public: to allocate the memory from a cache, volatile memory, or even from an existing bitmap's memory. - If a Peeker is installed via setPeeker, it may be used to peek into - meta data during the decode. + If an SkPngChunkReader is installed via setPeeker, it may be used to + peek into meta data during the decode. */ Result decode(SkStream*, SkBitmap* bitmap, SkColorType pref, Mode); Result decode(SkStream* stream, SkBitmap* bitmap, Mode mode) { @@ -350,7 +350,7 @@ protected: SkColorType getPrefColorType(SrcDepth, bool hasAlpha) const; private: - Peeker* fPeeker; + SkPngChunkReader* fPeeker; SkBitmap::Allocator* fAllocator; int fSampleSize; SkColorType fDefaultPref; // use if fUsePrefTable is false |