| Index: include/codec/SkCodec.h
|
| diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h
|
| index 363347dd72c08f0e05f97433bf9a5da473df05ea..6110bfe22cbbf382c60128e83d9e8d6bc22fb1f8 100644
|
| --- a/include/codec/SkCodec.h
|
| +++ b/include/codec/SkCodec.h
|
| @@ -18,6 +18,8 @@
|
| #include "SkTypes.h"
|
| #include "SkYUVSizeInfo.h"
|
|
|
| +#include <vector>
|
| +
|
| class SkColorSpace;
|
| class SkData;
|
| class SkPngChunkReader;
|
| @@ -220,6 +222,38 @@ public:
|
| };
|
|
|
| /**
|
| + * Additional options that only apply to multiframe images.
|
| + */
|
| + struct MultiFrameOptions {
|
| + MultiFrameOptions()
|
| + : fIndex(0)
|
| + , fHasPriorFrame(false)
|
| + {}
|
| +
|
| + /**
|
| + * The frame to decode.
|
| + */
|
| + size_t fIndex;
|
| +
|
| + /**
|
| + * If true, the dst already contains the prior frame.
|
| + *
|
| + * If fIndex needs to be blended with a prior frame (as reported by
|
| + * getFrameInfo[fIndex].fRequiredFrame), the client can set this to
|
| + * either true or false:
|
| + *
|
| + * true means that the prior frame is already in the dst, and this
|
| + * codec only needs to decode fIndex and blend it with the dst.
|
| + * Options.fZeroInitialized is ignored in this case.
|
| + *
|
| + * false means that the dst does not contain the prior frame, so this
|
| + * codec needs to first decode the prior frame (which in turn may need
|
| + * to decode its prior frame).
|
| + */
|
| + bool fHasPriorFrame;
|
| + };
|
| +
|
| + /**
|
| * Whether or not the memory passed to getPixels is zero initialized.
|
| */
|
| enum ZeroInitialized {
|
| @@ -243,10 +277,11 @@ public:
|
| struct Options {
|
| Options()
|
| : fZeroInitialized(kNo_ZeroInitialized)
|
| - , fSubset(NULL)
|
| + , fSubset(nullptr)
|
| + , fFrameOptions(nullptr)
|
| {}
|
|
|
| - ZeroInitialized fZeroInitialized;
|
| + ZeroInitialized fZeroInitialized;
|
| /**
|
| * If not NULL, represents a subset of the original image to decode.
|
| * Must be within the bounds returned by getInfo().
|
| @@ -264,7 +299,14 @@ public:
|
| * subset left and subset width to decode partial scanlines on calls
|
| * to getScanlines().
|
| */
|
| - SkIRect* fSubset;
|
| + const SkIRect* fSubset;
|
| +
|
| + /**
|
| + * Options that are only relevant for multi-frame images.
|
| + *
|
| + * Unowned pointer.
|
| + */
|
| + const MultiFrameOptions* fFrameOptions;
|
| };
|
|
|
| /**
|
| @@ -522,19 +564,6 @@ public:
|
| * Upside down bmps are an example.
|
| */
|
| kBottomUp_SkScanlineOrder,
|
| -
|
| - /*
|
| - * This indicates that the scanline decoder reliably outputs rows, but
|
| - * they will not be in logical order. If the scanline format is
|
| - * kOutOfOrder, the nextScanline() API should be used to determine the
|
| - * actual y-coordinate of the next output row.
|
| - *
|
| - * For this scanline ordering, it is advisable to get and skip
|
| - * scanlines one at a time.
|
| - *
|
| - * Interlaced gifs are an example.
|
| - */
|
| - kOutOfOrder_SkScanlineOrder,
|
| };
|
|
|
| /**
|
| @@ -550,7 +579,7 @@ public:
|
| * decoder.
|
| *
|
| * This will equal fCurrScanline, except in the case of strangely
|
| - * encoded image types (bottom-up bmps, interlaced gifs).
|
| + * encoded image types (bottom-up bmps).
|
| *
|
| * Results are undefined when not in scanline decoding mode.
|
| */
|
| @@ -566,6 +595,40 @@ public:
|
| */
|
| int outputScanline(int inputScanline) const;
|
|
|
| + // The required frame for an independent frame is marked as
|
| + // kIndependentFrame.
|
| + static constexpr size_t kIndependentFrame = static_cast<size_t>(-1);
|
| +
|
| + /**
|
| + * Information about individual frames in a multi-framed image.
|
| + */
|
| + struct FrameInfo {
|
| + /**
|
| + * The frame that this frame needs to be blended with, or
|
| + * kIndependentFrame.
|
| + */
|
| + size_t fRequiredFrame;
|
| +
|
| + /**
|
| + * Number of milliseconds to show this frame.
|
| + */
|
| + size_t fDuration;
|
| + };
|
| +
|
| + /**
|
| + * Return info about the frames in the image.
|
| + *
|
| + * May require reading through the stream to determine the number of
|
| + * frames.
|
| + *
|
| + * As such, future decoding calls may require a rewind.
|
| + *
|
| + * For single-frame images, this will return an empty vector.
|
| + */
|
| + std::vector<FrameInfo> getFrameInfo() {
|
| + return this->onGetFrameInfo();
|
| + }
|
| +
|
| protected:
|
| /**
|
| * Takes ownership of SkStream*
|
| @@ -706,6 +769,11 @@ protected:
|
|
|
| virtual int onOutputScanline(int inputScanline) const;
|
|
|
| + virtual std::vector<FrameInfo> onGetFrameInfo() {
|
| + // empty vector - this is not animated.
|
| + return {};
|
| + }
|
| +
|
| /**
|
| * Used for testing with qcms.
|
| * FIXME: Remove this when we are done comparing with qcms.
|
| @@ -782,7 +850,7 @@ private:
|
| * May create a sampler, if one is not currently being used. Otherwise, does
|
| * not affect ownership.
|
| *
|
| - * Only valid during scanline decoding.
|
| + * Only valid during scanline decoding or incremental decoding.
|
| */
|
| virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; }
|
|
|
|
|