aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/android
diff options
context:
space:
mode:
authorGravatar Leon Scroggins <scroggo@google.com>2017-07-10 19:51:46 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-10 19:51:59 +0000
commit8321f7585b6aded0c35e50e9af8709b25fdce3f6 (patch)
tree9a9e3a1843c8864a9e847d0c7b59b987946f6b24 /src/android
parenta48ae6ec2feb32e3d781ad43353209a90059a01d (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/android')
-rw-r--r--src/android/SkBitmapRegionCodec.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/android/SkBitmapRegionCodec.cpp b/src/android/SkBitmapRegionCodec.cpp
index c4e1ea124c..7ce9d26b4d 100644
--- a/src/android/SkBitmapRegionCodec.cpp
+++ b/src/android/SkBitmapRegionCodec.cpp
@@ -57,7 +57,13 @@ bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocat
SkImageInfo decodeInfo = SkImageInfo::Make(scaledSize.width(), scaledSize.height(),
dstColorType, dstAlphaType, dstColorSpace);
- SkASSERT(dstColorType != kIndex_8_SkColorType);
+ // Construct a color table for the decode if necessary
+ sk_sp<SkColorTable> colorTable(nullptr);
+ int maxColors = 256;
+ SkPMColor colors[256];
+ if (kIndex_8_SkColorType == dstColorType) {
+ colorTable.reset(new SkColorTable(colors, maxColors));
+ }
// Initialize the destination bitmap
int scaledOutX = 0;
@@ -84,7 +90,7 @@ bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocat
outInfo = outInfo.makeColorType(kAlpha_8_SkColorType).makeAlphaType(kPremul_SkAlphaType);
}
bitmap->setInfo(outInfo);
- if (!bitmap->tryAllocPixels(allocator, nullptr)) {
+ if (!bitmap->tryAllocPixels(allocator, colorTable.get())) {
SkCodecPrintf("Error: Could not allocate pixels.\n");
return false;
}
@@ -106,6 +112,8 @@ bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocat
SkAndroidCodec::AndroidOptions options;
options.fSampleSize = sampleSize;
options.fSubset = &subset;
+ options.fColorPtr = colors;
+ options.fColorCount = &maxColors;
options.fZeroInitialized = zeroInit;
void* dst = bitmap->getAddr(scaledOutX, scaledOutY);
@@ -116,6 +124,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;
}