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

Unified Diff: dm/DMSrcSink.cpp

Issue 1996993003: Finish supporting decoding opaque to non-opaque (Closed) Base URL: https://skia.googlesource.com/skia.git@opaque
Patch Set: Add tests 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 | « no previous file | src/codec/SkCodecPriv.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMSrcSink.cpp
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 028dff886b444d5b54736794cd357f16b759b5ab..33848975e98e1461bb4e3e9fc7f2d58476bbc8a6 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -314,7 +314,7 @@ static void premultiply_if_necessary(SkBitmap& bitmap) {
}
static bool get_decode_info(SkImageInfo* decodeInfo, SkColorType canvasColorType,
- CodecSrc::DstColorType dstColorType) {
+ CodecSrc::DstColorType dstColorType, SkAlphaType dstAlphaType) {
switch (dstColorType) {
case CodecSrc::kIndex8_Always_DstColorType:
if (kRGB_565_SkColorType == canvasColorType) {
@@ -348,6 +348,7 @@ static bool get_decode_info(SkImageInfo* decodeInfo, SkColorType canvasColorType
break;
}
+ *decodeInfo = decodeInfo->makeAlphaType(dstAlphaType);
return true;
}
@@ -373,8 +374,9 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
return SkStringPrintf("Couldn't create codec for %s.", fPath.c_str());
}
- SkImageInfo decodeInfo = codec->getInfo().makeAlphaType(fDstAlphaType);
- if (!get_decode_info(&decodeInfo, canvas->imageInfo().colorType(), fDstColorType)) {
+ SkImageInfo decodeInfo = codec->getInfo();
+ if (!get_decode_info(&decodeInfo, canvas->imageInfo().colorType(), fDstColorType,
+ fDstAlphaType)) {
return Error::Nonfatal("Testing non-565 to 565 is uninteresting.");
}
@@ -656,8 +658,9 @@ Error AndroidCodecSrc::draw(SkCanvas* canvas) const {
return SkStringPrintf("Couldn't create android codec for %s.", fPath.c_str());
}
- SkImageInfo decodeInfo = codec->getInfo().makeAlphaType(fDstAlphaType);
- if (!get_decode_info(&decodeInfo, canvas->imageInfo().colorType(), fDstColorType)) {
+ SkImageInfo decodeInfo = codec->getInfo();
+ if (!get_decode_info(&decodeInfo, canvas->imageInfo().colorType(), fDstColorType,
+ fDstAlphaType)) {
return Error::Nonfatal("Testing non-565 to 565 is uninteresting.");
}
@@ -793,11 +796,6 @@ Error ImageGenSrc::draw(SkCanvas* canvas) const {
// Test various color and alpha types on CPU
SkImageInfo decodeInfo = gen->getInfo().makeAlphaType(fDstAlphaType);
- if (kGray_8_SkColorType == decodeInfo.colorType() &&
- kOpaque_SkAlphaType != decodeInfo.alphaType()) {
- return Error::Nonfatal("Avoid requesting non-opaque kGray8 decodes.");
- }
-
int bpp = SkColorTypeBytesPerPixel(decodeInfo.colorType());
size_t rowBytes = decodeInfo.width() * bpp;
SkAutoMalloc pixels(decodeInfo.height() * rowBytes);
« no previous file with comments | « no previous file | src/codec/SkCodecPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698