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

Unified Diff: src/android/SkBitmapRegionCanvas.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/SkBitmapRegionCanvas.cpp
diff --git a/src/android/SkBitmapRegionCanvas.cpp b/src/android/SkBitmapRegionCanvas.cpp
index bac5dc1ffc7995fa57cb954f5db2987cf99a71c1..295a2462c764e77edd6397251f54825c53f1f16c 100644
--- a/src/android/SkBitmapRegionCanvas.cpp
+++ b/src/android/SkBitmapRegionCanvas.cpp
@@ -18,6 +18,15 @@ SkBitmapRegionCanvas::SkBitmapRegionCanvas(SkCodec* decoder)
bool SkBitmapRegionCanvas::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocator,
const SkIRect& desiredSubset, int sampleSize, SkColorType dstColorType,
bool requireUnpremul) {
+ // FIXME: This class works well as a performance/quality comparison for
scroggo 2015/12/09 20:57:31 Maybe this should be in the header?
msarett 2015/12/10 15:19:26 Done.
+ // SkBitmapRegionCodec, but it lacks several capabilities that are
+ // required by BitmapRegionDecoder in Android.
+ // (1) Decodes to kGray8 and kIndex8.
+ // (2) Decodes to kUnpremul.
+ // (3) Correcting an invalid dstColorType. For example, if the
+ // client requests kRGB_565 for a non-opaque image, rather than
+ // fail, we need to go ahead and decode to kN32.
+
// Reject color types not supported by this method
if (kIndex_8_SkColorType == dstColorType || kGray_8_SkColorType == dstColorType) {
SkCodecPrintf("Error: Color type not supported.\n");
@@ -34,8 +43,6 @@ bool SkBitmapRegionCanvas::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* alloca
dstAlphaType = kPremul_SkAlphaType;
}
- // FIXME: Can we add checks and support kIndex8 or unpremultiplied alpha in special cases?
-
// Fix the input sampleSize if necessary.
if (sampleSize < 1) {
sampleSize = 1;

Powered by Google App Engine
This is Rietveld 408576698