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/SkBmpRLECodec.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/SkBmpRLECodec.cpp')
-rw-r--r-- | src/codec/SkBmpRLECodec.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/codec/SkBmpRLECodec.cpp b/src/codec/SkBmpRLECodec.cpp index 0fcd290add..c6d788b800 100644 --- a/src/codec/SkBmpRLECodec.cpp +++ b/src/codec/SkBmpRLECodec.cpp @@ -34,13 +34,15 @@ SkBmpRLECodec::SkBmpRLECodec(int width, int height, const SkEncodedInfo& info, S SkCodec::Result SkBmpRLECodec::onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes, const Options& opts, + SkPMColor* inputColorPtr, + int* inputColorCount, int* rowsDecoded) { if (opts.fSubset) { // Subsets are not supported. return kUnimplemented; } - Result result = this->prepareToDecode(dstInfo, opts); + Result result = this->prepareToDecode(dstInfo, opts, inputColorPtr, inputColorCount); if (kSuccess != result) { return result; } @@ -61,13 +63,19 @@ SkCodec::Result SkBmpRLECodec::onGetPixels(const SkImageInfo& dstInfo, /* * Process the color table for the bmp input */ - bool SkBmpRLECodec::createColorTable(SkColorType dstColorType) { + bool SkBmpRLECodec::createColorTable(SkColorType dstColorType, int* numColors) { // Allocate memory for color table uint32_t colorBytes = 0; SkPMColor colorTable[256]; if (this->bitsPerPixel() <= 8) { // Inform the caller of the number of colors uint32_t maxColors = 1 << this->bitsPerPixel(); + if (nullptr != numColors) { + // We set the number of colors to maxColors in order to ensure + // safe memory accesses. Otherwise, an invalid pixel could + // access memory outside of our color table array. + *numColors = maxColors; + } // Don't bother reading more than maxColors. const uint32_t numColorsToRead = fNumColors == 0 ? maxColors : SkTMin(fNumColors, maxColors); @@ -233,7 +241,7 @@ void SkBmpRLECodec::setRGBPixel(void* dst, size_t dstRowBytes, } SkCodec::Result SkBmpRLECodec::onPrepareToDecode(const SkImageInfo& dstInfo, - const SkCodec::Options& options) { + const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputColorCount) { // FIXME: Support subsets for scanline decodes. if (options.fSubset) { // Subsets are not supported. @@ -248,17 +256,20 @@ SkCodec::Result SkBmpRLECodec::onPrepareToDecode(const SkImageInfo& dstInfo, SkColorType colorTableColorType = dstInfo.colorType(); if (this->colorXform()) { // Just set a known colorType for the colorTable. No need to actually transform - // the colors in the colorTable. + // the colors in the colorTable since we do not allow decoding RLE to kIndex8. colorTableColorType = kBGRA_8888_SkColorType; } // Create the color table if necessary and prepare the stream for decode // Note that if it is non-NULL, inputColorCount will be modified - if (!this->createColorTable(colorTableColorType)) { + if (!this->createColorTable(colorTableColorType, inputColorCount)) { SkCodecPrintf("Error: could not create color table.\n"); return SkCodec::kInvalidInput; } + // Copy the color table to the client if necessary + copy_color_table(dstInfo, fColorTable.get(), inputColorPtr, inputColorCount); + // Initialize a buffer for encoded RLE data if (!this->initializeStreamBuffer()) { SkCodecPrintf("Error: cannot initialize stream buffer.\n"); |