aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/images/SkImageDecoder_libpng.cpp
Commit message (Collapse)AuthorAge
* Switch SkAutoMalloc to SkAutoTMalloc to avoid castGravatar scroggo2015-12-10
| | | | | | | | | | | | Make SkAutoTMalloc's interface look more like SkAutoMalloc: - add free(), which does what you expect - make reset() return a pointer fPtr No public API changes (SkAutoTMalloc is in include/private) BUG=skia:2148 Review URL: https://codereview.chromium.org/1516833003
* Silence another PNG print statementGravatar scroggo2015-12-10
| | | | | | | It can still be turned on by using setting c_suppressPNGImageDecoderWarnings to true. Review URL: https://codereview.chromium.org/1512293003
* Silence libpng warnings in SkImageDecoderGravatar msarett2015-12-09
| | | | | | BUG=skia: Review URL: https://codereview.chromium.org/1512043002
* SkPNGImageEncoder encodes all SkColorTypesGravatar halcanary2015-12-07
| | | | Review URL: https://codereview.chromium.org/1506663002
* Add SkPngChunkReader.Gravatar scroggo2015-11-23
| | | | | | | | | | | | | | | | | | | | This class allows a client of SkCodec to read chunks in the data stream that are not recognized by libpng. This is used by Android to specify ninepatch data. Taken from SkImageDecoder::Peeker. Modify the name of the class and its method to be more specific to their use. Make SkImageDecoder::Peeker a subclass of the new class, to help stage the change in Android. Add a test to verify that it works. BUG=skia:4574 BUG=skia:3257 Committed: https://skia.googlesource.com/skia/+/3389e00136188800b98ca69488c0418c374fd78b Review URL: https://codereview.chromium.org/1040453002
* Revert of Add SkPngChunkReader. (patchset #9 id:160001 of ↵Gravatar scroggo2015-11-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://codereview.chromium.org/1040453002/ ) Reason for revert: Busted Chromium builds: ../../third_party/skia/src/ports/SkImageDecoder_empty.cpp:63:17: error: no type named 'Peeker' in 'SkImageDecoder' SkImageDecoder::Peeker* SkImageDecoder::setPeeker(Peeker*) { ~~~~~~~~~~~~~~~~^ ../../third_party/skia/src/ports/SkImageDecoder_empty.cpp:63:51: error: unknown type name 'Peeker' SkImageDecoder::Peeker* SkImageDecoder::setPeeker(Peeker*) { Original issue's description: > Add SkPngChunkReader. > > This class allows a client of SkCodec to read chunks in the data > stream that are not recognized by libpng. This is used by Android > to specify ninepatch data. > > Taken from SkImageDecoder::Peeker. Modify the name of the class > and its method to be more specific to their use. Make > SkImageDecoder::Peeker a subclass of the new class, to help stage > the change in Android. > > Add a test to verify that it works. > > BUG=skia:4574 > BUG=skia:3257 > > Committed: https://skia.googlesource.com/skia/+/3389e00136188800b98ca69488c0418c374fd78b TBR=djsollen@google.com,reed@google.com,msarett@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia:4574 Review URL: https://codereview.chromium.org/1472863003
* Add SkPngChunkReader.Gravatar scroggo2015-11-23
| | | | | | | | | | | | | | | | | | This class allows a client of SkCodec to read chunks in the data stream that are not recognized by libpng. This is used by Android to specify ninepatch data. Taken from SkImageDecoder::Peeker. Modify the name of the class and its method to be more specific to their use. Make SkImageDecoder::Peeker a subclass of the new class, to help stage the change in Android. Add a test to verify that it works. BUG=skia:4574 BUG=skia:3257 Review URL: https://codereview.chromium.org/1040453002
* Delete dead SkImageDecoder::buildTileIndex and decodeSubset codeGravatar msarett2015-11-10
| | | | | | | | | | | This approach to subset decoding is no longer supported. We have replaced it with an implementation that does not depend on forked libraries. https://codereview.chromium.org/1406153015/ BUG=skia: Review URL: https://codereview.chromium.org/1426943009
* Fix the build on Android devicesGravatar Matt Sarett2015-11-06
|
* Remove dependencies on Android's forked decoder librariesGravatar msarett2015-11-06
| | | | | | | | | | | Disable SkImageDecoder's code which relies on Android's customized libpng and libjpeg. Build standard versions of libpng and libjpeg-turbo everywhere. The SkImageDecoder code has been replaced with SkCodec, which can decode subsets using standard library APIs BUG=skia: Review URL: https://codereview.chromium.org/1406153015
* Supply separate flags for onBuildTileIndexGravatar scroggo2015-10-14
| | | | | | | | | | | | | Since png and jpeg's implementations of onBuildTileIndex rely on modifications to their underlying libraries, rather than whether we are running on Android, use separate flags that can be disabled independently. This will allow us to easily turn off the feature. It also is a step towards building and running on other platforms for testing (e.g. valgrind/ASAN to find memory leaks etc). Review URL: https://codereview.chromium.org/1401283003
* 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
* Enable both static and dynamically linked libpngGravatar djsollen2015-04-03
| | | | | | | | | | | All platforms except android are configured to use the statically linked copy of libpng. Android uses the system provided dynamic copy for SkImageDecoder and the static copy for SkCodec. The exception being android framework builds that currently use the dynamic copy everywhere. This CL also enables NEON optimizations for libpng. Review URL: https://codereview.chromium.org/1058823002
* Revert of Enable both static and dynamically linked libpng (patchset #4 ↵Gravatar djsollen2015-04-01
| | | | | | | | | | | | | | | | | | | | | | | id:60001 of https://codereview.chromium.org/1032253003/) Reason for revert: breaking the nexus_9 and ios builds. Original issue's description: > Enable both static and dynamically linked libpng > > All platforms except android are configured to use the statically linked copy of libpng. Android uses the system provided dynamic copy for SkImageDecoder and the static copy for SkCodec. The exception being android framework builds that currently use the dynamic copy everywhere. > > This CL also enables NEON optimizations for libpng. > > Committed: https://skia.googlesource.com/skia/+/2469c999518e7b0063d35e9e2eb074a0477c21ac TBR=scroggo@google.com,msarett@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1050183002
* Enable both static and dynamically linked libpngGravatar djsollen2015-04-01
| | | | | | | | All platforms except android are configured to use the statically linked copy of libpng. Android uses the system provided dynamic copy for SkImageDecoder and the static copy for SkCodec. The exception being android framework builds that currently use the dynamic copy everywhere. This CL also enables NEON optimizations for libpng. Review URL: https://codereview.chromium.org/1032253003
* C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla}Gravatar mtklein2015-03-25
| | | | | | | | | NOPRESUBMIT=true BUG=skia: DOCS_PREVIEW= https://skia.org/?cl=1037793002 Review URL: https://codereview.chromium.org/1037793002
* Indexed PNG decoding: Ensure color table is large enough that the bit depth ↵Gravatar dml2015-03-18
| | | | | | | | | | | of the image will not allow reads beyond its end. BUG=skia:3440 R=rmistry@google.com, scroggo@google.com Committed: https://skia.googlesource.com/skia/+/493c1ce1cd406ef28683203146274154783452ce Review URL: https://codereview.chromium.org/948163002
* Revert "Indexed PNG decoding: Ensure color table is large enough that the ↵Gravatar scroggo2015-03-17
| | | | | | | | | | | | | bit depth of the image will not allow reads beyond its end." This reverts commit 493c1ce1cd406ef28683203146274154783452ce. NOTRY=true NOTREECHECKS=true TBR=egdaniel@google.com,dml@google.com BUG=skia: Review URL: https://codereview.chromium.org/1014553003
* Indexed PNG decoding: Ensure color table is large enough that the bit depth ↵Gravatar Leon Scroggins III2015-03-17
| | | | | | | | | of the image will not allow reads beyond its end. BUG=skia:3440 R=rmistry@google.com, scroggo@google.com Review URL: https://codereview.chromium.org/948163002
* Fix a memory leak when decoding corrupted indexed PNGs.Gravatar dml2015-03-11
| | | | | | | | | | Commit to branch refs/heads/png-leak BUG=skia:3457 Committed: https://skia.googlesource.com/skia/+/561a1ca9559a1ea7589ab93350124284fcef3315 Review URL: https://codereview.chromium.org/951663002
* Revert of Fix a memory leak when decoding corrupted indexed PNGs. (patchset ↵Gravatar reed2015-03-07
| | | | | | | | | | | | | | | | | | | | | | | #2 id:20001 of https://codereview.chromium.org/951663002/) Reason for revert: speculative revert due to many failures in tree Original issue's description: > Fix a memory leak when decoding corrupted indexed PNGs. > Commit to branch refs/heads/png-leak > > BUG=skia:3457 > > Committed: https://skia.googlesource.com/skia/+/561a1ca9559a1ea7589ab93350124284fcef3315 TBR=scroggo@google.com,dml@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia:3457 Review URL: https://codereview.chromium.org/980203005
* Fix a memory leak when decoding corrupted indexed PNGs.Gravatar dml2015-03-06
| | | | | | | | Commit to branch refs/heads/png-leak BUG=skia:3457 Review URL: https://codereview.chromium.org/951663002
* Make SkStream *not* ref counted.Gravatar scroggo2015-01-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SkStream is a stateful object, so it does not make sense for it to have multiple owners. Make SkStream inherit directly from SkNoncopyable. Update methods which previously called SkStream::ref() (e.g. SkImageDecoder::buildTileIndex() and SkFrontBufferedStream::Create(), which required the existing owners to call SkStream::unref()) to take ownership of their SkStream parameters and delete when done (including on failure). Switch all SkAutoTUnref<SkStream>s to SkAutoTDelete<SkStream>s. In some cases this means heap allocating streams that were previously stack allocated. Respect ownership rules of SkTypeface::CreateFromStream() and SkImageDecoder::buildTileIndex(). Update the comments for exceptional methods which do not affect the ownership of their SkStream parameters (e.g. SkPicture::CreateFromStream() and SkTypeface::Deserialize()) to be explicit about ownership. Remove test_stream_life, which tested that buildTileIndex() behaved correctly when SkStream was a ref counted object. The test does not make sense now that it is not. In SkPDFStream, remove the SkMemoryStream member. Instead of using it, create a new SkMemoryStream to pass to fDataStream (which is now an SkAutoTDelete). Make other pdf rasterizers behave like SkPDFDocumentToBitmap. SkPDFDocumentToBitmap delete the SkStream, so do the same in the following pdf rasterizers: SkPopplerRasterizePDF SkNativeRasterizePDF SkNoRasterizePDF Requires a change to Android, which currently treats SkStreams as ref counted objects. Review URL: https://codereview.chromium.org/849103004
* Fix up all the easy virtual ... SK_OVERRIDE cases.Gravatar mtklein2015-01-09
| | | | | | | | | | | | This fixes every case where virtual and SK_OVERRIDE were on the same line, which should be the bulk of cases. We'll have to manually clean up the rest over time unless I level up in regexes. for f in (find . -type f); perl -p -i -e 's/virtual (.*)SK_OVERRIDE/\1SK_OVERRIDE/g' $f; end BUG=skia: Review URL: https://codereview.chromium.org/806653007
* remove dead SK_SUPPORT_LEGACY_IMAGEDECODER_CHOOSER codeGravatar reed2014-12-22
| | | | | | BUG=skia: Review URL: https://codereview.chromium.org/816273002
* SkColorTable locking serves no purpose anymore.Gravatar mtklein2014-12-02
| | | | | | | | | The only thing the unlock methods were doing was assert their balance. This removes the unlock methods and renames the lock methods "read". BUG=skia: Review URL: https://codereview.chromium.org/719213008
* Qualify the return value of SkImageDecoder::decodeGravatar scroggo2014-10-22
| | | | | | | | | | | | | | | | | | | | | | | Add a new enum to differentiate between a complete decode and a partial decode (with the third value being failure). Return this value from SkImageDecoder::onDecode (in all subclasses, plus SkImageDecoder_empty) and ::decode. For convenience, if the enum is treated as a boolean, success and partial success are both considered true. Note that the static helper functions (DecodeFile etc) still return true and false (for one thing, this allows us to continue to use SkImageDecoder::DecodeMemory as an SkPicture::InstallPixelRefProc in SkPicture::CreateFromStream). Also correctly report failure in SkASTCImageDecoder::onDecode when SkTextureCompressor::DecompressBufferFromFormat fails. BUG=skia:3037 BUG:b/17419670 Review URL: https://codereview.chromium.org/647023006
* Make SkImageDecoder_libpng be compilable with Chromium libpngGravatar kkinnunen2014-10-19
| | | | | | | | | | | | | Chromium has libpng with pngusr.h that disables certain functionality with defines. Use those defines when compiling SkImageDecoder_libpng.cpp. This makes it possible to use Skia PNG decoder and encoder when compiling dm with Chromium. Skia PNG decoder and encoder of course is not compiled to the skia library, but to dm with Chromium. BUG=skia:2992 Review URL: https://codereview.chromium.org/645883004
* remove alphatype from colortableGravatar reed2014-09-29
| | | | | | | | | | | the owning bitmap is (already) responsible for knowing the alphatype BUG=skia: R=djsollen@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/611093002
* "NULL !=" = NULLGravatar bsalomon2014-09-05
| | | | | | | | R=reed@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/544233002
* make allocPixels throw on failureGravatar reed2014-09-02
| | | | | | | | | BUG=skia: R=mtklein@google.com, fmalita@google.com, fmalita@chromium.org Author: reed@google.com Review URL: https://codereview.chromium.org/510423005
* Fix image decoder memory overwrite bug.Gravatar scroggo2014-07-25
| | | | | | | | | | | | | | | | In SkPNGImageDecoder::onDecodeSubset, use png_read_rows to write to the scratch memory provided. This is what we should have been doing anyway. Further, writing directly to the bitmap can cause writing to the wrong memory since the bitmap may not be as big as the scratch memory in the case of sampling with a short bitmap. Bug=b/13921093 R=djsollen@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/423473003
* stop using SkBitmap::ConfigGravatar reed2014-06-14
| | | | | | | | R=scroggo@google.com Author: reed@chromium.org Review URL: https://codereview.chromium.org/338493005
* hide SkImageDecoder::ChooserGravatar reed2014-06-11
| | | | | | | | | BUG=skia: R=scroggo@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/331433003
* hide SkBitmap::setConfigGravatar reed2014-06-09
| | | | | | | | | | patch from issue 325733002 TBR=scroggo Author: reed@chromium.org Review URL: https://codereview.chromium.org/322963002
* Fix issue in image decoders where the bitmap config was not properly set.Gravatar djsollen@google.com2014-02-19
| | | | | | | | R=scroggo@google.com Review URL: https://codereview.chromium.org/167763003 git-svn-id: http://skia.googlecode.com/svn/trunk@13503 2bbb7eff-a529-9590-31e7-b0007b416f81
* Revert "Revert of https://codereview.chromium.org/113823003/"Gravatar reed@google.com2013-12-30
| | | | | | | | | | This reverts commit 68b4b32066ea0ba9dbb5d326a836f8a54297b7aa. BUG= Review URL: https://codereview.chromium.org/122293002 git-svn-id: http://skia.googlecode.com/svn/trunk@12842 2bbb7eff-a529-9590-31e7-b0007b416f81
* Clean up after longjmp in SkImageDecoder_libpng.Gravatar scroggo@google.com2013-11-12
| | | | | | | | | | | | | In onDecodeInit, if longjmp sends us back to setjmp, destroy the png_struct and info_ptr before returning false. Since the PNGAutoClean has not been created yet, we were previously leaking resources. R=djsollen@google.com Review URL: https://codereview.chromium.org/68453006 git-svn-id: http://skia.googlecode.com/svn/trunk@12244 2bbb7eff-a529-9590-31e7-b0007b416f81
* Create nonPOD before setjmp.Gravatar scroggo@google.com2013-11-12
| | | | | | | | | | | | With PNGAutoClean created after setjmp, when longjmp is called its destructor is never called. Create it before setjmp, ensuring that its destructor is called. R=mtklein@google.com Review URL: https://codereview.chromium.org/65283002 git-svn-id: http://skia.googlecode.com/svn/trunk@12238 2bbb7eff-a529-9590-31e7-b0007b416f81
* Revert "Revert "add SK_ATTR_DEPRECATED -- will need to disable for chrome, ↵Gravatar reed@google.com2013-10-31
| | | | | | | | | | | | since it triggers a warning"" This reverts commit 1e787c38fa71f2a21fd728f1b1d620b9b09b0d3d. BUG= Review URL: https://codereview.chromium.org/54603004 git-svn-id: http://skia.googlecode.com/svn/trunk@12057 2bbb7eff-a529-9590-31e7-b0007b416f81
* Image decoder fixes (mostly) around A8.Gravatar scroggo@google.com2013-10-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Opaquness: When decoding Gray to A8 in libpng, set reallyHasAlpha to true and add a comment why we do not check for the real answer. Add comments in jpeg decoder explaining why A8 is not opaque. Fix a bug where an A8 subset is considered to be opaque. Other fixes: In SkJPEGImageDecoder, only allocate as much memory as needed for each source row, based on the input config. Also pull out common code into a static function. When performing the check for requiring unpremultiplied colors, allow A8 to succeed, since that setting should have no effect on A8. Add the check for requiring unpremultiplied colors to subset decoding. Fix a bug where attempting to sample gray to A8 does not sample. R=reed@google.com Review URL: https://codereview.chromium.org/26210007 git-svn-id: http://skia.googlecode.com/svn/trunk@11897 2bbb7eff-a529-9590-31e7-b0007b416f81
* store SkAlphaType inside SkBitmap, on road to support unpremulGravatar reed@google.com2013-10-21
| | | | | | | | | BUG= R=bsalomon@google.com, scroggo@google.com Review URL: https://codereview.chromium.org/25275004 git-svn-id: http://skia.googlecode.com/svn/trunk@11877 2bbb7eff-a529-9590-31e7-b0007b416f81
* Simplify code for configuring suppression of ImageDecoder warningsGravatar halcanary@google.com2013-10-14
| | | | | | | | | | | | | | | | | | | For images.png.suppressDecoderWarnings and images.jpeg.suppressDecoderWarnings, the default behavior is now: Debug - DON'T suppress Developer Release - suppress Release - suppress This behavior can be changed in Debug and in Developer through the SkRTConf mechanism. BUG=skia:1680 R=caryclark@google.com Review URL: https://codereview.chromium.org/26863003 git-svn-id: http://skia.googlecode.com/svn/trunk@11749 2bbb7eff-a529-9590-31e7-b0007b416f81
* Revert "Revert "change SkColorTable to be immutable""Gravatar reed@google.com2013-10-10
| | | | | | | | | | | | This reverts commit b8162cb840f4cb6002ef68d5ac775c6a122c52a9. Fixed was call-sites in benches that used the (now gone) setIsOpaque api. R=scroggo@google.com Review URL: https://codereview.chromium.org/26572006 git-svn-id: http://skia.googlecode.com/svn/trunk@11695 2bbb7eff-a529-9590-31e7-b0007b416f81
* Revert "change SkColorTable to be immutable"Gravatar reed@google.com2013-10-09
| | | | | | | | | | This reverts commit 1c0ff422868b3badf5ffe0790a5d051d1896e2f7. BUG= Review URL: https://codereview.chromium.org/26709002 git-svn-id: http://skia.googlecode.com/svn/trunk@11677 2bbb7eff-a529-9590-31e7-b0007b416f81
* change SkColorTable to be immutableGravatar reed@google.com2013-10-09
| | | | | | | | | BUG= R=scroggo@google.com Review URL: https://codereview.chromium.org/25353002 git-svn-id: http://skia.googlecode.com/svn/trunk@11676 2bbb7eff-a529-9590-31e7-b0007b416f81
* Make image decoding more fault resistant, less verbose.Gravatar halcanary@google.com2013-10-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change address what happens when a jpeg is partially downloaded before failing. Many browsers will render it anyway: we want Skia to do the same. The JpegTest takes a perfectly cromulent jpeg file and only passes into the ImageDecoder the first half of the image. We then verify that the image decoder returns a valid bitmap of the correct dimensions. We also fixed some png library errors, including issue 1691. Also, suppressed the majority of warnings from using libpng and libjpeg. By default, most warnings are *not* suppressed in debug mode. If you have a debug binary and wish to suppress warnings, set the following environment variables to true skia_images_png_suppressDecoderWarnings skia_images_jpeg_suppressDecoderWarnings or from within a program that links to Skia: #if defined(SK_DEBUG) #include "SkRTConf.h" SK_CONF_SET("images.jpeg.suppressDecoderWarnings", true); SK_CONF_SET("images.png.suppressDecoderWarnings", true); #endif I tested this, before (control) and after these changes (test), on 364,295 skps from the cluster telemetry. - number of errors+warnings in control = 2804 - number of errors+warnings fixed = 2283 - number of PNG verbosity fixed = 2152 - number of PNG error fixed = 4 - number of PNG segfault fixed = 3 - number of PNG errors changed to warnings = 62 - number of JPG verbosity fixed = 26 - number of JPG error fixed = 91 Not all errors and warning have been fixed. These numbers were generated using the find_bad_images_in_skps.py program. This program may be useful going forward for testing image-decoding libraries on skp files from the cluster telemetry. find_bad_images_in_skps.py depends on the test_image_decoder program, which simply executes the SkImageDecoder::DecodeFile function and uses its exit status to report success or failure. BUG=skia:1649 BUG=skia:1691 BUG=skia:1680 R=scroggo@google.com Review URL: https://codereview.chromium.org/24449003 git-svn-id: http://skia.googlecode.com/svn/trunk@11597 2bbb7eff-a529-9590-31e7-b0007b416f81
* Fixes for decoding to A8.Gravatar commit-bot@chromium.org2013-10-03
| | | | | | | | | | | | | | | | | | | | | | | | src/images/SkImageDecoder_libpng.cpp: A8 images are not opaque, so do not set the opaque flag. This fixes a bug where copyTo does not work as expected (when copying an A8 decoded image to ARGB_8888), leading to a bitmap hash that does not represent the image correctly (in skimage). tools/skimage_main.cpp: In write_bitmap, which is creating the image for visual comparison, copy A8 to 8888, since A8 cannot be encoded. In the section that tests reencoding, do not test reencoding A8, which is known to not work. R=mtklein@google.com, djsollen@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/25726004 git-svn-id: http://skia.googlecode.com/svn/trunk@11589 2bbb7eff-a529-9590-31e7-b0007b416f81
* Do not convert non gray PNG to A8.Gravatar scroggo@google.com2013-10-02
| | | | | | | | | | | | If the user requested A8, but the source is not gray, switch to ARGB8888. BUG=https://b.corp.google.com/issue?id=9189955 R=reed@google.com Review URL: https://codereview.chromium.org/24882002 git-svn-id: http://skia.googlecode.com/svn/trunk@11573 2bbb7eff-a529-9590-31e7-b0007b416f81