aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkBmpCodec.cpp
Commit message (Collapse)AuthorAge
...
* 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
* Call rewindIfNeeded in SkCodecGravatar scroggo2015-09-30
| | | | | | | | | | Rather than calling it in each subclass, call it once in the base class. Call it first, since other steps may modify internal structures which would be replaced by a call to onRewind. BUG=skia:4284 Review URL: https://codereview.chromium.org/1381483002
* Merge SkCodec with SkScanlineDecoderGravatar scroggo2015-09-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Benefits: - This mimics other decoding APIs (including the ones SkCodec relies on, e.g. a png_struct, which can be used to decode an entire image or one line at a time). - It allows a client to ask us to do what we can do efficiently - i.e. start from encoded data and either decode the whole thing or scanlines. - It removes the duplicate methods which appeared in both SkCodec and SkScanlineDecoder (some of which, e.g. in SkJpegScanlineDecoder, just call fCodec->sameMethod()). - It simplifies moving more checks into the base class (e.g. the examples in skbug.com/4284). BUG=skia:4175 BUG=skia:4284 ===================================================================== SkScanlineDecoder.h/.cpp: Removed. SkCodec.h/.cpp: Add methods, enums, and variables which were previously in SkScanlineDecoder. Default fCurrScanline to -1, as a sentinel that start has not been called. General changes: Convert SkScanlineDecoders to SkCodecs. General changes in SkCodec subclasses: Merge SkScanlineDecoder implementation into SkCodec. Most (all?) owned an SkCodec, so they now call this-> instead of fCodec->. SkBmpCodec.h/.cpp: Replace the unused rowOrder method with an override for onGetScanlineOrder. Make getDstRow const, since it is called by onGetY, which is const. SkCodec_libpng.h/.cpp: Make SkPngCodec an abstract class, with two subclasses which handle scanline decoding separately (they share code for decoding the entire image). Reimplement onReallyHasAlpha so that it can return the most recent result (e.g. after a scanline decode which only decoded part of the image) or a better answer (e.g. if the whole image is known to be opaque). Compute fNumberPasses early, so we know which subclass to instantiate. Make SkPngInterlaceScanlineDecoder use the base class' fCurrScanline rather than a separate variable. CodexTest.cpp: Add tests for the state changes in SkCodec (need to call start before decoding scanlines; calling getPixels means that start will need to be called again before decoding more scanlines). Add a test which decodes in stripes, currently only used for an interlaced PNG. TODO: Add tests for onReallyHasAlpha. Review URL: https://codereview.chromium.org/1365313002
* Remove SkNEW and SkDELETE macrosGravatar mdempsky2015-09-22
| | | | | | | | | | | | | | | This CL removes the uses of SkNEW that have resprouted since commit 385fe4d, and removes the macros entirely now that Android and Chromium have been cleaned up to no longer depend on them. A bunch of files implicitly depend on #include <new> from SkPostConfig.h still though, so keep that for now. To be fixed in a followup CL. [mtklein mucking around] Only public API removed. TBR=reed@google.com Review URL: https://codereview.chromium.org/1360653004
* Fix bmp bug in ReadHeader()Gravatar msarett2015-09-01
| | | | | | | | | | | | | For BmpMaskCodecs, we need to skip any offset after the header to get to the start of pixel data. Before this fix, we only skipped this data when codecOut is non-NULL (instead of on every call to ReadHeader()). https://gold.skia.org/search?q=1&neg=true&unt=false&query=name%3Drgb16-565pal.bmp_0.200%26name%3Drgb16-565pal.bmp%26name%3Drgb16-565pal.bmp_0.250%26name%3Drgb16-565pal.bmp_0.333%26name%3Drgb16-565pal.bmp_0.375%26name%3Drgb16-565pal.bmp_0.400%26name%3Drgb16-565pal.bmp_0.500%26source_type%3Dimage BUG=skia: Review URL: https://codereview.chromium.org/1318393004
* 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
* Style Change: SkNEW->new; SkDELETE->deleteGravatar halcanary2015-08-26
| | | | | | DOCS_PREVIEW= https://skia.org/?cl=1316123003 Review URL: https://codereview.chromium.org/1316123003
* Support more swizzles to 565 in SkCodecGravatar scroggo2015-08-14
| | | | | | | | | | | | | | | | | | | | | | | Add more swizzling functions for swizzling to 565. Much of this code was revived from crrev.com/1055743003 (for BMP). Also added swizzling functions for WBMP. Consolidate the static function conversion_possible. In SkCodec::getPixels, check that the alphatype corresponds to the colorType. This prevents requesting 565 + non-opaque. In SkIcoCodec, report that the image is unpremul (instead of whatever the largest embedded codec thinks), but modify the requested info to have the alpha type expected/required by the embedded codec. Add tests for decoding to 565. BUG=skia:3257 BUG=skia:3683 Review URL: https://codereview.chromium.org/1277213002
* Fix bmp RLE "bug"Gravatar msarett2015-08-12
| | | | | | | | | | | | | | | | | Chromium's test suite contains an RLE image that reports a certain file size in the header, but then contains additional encoded data. Our bmp decoder would only decode half of the image, before stopping. With this fix, we check for additional data before returning kIncompleteInput. If this lands, I will upload the test image to the bots. Also adding an invalid image test to CodexTest. BUG=skia: Review URL: https://codereview.chromium.org/1273853004
* Consolidate SkCodec functions for handling rewindGravatar scroggo2015-08-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, many of our codec implementations followed the same pattern (often in a function named handleRewind): switch (this->rewindIfNeeded()) { case CouldNotRewind: return CouldNotRewind; case NoRewindNecessary: // keep going break; case Rewound: <re-read header etc> break; } In this CL, remove the enum, and put the piece that happens in the Rewound case into a virtual function, onRewind. rewindIfNeeded now contains the common pieces from various functions named handleRewind. In SkBmpCodec, add a function that returns whether the BMP is in ICO, so it can have a common implementation for onRewind. BUG=skia:3257 Review URL: https://codereview.chromium.org/1288483002
* Split SkBmpCodec into three separate classesGravatar msarett2015-08-06
| | | | | | | | | | | | | | Will regress behavior on gold on test32bfv4.bmp, where we will no longer fix transparent decodes. TODO: Start fixing transparent decodes again, or decide that we don't want to fix them and remove isTransparent from SkSwizzler. I think this may become more clear when I start implementing the scanline decoder. BUG=skia: Review URL: https://codereview.chromium.org/1258863008
* Rename SkCodec_libbmp to SkBmpCodecGravatar msarett2015-07-30
BUG=skia: Review URL: https://codereview.chromium.org/1254963006