diff options
author | Leon Scroggins III <scroggo@google.com> | 2018-01-14 14:46:51 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-01-16 20:36:09 +0000 |
commit | 42ee2845673c38f6d70f0d8ddf7e26dce8aa61d3 (patch) | |
tree | 623988f152fca794623e25458bf55212fe5b670d /include | |
parent | 23e0cf29639459fb8695bf8174d82ae47fd0d0bb (diff) |
Use SkAndroidCodec in SkAnimatedImage
Bug: b/63909536
Bug: b/63908092
SkAnimatedImage is designed around a specific Android use case, so move
it into the android folders.
Make SkAnimatedImage hold an SkAndroidCodec (instead of an SkCodec).
Expose fCodec so that SkAnimatedImage can animate by using the internal
SkCodec.
Update the sample to use SkAndroidCodec.
Allow webp to decode a scaled down animation. For RestoreBG frames,
adjust the frameRect (which is erased) to account for the scaling. Add
a test to verify that we decode a webp with a RestoreBG frame
successfully. Disable scaling for later frames in other formats (GIF,
for now), since the code for erasing a RestoreBG frame is currently
unaware of the sampling.
Change-Id: I5dd2b86138f2c7f6adcd08dce1bd49040f7dc224
Reviewed-on: https://skia-review.googlesource.com/94621
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/android/SkAnimatedImage.h (renamed from include/codec/SkAnimatedImage.h) | 22 | ||||
-rw-r--r-- | include/codec/SkAndroidCodec.h | 4 |
2 files changed, 13 insertions, 13 deletions
diff --git a/include/codec/SkAnimatedImage.h b/include/android/SkAnimatedImage.h index aece2f66d1..1bd9291057 100644 --- a/include/codec/SkAnimatedImage.h +++ b/include/android/SkAnimatedImage.h @@ -12,7 +12,7 @@ #include "SkCodecAnimation.h" #include "SkDrawable.h" -class SkCodec; +class SkAndroidCodec; /** * Thread unsafe drawable for drawing animated images (e.g. GIF). @@ -20,12 +20,12 @@ class SkCodec; class SK_API SkAnimatedImage : public SkDrawable { public: /** - * Create an SkAnimatedImage from the SkCodec. + * Create an SkAnimatedImage from the SkAndroidCodec. * * Returns null on failure to allocate pixels. On success, this will * decode the first frame. It will not animate until start() is called. */ - static sk_sp<SkAnimatedImage> MakeFromCodec(std::unique_ptr<SkCodec>); + static sk_sp<SkAnimatedImage> Make(std::unique_ptr<SkAndroidCodec>); ~SkAnimatedImage() override; @@ -70,15 +70,15 @@ private: bool copyTo(Frame*) const; }; - std::unique_ptr<SkCodec> fCodec; - bool fFinished; - bool fRunning; - double fNowMS; - double fRemainingMS; - Frame fActiveFrame; - Frame fRestoreFrame; + std::unique_ptr<SkAndroidCodec> fCodec; + bool fFinished; + bool fRunning; + double fNowMS; + double fRemainingMS; + Frame fActiveFrame; + Frame fRestoreFrame; - SkAnimatedImage(std::unique_ptr<SkCodec>); + SkAnimatedImage(std::unique_ptr<SkAndroidCodec>); typedef SkDrawable INHERITED; }; diff --git a/include/codec/SkAndroidCodec.h b/include/codec/SkAndroidCodec.h index e1e2843393..2bf38025bf 100644 --- a/include/codec/SkAndroidCodec.h +++ b/include/codec/SkAndroidCodec.h @@ -231,12 +231,12 @@ public: return this->getAndroidPixels(info, pixels, rowBytes); } + SkCodec* codec() const { return fCodec.get(); } + protected: SkAndroidCodec(SkCodec*); - SkCodec* codec() const { return fCodec.get(); } - virtual SkISize onGetSampledDimensions(int sampleSize) const = 0; virtual bool onGetSupportedSubset(SkIRect* desiredSubset) const = 0; |