aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkSwizzler.h
Commit message (Collapse)AuthorAge
* Fix double CMYK->RGBA conversion on swizzled jpeg decodesGravatar Matt Sarett2016-12-13
| | | | | | | | | BUG=skia: Change-Id: I4e8c4128f974cc491fcef0bbc1137b5d62b6f967 Reviewed-on: https://skia-review.googlesource.com/5933 Commit-Queue: Matt Sarett <msarett@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com>
* 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
* Implement Fill() for incomplete decodes to RGBA_F16Gravatar msarett2016-09-13
| | | | | | | | | Before this patch, we would hit an SkASSERT(false). BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2335203002 Review-Url: https://codereview.chromium.org/2335203002
* Fix color xform width bug when scaling/subsettingGravatar msarett2016-08-22
| | | | | | | | | | | | | This was not caught by the bots because we don't test color correct modes with our many image decoding tests (takes too long). Adding a unit test. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2247743002 Review-Url: https://codereview.chromium.org/2247743002
* Remove SkEncodedInfo kPreSwizzled_Color from public APIGravatar msarett2016-04-25
| | | | | | | BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1918943002 Review URL: https://codereview.chromium.org/1918943002
* Use SkEncodedInfo in place of SkSwizzler::SrcConfigGravatar msarett2016-04-22
| | | | | | | BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1911613002 Review URL: https://codereview.chromium.org/1911613002
* Handle gray alpha conversions in SkSwizzlerGravatar msarett2016-02-03
| | | | | | | | | | | | | | | | | | | | | Nothing fancy here. By doing the entire conversion ourselves, we only need to make one conversion pass over each row. Additionally, we optimize the premultiply since we know each color component of the pixel is identical. This will also enable us to follow up with platform specific optimizations. PNG Decode Time Nexus 6P (for a test set of GrayAlpha encoded PNGs) Regular Unpremul 0.95x Zero Init Unpremul 0.94x Regular Premul 0.91x Zero Init Premul 0.90x BUG=skia:4767 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1665583002 Review URL: https://codereview.chromium.org/1665583002
* Use fActualProc to choose fFastProc or fSlowProc in SkSwizzlerGravatar msarett2016-01-21
| | | | | | | | | | | | | | | | | | (1) We will now (correctly) choose fFastProc if the client calls setSampleX(1). (2) The logic to choose between fFastProc and fSlowProc is now performed once, rather than every time we call swizzle(). (3) This will be easier to extend when we add fFastSampleProcs for different sample sizes. This comes from Leon's suggestion in: https://codereview.chromium.org/1582083005 BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1616753003 Review URL: https://codereview.chromium.org/1616753003
* Clean up unused or overly complex modes in SkSwizzlerGravatar msarett2016-01-19
| | | | | | | BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1582083005 Review URL: https://codereview.chromium.org/1582083005
* Use SkOpts routines in SkSwizzlerGravatar msarett2016-01-12
| | | | | | | | | | | This is a bit tricky because we don't intend to support sampling in SkOpts. The swizzler will fallback to a default routine in the event that sampling is requested. BUG=skia:4767 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1563393002 Review URL: https://codereview.chromium.org/1563393002
* SkSwizzler: Factor skipping zeros out into a helper function.Gravatar mtklein2016-01-11
| | | | | | | | | | | | | | | I figure something like this lets us not worry about it in the new opts. This skips only leading zeros per-scanline, not all zeros, but my bet is that leading zeros are all that matters: it's got to be rare that a scanline is both larger than 1024 pixels and has runs of 1024 transparent pixels in the middle. I bet the big bang for the buck comes from skipping full scanlines (or even multiple adjacent scanlines). BUG=skia:4767 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1566653007 Review URL: https://codereview.chromium.org/1566653007
* Delete reallyHasAlpha() from SkCodecGravatar msarett2016-01-11
| | | | | | | | TBR=reed BUG=skia:3582 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1557403002 Review URL: https://codereview.chromium.org/1557403002
* Make SkAndroidCodec support icoGravatar msarett2015-12-04
| | | | | | BUG=skia: Review URL: https://codereview.chromium.org/1472933002
* Revert of Make SkAndroidCodec support ico (patchset #7 id:130002 of ↵Gravatar scroggo2015-12-04
| | | | | | | | | | | | | | | | | | | | | | | | | https://codereview.chromium.org/1472933002/ ) Reason for revert: Crashing: https://uberchromegw.corp.google.com/i/client.skia.android/builders/Test-Android-GCC-NexusPlayer-CPU-SSE4-x86-Release/builds/1499/steps/dm/logs/stdio Also, related ASAN failures: https://uberchromegw.corp.google.com/i/client.skia/builders/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN/builds/3676/steps/dm/logs/stdio Original issue's description: > Make SkAndroidCodec support ico > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/1603e9310f62cf0dd543cdb09dea06aa78373f13 TBR=djsollen@google.com,msarett@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1498903004
* Make SkAndroidCodec support icoGravatar msarett2015-12-04
| | | | | | BUG=skia: Review URL: https://codereview.chromium.org/1472933002
* Make SkAndroidCodec support gifGravatar msarett2015-11-17
| | | | | | | | | Involves a few bug fixes in SkCodec_libgif and a bit more complexity in SkSwizzler. BUG=skia:4405 Review URL: https://codereview.chromium.org/1445313002
* Use SkSwizzler to convert from CMYKGravatar scroggo2015-10-23
| | | | | | | | | | | | | Move convert_CMYK_to_RGBA into two functions in SkSwizzler: one for 565 and one for 8888. For simplicity, when converting to 8888, we no longer convert in place. BUG=skia:4476 Committed: https://skia.googlesource.com/skia/+/450ee8f26d39f975cf6af37a27de658ae5a9fa10 Review URL: https://codereview.chromium.org/1411083009
* Revert of Use SkSwizzler to convert from CMYK (patchset #4 id:60001 of ↵Gravatar scroggo2015-10-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | https://codereview.chromium.org/1411083009/ ) Reason for revert: Breaking ASAN. See http://build.chromium.org/p/client.skia/builders/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-ASAN/builds/2879 Original issue's description: > Use SkSwizzler to convert from CMYK > > Move convert_CMYK_to_RGBA into two functions in SkSwizzler: one for 565 > and one for 8888. > > For simplicity, when converting to 8888, we no longer convert in place. > > BUG=skia:4476 > > Committed: https://skia.googlesource.com/skia/+/450ee8f26d39f975cf6af37a27de658ae5a9fa10 TBR=msarett@google.com,scroggo@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia:4476 Review URL: https://codereview.chromium.org/1411193006
* Use SkSwizzler to convert from CMYKGravatar scroggo2015-10-23
| | | | | | | | | | | Move convert_CMYK_to_RGBA into two functions in SkSwizzler: one for 565 and one for 8888. For simplicity, when converting to 8888, we no longer convert in place. BUG=skia:4476 Review URL: https://codereview.chromium.org/1411083009
* Fix SkSwizzler bugGravatar msarett2015-10-16
| | | | | | | | | | | | | | | Now, that we are subsetting, fX0 is not necessarily less than fSrcWidth (since fSrcWidth is really the subset width). Ex: We may want a 10 pixel subset starting twenty pixels from the left edge. In that case, fX0=20 and fSrcWidth=10. Let's rename the width as fSubsetWidth to avoid confusion and remove the check. BUG=skia: Review URL: https://codereview.chromium.org/1407603003
* Add subsetting to SkScanlineDecoderGravatar msarett2015-10-13
| | | | | | | | | | | | This CL allows the SkScanlineDecoder to decode partial scanlines. This is a first step in efficiently implementing subsetting in SkScaledCodec. BUG=skia:4209 Review URL: https://codereview.chromium.org/1390213002
* Fill incomplete images in SkCodec parent classGravatar msarett2015-10-09
| | | | | | | | | | | | | | | | | | | | | | | | | Rather than implementing some sort of "fill" in every SkCodec subclass for incomplete images, let's make the parent class handle this situation. This includes an API change to SkCodec.h SkCodec::getScanlines() now returns the number of lines it read successfully, rather than an SkCodec::Result enum. getScanlines() most often fails on an incomplete input, in which case it is useful to know how many lines were successfully decoded - this provides more information than kIncomplete vs kSuccess. We do lose information when the API is used improperly, as we are no longer able to return kInvalidParameter or kScanlineNotStarted. Known Issues: Does not work for incomplete fFrameIsSubset gifs. Does not work for incomplete icos. BUG=skia: Review URL: https://codereview.chromium.org/1332053002
* Move all knowledge of X sampling into SkScaledCodecGravatar scroggo2015-10-02
| | | | | | | | | | | | | | | | | | | | | | | Prior to this CL, each SkCodec subclass that allows sampling does an extra check in onStartScanlineDecode to determine whether the X dimension is supported for sampling. Remove this check, and provide a way for SkScaledCodec to directly access the SkSwizzler, and update it to do sampling. This way, the SkCodec knows nothing of sampling, but we can still save the extra step of sampling afterwards. FIXME: SkBmpRLECodec still calls SkScaledCodec::DimensionsSupported. It seems like it could directly support sampling, rather than dealing with SkScaledCodec (partially). Add a new base class for SkSwizzler. It allows updating the swizzler after it was created, which is done by SkScaledCodec. Modify SkSwizzler's constructor/factory function to stop taking any info about sampling, assume the sample size is one, and move modifying that into a virtual function overridden from the base class. BUG=skia:4284 Review URL: https://codereview.chromium.org/1372973002
* Scanline decoding for bmpGravatar msarett2015-08-31
| | | | | | | | | | | | | Redesigns SkScanlineDecoder.h to indicate the ordering in which the scanlines are provided Refactors SkSwizzler::Fill() to include the zeroInit check and to actually be correct. BUG=skia:3257 BUG=skia:4198 Review URL: https://codereview.chromium.org/1287423002
* Style Change: NULL->nullptrGravatar halcanary2015-08-27
| | | | | | DOCS_PREVIEW= https://skia.org/?cl=1316233002 Review URL: https://codereview.chromium.org/1316233002
* SkScaledCodec classGravatar emmaleer2015-08-14
| | | | | | | | | | | | | | | | | | | | | | | | This class does scaling by using a scanlineDecoder. getScanlines and skipScanlines are used for y sampling, the swizzler is used for x sampling this class is currently only working for png and jpeg images I will update other Codec types to work soon For SkJpegCodec to implement width wise swizzling it now uses a swizzler. I ran performance tests on this change. Here are the performance test results: https://docs.google.com/a/google.com/spreadsheets/d/1D7-Q_GXD_dI68LZO005NNvb8Wq2Ee0wEBEPG72671yw/edit?usp=sharing BUG=skia: Committed: https://skia.googlesource.com/skia/+/0944100ac89f797714eeae0cf2875e2335ff52ee Committed: https://skia.googlesource.com/skia/+/d518ea7927f9f4e0ed5b4134d1b4f48243855a47 Committed: https://skia.googlesource.com/skia/+/b157917507d4f7d2651f0aeb566d31603cc02240 Review URL: https://codereview.chromium.org/1260673002
* Revert of SkScaledCodec class (patchset #35 id:680001 of ↵Gravatar egdaniel2015-08-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://codereview.chromium.org/1260673002/ ) Reason for revert: breaking ubuntu bots Original issue's description: > SkScaledCodec class > > This class does scaling by using a scanlineDecoder. > getScanlines and skipScanlines are used for y sampling, > the swizzler is used for x sampling > > this class is currently only working for png and jpeg images > I will update other Codec types to work soon > > For SkJpegCodec to implement width wise swizzling it now > uses a swizzler. I ran performance tests on this change. > Here are the performance test results: > https://docs.google.com/a/google.com/spreadsheets/d/1D7-Q_GXD_dI68LZO005NNvb8Wq2Ee0wEBEPG72671yw/edit?usp=sharing > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/0944100ac89f797714eeae0cf2875e2335ff52ee > > Committed: https://skia.googlesource.com/skia/+/d518ea7927f9f4e0ed5b4134d1b4f48243855a47 > > Committed: https://skia.googlesource.com/skia/+/b157917507d4f7d2651f0aeb566d31603cc02240 TBR=scroggo@google.com,msarett@google.com,djsollen@google.com,mtklein@google.com,emmaleer@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1285173003
* SkScaledCodec classGravatar emmaleer2015-08-14
| | | | | | | | | | | | | | | | | | | | | | This class does scaling by using a scanlineDecoder. getScanlines and skipScanlines are used for y sampling, the swizzler is used for x sampling this class is currently only working for png and jpeg images I will update other Codec types to work soon For SkJpegCodec to implement width wise swizzling it now uses a swizzler. I ran performance tests on this change. Here are the performance test results: https://docs.google.com/a/google.com/spreadsheets/d/1D7-Q_GXD_dI68LZO005NNvb8Wq2Ee0wEBEPG72671yw/edit?usp=sharing BUG=skia: Committed: https://skia.googlesource.com/skia/+/0944100ac89f797714eeae0cf2875e2335ff52ee Committed: https://skia.googlesource.com/skia/+/d518ea7927f9f4e0ed5b4134d1b4f48243855a47 Review URL: https://codereview.chromium.org/1260673002
* Revert of SkScaledCodec class (patchset #34 id:660001 of ↵Gravatar emmaleer2015-08-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://codereview.chromium.org/1260673002/ ) Reason for revert: Seg-faulting: http://build.chromium.org/p/client.skia/builders/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86-Release/builds/1608/steps/dm/logs/stdio Original issue's description: > SkScaledCodec class > > This class does scaling by using a scanlineDecoder. > getScanlines and skipScanlines are used for y sampling, > the swizzler is used for x sampling > > this class is currently only working for png and jpeg images > I will update other Codec types to work soon > > For SkJpegCodec to implement width wise swizzling it now > uses a swizzler. I ran performance tests on this change. > Here are the performance test results: > https://docs.google.com/a/google.com/spreadsheets/d/1D7-Q_GXD_dI68LZO005NNvb8Wq2Ee0wEBEPG72671yw/edit?usp=sharing > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/0944100ac89f797714eeae0cf2875e2335ff52ee > > Committed: https://skia.googlesource.com/skia/+/d518ea7927f9f4e0ed5b4134d1b4f48243855a47 TBR=scroggo@google.com,msarett@google.com,djsollen@google.com,mtklein@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1294613002
* SkScaledCodec classGravatar emmaleer2015-08-13
| | | | | | | | | | | | | | | | | | | | This class does scaling by using a scanlineDecoder. getScanlines and skipScanlines are used for y sampling, the swizzler is used for x sampling this class is currently only working for png and jpeg images I will update other Codec types to work soon For SkJpegCodec to implement width wise swizzling it now uses a swizzler. I ran performance tests on this change. Here are the performance test results: https://docs.google.com/a/google.com/spreadsheets/d/1D7-Q_GXD_dI68LZO005NNvb8Wq2Ee0wEBEPG72671yw/edit?usp=sharing BUG=skia: Committed: https://skia.googlesource.com/skia/+/0944100ac89f797714eeae0cf2875e2335ff52ee Review URL: https://codereview.chromium.org/1260673002
* Revert of SkScaledCodec class (patchset #32 id:620001 of ↵Gravatar emmaleer2015-08-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://codereview.chromium.org/1260673002/ ) Reason for revert: Segfaulting: http://build.chromium.org/p/client.skia/builders/Test-Ubuntu-GCC-GCE-CPU-AVX2-x86-Release/builds/1605/steps/dm/logs/stdio Original issue's description: > SkScaledCodec class > > This class does scaling by using a scanlineDecoder. > getScanlines and skipScanlines are used for y sampling, > the swizzler is used for x sampling > > this class is currently only working for png and jpeg images > I will update other Codec types to work soon > > For SkJpegCodec to implement width wise swizzling it now > uses a swizzler. I ran performance tests on this change. > Here are the performance test results: > https://docs.google.com/a/google.com/spreadsheets/d/1D7-Q_GXD_dI68LZO005NNvb8Wq2Ee0wEBEPG72671yw/edit?usp=sharing > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/0944100ac89f797714eeae0cf2875e2335ff52ee TBR=scroggo@google.com,msarett@google.com,djsollen@google.com,mtklein@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1294593002
* SkScaledCodec classGravatar emmaleer2015-08-13
| | | | | | | | | | | | | | | | | | This class does scaling by using a scanlineDecoder. getScanlines and skipScanlines are used for y sampling, the swizzler is used for x sampling this class is currently only working for png and jpeg images I will update other Codec types to work soon For SkJpegCodec to implement width wise swizzling it now uses a swizzler. I ran performance tests on this change. Here are the performance test results: https://docs.google.com/a/google.com/spreadsheets/d/1D7-Q_GXD_dI68LZO005NNvb8Wq2Ee0wEBEPG72671yw/edit?usp=sharing BUG=skia: Review URL: https://codereview.chromium.org/1260673002
* Scanline decoding for wbmpGravatar msarett2015-08-05
| | | | | | | | | | | | | | | We are also changing the wbmp to use SkSwizzler. This will allow us to take advantage of the sampling routines that are being implemented in SkSwizzler. The image in this upload came from: https://commons.wikimedia.org/wiki/File:Android_robot.png It is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license. BUG=skia: Review URL: https://codereview.chromium.org/1254483004
* Pass the destination pointer to next() in SkSwizzlerGravatar msarett2015-07-27
| | | | | | | | | | | Per our discussion, we can make the swizzler simpler and more usable for SkCodec and SkScanlineDecoder by only having a single version of next() which takes a pointer to the srcRow and a pointer to the dstRow. BUG=skia: Review URL: https://codereview.chromium.org/1256373002
* SkCodec no longer inherits from SkImageGenerator.Gravatar scroggo2015-07-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SkImageGenerator makes some assumptions that are not necessarily valid for SkCodec. For example, SkCodec does not assume that it can always be rewound. We also have an ongoing question of what an SkCodec should report as its default settings (i.e. the return from getInfo). It makes sense for an SkCodec to report that its pixels are unpremultiplied, if that is the case for the underlying data, but if a client of SkImageGenerator uses the default settings (as many do), they will receive unpremultiplied pixels which cannot (currently) be drawn with Skia. We may ultimately decide to revisit SkCodec reporting an SkImageInfo, but I have left it unchanged for now. Import features of SkImageGenerator used by SkCodec into SkCodec. I have left SkImageGenerator unchanged for now, but it no longer needs Result or Options. This will require changes to Chromium. Manually handle the lifetime of fScanlineDecoder, so SkScanlineDecoder.h can include SkCodec.h (where Result is), and SkCodec.h does not need to include it (to delete fScanlineDecoder). In many places, make the following simple changes: - Now include SkScanlineDecoder.h, which is no longer included by SkCodec.h - Use the enums in SkCodec, rather than SkImageGenerator - Stop including SkImageGenerator.h where no longer needed Review URL: https://codereview.chromium.org/1220733013
* SkJpegCodecGravatar msarett2015-04-15
| | | | | | | | | | | | Enables basic decoding for jpegs Includes rewinding 565, YUV, and Jpeg encoding are not yet implemented BUG=skia:3257 Review URL: https://codereview.chromium.org/1076923002
* Implementing filling for SkBmpCodecGravatar msarett2015-04-10
| | | | | | | | | | | | | | | The bmp codec currently returns kIncompleteInput when the stream is truncated, which we treat as a partial success. However, we neglect the fill the remaining pixels in the image, leaving these uninitialized. This CL addresses this problem by initializing the remaining pixels in the image to default values. BUG=skia:3257 Review URL: https://codereview.chromium.org/1075243003
* ***Disables swizzles to 565.Gravatar msarett2015-04-09
| | | | | | | | | | | | | | | | | | | | | | | We may want to enable swizzles to 565 for images that are encoded in a format similar to 565, however, we do not want to take images that decode naturally to kN32 and then convert them to 565. ***Enable swizzles to kIndex_8. For images encoded in a color table format, we suggest that they be decoded to kIndex_8. When we decode, we only allow conversion to kIndex_8 if it matches the suggested color type (except wbmp which seems good as is). ***Modify dm to test images that decode to kIndex_8. BUG=skia:3257 BUG=skia:3440 Review URL: https://codereview.chromium.org/1055743003
* Add scanline decoding to SkCodec.Gravatar scroggo2015-03-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an interface for decoding scanlines, and implement that interface in the PNG decoder. Use a separate method to determine whether an image that used a type with alpha was actually opaque. SkScanlineDecoder.h: New interface for decoding scanlines. SkCodec.h: Add getScanlineDecoder. Add a virtual function (with non-virtual caller) for determining whether the image truly had alpha. The client can call this to determine if the image was actually opaque if it reported having alpha. Remove code to sneakily change the passed in alpha type. SkCodec_libpng.*: Split up code onGetPixels into helper functions that can be shared with the scanline decoder. Implement scanline decoding. Implement onReallyHasAlpha. SkSwizzler.*: Add a new SrcConfig as a default, which is invalid. Add a function for setting fDstRow directly. Assert fDstRow is not NULL. BUG=skia:3257 Review URL: https://codereview.chromium.org/1010903003
* Option for SkCodec to treat dst as all zeroes.Gravatar scroggo2015-03-17
| | | | | | | This recreates SkImageDecoder's feature to skip writing zeroes for SkCodec. Review URL: https://codereview.chromium.org/980903002
* Revert "Revert of fix for invalid for loop syntax broke build (patchset #1 ↵Gravatar msarett2015-03-16
| | | | | | | | | | | | | | | | id:1 of https://codereview.chromium.org/1007373003/)" This reverts commit d18475854ce232de71c5463e0654f459d4abfd43. Revert "Revert "Implementation of image decoding for bmp files, in accordance with the new API."" This reverts commit dfdec78a5d02e8690998741a9fe5b71a08ca3232. BUG=skia: TBR= Review URL: https://codereview.chromium.org/1016443003
* Revert "Implementation of image decoding for bmp files, in accordance with ↵Gravatar msarett2015-03-16
| | | | | | | | | | | | | the new API." This reverts commit 3675874468de7228944ce21922e6ec863f5f2310. BUG=skia: NOTREECHECKS=true NOTRY=true TBR= Review URL: https://codereview.chromium.org/1012873002
* Implementation of image decoding for bmp files, in accordance with the new API.Gravatar msarett2015-03-16
| | | | | | | | | | Currently decodes to opaque and unpremul. Tested on local test suite. BUG=skia:3257 Review URL: https://codereview.chromium.org/947283002
* Add SkCodec, including PNG implementation.Gravatar scroggo2015-03-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DM: Add a flag to use SkCodec instead of SkImageDecoder. SkCodec: Base class for codecs, allowing creation from an SkStream or an SkData. An SkCodec, on creation, knows properties of the data like its width and height. Further calls can be used to generate the image. TODO: Add scanline iterator SkPngCodec: New decoder for png. Wraps libpng. The code has been repurposed from SkImageDecoder_libpng. TODO: Handle other destination colortypes TODO: Substitute the transpose color TODO: Allow silencing warnings TODO: Use RGB instead of filler? TODO: sRGB SkSwizzler: Simplified version of SkScaledSampler. Unlike the sampler, this object does no sampling. TODO: Implement other swizzles. Requires a gclient sync to pull down libpng. BUG=skia:3257 Committed: https://skia.googlesource.com/skia/+/ca358852b4fed656d11107b2aaf28318a4518b49 (and then reverted) Review URL: https://codereview.chromium.org/930283002
* Revert of Add SkCodec, including PNG implementation. (patchset #24 id:460001 ↵Gravatar scroggo2015-03-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | of https://codereview.chromium.org/930283002/) Reason for revert: Breaking windows bots all over the place :( Original issue's description: > Add SkCodec, including PNG implementation. > > DM: > Add a flag to use SkCodec instead of SkImageDecoder. > > SkCodec: > Base class for codecs, allowing creation from an SkStream or an SkData. > An SkCodec, on creation, knows properties of the data like its width and height. Further calls can be used to generate the image. > TODO: Add scanline iterator > > SkPngCodec: > New decoder for png. Wraps libpng. The code has been repurposed from SkImageDecoder_libpng. > TODO: Handle other destination colortypes > TODO: Substitute the transpose color > TODO: Allow silencing warnings > TODO: Use RGB instead of filler? > TODO: sRGB > > SkSwizzler: > Simplified version of SkScaledSampler. Unlike the sampler, this object does no sampling. > TODO: Implement other swizzles. > > BUG=skia:3257 > > Committed: https://skia.googlesource.com/skia/+/ca358852b4fed656d11107b2aaf28318a4518b49 TBR=reed@google.com,djsollen@google.com,msarett@google.com,mtklein@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia:3257 Review URL: https://codereview.chromium.org/972743003
* Add SkCodec, including PNG implementation.Gravatar scroggo2015-03-02
DM: Add a flag to use SkCodec instead of SkImageDecoder. SkCodec: Base class for codecs, allowing creation from an SkStream or an SkData. An SkCodec, on creation, knows properties of the data like its width and height. Further calls can be used to generate the image. TODO: Add scanline iterator SkPngCodec: New decoder for png. Wraps libpng. The code has been repurposed from SkImageDecoder_libpng. TODO: Handle other destination colortypes TODO: Substitute the transpose color TODO: Allow silencing warnings TODO: Use RGB instead of filler? TODO: sRGB SkSwizzler: Simplified version of SkScaledSampler. Unlike the sampler, this object does no sampling. TODO: Implement other swizzles. BUG=skia:3257 Review URL: https://codereview.chromium.org/930283002