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

Unified Diff: src/android/SkBitmapRegionCodec.cpp

Issue 1513023002: Make BitmapRegionDecoder succeed on invalid requests (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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
Index: src/android/SkBitmapRegionCodec.cpp
diff --git a/src/android/SkBitmapRegionCodec.cpp b/src/android/SkBitmapRegionCodec.cpp
index 415b60c5ab354e9ddeac605585e02b4e68244c30..2569ac598bacf5d538060ae20d00df65deaabc84 100644
--- a/src/android/SkBitmapRegionCodec.cpp
+++ b/src/android/SkBitmapRegionCodec.cpp
@@ -17,7 +17,7 @@ SkBitmapRegionCodec::SkBitmapRegionCodec(SkAndroidCodec* codec)
{}
bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocator,
- const SkIRect& desiredSubset, int sampleSize, SkColorType dstColorType,
+ const SkIRect& desiredSubset, int sampleSize, SkColorType prefColorType,
bool requireUnpremul) {
// Fix the input sampleSize if necessary.
@@ -50,10 +50,10 @@ bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocat
SkISize scaledSize = fCodec->getSampledSubsetDimensions(sampleSize, subset);
// Create the image info for the decode
- SkAlphaType dstAlphaType = fCodec->getInfo().alphaType();
- if (kOpaque_SkAlphaType != dstAlphaType) {
- dstAlphaType = requireUnpremul ? kUnpremul_SkAlphaType : kPremul_SkAlphaType;
- }
+ SkColorType dstColorType = SkAndroidCodec::FixRequestedColorType(prefColorType,
+ fCodec->getInfo().colorType(), fCodec->getInfo().alphaType());
+ SkAlphaType dstAlphaType = SkAndroidCodec::FixRequestedAlphaType(requireUnpremul,
+ fCodec->getInfo().alphaType());
SkImageInfo decodeInfo = SkImageInfo::Make(scaledSize.width(), scaledSize.height(),
dstColorType, dstAlphaType);
@@ -94,6 +94,9 @@ bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocat
scaledOutHeight += scaledOutY + scaledExtraY;
}
SkImageInfo outInfo = decodeInfo.makeWH(scaledOutWidth, scaledOutHeight);
+ if (kGray_8_SkColorType == dstColorType) {
scroggo 2015/12/09 20:57:31 Comment explaining why?
msarett 2015/12/10 15:19:26 Done.
+ outInfo = SkImageInfo::MakeA8(scaledOutWidth, scaledOutHeight);
+ }
bitmap->setInfo(outInfo);
if (!bitmap->tryAllocPixels(allocator, colorTable.get())) {
SkCodecPrintf("Error: Could not allocate pixels.\n");

Powered by Google App Engine
This is Rietveld 408576698