Chromium Code Reviews| Index: include/codec/SkCodec.h |
| diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h |
| index 363347dd72c08f0e05f97433bf9a5da473df05ea..be01c63bf154a924f99126aa8e936d9d31c20066 100644 |
| --- a/include/codec/SkCodec.h |
| +++ b/include/codec/SkCodec.h |
| @@ -244,6 +244,8 @@ public: |
| Options() |
| : fZeroInitialized(kNo_ZeroInitialized) |
|
msarett
2016/09/21 22:23:48
I dislike having this option. Obviously unrelated
scroggo
2016/09/22 16:46:43
It's certainly awkward to have both fZeroInitializ
|
| , fSubset(NULL) |
| + , fFrameIndex(0) |
|
msarett
2016/09/21 22:23:48
I think I might prefer it if all of the "multi-fra
scroggo
2016/09/22 16:46:42
I considered that, but I'm not sure whether it's b
|
| + , fHasPriorFrame(false) |
| {} |
|
msarett
2016/09/21 22:23:48
While I'm nitting on the Options object, here's an
scroggo
2016/09/22 16:46:43
Yeah, we put those in the AndroidOptions object as
|
| ZeroInitialized fZeroInitialized; |
| @@ -265,6 +267,30 @@ public: |
| * to getScanlines(). |
| */ |
| SkIRect* fSubset; |
| + |
| + /** |
| + * For multiframe images, this represents the frame to decode. |
| + * |
| + * Ignored by single frame images. |
| + */ |
| + size_t fFrameIndex; |
| + |
| + /** |
| + * If true, the dst already contains the prior frame. |
| + * |
| + * Only meaningful for multiframe images. If fFrameIndex needs to be |
| + * blended with a prior frame (as reported by |
| + * getRequiredFrame(fFrameIndex)), 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 fFrameIndex and blend it with the dst. |
| + * |
| + * false means that the dst is uninitialized, so this codec needs to |
| + * first decode the prior frame (which in turn may need to decode its |
| + * prior frame). |
| + */ |
| + bool fHasPriorFrame; |
|
cblume
2016/09/22 01:08:47
I am curious about the design of this.
As I under
cblume
2016/09/22 01:42:19
Adding to this:
If we are still downloading the im
scroggo
2016/09/22 16:46:43
Agreed.
scroggo
2016/09/22 16:46:43
That is correct.
cblume
2016/09/22 21:29:02
I agree with what you are saying. Good thinking.
scroggo
2016/09/23 15:53:15
My preference would be to hide the dispose method
cblume
2016/09/23 19:15:45
I agree. We can cross that bridge if it becomes ne
|
| }; |
| /** |
| @@ -566,6 +592,40 @@ public: |
| */ |
| int outputScanline(int inputScanline) const; |
| + /** |
| + * Return the number of 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. |
| + */ |
| + size_t getFrameCount() { |
|
msarett
2016/09/21 22:23:48
Can we get away with not having this? Seems like
cblume
2016/09/22 01:08:47
In the case of gif and apng, we won't know in adva
cblume
2016/09/22 01:42:19
Correcting myself:
We could still be wise about wh
joostouwerling
2016/09/22 15:43:16
For apng, the acTL chunk with the number of frames
scroggo
2016/09/22 16:46:42
FWIW, my initial design (patch set 1, which I work
cblume
2016/09/22 21:29:02
Oh man, that is a bummer.
As a client, having the
scroggo
2016/09/23 15:53:15
It might be easier not to provide the metadata up
cblume
2016/09/23 19:15:45
An alternative would be if Chrome changed its catc
scroggo
2016/09/23 21:15:00
Those sound like good reasons to change the catchu
cblume
2016/09/23 23:31:32
Oh no no. I didn't mean that the API changes. I me
scroggo
2016/09/26 15:51:43
+1
|
| + return this->onGetFrameCount(); |
| + } |
| + |
| + // The required frame for an independent frame is marked as |
| + // kIndependentFrame. |
| + static constexpr size_t kIndependentFrame = static_cast<size_t>(-1); |
| + |
| + /** |
| + * For a multiframed image, return the image that frame |index| needs to |
| + * be blended with. |
| + * |
| + * If the frame needs no blending, return kIndependentFrame. |
| + */ |
| + size_t getRequiredFrame(size_t index) { |
| + return this->onGetRequiredFrame(index); |
| + } |
| + |
| + /** |
| + * For a multiframed image, return the number of 1/100 seconds to |
| + * show frame |index|. |
| + */ |
| + size_t getFrameDuration(size_t index) { |
| + return this->onGetFrameDuration(index); |
| + } |
| + |
| protected: |
| /** |
| * Takes ownership of SkStream* |
| @@ -706,6 +766,18 @@ protected: |
| virtual int onOutputScanline(int inputScanline) const; |
| + virtual size_t onGetFrameCount() { |
| + return 1; |
| + } |
| + |
| + virtual size_t onGetRequiredFrame(size_t) { |
| + return kIndependentFrame; |
| + } |
| + |
| + virtual size_t onGetFrameDuration(size_t) { |
| + return 0; |
| + } |
| + |
| /** |
| * Used for testing with qcms. |
| * FIXME: Remove this when we are done comparing with qcms. |