diff options
author | msarett <msarett@google.com> | 2016-05-17 08:52:11 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-17 08:52:11 -0700 |
commit | b1be46b1d938c21eafa7ded5560bcc10b71cd471 (patch) | |
tree | eb2d65594bcf9580672138a5d379a8749e3e984f /src/android | |
parent | 4bb7ce7b3d64841bed5a4e8e71f2a8e79d3db413 (diff) |
Ensure that SkColorTable->fCount is set properly after decodes
We now have some blits that will process the color table.
If we erroneously report that the size of the color table is 256,
we will do extra work and annoy MSAN.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1982753002
Review-Url: https://codereview.chromium.org/1982753002
Diffstat (limited to 'src/android')
-rw-r--r-- | src/android/SkBitmapRegionCodec.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/android/SkBitmapRegionCodec.cpp b/src/android/SkBitmapRegionCodec.cpp index be3d5bcce7..065351d2ba 100644 --- a/src/android/SkBitmapRegionCodec.cpp +++ b/src/android/SkBitmapRegionCodec.cpp @@ -57,22 +57,10 @@ bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocat // Construct a color table for the decode if necessary SkAutoTUnref<SkColorTable> colorTable(nullptr); - SkPMColor* colorPtr = nullptr; - int* colorCountPtr = nullptr; int maxColors = 256; SkPMColor colors[256]; if (kIndex_8_SkColorType == dstColorType) { - // TODO (msarett): This performs a copy that is unnecessary since - // we have not yet initialized the color table. - // And then we need to use a const cast to get - // a pointer to the color table that we can - // modify during the decode. We could alternatively - // perform the decode before creating the bitmap and - // the color table. We still would need to copy the - // colors into the color table after the decode. colorTable.reset(new SkColorTable(colors, maxColors)); - colorPtr = const_cast<SkPMColor*>(colorTable->readColors()); - colorCountPtr = &maxColors; } // Initialize the destination bitmap @@ -122,8 +110,8 @@ bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocat SkAndroidCodec::AndroidOptions options; options.fSampleSize = sampleSize; options.fSubset = ⊂ - options.fColorPtr = colorPtr; - options.fColorCount = colorCountPtr; + options.fColorPtr = colors; + options.fColorCount = &maxColors; options.fZeroInitialized = zeroInit; void* dst = bitmap->getAddr(scaledOutX, scaledOutY); @@ -141,6 +129,11 @@ bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocat return false; } + // Intialize the color table + if (kIndex_8_SkColorType == dstColorType) { + colorTable->dangerous_overwriteColors(colors, maxColors); + } + return true; } |