aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/android/SkAnimatedImage.cpp
Commit message (Collapse)AuthorAge
* Stop using SkTSwap.Gravatar Ben Wagner2018-06-19
| | | | | | | | | | | | | Use std::swap instead. It does not appear that any external user specializes SkTSwap, but some may still use it. This removes all use in Skia so that SkTSwap can later be removed in a smaller CL. After that the <utility> include can be removed from SkTypes.h. Change-Id: If03d4ee07dbecda961aa9f0dc34d171ef5168753 Reviewed-on: https://skia-review.googlesource.com/135578 Reviewed-by: Hal Canary <halcanary@google.com> Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
* Make sk_sp operator bool explicit.Gravatar Ben Wagner2018-05-30
| | | | | | | | | | | | | The sk_sp class has been using the operator pointer to field as a c++98 version of explicit operator bool. This change updates this class to use explicit operator bool. The one visible change is that the pointer to field version isn't quite as explcit, requiring code changes for some users. Change-Id: Iddf8fb347b1d3ec33db1af08489c9fd885c9bf08 Reviewed-on: https://skia-review.googlesource.com/130380 Commit-Queue: Ben Wagner <bungeman@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
* Alternate between two SkBitmaps in SkAnimatedImageGravatar Leon Scroggins III2018-05-23
| | | | | | | | | | | | | | | | | | | | | | Bug: 78866720 The client in Android calls newPictureSnapshot, which results in copying the mutable SkBitmap into a newly allocated one in each frame. Avoid this by calling SkMakeImageFromRasterBitmap with kNever_SkCopyPixelsMode. Make SkAnimatedImage copy on write, by copying before decoding if the bitmap's pixel ref is not unique. Android's AnimatedImageDrawable's current architecture only decodes one frame in advance, so it will never need to perform the copy on write. This will save one bitmap allocation per GIF frame. Add a test to verify that copy on write works as expected. Change-Id: I87eb6e84089096cd2d618b91fb627fc58677e66a Reviewed-on: https://skia-review.googlesource.com/129841 Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com> Auto-Submit: Leon Scroggins <scroggo@google.com>
* Fix drawing SkAnimatedImages with transparencyGravatar Leon Scroggins III2018-03-06
| | | | | | | | | | | | Bug: b/74195953 Do not use SkBlendMode::kSrc, which overwrites the pixels that were already present. Instead, blend normally. Change-Id: Ie6843c6278212fddddd0ba0ae292fdb5eaf2342e Reviewed-on: https://skia-review.googlesource.com/112200 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Address MSAN bug in SkAnimatedImage::decodeNextFrameGravatar Kevin Lubick2018-02-13
| | | | | | | | Bug: oss-fuzz:6284 Change-Id: I77537d6624e7d03fbbfe96046300a9dd7d609064 Reviewed-on: https://skia-review.googlesource.com/106930 Commit-Queue: Kevin Lubick <kjlubick@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com>
* Simplify SkAnimatedImageGravatar Leon Scroggins III2018-01-30
| | | | | | | | | | | | | Bug: b/63908092 Rather than keeping track of the time and whether the animation is running, leave that up to the client. Offer a single method to decode the next frame, allowing the client to stay one frame ahead. Change-Id: I546013e32e3a0874181b0dce1349bbec07aaadd4 Reviewed-on: https://skia-review.googlesource.com/101544 Reviewed-by: Derek Sollenberger <djsollen@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Make SkAnimatedImage::update return sentinel when stoppedGravatar Leon Scroggins III2018-01-23
| | | | | | | | Bug: b/63908092 Change-Id: I585f3d3efde1db4d5be36b11f19fe6e88f131608 Reviewed-on: https://skia-review.googlesource.com/98062 Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Respect repetition count in SkAnimatedImageGravatar Leon Scroggins III2018-01-22
| | | | | | | | | | | | | | | | | | | | | | | | | | Bug: b/63908092 By default use the repetition count stored in the encoded data (if any). Allow setting the repetition count manually, so that the animation will stop after n+1 total cycles (unless -1 is used for infinite). If the animation is complete, make start reset it. When the animation is not running, make update return max double (i.e. no need to update any time soon). Fix a bug where the first call to update returned -1. Share write_bm with CodecAnimTest, for debugging. Update Sample to check isRunning rather than keeping its own record of whether the animation is running. Change-Id: I883e4d7325f7a7b23a422fa9d756f9ea3018f0f8 Reviewed-on: https://skia-review.googlesource.com/97082 Reviewed-by: Derek Sollenberger <djsollen@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Add Android ImageDecoder features to SkAnimatedImageGravatar Leon Scroggins III2018-01-17
| | | | | | | | | | | | | | | | 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>
* Use SkAndroidCodec in SkAnimatedImageGravatar Leon Scroggins III2018-01-16
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>