diff options
author | Leon Scroggins <scroggo@google.com> | 2017-07-10 19:51:46 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-07-10 19:51:59 +0000 |
commit | 8321f7585b6aded0c35e50e9af8709b25fdce3f6 (patch) | |
tree | 9a9e3a1843c8864a9e847d0c7b59b987946f6b24 /src/codec/SkPngCodec.cpp | |
parent | a48ae6ec2feb32e3d781ad43353209a90059a01d (diff) |
Revert "Remove support for decoding to kIndex_8"
This reverts commit 742a3e298fda669006147e4a305bab8452369b1f.
Reason for revert: Breaking Android roll:
frameworks/base/core/jni/android/graphics/BitmapFactory.cpp:453:18: error: no member named 'fColorPtr' in 'SkAndroidCodec::AndroidOptions'
codecOptions.fColorPtr = colorPtr;
~~~~~~~~~~~~ ^
frameworks/base/core/jni/android/graphics/BitmapFactory.cpp:454:18: error: no member named 'fColorCount' in 'SkAndroidCodec::AndroidOptions'
codecOptions.fColorCount = colorCount;
~~~~~~~~~~~~ ^
Original change's description:
> Remove support for decoding to kIndex_8
>
> Fix up callsites, and remove tests that no longer make sense.
>
> Bug: skia:6828
> Change-Id: I2548c4b7528b7b1be7412563156f27b52c9d4295
> Reviewed-on: https://skia-review.googlesource.com/21664
> Reviewed-by: Derek Sollenberger <djsollen@google.com>
> Commit-Queue: Leon Scroggins <scroggo@google.com>
TBR=djsollen@google.com,scroggo@google.com
Change-Id: I1bc669441f250690884e75a9a61427fdf75c6907
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:6828
Reviewed-on: https://skia-review.googlesource.com/22120
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'src/codec/SkPngCodec.cpp')
-rw-r--r-- | src/codec/SkPngCodec.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp index ea832ff688..d77fe4007d 100644 --- a/src/codec/SkPngCodec.cpp +++ b/src/codec/SkPngCodec.cpp @@ -245,7 +245,7 @@ void SkPngCodec::processData() { static const SkColorType kXformSrcColorType = kRGBA_8888_SkColorType; // Note: SkColorTable claims to store SkPMColors, which is not necessarily the case here. -bool SkPngCodec::createColorTable(const SkImageInfo& dstInfo) { +bool SkPngCodec::createColorTable(const SkImageInfo& dstInfo, int* ctableCount) { int numColors; png_color* palette; @@ -308,6 +308,11 @@ bool SkPngCodec::createColorTable(const SkImageInfo& dstInfo) { sk_memset32(colorTable + numColors, lastColor, maxColors - numColors); } + // Set the new color count. + if (ctableCount != nullptr) { + *ctableCount = maxColors; + } + fColorTable.reset(new SkColorTable(colorTable, maxColors)); return true; } @@ -968,7 +973,8 @@ void SkPngCodec::destroyReadStruct() { // Getting the pixels /////////////////////////////////////////////////////////////////////////////// -SkCodec::Result SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const Options& options) { +SkCodec::Result SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const Options& options, + SkPMColor ctable[], int* ctableCount) { if (setjmp(PNG_JMPBUF((png_struct*)fPng_ptr))) { SkCodecPrintf("Failed on png_read_update_info.\n"); return kInvalidInput; @@ -1005,11 +1011,14 @@ SkCodec::Result SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const O } if (SkEncodedInfo::kPalette_Color == this->getEncodedInfo().color()) { - if (!this->createColorTable(dstInfo)) { + if (!this->createColorTable(dstInfo, ctableCount)) { return kInvalidInput; } } + // Copy the color table to the client if they request kIndex8 mode. + copy_color_table(dstInfo, fColorTable.get(), ctable, ctableCount); + this->initializeSwizzler(dstInfo, options, skipFormatConversion); return kSuccess; } @@ -1083,12 +1092,13 @@ bool SkPngCodec::onRewind() { SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t rowBytes, const Options& options, + SkPMColor ctable[], int* ctableCount, int* rowsDecoded) { if (!conversion_possible(dstInfo, this->getInfo())) { return kInvalidConversion; } - Result result = this->initializeXforms(dstInfo, options); + Result result = this->initializeXforms(dstInfo, options, ctable, ctableCount); if (kSuccess != result) { return result; } @@ -1103,12 +1113,13 @@ SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst, } SkCodec::Result SkPngCodec::onStartIncrementalDecode(const SkImageInfo& dstInfo, - void* dst, size_t rowBytes, const SkCodec::Options& options) { + void* dst, size_t rowBytes, const SkCodec::Options& options, + SkPMColor* ctable, int* ctableCount) { if (!conversion_possible(dstInfo, this->getInfo())) { return kInvalidConversion; } - Result result = this->initializeXforms(dstInfo, options); + Result result = this->initializeXforms(dstInfo, options, ctable, ctableCount); if (kSuccess != result) { return result; } |