This is a reland of 4fdf9f9ce5
No change from the original, which was just reverted to be able to
cleanly revert its parent, which has now been relanded with a fix.
Original change's description:
> SkAnimatedImage: Use fSampleSize
>
> Bug: b/163595585
>
> This will allow using less memory when decoding an animated GIF by
> sampling at decode time. This is tested by the animated_image GMs.
>
> Change-Id: I748b2180827623e4ca1fc0fd4d6dd02733b3b5f2
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333226
> Commit-Queue: Leon Scroggins <scroggo@google.com>
> Reviewed-by: Derek Sollenberger <djsollen@google.com>
Bug: b/163595585
Change-Id: I3249bd04b64750a50a4c5c787db3e80ac4d85e67
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335279
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
This reverts commit 4fdf9f9ce5.
Reason for revert: Google3 and ASAN failures caused by the prior
change, which this depends on.
Original change's description:
> SkAnimatedImage: Use fSampleSize
>
> Bug: b/163595585
>
> This will allow using less memory when decoding an animated GIF by
> sampling at decode time. This is tested by the animated_image GMs.
>
> Change-Id: I748b2180827623e4ca1fc0fd4d6dd02733b3b5f2
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333226
> Commit-Queue: Leon Scroggins <scroggo@google.com>
> Reviewed-by: Derek Sollenberger <djsollen@google.com>
TBR=djsollen@google.com,scroggo@google.com
Change-Id: I0d30ada4eba2302ce0c5f85b1174d0618ae0f589
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: b/163595585
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334839
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Bug: b/163595585
This will allow using less memory when decoding an animated GIF by
sampling at decode time. This is tested by the animated_image GMs.
Change-Id: I748b2180827623e4ca1fc0fd4d6dd02733b3b5f2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333226
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Bug: skia:10914
Bug: b/163595585
In a WebP image, it is possible to combine animation with an EXIF
orientation. While SkAndroidCodec attempts to handle orientation itself
by decoding into temporary memory and then drawing through a matrix,
this doesn't work directly when compositing a P-frame into a prior
frame. SkAnimatedImage already uses an SkMatrix to handle cropping and
scaling, so update that matrix to include the orientation.
Make SkAnimatedImage a friend of SkAndroidCodec. This allows the former
to have the same ExifOrientationBehavior specified by the latter, and to
recreate the latter so it does not try to handle the orientation itself.
Clip SkAnimatedImage to its bounds. Android's AnimatedImageDrawable
performs its own clip, but this makes a crop rect work for other
clients.
Update getCurrentFrame to take cropping, scaling, and orientation into
account. This method is used by CanvasKit, which does not use cropping
or scaling, but will now properly orient an animation with an EXIF
orientation.
Add a GM that exercises the various combinations of ways SkAnimatedImage
can be used:
- via newPictureSnapshot (as in Android) versus getCurrentFrame
- scaling down to a dimension that can be output from the
SkAndroidCodec, versus up, which SkAnimatedImage scales
- with a crop rect
- with a post processor
Change-Id: If1854e9aea23fc4afddf75d39132b38e3fbc6071
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333223
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
The only caller is CanvasKit, and SkAnimatedImage already has getBounds
(from SkDrawable) which does the same thing, except it returns
SkScalars. It also takes scaling and cropping into account, which
CanvasKit does not use, and in a future commit, it will consider
orientation. Switch CanvasKit to use getBounds.
Change-Id: Ia956f91d241641aec450f3aba99583e95a3ff386
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333222
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
This version was used before we added the version with an SkImageInfo
parameter to handle the SkColorSpace. That version supports all use
cases supported by this old one.
Change-Id: I966cfc83ac34d4951283eaf9e81febb032f461cf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333221
Commit-Queue: Leon Scroggins <scroggo@google.com>
Auto-Submit: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Mechanically updated via Xcode "Replace Regular Expression":
typedef (.*) INHERITED;
-->
using INHERITED = $1;
The ClangTidy approach generated an even larger CL which would have
required a significant amount of hand-tweaking to be usable.
Change-Id: I671dc9d9efdf6d60151325c8d4d13fad7e10a15b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/314999
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Expose a android framework-only function to reset the saved clip geometry
a device-space pixel rect (e.g. the device clip restriction). Using a
regular intersect clip operation after this call should match the
behavior of the legacy replace operation with a clip restriction.
This is a step to removing the separate device clip
restriction API and the deprecated expanding clip ops, as part of the
plan described here: https://docs.google.com/document/d/1ddIk74A1rL5Kj5kGcnInOYKVAXs3J2IsSgU5BLit0Ng/edit?usp=sharing
Bug: skia:10207
Bug: skia:10209
Change-Id: I57d3bcc7b5b257935eb2bf2099d472f2ef354d5b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298824
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Bug: skia:10154
Once ag/11371053 lands, Android will only be referencing the new version
at android::skia::BitmapRegionDecoder. Remove the old code that remained
for the transition.
Change-Id: Ic532d705e8f2861f56dcaa0ac1c68dd2b0712035
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291357
Commit-Queue: Leon Scroggins <scroggo@google.com>
Auto-Submit: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Bug: skia:10154
This will make it clear that these files are for Android use and
avoid compiling them for other clients.
Update testing tools to use android::skia::BitmapRegionDecoder, but
only if SK_ENABLE_ANDROID_UTILS is defined.
Take this opportunity to clean up the class:
- The base class, which was originally designed to allow switching
amongst different implementations, is no longer needed. Rename
SkBitmapRegionCodec to android::skia::BitmapRegionDecoder
(following the new convention and matching the Java API name).
Continue to inherit from SkBitmapRegionDecoder temporarily, to
allow Android to switch to the new API.
- Use std::unique_ptr instead of passing raw pointers.
Add a test to verify that we only create a BitmapRegionDecoder if
it is one of the supported types.
Change-Id: Ied13fc8acb105fde042553331846d95ae15d6b57
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/287498
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Flutter on the web wants to be able to extract arbitrary frames from
an animated image and pass those into functions like:
drawAtlas, drawImage, drawImageRect
This should allow that to happen w/o having to add lots of variants like
drawAnimatedImage. If this sticks, is drawAnimatedImage still useful?
(maybe it saves a copy?)
Change-Id: I99d7045c5dea61d0a1bd6d335c88e7517f2c4fc2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/263020
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Mike Reed <reed@google.com>
With these things exposed, I think Flutter will not need
CanvasKit to expose the very complex SkCodec API.
Change-Id: Iace1b496d1dcb8842181466e860e8f212aba7b48
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/253542
Reviewed-by: Leon Scroggins <scroggo@google.com>
Current strategy: everything from the top
Things to look at first are the manual changes:
- added tools/rewrite_includes.py
- removed -Idirectives from BUILD.gn
- various compile.sh simplifications
- tweak tools/embed_resources.py
- update gn/find_headers.py to write paths from the top
- update gn/gn_to_bp.py SkUserConfig.h layout
so that #include "include/config/SkUserConfig.h" always
gets the header we want.
No-Presubmit: true
Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Implement SkAndroidFrameworkUtil::getBaseWrappedCanvas, which gets
the real canvas behind SkPaintFilterCanvas. This is useful, because
SkCanvas::drawDrawable works differently on a GPU backed canvas.
Test: Built and ran with Android
Bug: b/128792554
Change-Id: I5b75d42256d7a4efca987d55be2ce064c10fb4e7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/204442
Commit-Queue: Stan Iliev <stani@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Add a new constructor which merges the SkISize scaledSize with the
SkImageInfo. This allows passing an SkColorSpace to the decode.
Update the test to call the new API.
Bug: b/123301872
Change-Id: I9fd89198e97ac9b8e6dc9fcfe89ed38913a0fe69
Reviewed-on: https://skia-review.googlesource.com/c/189303
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
This API enables the framework to implement unclipped saveLayer
calls in a more efficient manner, by requiring fewer render target
switches on the GPU.
Bug: b/119222339
Change-Id: I7276675a4c1389f8493d2583ff7d6533b57a7b3b
Reviewed-on: https://skia-review.googlesource.com/c/173102
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Derek Sollenberger <djsollen@google.com>
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>
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>
Bug: b/63908092
Android does not need to have its end listener attached if the
repetition count is infinite. Provide an accessor so it will know.
Change-Id: I481b048994a6e86ae88c913a5dcca3788b92bae2
Reviewed-on: https://skia-review.googlesource.com/99883
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
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>
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>
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>
This CL enables us to set the default visibility of the symbols
on Android to hidden. It is the intent that all of he SK_APIs
that have been added to /src directies should be removed as soon
as we can remove their callers within Android.
Bug: b/31971097
Change-Id: Ic787f94df0fb0c2b8d941aa7095a12b317c4b5de
Reviewed-on: https://skia-review.googlesource.com/49501
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Derek Sollenberger <djsollen@google.com>
Move common code into the base class, so subclasses need not call
conversion_possible.
Use SkEncodedInfo rather than SkImageInfo, and use the proper frame.
API Changes:
- SkAndroidCodec:
- Add getEncodedInfo(), for SkBitmapRegionCodec
- SkEncodedInfo:
- Add opaque() helper
- SkBitmapRegionDecoder:
- Remove unused conversionSupported
(Split off from skia-review.googlesource.com/c/25746)
Bug: skia:5601
Change-Id: If4a40d4b98a3dd0afde2b6058f92315a393a5baf
Reviewed-on: https://skia-review.googlesource.com/34361
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
Add a private API used by Android framework, which writes the clip
into a stencil buffer. This is used by HWUI to clip the WebView.
Bug: 31489986
Change-Id: I94515f1539acd9d069c8aceb3300577feed9c94f
Reviewed-on: https://skia-review.googlesource.com/29521
Commit-Queue: Stan Iliev <stani@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Also, no more SkImageEncoder class.
SK_SUPPORT_LEGACY_IMAGE_ENCODER_CLASS now only guards some
old API shims.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=5006
Change-Id: I3797f584f3e8e12ade10d31e8733163453725f40
Reviewed-on: https://skia-review.googlesource.com/5006
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Mike Reed <reed@google.com>
This will expose the BitmapRegionDecoder API as a public include
and move the implementation to src.
This makes this code more naturally exposed in Android and easier
to test in DM and nanobench.
BUG=skia:
Review URL: https://codereview.chromium.org/1438873002