diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/codec/SkCodec.h | 11 | ||||
-rw-r--r-- | include/core/SkImageDecoder.h | 34 | ||||
-rw-r--r-- | include/core/SkPngChunkReader.h | 45 |
3 files changed, 19 insertions, 71 deletions
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h index dffab6b377..d90fea8ced 100644 --- a/include/codec/SkCodec.h +++ b/include/codec/SkCodec.h @@ -17,7 +17,6 @@ #include "SkTypes.h" class SkData; -class SkPngChunkReader; class SkSampler; /** @@ -29,24 +28,18 @@ public: * If this stream represents an encoded image that we know how to decode, * return an SkCodec that can decode it. Otherwise return NULL. * - * If SkPngChunkReader is not NULL, take a ref and pass it to libpng if - * the image is a png. - * * If NULL is returned, the stream is deleted immediately. Otherwise, the * SkCodec takes ownership of it, and will delete it when done with it. */ - static SkCodec* NewFromStream(SkStream*, SkPngChunkReader* = NULL); + static SkCodec* NewFromStream(SkStream*); /** * If this data represents an encoded image that we know how to decode, * return an SkCodec that can decode it. Otherwise return NULL. * - * If SkPngChunkReader is not NULL, take a ref and pass it to libpng if - * the image is a png. - * * Will take a ref if it returns a codec, else will not affect the data. */ - static SkCodec* NewFromData(SkData*, SkPngChunkReader* = NULL); + static SkCodec* NewFromData(SkData*); virtual ~SkCodec(); diff --git a/include/core/SkImageDecoder.h b/include/core/SkImageDecoder.h index 30323b59ee..144878c166 100644 --- a/include/core/SkImageDecoder.h +++ b/include/core/SkImageDecoder.h @@ -10,14 +10,11 @@ #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; @@ -129,20 +126,23 @@ public: */ bool getRequireUnpremultipliedColors() const { return fRequireUnpremultipliedColors; } -#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 { + /** \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 { public: - bool readChunk(const char tag[], const void* data, size_t length) final { - return this->peek(tag, data, length); - } + /** Return true to continue decoding, or false to indicate an error, which + will cause the decoder to not return the image. + */ virtual bool peek(const char tag[], const void* data, size_t length) = 0; + private: + typedef SkRefCnt INHERITED; }; -#endif - SkPngChunkReader* getPeeker() const { return fPeeker; } - SkPngChunkReader* setPeeker(SkPngChunkReader*); + + Peeker* getPeeker() const { return fPeeker; } + Peeker* setPeeker(Peeker*); /** * 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 an SkPngChunkReader is installed via setPeeker, it may be used to - peek into meta data during the decode. + If a Peeker 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: - SkPngChunkReader* fPeeker; + Peeker* fPeeker; SkBitmap::Allocator* fAllocator; int fSampleSize; SkColorType fDefaultPref; // use if fUsePrefTable is false diff --git a/include/core/SkPngChunkReader.h b/include/core/SkPngChunkReader.h deleted file mode 100644 index f424dd8cfc..0000000000 --- a/include/core/SkPngChunkReader.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef SkPngChunkReader_DEFINED -#define SkPngChunkReader_DEFINED - -#include "SkTypes.h" -#include "SkRefCnt.h" - -/** - * SkPngChunkReader - * - * Base class for optional callbacks to retrieve meta/chunk data out of a PNG - * encoded image as it is being decoded. - * Used by SkImageDecoder and SkCodec. - */ -class SkPngChunkReader : public SkRefCnt { -public: - /** - * This will be called by the decoder when it sees an unknown chunk. - * - * Use by SkCodec: - * Depending on the location of the unknown chunks, this callback may be - * called by - * - the factory (NewFromStream/NewFromData) - * - getPixels - * - startScanlineDecode - * - the first call to getScanlines/skipScanlines - * The callback may be called from a different thread (e.g. if the SkCodec - * is passed to another thread), and it may be called multiple times, if - * the SkCodec is used multiple times. - * - * @param tag Name for this type of chunk. - * @param data Data to be interpreted by the subclass. - * @param length Number of bytes of data in the chunk. - * @return true to continue decoding, or false to indicate an error, which - * will cause the decoder to not return the image. - */ - virtual bool readChunk(const char tag[], const void* data, size_t length) = 0; -}; -#endif // SkPngChunkReader_DEFINED |