aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec
Commit message (Collapse)AuthorAge
* 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 old lazy image decoding heuristic logicGravatar Brian Osman2018-07-11
| | | | | | | | | | | This led to removing a lot of transfer function behavior code. There is more that could be done, and we need to add in decoding to dst color space, but this CL is almost entirely mechanical. Change-Id: I91b2169f95aadcfaacdd2b9821bb1a01ce53f9a6 Reviewed-on: https://skia-review.googlesource.com/140349 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
* basic first pass at RGBA F32 supportGravatar Mike Klein2018-06-26
| | | | | | | | | | | | | Draws basically the same as f16. The existing load_f32, load_f32_dst, and store_f32 stages all had the same bug that we'd never noticed because dy was always 0 until now. Change-Id: Ibbd393fa1acc5df414be4cdef0f5a9d11dcccdb3 Reviewed-on: https://skia-review.googlesource.com/137585 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Mike Reed <reed@google.com>
* Revert "Revert "SkTypes: extract SkTo""Gravatar Hal Canary2018-06-14
| | | | | | | | | | | | | | | | This reverts commit fdcfb8b7c23fbf18f872d2c31d27978235033876. > Original change's description: > > SkTypes: extract SkTo > > > > Change-Id: I8de790d5013db2105ad885fa2683303d7c250b09 > > Reviewed-on: https://skia-review.googlesource.com/133620 > > Reviewed-by: Mike Klein <mtklein@google.com> Change-Id: Ida74fbc5c21248a724a5edbf9fae18a33bcb23aa Reviewed-on: https://skia-review.googlesource.com/134506 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* Does everyone support __has_include() now?Gravatar Mike Klein2018-06-13
| | | | | | | | | | Let's find out. Change-Id: I8ff2103c389d6627f3963a2f067baa0a211647c9 Reviewed-on: https://skia-review.googlesource.com/134510 Commit-Queue: Ben Wagner <bungeman@google.com> Auto-Submit: Mike Klein <mtklein@chromium.org> Reviewed-by: Ben Wagner <bungeman@google.com>
* Revert "SkTypes: extract SkTo"Gravatar Hal Canary2018-06-13
| | | | | | | | | | | | | | | | | | | | | | | This reverts commit 2a2f67592602b18527bc3fd449132d420cd5b62e. Reason for revert: this appears to be what is holding up the Chrome roll. Original change's description: > SkTypes: extract SkTo > > Change-Id: I8de790d5013db2105ad885fa2683303d7c250b09 > Reviewed-on: https://skia-review.googlesource.com/133620 > Reviewed-by: Mike Klein <mtklein@google.com> TBR=mtklein@google.com,halcanary@google.com No-Presubmit: true No-Tree-Checks: true No-Try: true Change-Id: Iafd738aedfb679a23c061a51afe4b98a8d4cdfae Reviewed-on: https://skia-review.googlesource.com/134504 Reviewed-by: Hal Canary <halcanary@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* SkMacros split from SkTypes.hGravatar Hal Canary2018-06-12
| | | | | | | Change-Id: I383719ee181c6925ebf62ffc70e1c0f12ee7cf84 Reviewed-on: https://skia-review.googlesource.com/134326 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* SkTypes: extract SkToGravatar Hal Canary2018-06-12
| | | | | | Change-Id: I8de790d5013db2105ad885fa2683303d7c250b09 Reviewed-on: https://skia-review.googlesource.com/133620 Reviewed-by: Mike Klein <mtklein@google.com>
* trim #include <new> from SkPostConfig.hGravatar Mike Klein2018-06-11
| | | | | | | Change-Id: I693ddcd4ade101ba4eb4102e03adce183aa1d672 Reviewed-on: https://skia-review.googlesource.com/133829 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
* remove linear blending from SkWebpCodecGravatar Mike Klein2018-06-08
| | | | | | | | | | Change-Id: Ia4cf10ba999b48437491416b0fb21d7726d73b4f Reviewed-on: https://skia-review.googlesource.com/133444 Commit-Queue: Mike Klein <mtklein@chromium.org> Commit-Queue: Brian Osman <brianosman@google.com> Auto-Submit: Mike Klein <mtklein@chromium.org> Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
* Move SkColorTable to src/codecGravatar Leon Scroggins III2018-06-01
| | | | | | | | | | | | | | | It is no longer needed anywhere else, and simply happens to be an implementation detail of SkCodec (at least for now). Remove references to SkColorTable in other classes, and clean up some includes of SkConvertPixels I found along the way. Remove unused includes/methods on SkColorTable Change-Id: I46c8e46f5b77c37710b6cf595d48107d55871d52 Reviewed-on: https://skia-review.googlesource.com/130845 Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
* Add a dummy SkColorTable.cpp in src/codecGravatar Leon Scroggins III2018-05-30
| | | | | | | | | | | | I'm planning to move the real SkColorTable.cpp to src/codec, but that will require updating Chromium's BUILD.gn file to build it. Put this one here so that Chromium has something to build until the real move takes place. Change-Id: I1f217cfc1f7841db34781510ef851497c58c086d Reviewed-on: https://skia-review.googlesource.com/130940 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Properly zero in webp if no prior frameGravatar Leon Scroggins III2018-05-24
| | | | | | | | | | | | | | | When erasing the prior frame rect, we need to update the frame rect to take scaling into account. We already do if the prior frame was provided; also do so if it was not provided. Note that this only affects an image with a restore previous frame that is being scaled. webp does not support restore previous, so this will not affect AnimatedImageDrawable in Android. Change-Id: I2d9a4ad45262a0e7afd1134958aff5c6e2ca6687 Reviewed-on: https://skia-review.googlesource.com/115646 Reviewed-by: Derek Sollenberger <djsollen@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Make DNG decodes single threaded on AndroidGravatar Leon Scroggins III2018-05-23
| | | | | | | | | | | | | | | | | Bug: 78878033 Test: testWarpedDng in CtsGraphicsTestCases Previously this was set to 4 threads. For some images, this requires allocating close to 2 GB of memory. This is not something we can support on all devices. Unfortunately, we cannot tell the difference between images that will allocate so much memory, so just use one thread all the time. Change-Id: I9fb9a65af97efd63fac8f6b282525ff3b650968d Reviewed-on: https://skia-review.googlesource.com/129840 Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com> Auto-Submit: Leon Scroggins <scroggo@google.com>
* Reland "start cleaning up non-skcms SkColorSpaceXforms"Gravatar Mike Klein2018-05-23
| | | | | | | | | | | | | | | | | | | | | | | | This is a reland of 339133f82c30cd3080672db28e6f72c894cba05a Original change's description: > start cleaning up non-skcms SkColorSpaceXforms > > I think this gets rid of > - SkColorSpaceXform_Base > - SkColorSpaceXform_XYZ > - SkColorSpaceXform_A2B > and lots of support code. Might be more left to clean up? > > Change-Id: I560d974d1e879dfd6a63ee2244a3dd88bd495c8a > Reviewed-on: https://skia-review.googlesource.com/129512 > Commit-Queue: Brian Osman <brianosman@google.com> > Auto-Submit: Mike Klein <mtklein@chromium.org> > Reviewed-by: Brian Osman <brianosman@google.com> Change-Id: I33ee0d8bcfd72c401823a2e7d5168c9ecc9a5181 Reviewed-on: https://skia-review.googlesource.com/129624 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
* Revert "start cleaning up non-skcms SkColorSpaceXforms"Gravatar Mike Klein2018-05-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 339133f82c30cd3080672db28e6f72c894cba05a. Reason for revert: broke NinePatchDrawableTest.testGetPadding? stranger things have happened. Original change's description: > start cleaning up non-skcms SkColorSpaceXforms > > I think this gets rid of > - SkColorSpaceXform_Base > - SkColorSpaceXform_XYZ > - SkColorSpaceXform_A2B > and lots of support code. Might be more left to clean up? > > Change-Id: I560d974d1e879dfd6a63ee2244a3dd88bd495c8a > Reviewed-on: https://skia-review.googlesource.com/129512 > Commit-Queue: Brian Osman <brianosman@google.com> > Auto-Submit: Mike Klein <mtklein@chromium.org> > Reviewed-by: Brian Osman <brianosman@google.com> TBR=mtklein@chromium.org,brianosman@google.com Change-Id: I9e76195481b8658b34936aeece278d81c286c0fa No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/129680 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
* start cleaning up non-skcms SkColorSpaceXformsGravatar Mike Klein2018-05-22
| | | | | | | | | | | | | | I think this gets rid of - SkColorSpaceXform_Base - SkColorSpaceXform_XYZ - SkColorSpaceXform_A2B and lots of support code. Might be more left to clean up? Change-Id: I560d974d1e879dfd6a63ee2244a3dd88bd495c8a Reviewed-on: https://skia-review.googlesource.com/129512 Commit-Queue: Brian Osman <brianosman@google.com> Auto-Submit: Mike Klein <mtklein@chromium.org> Reviewed-by: Brian Osman <brianosman@google.com>
* Remove sk_64_isS32 and sk_64_asS32Gravatar Herb Derby2018-05-21
| | | | | | | | | This is an API change. I assume that only Skia uses these routines. Change-Id: Iefc98fa5c0b83eb4f52c478e345fd99121ecb254 Reviewed-on: https://skia-review.googlesource.com/129440 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
* Remove SK_IGNORE_SKIMAGE_ONREFENCODED_CHANGE.Gravatar Ben Wagner2018-05-17
| | | | | | | | | All implementers have been updated, so remove the flag and old code. Change-Id: Ie9747f37dd0ea3f1db682891bcae2496a470bc3a Reviewed-on: https://skia-review.googlesource.com/128883 Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
* SkImage::onRefEncoded to return sk_sp.Gravatar Ben Wagner2018-05-16
| | | | | | | | | | | | This changes SkImage::onRefEncoded and downstack calls to return sk_sp. All of the values returned are already sk_sp, so this just updates the API. This change is currently behind the new flag SK_IGNORE_SKIMAGE_ONREFENCODED_CHANGE so that Chromium can be updated. Change-Id: Ic53a88ae23fa8b3b41b84c4abdc4b74e9879da38 Reviewed-on: https://skia-review.googlesource.com/128311 Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
* non-linear blending first stepsGravatar Mike Klein2018-05-10
| | | | | | | | | | | | | | | | | | | | | | | Code: - Add a non-linear blending bit and makeNonlinearBlending() to SkColorSpace - remove enough F16=linear checks to make it possible to create surfaces and encode pngs with nonlinear F16 Testing: - add "esrgb" software config to DM, run it - add "srgbnl" software config, run it - deemphasize importance of "srgb" config on bots - update unit tests to reflect relaxed F16 constraints - add a new unit test file with _really_ basic tests, and a new unit test that's not working yet Bug: skia:7942 Change-Id: I8ac042bdf9f3d791765393b68fd9256375184d83 Reviewed-on: https://skia-review.googlesource.com/127325 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Reduce threads used for DNG decodes on AndroidGravatar Leon Scroggins III2018-04-20
| | | | | | | | | | | | | | | | Bug: b/78120086 DNG files require lots of memory to decode. We recently removed the limit on how much SkRawCodec can allocate, allowing it to decode large warped DNG files, so long as the device has enough memory. But in practice, running too many threads at once with each thread allocating a lot of memory results in crashing on Android. Reduce the number of threads so we save memory and do not crash. Change-Id: I464b5a21c019463d2ec31e333f25ebb0b81605bd Reviewed-on: https://skia-review.googlesource.com/122786 Reviewed-by: Derek Sollenberger <djsollen@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Remove the limit on dng allocationsGravatar Leon Scroggins III2018-04-19
| | | | | | | | | | | | | | Bug: 78120086 Test: TODO The limit was artificial, and did not allow for certain transformations. SkRawCodec will already fail gracefully on failures to allocate, so just rely on that. Change-Id: Id9f92b6935d77dc6ff8a06b13bd157f476a3f84c Reviewed-on: https://skia-review.googlesource.com/121946 Reviewed-by: Derek Sollenberger <djsollen@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* SkPDF: smarter Jpeg when libjpeg-turbo is presentGravatar Hal Canary2018-04-07
| | | | | | | | | | | | The fallback code does not parse the color type for EXIF-only jpegs. Since these exist in the wild, we need to find out if they are really standard YUV or greyscale Jpegs and embed them in PDFs if they are. BUG=chromium:801430 Change-Id: I93eaf8b8fc22b7169b2fce9520e022b72ad0bf81 Reviewed-on: https://skia-review.googlesource.com/118992 Commit-Queue: Hal Canary <halcanary@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com>
* Fix fuschia rollGravatar Leon Scroggins III2018-03-01
| | | | | | | | | Only call png_set_option ifdef PNG_SET_OPTION_SUPPORTED. Change-Id: Ib3d03e15b12b6229f98544b195a6bc32b5aa2f0f Reviewed-on: https://skia-review.googlesource.com/111601 Reviewed-by: Ben Wagner <benjaminwagner@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Support pngs with incorrect CMF bytesGravatar Leon Scroggins III2018-02-28
| | | | | | | | | | | | | Bug: chromium:807324 Though these pngs are technically incorrect, many such PNGs exist, and they are supported in Chromium. Ensure that users of SkCodec (e.g. Android, Flutter) display them as well. Change-Id: I2f1e573b4b7039cea81f96397cc0aa4cbc9461c3 Reviewed-on: https://skia-review.googlesource.com/111082 Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Derek Sollenberger <djsollen@google.com>
* Ensure all rows of a gif are initializedGravatar Leon Scroggins III2018-02-16
| | | | | | | | | | | | | | | | | Bug: oss-fuzz:6274 Even if a frame does not have enough LZW blocks to decode all rows, (which is unknown until we actually decode them), it is marked complete once there are no more LZW blocks. When decoding, even if we've decoded all LZW blocks, check fRowsDecoded to determine whether we've actually all the rows. Report the number of rows decoded so that SkCodec can fill in the remaining ones. Change-Id: I1d6e0c29e3c37649725836cf24a4a239e3266b76 Reviewed-on: https://skia-review.googlesource.com/106964 Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
* Check for min int in BMP headerGravatar Leon Scroggins III2018-02-15
| | | | | | | | | | | Bug: os-fuzz:6288 Negating it is undefined, so don't try. Change-Id: I055520b8036dd8b355e744114717e08d76206bc1 Reviewed-on: https://skia-review.googlesource.com/107062 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Check the length of marker before reading itGravatar Leon Scroggins III2018-02-13
| | | | | | | | Bug: os-fuzz:6295 Change-Id: I0ea9a3c54d61d41f21f2e9b945ab83fa2beb00d8 Reviewed-on: https://skia-review.googlesource.com/107025 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Add 2 fuzz targets for image decoding (oss-fuzz)Gravatar Kevin Lubick2018-02-12
| | | | | | | | | | | This also adds in a few small guards to prevent libfuzzer from frequently running out of memory when an image claims to have billions of pixels. Bug: skia: Change-Id: I47a9daac832c4d85a42000698482b61721c38880 Reviewed-on: https://skia-review.googlesource.com/106264 Commit-Queue: Kevin Lubick <kjlubick@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com>
* move a bunch of helpers from SkImageInfo.h into privGravatar Mike Reed2018-02-09
| | | | | | | | | Bug: skia: Change-Id: I8c91cfdb89e4f22448d1201d391556fe43d86dca Reviewed-on: https://skia-review.googlesource.com/105289 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org> Reviewed-by: Cary Clark <caryclark@google.com>
* 1010102, 101010x, 888x in swGravatar Mike Klein2018-01-30
| | | | | | | | | | | | | | | | | | | Same sort of deal as before, now with all three new formats. While I was at it, I made sure RGBA 8888 and BGRA 8888 both work too. We don't want the 101010's in lowp, but 888x should be fine. After looking at the DM images on monitors at work, I decided to re-enable dither even on 10-bit images. Looking at the GMs in 888x or 101010x is interesting... I think we must not be clearing the memory allocated for layers? Seems like we want to allocate layers as 8888? Change-Id: I3a85b4f00877792a6425a7e7eb31eacb04ae9218 Reviewed-on: https://skia-review.googlesource.com/101640 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Add kRGBX_8888, kRGBA_1010102, and kRGBX_1010102 color types. Unused for now.Gravatar Brian Salomon2018-01-30
| | | | | | | | | BUG= skia:7533 Change-Id: I4b3f6b827fd833ba2d07895884d2abc9a3132366 Reviewed-on: https://skia-review.googlesource.com/99781 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Brian Salomon <bsalomon@google.com>
* Make SkAndroidCodec (optionally) respect originGravatar Leon Scroggins III2018-01-26
| | | | | | | | | | | | | | | | | Bug: b/63909536 ImageDecoder will respect the origin, but BitmapFactory will maintain its current behavior of not respecting it. Add an option to respect it. In addition, add support for reading the EXIF data from a WEBP. This seems to be an uncommon use case, but is occasionally used when converting from a JPEG. Add 8 WEBPs, all converted (with cwebp) from their analogous JPEG files already checked in. Change-Id: I38afca58c86fa99ee9ab7d1dc83aaa4f23132c11 Reviewed-on: https://skia-review.googlesource.com/95300 Reviewed-by: Derek Sollenberger <djsollen@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* remove SkColorSpace_BaseGravatar Mike Klein2018-01-26
| | | | | | | | | | | | The type SkColorSpace_Base doesn't need to exist. Its one type() query can be answered instead by toXYZD50(). Now all that's left in the file is SkGammas, so rename it to SkGammas.h. Change-Id: Id60ddbfb342accfd5674ae89b37a24a6583ef7b8 Reviewed-on: https://skia-review.googlesource.com/99702 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Stop defining SK_CODEC_PRINTF in debugGravatar Leon Scroggins III2018-01-19
| | | | | | | | | | | Too much spew during DM. TBR=reed@google.com Change-Id: Ifad53b1abb35d1768e83e7867f9e808df3fcaef1 Reviewed-on: https://skia-review.googlesource.com/97160 Reviewed-by: Leon Scroggins <scroggo@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Add SkAndroidCodec::computeSampledSizeGravatar Leon Scroggins III2018-01-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: b/63909536 Android's ImageDecoder API takes as input an arbitrary width and height to scale the image to. Internally, this uses SkAndroidCodec to sample, and then (if not a perfect match) scales to the desired size with drawing. computeSampledSize is a modified version of what ImageDecoder currently does to convert from arbitrary dimensions to a sampleSize. Moving it here allows it to be shared by SkAnimatedImage. The modified version also corrects two bugs: - a client using the dimensions returned by getSampledDimensions previously may have resulted in ImageDecoder decoding to a larger size and then scaling it. (example found in tests: dog.jpg is 180 x 180. getSampledDimensions(8) returns 23 x 23, but the old method resulted in using sampleSize of 7 and downscaling the resulting 25 x 25 image.) - recompute the sampleSize based on the size returned by getSampledDimensions. Change-Id: I022040e8bac31c20988903a0452257f7ae902bc7 Reviewed-on: https://skia-review.googlesource.com/94620 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>
* 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>
* Add an SkDrawable for animated images (e.g. GIF)Gravatar Leon Scroggins III2018-01-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: b/63909536 SkAnimatedImage is a simple drawable for animating a GIF. Thread-safety is left up to the client. At most two bitmaps are stored in the drawable; one for the current frame and one for a frame that may need to be restored. The backup frame prevents some cases where we would otherwise have to re-decode from the beginning of the image. The API lets the client set the time value, and decodes to match that time. TODO: - Callback for when the animation is complete - Ability to use SkAndroidCodec - Modify the loop count (or leave that up to client?) - Better and/or client-specific caching Other changes: - Add a sample which animates a GIF - Reenable SK_CODEC_PRINTF for debug builds and Android Change-Id: I945ffbccdb6008f2a05ed4d9b2af869a261fb300 Reviewed-on: https://skia-review.googlesource.com/93420 Reviewed-by: Derek Sollenberger <djsollen@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* begin cleanup of malloc porting layerGravatar Mike Reed2018-01-05
| | | | | | | | | | | | | | 1. Merge some of the allocators into sk_malloc_flags by redefining a flag to mean zero-init 2. Add more private helpers to simplify our call-sites (and handle some overflow mul checks) 3. The 2-param helpers rely on the saturating SkSafeMath::Mul to pass max_size_t as the request, which should always fail. Bug:508641 Change-Id: I322f1e6ed91113467e0fdb12c91c3dad33d890c8 Reviewed-on: https://skia-review.googlesource.com/90940 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Stephan Altmueller <stephana@google.com>
* Add SkAndroidCodec::MakeFromCodecGravatar Leon Scroggins III2018-01-04
| | | | | | | | | | | | | Bug: b/71578461 Bug: b/63909536 This allows using APIs on SkCodec (e.g. the out-param result on SkCodec::MakeFrom(Stream/Data), getOrigin) when an SkAndroidCodec is ultimately desired without duplicating the APIs on SkAndroidCodec. Change-Id: Ie9803278348acfb3955a795772d6472c15541646 Reviewed-on: https://skia-review.googlesource.com/90844 Reviewed-by: Derek Sollenberger <djsollen@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
* Consider overflow in is_orientation_markerGravatar Leon Scroggins III2017-12-19
| | | | | | | | | | | | | Bug: skia:7404 Use a uint64_t to store the four byte integer in order to protect against overflow in the encoded (untrusted) offset. Change-Id: I9592983a7a5353219507b7ec85eae2f2c4a16a1a Reviewed-on: https://skia-review.googlesource.com/85900 Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Herb Derby <herb@google.com> Reviewed-by: Kevin Lubick <kjlubick@google.com>
* remove append_from_srgb()Gravatar Mike Klein2017-12-18
| | | | | | | | | | | It's now no different than append(from_srgb). Bug: skia:7419 Change-Id: I97c59b6987f033ec2f1859db40ca3056b87b370a Reviewed-on: https://skia-review.googlesource.com/86741 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Remove SkColorSpace_Base::MakeNamed, along with most uses of Adobe RGBGravatar Brian Osman2017-12-14
| | | | | | | | Bug: skia: Change-Id: Ic914aacc4c47200714d66cf4487932bcb8a7693a Reviewed-on: https://skia-review.googlesource.com/85040 Commit-Queue: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org>
* Revert "Remove SkColorSpace_Base::MakeNamed, along with most uses of Adobe RGB"Gravatar Mike Klein2017-12-14
| | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 411b8ea74d66d08252d9b617d7e7d458604dbc2e. Reason for revert: a couple layout tests in the roll. :/ Original change's description: > Remove SkColorSpace_Base::MakeNamed, along with most uses of Adobe RGB > > Bug: skia: > Change-Id: If5935eac48184bc8cbe4db21dac4d6033a8704e6 > Reviewed-on: https://skia-review.googlesource.com/84200 > Commit-Queue: Brian Osman <brianosman@google.com> > Reviewed-by: Mike Klein <mtklein@chromium.org> TBR=mtklein@chromium.org,brianosman@google.com Change-Id: I6d2eb57b613035ec26da15218182c808bed364ed No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/84920 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
* Remove SkColorSpace_Base::MakeNamed, along with most uses of Adobe RGBGravatar Brian Osman2017-12-13
| | | | | | | | Bug: skia: Change-Id: If5935eac48184bc8cbe4db21dac4d6033a8704e6 Reviewed-on: https://skia-review.googlesource.com/84200 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org>
* Push much of the SkColorSpace_Base interface up to SkColorSpaceGravatar Brian Osman2017-12-12
| | | | | | | | | | | Some pieces still remain, but the next step looks less mechanical, so I wanted to land this piece independently. Bug: skia: Change-Id: Ie63afcfa08af2f6e4996911fa2225c43441dbfb2 Reviewed-on: https://skia-review.googlesource.com/84120 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Brian Osman <brianosman@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>