aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/codec/SkCodec.h
Commit message (Collapse)AuthorAge
* Move SkNoncopyable to include/private.Gravatar Ben Wagner2018-07-17
| | | | | | | Change-Id: I62f60ea52faeebddecacf03d9429ac3f7c516b8e Reviewed-on: https://skia-review.googlesource.com/141823 Commit-Queue: Ben Wagner <bungeman@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
* Remove SkTransferFunctionBehaviorGravatar Brian Osman2018-07-17
| | | | | | | | Bug: skia: Change-Id: Iccbe609b2a8d4c9098ef36aa6530dbc3771e0c11 Reviewed-on: https://skia-review.googlesource.com/141055 Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
* Replace nearly all kRespect with kIgnoreGravatar Brian Osman2018-07-12
| | | | | | | | | | | | | | | | | | | | | | | | | | - Encoders and decoders always assume kIgnore. - They are less opinionated about F16 and color space, we just trust the color space that's passed in, and put that directly in the image (no sRGB encoding). - SkBitmap and SkPixmap read/write pixels functions were defaulting to kResepct, those are now always kIgnore. - Many other bits of plumbing are simplified, and I added a default of kIgnore to SkImage::makeColorSpace, so we can phase out that argument entirely. - Still need to add defaults to other public APIs that take SkTransferFunctionBehavior. - This makes gold think that we've dramatically changed the contents of all F16 images, but that's because it doesn't understand the (now linear) color space that's embedded. Once we triage them all once, they will work fine (and they'll look perfect in the browser). Bug: skia: Change-Id: I62fa090f96cae1b67d181ce14bd91f34ff2ed747 Reviewed-on: https://skia-review.googlesource.com/140570 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
* Remove ColorCodecBenchGravatar Brian Osman2018-05-23
| | | | | | | | | | | This wasn't being run (AFAICT) and was built on pre-skcms color management. Change-Id: I506e8767f716bc6e4590ce255c5e40f1064fc152 Reviewed-on: https://skia-review.googlesource.com/129644 Commit-Queue: Brian Osman <brianosman@google.com> Commit-Queue: Mike Klein <mtklein@google.com> Auto-Submit: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
* Add a method to convert SkCodec::Result to a stringGravatar Leon Scroggins III2018-01-16
| | | | | | | | Bug: b/63909536 Change-Id: Ic91e3401359f80eadd9d1cd79aa8ef642c60b0fc Reviewed-on: https://skia-review.googlesource.com/94781 Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Derek Sollenberger <djsollen@google.com>
* Reland "Hide SkEncodedInfo"Gravatar Leon Scroggins III2017-12-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This partially reverts commit 1793e7bb46c1f9d430c1a699a1c3d3168159b659. Hide SkEncodedInfo Bug: skia:7353 Bug: skia:6839 This contains information that is not necessary for clients to know. The Color enum tells the number of components in the input, but this is only interesting internally (to the SkSwizzler). Similarly, the Alpha enum differs from SkAlphaType in that it has kBinary instead of kPremul. This is useful information only internally for determining whether the SkColorSpaceXform needs to premultiply. The bitsPerComponent is potentially useful for a client; Android (in SkAndroidCodec) uses it to determine the SkColorType. Rather than exposing bitsPerComponent, make SkAndroidCodec a friend so it can access the SkEncodedInfo. A future change will change SkCodec to recommend F16 for bitsPerComponent > 8, but that will be more involved; it was the reason for the revert of this CL. Switch conversionSupported to use an SkColorType, which is enough info. Replace the SkEncodedInfo::Alpha field on SkCodec::FrameInfo with an SkAlphaType. SkCodec still needs an SkEncodedInfo, so move its header (which is already not SK_API) to include/private. TBR=mtklein@chromium.org,reed@google.com Change-Id: I928b1f55317602cb37d29da63b53026c8d139cee Reviewed-on: https://skia-review.googlesource.com/80860 Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Revert "Hide SkEncodedInfo"Gravatar Leon Scroggins2017-12-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit c6f7a4ffa9522159efc42f7c948bba5e66bb8844. Reason for revert: Causing differences in Gold, stemming from the fact that this changes the recommended SkImageInfo for 16 bits-per-component PNG from N32 to F16. - an F16 bitmap already png-encodes to a 16 bits-per-component PNG, but it does not encode a linear colorspace (possibly a bug?). when we decode this PNG using getInfo(), it fails because it has an F16 color type and non-linear colorspace. (In the encode-srgb-png gm, this results in blank results for F16.) We could correct this on the encoder side, but it seems possible that a 16 bits-per-component PNG could be encoded with a different color space. In that case, we'd want SkCodec to recommend F16/SRGBLinear, but I think we'd want the SkCodec to store the encoded SkColorSpace so that we can Xform between the two. Currently SkCodec only stores one color space, so that will require a refactor. - When decoding 16-bits-per-component PNGs, we are now decoding them to F16. This shows differences in Gold. The srgb/gpu results now look more like F16. I think this is fine. Original change's description: > Hide SkEncodedInfo > > Bug: skia:7353 > Bug: skia:6839 > > This contains information that is not necessary for clients to know. The > Color enum tells the number of components in the input, but this is only > interesting internally (to the SkSwizzler). > > Similarly, the Alpha enum differs from SkAlphaType in that it has > kBinary instead of kPremul. This is useful information only internally > for determining whether the SkColorSpaceXform needs to premultiply. > > The bitsPerComponent is potentially useful for a client; Android (in > SkAndroidCodec) uses it to determine the SkColorType. Rather than > exposing bitsPerComponent, use it to make the same decision that Android > would have made - 16 bits per component means to set the info to F16. Add > a test that computeOutputColorType behaves as expected. > > Switch conversionSupported to use an SkColorType, which is enough info. > > Replace the SkEncodedInfo::Alpha field on SkCodec::FrameInfo with an > SkAlphaType. > > SkCodec still needs an SkEncodedInfo, so move its header (which is > already not SK_API) to include/private. > > Change-Id: Ie2cf11339bf999ebfd4390c0f448f7edd6feabda > Reviewed-on: https://skia-review.googlesource.com/79260 > Reviewed-by: Mike Reed <reed@google.com> > Reviewed-by: Mike Klein <mtklein@chromium.org> > Commit-Queue: Leon Scroggins <scroggo@google.com> TBR=mtklein@chromium.org,scroggo@google.com,reed@google.com Change-Id: I0c5dd1461e1b70d1e55349a8e7ee6b029c3f556e No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:7353, skia:6839 Reviewed-on: https://skia-review.googlesource.com/80660 Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Hide SkEncodedInfoGravatar Leon Scroggins III2017-12-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: skia:7353 Bug: skia:6839 This contains information that is not necessary for clients to know. The Color enum tells the number of components in the input, but this is only interesting internally (to the SkSwizzler). Similarly, the Alpha enum differs from SkAlphaType in that it has kBinary instead of kPremul. This is useful information only internally for determining whether the SkColorSpaceXform needs to premultiply. The bitsPerComponent is potentially useful for a client; Android (in SkAndroidCodec) uses it to determine the SkColorType. Rather than exposing bitsPerComponent, use it to make the same decision that Android would have made - 16 bits per component means to set the info to F16. Add a test that computeOutputColorType behaves as expected. Switch conversionSupported to use an SkColorType, which is enough info. Replace the SkEncodedInfo::Alpha field on SkCodec::FrameInfo with an SkAlphaType. SkCodec still needs an SkEncodedInfo, so move its header (which is already not SK_API) to include/private. Change-Id: Ie2cf11339bf999ebfd4390c0f448f7edd6feabda Reviewed-on: https://skia-review.googlesource.com/79260 Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Move SkCodec::Origin into its own fileGravatar Leon Scroggins III2017-10-18
| | | | | | | | | | | | | | It is now used by SkPixmap and will soon be in SkJpegEncoder. No need for those to depend on SkCodec. Bug: 768878 TBR=reed@google.com (reed@ already approved the API change in https://skia-review.googlesource.com/60721) Change-Id: If1a6e1d5b60a7a3d8c97818e15a48d28ba804668 Reviewed-on: https://skia-review.googlesource.com/61680 Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Revert "Add an Option for orientation on JPEG encodes"Gravatar Ben Wagner2017-10-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 5411a60e0d7370a5d47b5049de845a06fe52e98b. Reason for revert: ASAN and Coverage failing: https://chromium-swarm.appspot.com/task?id=394978f3b7d44610 Flutter_Android failing. Original change's description: > Add an Option for orientation on JPEG encodes > > Move Origin to its own header so that SkPixmap and SkJpegEncoder need > not depend on SkCodec. > > Add libexif, which is already used by Android, and use it to write the > orientation. Write a makefile based on the Android.bp in Android, minus > warnings. (libexif has an LGPL license.) > > Add a test that verifies all the orientations work. > > Optionally enable writing the orientation (and therefore including > libexif). Chromium does not currently need it, and Android does not > expose an API that would allow using it. Disable on Windows, where we > still have build errors to fix. > > Bug: skia:7138 > Change-Id: Iaeff44c36aebe0e639666979dc00e1b7594bbeb1 > Reviewed-on: https://skia-review.googlesource.com/60721 > Commit-Queue: Leon Scroggins <scroggo@google.com> > Reviewed-by: Mike Klein <mtklein@chromium.org> > Reviewed-by: Mike Reed <reed@google.com> TBR=mtklein@chromium.org,mtklein@google.com,scroggo@google.com,reed@google.com Change-Id: I05b7ae8d1c5bbd1de1642d9ef024943500256273 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:7138 Reviewed-on: https://skia-review.googlesource.com/61620 Reviewed-by: Ben Wagner <benjaminwagner@google.com> Commit-Queue: Ben Wagner <benjaminwagner@google.com>
* Add an Option for orientation on JPEG encodesGravatar Leon Scroggins III2017-10-18
| | | | | | | | | | | | | | | | | | | | | | | Move Origin to its own header so that SkPixmap and SkJpegEncoder need not depend on SkCodec. Add libexif, which is already used by Android, and use it to write the orientation. Write a makefile based on the Android.bp in Android, minus warnings. (libexif has an LGPL license.) Add a test that verifies all the orientations work. Optionally enable writing the orientation (and therefore including libexif). Chromium does not currently need it, and Android does not expose an API that would allow using it. Disable on Windows, where we still have build errors to fix. Bug: skia:7138 Change-Id: Iaeff44c36aebe0e639666979dc00e1b7594bbeb1 Reviewed-on: https://skia-review.googlesource.com/60721 Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Reed <reed@google.com>
* Revert[4] "apply codec origin in generator"Gravatar Mike Reed2017-10-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit dd340146f1fe7414702d6fea251da989d425691e. Reason for revert: ios gn file fixed Original change's description: > Revert "Revert "Revert "apply codec origin in generator""" > > This reverts commit 82269abfec798621c8dbbc6bd48996c0b2686f41. > > Reason for revert: ios build needs include path for SkCodec.h > > Original change's description: > > Revert "Revert "apply codec origin in generator"" > > > > This reverts commit 363dd988a55c2ed3fa92e2368c1c889101425734. > > > > Reason for revert: pdfium fix landed > > > > Original change's description: > > > Revert "apply codec origin in generator" > > > > > > This reverts commit fa15877f487333bec876e7315cf584c0d598d098. > > > > > > Reason for revert: Appears to break PDFium. > > > > > > Original change's description: > > > > apply codec origin in generator > > > > > > > > Bug: skia: > > > > Change-Id: I383dacb49b1e3c88467ccdbf3288764bb1bbf01a > > > > Reviewed-on: https://skia-review.googlesource.com/58600 > > > > Reviewed-by: Leon Scroggins <scroggo@google.com> > > > > Commit-Queue: Mike Reed <reed@google.com> > > > > > > TBR=scroggo@google.com,reed@google.com > > > > > > Change-Id: Id97137d6ec39ca638c941928bae6510814b1c499 > > > No-Presubmit: true > > > No-Tree-Checks: true > > > No-Try: true > > > Bug: skia: > > > Reviewed-on: https://skia-review.googlesource.com/60041 > > > Reviewed-by: Ben Wagner <benjaminwagner@google.com> > > > Commit-Queue: Ben Wagner <benjaminwagner@google.com> > > > > TBR=benjaminwagner@google.com,scroggo@google.com,reed@google.com > > > > Change-Id: I1b54a6e6e6cbda07f346ffbbc4977f9db705abcd > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Bug: skia: > > Reviewed-on: https://skia-review.googlesource.com/60320 > > Reviewed-by: Mike Reed <reed@google.com> > > Commit-Queue: Mike Reed <reed@google.com> > > TBR=benjaminwagner@google.com,scroggo@google.com,reed@google.com > > Change-Id: I4c2d310521d1a678b407d30b9fe3c261c49d67bc > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/60560 > Reviewed-by: Mike Reed <reed@google.com> > Commit-Queue: Mike Reed <reed@google.com> TBR=benjaminwagner@google.com,scroggo@google.com,reed@google.com Change-Id: I5c1e53aff3ad174b0d4a806c35b7cdcd194479d7 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/60563 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
* Revert "Revert "Revert "apply codec origin in generator"""Gravatar Mike Reed2017-10-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 82269abfec798621c8dbbc6bd48996c0b2686f41. Reason for revert: ios build needs include path for SkCodec.h Original change's description: > Revert "Revert "apply codec origin in generator"" > > This reverts commit 363dd988a55c2ed3fa92e2368c1c889101425734. > > Reason for revert: pdfium fix landed > > Original change's description: > > Revert "apply codec origin in generator" > > > > This reverts commit fa15877f487333bec876e7315cf584c0d598d098. > > > > Reason for revert: Appears to break PDFium. > > > > Original change's description: > > > apply codec origin in generator > > > > > > Bug: skia: > > > Change-Id: I383dacb49b1e3c88467ccdbf3288764bb1bbf01a > > > Reviewed-on: https://skia-review.googlesource.com/58600 > > > Reviewed-by: Leon Scroggins <scroggo@google.com> > > > Commit-Queue: Mike Reed <reed@google.com> > > > > TBR=scroggo@google.com,reed@google.com > > > > Change-Id: Id97137d6ec39ca638c941928bae6510814b1c499 > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Bug: skia: > > Reviewed-on: https://skia-review.googlesource.com/60041 > > Reviewed-by: Ben Wagner <benjaminwagner@google.com> > > Commit-Queue: Ben Wagner <benjaminwagner@google.com> > > TBR=benjaminwagner@google.com,scroggo@google.com,reed@google.com > > Change-Id: I1b54a6e6e6cbda07f346ffbbc4977f9db705abcd > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/60320 > Reviewed-by: Mike Reed <reed@google.com> > Commit-Queue: Mike Reed <reed@google.com> TBR=benjaminwagner@google.com,scroggo@google.com,reed@google.com Change-Id: I4c2d310521d1a678b407d30b9fe3c261c49d67bc No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/60560 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
* Revert "Revert "apply codec origin in generator""Gravatar Mike Reed2017-10-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 363dd988a55c2ed3fa92e2368c1c889101425734. Reason for revert: pdfium fix landed Original change's description: > Revert "apply codec origin in generator" > > This reverts commit fa15877f487333bec876e7315cf584c0d598d098. > > Reason for revert: Appears to break PDFium. > > Original change's description: > > apply codec origin in generator > > > > Bug: skia: > > Change-Id: I383dacb49b1e3c88467ccdbf3288764bb1bbf01a > > Reviewed-on: https://skia-review.googlesource.com/58600 > > Reviewed-by: Leon Scroggins <scroggo@google.com> > > Commit-Queue: Mike Reed <reed@google.com> > > TBR=scroggo@google.com,reed@google.com > > Change-Id: Id97137d6ec39ca638c941928bae6510814b1c499 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/60041 > Reviewed-by: Ben Wagner <benjaminwagner@google.com> > Commit-Queue: Ben Wagner <benjaminwagner@google.com> TBR=benjaminwagner@google.com,scroggo@google.com,reed@google.com Change-Id: I1b54a6e6e6cbda07f346ffbbc4977f9db705abcd No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/60320 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
* Revert "apply codec origin in generator"Gravatar Ben Wagner2017-10-16
| | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit fa15877f487333bec876e7315cf584c0d598d098. Reason for revert: Appears to break PDFium. Original change's description: > apply codec origin in generator > > Bug: skia: > Change-Id: I383dacb49b1e3c88467ccdbf3288764bb1bbf01a > Reviewed-on: https://skia-review.googlesource.com/58600 > Reviewed-by: Leon Scroggins <scroggo@google.com> > Commit-Queue: Mike Reed <reed@google.com> TBR=scroggo@google.com,reed@google.com Change-Id: Id97137d6ec39ca638c941928bae6510814b1c499 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/60041 Reviewed-by: Ben Wagner <benjaminwagner@google.com> Commit-Queue: Ben Wagner <benjaminwagner@google.com>
* apply codec origin in generatorGravatar Mike Reed2017-10-16
| | | | | | | | Bug: skia: Change-Id: I383dacb49b1e3c88467ccdbf3288764bb1bbf01a Reviewed-on: https://skia-review.googlesource.com/58600 Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Mike Reed <reed@google.com>
* Remove SK_LEGACY_FRAME_INFO_ALPHA_TYPEGravatar Leon Scroggins III2017-09-01
| | | | | | | | | | | | With https://chromium-review.googlesource.com/c/621815, Chromium no longer references this. Delete it. TBR=reed@google.com Bug: skia:6839 Change-Id: Icd3d394858859e6732b1429394c7c04bb22b9dea Reviewed-on: https://skia-review.googlesource.com/36581 Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com>
* Call initializeColorXform inside SkCodecGravatar Leon Scroggins III2017-08-18
| | | | | | | | | | | | | | | | | | | | | | | | Make initializeColorXform private, and only call in the base class. Add virtual method to skip initializeColorXform, for classes that do not need one. Change SkCodec::FrameInfo's SkAlphaType to an SkEncodedInfo::Alpha. This allows proper checking internally whether SkCodec needs to do a color correct premultiply. Depends on https://chromium-review.googlesource.com/c/620947, for this API change. (Separated from review.skia.org/25746) Bug: skia:5609 Bug: skia:6839 Change-Id: Icb0d46659c546060c34d32eaf792c86708726c7a Reviewed-on: https://skia-review.googlesource.com/35880 Reviewed-by: Chris Blume <cblume@chromium.org> Reviewed-by: Derek Sollenberger <djsollen@google.com> Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Reland "skia: add heif decoding support"Gravatar Leon Scroggins III2017-08-18
| | | | | | | | | | | | | | This reverts commit db68a426b6ba3a0fa1cace25ac306037eb7413a6. Fixes errors in Android and Google3 Bug: b/64077740 Change-Id: I3d2bb1223e4d8ba912ea2b88144aeecc487fce1a Reviewed-on: https://skia-review.googlesource.com/35701 Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Chong Zhang <chz@google.com> Reviewed-by: Mike Klein <mtklein@google.com> Reviewed-by: Derek Sollenberger <djsollen@google.com>
* Move calls to conversion_possible to SkCodecGravatar Leon Scroggins III2017-08-17
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* Revert "skia: add heif decoding support"Gravatar Mike Klein2017-08-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit c2a954290dc3888f877a047098b84c24363895fb. Reason for revert: both Android and Google3 rolls cannot compile. Android cannot cast std::unique_ptr<T> to T*, Google3 cannot find HeifDecoderAPI.h. Original change's description: > skia: add heif decoding support > > Bug: b/64077740 > Change-Id: I11e0243bcc4c21c0aa5aa29a719dd0fcba7ae6f7 > Reviewed-on: https://skia-review.googlesource.com/35123 > Reviewed-by: Chong Zhang <chz@google.com> > Reviewed-by: Leon Scroggins <scroggo@google.com> > Commit-Queue: Chong Zhang <chz@google.com> > Commit-Queue: Leon Scroggins <scroggo@google.com> TBR=scroggo@google.com,chz@google.com Change-Id: Id98f025e63daec50408186000453d1695170f7a8 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: b/64077740 Reviewed-on: https://skia-review.googlesource.com/35741 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
* skia: add heif decoding supportGravatar Chong Zhang2017-08-16
| | | | | | | | | | Bug: b/64077740 Change-Id: I11e0243bcc4c21c0aa5aa29a719dd0fcba7ae6f7 Reviewed-on: https://skia-review.googlesource.com/35123 Reviewed-by: Chong Zhang <chz@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Chong Zhang <chz@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* remove SK_SUPPORT_LEGACY_CODEC_NEW dead codeGravatar Mike Reed2017-07-26
| | | | | | | | Bug: skia: Change-Id: I59185b8acc00b6df854c613ba29d1002111fcb42 Reviewed-on: https://skia-review.googlesource.com/27240 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
* use unique_ptr for codec factoriesGravatar Mike Reed2017-07-25
| | | | | | | | | | Will need guards for android (at least) Bug: skia: Change-Id: I2bb8e656997984489ef1f2e41cd3d301c4e7b947 Reviewed-on: https://skia-review.googlesource.com/26040 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Reed <reed@google.com>
* Report error on failure to create SkCodecGravatar Leon Scroggins III2017-07-14
| | | | | | | | | | | | | | | | | | Update NewFromStream to report an error on failure to create an SkCodec, so that a client can distinguish between - not enough data - invalid data In Chromium, this will allow blink::ImageDecoder to call SetFailed if the stream is invalid early and we never create an SkCodec. Without this, ImageDecoder will keep trying to create an SkCodec when it receives more data. Change-Id: I4f505c56d91c982be36a828fd0f7db17b1596588 Reviewed-on: https://skia-review.googlesource.com/22642 Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Derek Sollenberger <djsollen@google.com> Reviewed-by: Chris Blume <cblume@chromium.org>
* Reland "Remove support for decoding to kIndex_8"Gravatar Leon Scroggins2017-07-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Original change's description: > > Remove support for decoding to kIndex_8 > > > > Fix up callsites, and remove tests that no longer make sense. > > > > Bug: skia:6828 > > Change-Id: I2548c4b7528b7b1be7412563156f27b52c9d4295 > > Reviewed-on: https://skia-review.googlesource.com/21664 > > Reviewed-by: Derek Sollenberger <djsollen@google.com> > > Commit-Queue: Leon Scroggins <scroggo@google.com> > > TBR=djsollen@google.com,scroggo@google.com > > Change-Id: I1bc669441f250690884e75a9a61427fdf75c6907 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:6828 > Reviewed-on: https://skia-review.googlesource.com/22120 > Reviewed-by: Leon Scroggins <scroggo@google.com> > Commit-Queue: Leon Scroggins <scroggo@google.com> TBR=djsollen@google.com,scroggo@google.com Bug: skia:6828 Change-Id: I36ff5a11c529d29e8adc95f43b8edc6fd1dbf5b8 Reviewed-on: https://skia-review.googlesource.com/22320 Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Revert "Remove support for decoding to kIndex_8"Gravatar Leon Scroggins2017-07-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 742a3e298fda669006147e4a305bab8452369b1f. Reason for revert: Breaking Android roll: frameworks/base/core/jni/android/graphics/BitmapFactory.cpp:453:18: error: no member named 'fColorPtr' in 'SkAndroidCodec::AndroidOptions' codecOptions.fColorPtr = colorPtr; ~~~~~~~~~~~~ ^ frameworks/base/core/jni/android/graphics/BitmapFactory.cpp:454:18: error: no member named 'fColorCount' in 'SkAndroidCodec::AndroidOptions' codecOptions.fColorCount = colorCount; ~~~~~~~~~~~~ ^ Original change's description: > Remove support for decoding to kIndex_8 > > Fix up callsites, and remove tests that no longer make sense. > > Bug: skia:6828 > Change-Id: I2548c4b7528b7b1be7412563156f27b52c9d4295 > Reviewed-on: https://skia-review.googlesource.com/21664 > Reviewed-by: Derek Sollenberger <djsollen@google.com> > Commit-Queue: Leon Scroggins <scroggo@google.com> TBR=djsollen@google.com,scroggo@google.com Change-Id: I1bc669441f250690884e75a9a61427fdf75c6907 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:6828 Reviewed-on: https://skia-review.googlesource.com/22120 Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Remove support for decoding to kIndex_8Gravatar Leon Scroggins III2017-07-10
| | | | | | | | | | Fix up callsites, and remove tests that no longer make sense. Bug: skia:6828 Change-Id: I2548c4b7528b7b1be7412563156f27b52c9d4295 Reviewed-on: https://skia-review.googlesource.com/21664 Reviewed-by: Derek Sollenberger <djsollen@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Add SkCodec::Result indicating error in the dataGravatar Leon Scroggins III2017-07-06
| | | | | | | | | | | | | | | | | | Previously, SkGifCodec treated an error in the LZW data as incomplete, since we can still draw the partially decoded image. But a client doing incremental decodes needs to distinguish this from truly incomplete data. In the case of an error, the client should not attempt to provide more data and decode again. Add kErrorInInput, and return it when SkGifCodec sees a fatal error. Treat it the same as kIncompleteInput when it comes to filling and DM. Bug: skia:6825 Change-Id: Ic6ce3a62c0b065ed34dcd8006309e43272a3db9f Reviewed-on: https://skia-review.googlesource.com/21530 Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Chris Blume <cblume@chromium.org>
* Consolidate decoding frames into SkCodecGravatar Leon Scroggins III2017-06-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new private method to SkCodec that handles Options.fFrameIndex: - Check to ensure the index is valid - Call onGetFrameCount to force parsing the stream - Recursively call getPixels (it should be complete, so no need for incremental decoding) to decode the prior frame if necessary - Zero fill a RestoreBGColor frame Call the method in getPixels and startIncrementalDecode, and remove duplicate code from GIF and WEBP. Remove support for scaling frames beyond the first, which is currently unused. Preserve the feature of SkGifCodec that it will only parse to the end of the first frame if the first frame is asked for. (Also note that when we continue a partial frame, we won't force parsing the full stream.) If the client only wants the first frame, parsing the rest would be unnecessary. But if the client wants the second, we assume they will want any remaining frames, so we parse the remainder of the stream. This simplifies the code (so SkCodec does not have to ask its subclass to parse up to a particular frame). Update tests that relied on the old behavior: - Codec_partialAnim now hardcodes the bytes needed. Previously it relied on the old behavior that GIF only parsed up to the frame being decoded. - Codec_skipFullParse now only tests the first frame, since that is the case where it is important to skip a full parse. TBR=reed@google.com No changes to the public API. Change-Id: Ic2f075452dfeedb4e3e60e6cf4df33ee7bd38495 Reviewed-on: https://skia-review.googlesource.com/19276 Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Remove debug checks for unsupported ICC profilesGravatar Matt Sarett2017-06-09
| | | | | | | | | | | | This was never fully integrated with our automated image testing. I feel it has limited usefulness in terms of catching bugs. Bug: skia: Change-Id: Iecd0a4e9b664ab0b351debde45ada864379de7ec Reviewed-on: https://skia-review.googlesource.com/19267 Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
* Make SkCodec more flexible about its required frameGravatar Leon Scroggins III2017-06-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SkCodec sets fRequiredFrame to be the earliest possible frame that a given frame can depend on. e.g. - Frame A fills the screen, Keep - Frame B does not cover A, Keep - Frame C covers B but not A, and is opaque Frame C can depend on either A or B. SkCodec already reports that C depends on A. This CL allows a client of SkCodec to use either A or B to create C. Also expose the DisposalMethod. Since any frame between A and C can be used to create C except for DisposePrevious frames, the client needs to be able to know the disposal method so they do not try to use such a frame to create C. Further, the disposal method can be used to give the client a better idea whether they will continue to need a frame. (e.g. if frame i is DisposePrevious and depends on i-1, the client may not want to steal i-1 to create i, since i+1 may also depend on i-1.) TODO: Share code for decoding prior frames between GIF and WEBP Change-Id: I91a5ae22ba3d8dfbe0bde833fa67ae3da0d81ed6 Reviewed-on: https://skia-review.googlesource.com/13722 Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Chris Blume <cblume@chromium.org> Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Simplify SkCodecs' call to SkColorSpaceXform::applyGravatar Leon Scroggins III2017-06-05
| | | | | | | | | | | | | | | | | | | | | | | | | | Most SkCodec subclasses did the following to apply their SkColorSpaceXform: dstFormat = select_xform_format(dstInfo.colorType()); srcFormat = select_xform_format(<something that doesn't change>); xformAlphaType = select_xform_alpha(dstInfo.alphaType(), this->getInfo().alphaType()); this->colorXform()->apply(dstFormat, dst, srcFormat, src, width, xformAlphaType); Consolidate the computation of these parameters into SkCodec and add a new method to SkCodec that calls apply() with those parameters. Add a SkColorSpaceXform::ColorFormat to SkCodec. This allows the new method SkCodec::applyColorXform to supply the ColorFormat. TBR=reed@google.com (No change to public API.) Change-Id: I8ea7ba4c0024be827a9f9359796c778744330f6e Reviewed-on: https://skia-review.googlesource.com/18523 Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Add animation support to SkWebpCodecGravatar Leon Scroggins III2017-05-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TBR=reed@google.com (No change to the public API, but changed a header file) SkWebpCodec: - Implement onGetFrameCount, onGetFrameInfo, and onGetRepetitionCount - Respect the alpha reported by libwebp. Although the spec states that it is only a hint, the libwebp encoder uses it properly. Respecting allows us to draw opaque images faster and decode them to 565. This also matches other SkCodecs (and Chromium). - onGetPixels: - Decode the frame requested, recursively decoding required frame if necessary - When blending with a prior frame, use SkRasterPipeline SkCodec: - Move check for negative index to getFrameInfo - Reset the colorXform if one is not needed SkCodecAnimation: - Add new blend enum, for WebP's (and APNG's) non-blending option SkFrameHolder: - New base classes for frames and the owner of the frames, allowing code sharing between SkWebpCodec and SkGifCodec (particularly for determining whether a frame has alpha and what frame it depends on) - When moving items from SkGIFFrameContext, use Skia conventions (i.e. int instead of unsigned) - Rename "delay time" to "duration", to match e.g. SkFrameInfo:: fDuration SkGifImageReader: - Move pieces to SkFrameHolder, and adapt to changes made in the process - Make setAlphaAndRequiredFrame (now on the base class SkFrameHolder) more general to support webp, and add support for frames that do not blend - Change SkGIFFrameContext from a struct to a class, to match how we use the distinction elsewhere (i.e. struct is a small object with public fields) - Rework hasTransparentPixel (now hasTransparency, since it returns true in some cases where there is not a transparent pixel) to better fit with the modified setAlphaAndRequiredFrame. Also be more consistent when there is no transparent pixel but no color map. - Simplify an if condition that was previously simplified in 2d61e717 but accidentally got reverted in a4db9be6 CodecAnimTest: - Test new animated webp files - Rearrange the test to more cleanly print alpha type mismatches for the first frame resources: - webp-animated.webp - animated webp from Chromium - blendBG.webp - new webp file using bits of webp-animated-semitransparent4.webp from Chromium - tests required frame and alpha when using the non-blending mode - frames have the following properties: - Frame 0: no alpha, fills screen - Frame 1: alpha, fills screen - Frame 2: no alpha, fills screen - Frame 3: alpha, fills screen, blendBG - Frame 4: no alpha, fills screen, blendBG - Frame 5: alpha, blendBG - Frame 6: covers 4, has alpha, blendBG - also used to test decoding to 565 if the new frame data has alpha but blends onto an opaque frame DM.cpp: - Test animated images to non-native 8888 and unpremul DMSrcSink.cpp: - Do not test non-native 8888 decodes to f16 dst - Test unpremul decodes to f16 - Copy a frame of an animated image prior to drawing, since in unpremul mode, the DM code will premultiply first. Bug: skia: 3315 Change-Id: I4e55ae2ee5bc095b37a743bdcfac644be603b980 Reviewed-on: https://skia-review.googlesource.com/16707 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Matt Sarett <msarett@google.com>
* Switch SkCodec to int for counts and indicesGravatar Leon Scroggins III2017-04-17
| | | | | | | | | | | | This matches other Skia APIs. size_t was adopted from blink/ GIFImageReader. Change-Id: Ic83e59f0942f597c4fb834e623acd9886ad483fe Reviewed-on: https://skia-review.googlesource.com/13274 Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Matt Sarett <msarett@google.com> Reviewed-by: Chris Blume <cblume@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Add SkCodec methods for individual framesGravatar Leon Scroggins III2017-04-12
| | | | | | | | | | | | | | | | | | | | | Add a version of getFrameInfo that returns information about a single frame, allowing a client to skip creating the entire vector. Add getFrameCount, for determining the number of frames in the image. Reimplement std::vector<FrameInfo> getFrameInfo with the new methods. Updates to the test: - getFrameInfo(size_t, FrameInfo*) fails before parsing - Test both versions of getFrameInfo - Recreate the codec between tests, to test parsing Change-Id: I77c19087f2f8dcf2c536d80167b18ad1ca96ae94 Reviewed-on: https://skia-review.googlesource.com/13190 Reviewed-by: Matt Sarett <msarett@google.com> Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Chris Blume <cblume@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Correct GIF frame dependencies and track alphaGravatar Leon Scroggins III2017-04-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add SkCodec::FrameInfo::fAlphaType. The SkImageInfo for the SkCodec specifies the SkAlphaType for the first frame, but the opacity can vary from frame to frame. When determining the required frame, also compute whether a frame has alpha. Update how we determine the required frame, which had bugs. (Update a test that had an incorrect required frame as a result.) Add new test images covering cases that have been fixed: - randPixelsAnim2.gif It has the following frames: A (keep) B (keep) (subset) C (disposePrevious) (covers B) D (any) (does *not* cover B) B and C depend on A, but D depends on B, since after disposing C, B should be visible again. - alphabetAnim.gif Includes frames which fill the image size, with different disposal methods and transparencies. Change-Id: Ie086167711c4cac4931ed8c4ddaeb9c9b0b91fdb Reviewed-on: https://skia-review.googlesource.com/9810 Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Matt Sarett <msarett@google.com>
* Add SkTransferFunctionBehavior flag: Use in codec and encoderGravatar Matt Sarett2017-03-24
| | | | | | | | | | | | | | This is a step towards removing the non-linear blending flag from SkColorSpace. The flag on SkColorSpace used to control the premul behavior - now it is controlled by this option. BUG=skia: Change-Id: Ia29bd8c2b0596a93c6aa14332dcd9bd39e388a90 Reviewed-on: https://skia-review.googlesource.com/10008 Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
* SK_API-export SkCodecGravatar Florin Malita2016-12-14
| | | | | | | | | R=scroggo@google.com,reed@google.com Change-Id: Ic9fba1919aeb2c5e92c053d43a41d33201abc37c Reviewed-on: https://skia-review.googlesource.com/6080 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Leon Scroggins <scroggo@google.com>
* Add SkCodec::FrameInfo::fFullyReceivedGravatar Leon Scroggins III2016-12-14
| | | | | | | | | | | | | | This indicates whether the frame has been fully received, i.e. the stream contains enough data to decode to the end of the frame. A client may want to use this to know whether they should attempt to decode this frame, if they do not want to decode partial frames. Change-Id: I336c7031b0c0b8c1401ce040f5372aedc87fdc14 Reviewed-on: https://skia-review.googlesource.com/5703 Reviewed-by: Chris Blume <cblume@google.com> Reviewed-by: Derek Sollenberger <djsollen@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Updated the get_images_from_skps tool to check for ICC profile supportGravatar raftias2016-12-12
| | | | | | | | | | | | | | | | | | | Tool will now check for and output all unsuccessfully parsed ICC profiles in input sksp images if --testColorCorrectionSupported is set as a flag. All ICC-aware codecs had to be slightly modified in order to expose this information, as the logic for accessing the ICC profiles is all within the codecs. If --writeFailedImages is set, it will also output all images whoses ICC profiles were not supported. TBR=reed@google.com BUG=skia: Change-Id: Ic310d82bdebf92f8d3bc0ad3dcc688136b6de377 Reviewed-on: https://skia-review.googlesource.com/5355 Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Robert Aftias <raftias@google.com>
* Be explicit about the vector<FrameInfo> typeGravatar Leon Scroggins III2016-12-02
| | | | | | | | | | | This fixes a compile error in Chromium. BUG=skia:6026 Change-Id: Idd5ad22cb52a084836de6e1427f1f047d1feab08 Reviewed-on: https://skia-review.googlesource.com/5500 Reviewed-by: Derek Sollenberger <djsollen@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* SkImageEncoder: simplify APIGravatar Hal Canary2016-11-23
| | | | | | | | | | | | | | | | | | | | | | | | (re-land 248ff02 & 2cb6cb7, with changes) - Hide SkImageEncoder class in private header. - SkImageEncoder::Type becomes SkEncodedImageFormat - SkEncodedFormat becomes SkEncodedImageFormat - SkImageEncoder static functions replaced with single function EncodeImage() - utility wrappers for EncodeImage() are in sk_tool_utils.h TODO: remove link-time registration mechanism. TODO: clean up clients use of API and flip the flag. TODO: implement EncodeImage() in chromeium/skia/ext Change-Id: I47d451e50be4d5c6c130869c7fa7c2857243d9f0 Reviewed-on: https://skia-review.googlesource.com/4909 Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-on: https://skia-review.googlesource.com/5186 Commit-Queue: Hal Canary <halcanary@google.com> Reviewed-by: Hal Canary <halcanary@google.com>
* Revert 248ff023 & 2cb6cb72Gravatar Hal Canary2016-11-22
| | | | | | | | | | | | | | Revert "SkImageEncoder: simplify API" This reverts commit 248ff02331d7f73ee4b6c5a7eabeae1080c16cd4. Revert "Fix bug: can't convert nullptr -> bool" This reverts commit 2cb6cb7218171b357bb5c934f032ba69c7b78401. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=5151 NOTRY=true Change-Id: I5f6414392d6545f74db0b5bb50608d04f053a8ec Reviewed-on: https://skia-review.googlesource.com/5151 Commit-Queue: Hal Canary <halcanary@google.com> Reviewed-by: Hal Canary <halcanary@google.com>
* SkImageEncoder: simplify APIGravatar Hal Canary2016-11-22
| | | | | | | | | | | | | | | | | | | | | | - Hide SkImageEncoder class in private header. - SkImageEncoder::Type becomes SkEncodedImageFormat - SkEncodedFormat becomes SkEncodedImageFormat - SkImageEncoder static functions replaced with single function EncodeImage() - utility wrappers for EncodeImage() are in sk_tool_utils.h TODO: remove link-time registration mechanism. TODO: clean up clients use of API and flip the flag. TODO: implement EncodeImage() in chromeium/skia/ext GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4909 Change-Id: Ib48b31fdc05cf23cda7f56ebfd67c841c149ce70 Reviewed-on: https://skia-review.googlesource.com/4909 Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* Delete qcmsGravatar Matt Sarett2016-11-01
| | | | | | | | | | | | | | | | | | | | This was always intended to be a temporary dependency to use for testing. It has served its purpose. Also, this has already been dropped (accidentally, I think) by the new GN build. TBR=reed@google.com BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4220 Change-Id: Ic72ee08bbfaf86ed86a4122fd38be2921eb1327e Reviewed-on: https://skia-review.googlesource.com/4220 Reviewed-by: Matt Sarett <msarett@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
* Report repetition count in SkCodecGravatar scroggo2016-11-01
| | | | | | | | | | | | | | | | | | | | | Add a new accessor to retrieve the repetition count. Remove constants (and corresponding copyright) in SkCodecAnimation. These may make sense for the calling code, but are not needed here. kRepetitionCountInfinite corresponds to Blink's kAnimationLoopInfinite. Move cLoopCountNotSeen to private. It is used to determine whether we still need to parse. Add a new enum to the parse query - only parse enough to determine the repetition count. Unlike Chromium, SkGifCodec does not account for deleting the reader (which SkGifCodec does not do) or failed decodes. Add a test. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2447863002 Review-Url: https://codereview.chromium.org/2447863002
* Tag images as sRGB by default in SkCodecGravatar Matt Sarett2016-10-31
| | | | | | | | | | | | | | Unmarked images should be treated as sRGB. BUG=skia:4895 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4151 Change-Id: I5f8c308d22fd2d069cbfa89c5a5bb19ae6fde8bd Reviewed-on: https://skia-review.googlesource.com/4151 Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Matt Sarett <msarett@google.com>
* Remove SkAutoTUnref and SkAutoTDelete from public includes.Gravatar bungeman2016-10-27
| | | | | | | | | | | | | | | This also makes the required changed to src, tests, and tools. The few public APIs modified by this change appear to be unused outside of Skia. Removing these from the public API makes it easier to ensure users are no longer using them. This also updates GrGpu::wrapBackendXXX and the ::onWrapBackendXXX methods to clarify ownership. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2448593002 Review-Url: https://codereview.chromium.org/2448593002
* Add support for multiple frames in SkCodecGravatar scroggo2016-10-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an interface to decode frames beyond the first in SkCodec, and add an implementation for SkGifCodec. Add getFrameData to SkCodec. This method reads ahead in the stream to return a vector containing meta data about each frame in the image. This is not required in order to decode frames beyond the first, but it allows a client to learn extra information: - how long the frame should be displayed - whether a frame should be blended with a prior frame, allowing the client to provide the prior frame to speed up decoding Add a new fields to SkCodec::Options: - fFrameIndex - fHasPriorFrame The API is designed so that SkCodec never caches frames. If a client wants a frame beyond the first, they specify the frame in Options.fFrameIndex. If the client does not have the frame's required frame (the frame that this frame must be blended on top of) cached, they pass false for Options.fHasPriorFrame. Unless the frame is independent, the codec will then recursively decode all frames necessary to decode fFrameIndex. If the client has the required frame cached, they can put it in the dst they pass to the codec, and the codec will only draw fFrameIndex onto it. Replace SkGifCodec's scanline decoding support with progressive decoding, and update the tests accordingly. Implement new APIs in SkGifCodec. Instead of using gif_lib, use GIFImageReader, imported from Chromium (along with its copyright headers) with the following changes: - SkGifCodec is now the client - Replace blink types - Combine GIFColorMap::buildTable and ::getTable into a method that creates and returns an SkColorTable - Input comes from an SkStream, instead of a SegmentReader. Add SkStreamBuffer, which buffers the (potentially partial) stream in order to decode progressively. (FIXME: This requires copying data that previously was read directly from the SegmentReader. Does this hurt performance? If so, can we fix it?) - Remove UMA code - Instead of reporting screen width and height to the client, allow the client to query for it - Fail earlier if the first frame AND screen have size of zero - Compute required previous frame when adding a new one - Move GIFParseQuery from GIFImageDecoder to GIFImageReader - Allow parsing up to a specific frame (to skip parsing the rest of the stream if a client only wants the first frame) - Compute whether the first frame has alpha and supports index 8, to create the SkImageInfo. This happens before reporting that the size has been decoded. Add GIFImageDecoder::haveDecodedRow to SkGifCodec, imported from Chromium (along with its copyright header), with the following changes: - Add support for sampling - Use the swizzler - Keep track of the rows decoded - Do *not* keep track of whether we've seen alpha Remove SkCodec::kOutOfOrder_SkScanlineOrder, which was only used by GIF scanline decoding. Call onRewind even if there is no stream (SkGifCodec needs to clear its decoded state so it will decode from the beginning). Add a method to SkSwizzler to access the offset into the dst, taking subsetting into account. Add a GM that animates a GIF. Add tests for the new APIs. *** Behavior changes: * Previously, we reported that an image with a subset frame and no transparent index was opaque and used the background index (if present) to fill the background. This is necessary in order to support index 8, but it does not match viewers/browsers I have seen. Examples: - Chromium and Gimp render the background transparent - Firefox, Safari, Linux Image Viewer, Safari Preview clip to the frame (for a single frame image) This CL matches Chromium's behavior and renders the background transparent. This allows us to have consistent behavior across products and simplifies the code (relative to what we would have to do to continue the old behavior on Android). It also means that we will no longer support index 8 for some GIFs. * Stop checking for GIFSTAMP - all GIFs should be either 89a or 87a. This matches Chromium. I suspect that bugs would have been reported if valid GIFs started with "GIFVER" instead of "GIF89a" or "GIF87a" (but did not decode in Chromium). *** Future work not included in this CL: * Move some checks out of haveDecodedRow, since they are the same for the entire frame e.g. - intersecting the frameRect with the full image size - whether there is a color table * Change when we write transparent pixels - In some cases, Chromium deemed this unnecessary, but I suspect it is slower than the fallback case. There will continue to be cases where we should *not* write them, but for e.g. the first pass where we have already cleared to transparent (which we may also be able to skip) writing the transparent pixels will not make anything incorrect. * Report color type and alpha type per frame - Depending on alpha values, disposal methods, frame rects, etc, subsequent frames may have different properties than the first. * Skip copies of the encoded data - We copy the encoded data in case the stream is one that cannot be rewound, so we can parse and then decode (possibly not immediately). For some input streams, this is unnecessary. - I was concerned this cause a performance regression, but on average the new code is faster than the old for the images I tested [1]. - It may cause a performance regression for Chromium, though, where we can always move back in the stream, so this should be addressed. Design doc: https://docs.google.com/a/google.com/document/d/12Qhf9T92MWfdWujQwCIjhCO3sw6pTJB5pJBwDM1T7Kc/ [1] https://docs.google.com/a/google.com/spreadsheets/d/19V-t9BfbFw5eiwBTKA1qOBkZbchjlTC5EIz6HFy-6RI/ GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=2045293002 Review-Url: https://codereview.chromium.org/2045293002