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

Unified Diff: src/android/SkBitmapRegionDecoder.cpp

Issue 1446543002: Only support jpeg, png, and webp for BRD (Closed) Base URL: https://skia.googlesource.com/skia.git@reeanble
Patch Set: Created 5 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/android/SkBitmapRegionDecoder.cpp
diff --git a/src/android/SkBitmapRegionDecoder.cpp b/src/android/SkBitmapRegionDecoder.cpp
index 7dc05059e1b76255f307cda621bc02a5d3856584..a153282b0943b1028ce101d2ac251c2c124c1167 100644
--- a/src/android/SkBitmapRegionDecoder.cpp
+++ b/src/android/SkBitmapRegionDecoder.cpp
@@ -30,29 +30,43 @@ SkBitmapRegionDecoder* SkBitmapRegionDecoder::Create(
return nullptr;
}
- if (SkEncodedFormat::kWEBP_SkEncodedFormat == codec->getEncodedFormat()) {
- // FIXME: Support webp using a special case. Webp does not support
- // scanline decoding.
- return nullptr;
- }
-
- switch (codec->getScanlineOrder()) {
- case SkCodec::kTopDown_SkScanlineOrder:
- case SkCodec::kNone_SkScanlineOrder:
+ SkEncodedFormat format = codec->getEncodedFormat();
+ switch (format) {
+ case SkEncodedFormat::kJPEG_SkEncodedFormat:
+ case SkEncodedFormat::kPNG_SkEncodedFormat:
break;
default:
- SkCodecPrintf("Error: Scanline ordering not supported.\n");
+ // FIXME: Support webp using a special case. Webp does not support
+ // scanline decoding.
return nullptr;
}
+
+ // If the image is a jpeg or a png, the scanline ordering should always be
+ // kTopDown or kNone. It is relevant to check because this implementation
+ // only supports these two scanline orderings.
+ SkASSERT(SkCodec::kTopDown_SkScanlineOrder == codec->getScanlineOrder() ||
+ SkCodec::kNone_SkScanlineOrder == codec->getScanlineOrder());
+
return new SkBitmapRegionCanvas(codec.detach());
}
case kAndroidCodec_Strategy: {
SkAutoTDelete<SkAndroidCodec> codec =
SkAndroidCodec::NewFromStream(streamDeleter.detach());
- if (NULL == codec) {
+ if (nullptr == codec) {
SkCodecPrintf("Error: Failed to create codec.\n");
return NULL;
}
+
+ SkEncodedFormat format = codec->getEncodedFormat();
+ switch (format) {
+ case SkEncodedFormat::kJPEG_SkEncodedFormat:
+ case SkEncodedFormat::kPNG_SkEncodedFormat:
+ case SkEncodedFormat::kWEBP_SkEncodedFormat:
+ break;
+ default:
+ return nullptr;
+ }
+
return new SkBitmapRegionCodec(codec.detach());
}
default:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698