diff options
author | Leon Scroggins III <scroggo@google.com> | 2018-01-16 15:26:35 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-01-17 17:46:17 +0000 |
commit | b1b7f70103378aff5e9a315e7788866b648ab4b1 (patch) | |
tree | 5e9c63445bbd5c7ebb301273e929e942ad4642a0 /include/android | |
parent | 9d8abc5816d9e5533e7943c52fa6856177f482b2 (diff) |
Add Android ImageDecoder features to SkAnimatedImage
Bug: b/63909536
Bug: b/63908092
- Scale to an arbitrary size, using the decoding library if it supports
it, and Skia otherwise
- Crop to a subset
- Post-processing with an SkPicture, to facilitate circle masks etc
- isRunning, to implement Animatable2 interface in Java
Change-Id: I13dbabee8e4a22e5cc193856aa3e94ce23ae4cb5
Reviewed-on: https://skia-review.googlesource.com/94660
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'include/android')
-rw-r--r-- | include/android/SkAnimatedImage.h | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/include/android/SkAnimatedImage.h b/include/android/SkAnimatedImage.h index 1bd9291057..1c1a2fc039 100644 --- a/include/android/SkAnimatedImage.h +++ b/include/android/SkAnimatedImage.h @@ -11,8 +11,11 @@ #include "SkBitmap.h" #include "SkCodecAnimation.h" #include "SkDrawable.h" +#include "SkMatrix.h" +#include "SkRect.h" class SkAndroidCodec; +class SkPicture; /** * Thread unsafe drawable for drawing animated images (e.g. GIF). @@ -24,6 +27,16 @@ public: * * Returns null on failure to allocate pixels. On success, this will * decode the first frame. It will not animate until start() is called. + * + * @param scaledSize Size to draw the image, possibly requiring scaling. + * @param cropRect Rectangle to crop to after scaling. + * @param postProcess Picture to apply after scaling and cropping. + */ + static sk_sp<SkAnimatedImage> Make(std::unique_ptr<SkAndroidCodec>, + SkISize scaledSize, SkIRect cropRect, sk_sp<SkPicture> postProcess); + + /** + * Simpler version that uses the default size, no cropping, and no postProcess. */ static sk_sp<SkAnimatedImage> Make(std::unique_ptr<SkAndroidCodec>); @@ -47,6 +60,13 @@ public: void reset(); /** + * Whether the animation is active. + * + * If true, update() can be called to animate. + */ + bool isRunning() const { return fRunning && !fFinished; } + + /** * Update the current time. If the image is animating, this may decode * a new frame. * @@ -71,6 +91,13 @@ private: }; std::unique_ptr<SkAndroidCodec> fCodec; + const SkISize fScaledSize; + const SkImageInfo fDecodeInfo; + const SkIRect fCropRect; + const sk_sp<SkPicture> fPostProcess; + const bool fSimple; // no crop, scale, or postprocess + SkMatrix fMatrix; // used only if !fSimple + bool fFinished; bool fRunning; double fNowMS; @@ -78,7 +105,8 @@ private: Frame fActiveFrame; Frame fRestoreFrame; - SkAnimatedImage(std::unique_ptr<SkAndroidCodec>); + SkAnimatedImage(std::unique_ptr<SkAndroidCodec>, SkISize scaledSize, + SkImageInfo decodeInfo, SkIRect cropRect, sk_sp<SkPicture> postProcess); typedef SkDrawable INHERITED; }; |