Chromium Code Reviews| Index: dm/DMSrcSink.cpp |
| diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp |
| index d99f0115b3ad108bbc368361303d0daa9babfefb..ba5f1abff8e80e96d827b59c87aafb7b19163775 100644 |
| --- a/dm/DMSrcSink.cpp |
| +++ b/dm/DMSrcSink.cpp |
| @@ -70,14 +70,27 @@ Error ImageSrc::draw(SkCanvas* canvas) const { |
| SkAutoLockPixels alp(bitmap); |
| const SkImageGenerator::Result result = codec->getPixels(info, bitmap.getPixels(), |
| bitmap.rowBytes()); |
| - if (result != SkImageGenerator::kSuccess) { |
| - return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str()); |
| + switch (result) { |
| + case SkImageGenerator::kSuccess: |
| + // We consider incomplete to be valid, since we should still decode what is |
| + // available. |
| + case SkImageGenerator::kIncompleteInput: |
| + break; |
| + case SkImageGenerator::kInvalidConversion: |
| + return Error::Nonfatal("Incompatible colortype conversion"); |
| + default: |
| + // Everything else is considered a failure. |
| + return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str()); |
| } |
| } else { |
| if (!SkImageDecoder::DecodeMemory(encoded->data(), encoded->size(), &bitmap, |
| dstColorType, SkImageDecoder::kDecodePixels_Mode)) { |
| return SkStringPrintf("Couldn't decode %s.", fPath.c_str()); |
| } |
| + if (kRGB_565_SkColorType == dstColorType && !bitmap.isOpaque()) { |
| + // Do not draw a bitmap with alpha to a destination without alpha. |
| + return Error::Nonfatal("Skipping drawing non-opaque image to opaque dst."); |
|
mtklein
2015/03/05 17:07:36
we're going to add "skipped: " to the front of thi
scroggo
2015/03/05 19:34:24
Done.
|
| + } |
| } |
| encoded.reset((SkData*)NULL); // Might as well drop this when we're done with it. |
| canvas->drawBitmap(bitmap, 0,0); |
| @@ -110,6 +123,15 @@ Error ImageSrc::draw(SkCanvas* canvas) const { |
| return SkStringPrintf("Could not decode subset (%d, %d, %d, %d).", |
| x, y, x+subsetWidth, y+subsetHeight); |
| } |
| + if (kRGB_565_SkColorType == dstColorType && !subset.isOpaque()) { |
| + // Do not draw a bitmap with alpha to a destination without alpha. |
| + // This is not an error, but there is nothing interesting to show. |
| + |
| + // This should only happen on the first iteration through the loop. |
| + SkASSERT(0 == x && 0 == y); |
| + |
| + return Error::Nonfatal("Skipping drawing non-opaque image to opaque dst."); |
| + } |
| canvas->drawBitmap(subset, SkIntToScalar(x), SkIntToScalar(y)); |
| } |
| } |