Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1068)

Unified Diff: src/android/SkBitmapRegionCodec.cpp

Issue 1982753002: Ensure that SkColorTable->fCount is set properly after decodes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkColorTable.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/android/SkBitmapRegionCodec.cpp
diff --git a/src/android/SkBitmapRegionCodec.cpp b/src/android/SkBitmapRegionCodec.cpp
index be3d5bcce7179dd7e29871ad72f1d602c2d22bd0..065351d2bacd10fa382243c4b61c04b6df4f1193 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 = &subset;
- 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;
}
« no previous file with comments | « include/core/SkColorTable.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698