Chromium Code Reviews| Index: src/core/SkBitmap.cpp |
| diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp |
| index 9a116dfc2ed511a90f35bb63f35377fdb824fd7b..9000a3669ff64bff76d9c2e1bd41704bebd222fe 100644 |
| --- a/src/core/SkBitmap.cpp |
| +++ b/src/core/SkBitmap.cpp |
| @@ -1017,11 +1017,12 @@ bool SkBitmap::canCopyTo(Config dstConfig) const { |
| break; |
| case kA1_Config: |
| case kIndex8_Config: |
| - case kARGB_4444_Config: |
| if (!sameConfigs) { |
| return false; |
| } |
| break; |
| + case kARGB_4444_Config: |
| + return sameConfigs || kARGB_8888_Config == this->config(); |
| default: |
| return false; |
| } |
| @@ -1109,6 +1110,21 @@ bool SkBitmap::copyTo(SkBitmap* dst, Config dstConfig, Allocator* alloc) const { |
| dstP += tmpDst.rowBytes(); |
| } |
| } |
| + } else if (SkBitmap::kARGB_4444_Config == dstConfig |
| + && SkBitmap::kARGB_8888_Config == src->config()) { |
| + SkASSERT(src->height() == tmpDst.height()); |
| + SkASSERT(src->width() == tmpDst.width()); |
| + for (int y = 0; y < src->height(); ++y) { |
| + SkPMColor16* SK_RESTRICT dstRow = (SkPMColor16*) tmpDst.getAddr16(0, y); |
| + SkPMColor* SK_RESTRICT srcRow = (SkPMColor*) src->getAddr32(0, y); |
| + DITHER_4444_SCAN(y); |
| + for (int x = 0; x < src->width(); ++x) { |
| + SkColor c = SkUnPreMultiply::PMColorToColor(srcRow[x]); |
|
reed1
2013/08/07 18:30:03
Why the unpremultiply step? I think you can call t
scroggo
2013/08/07 19:04:19
Overlooked that one. New patch calls the version t
|
| + dstRow[x] = SkDitherARGB32To4444(SkColorGetA(c), SkColorGetR(c), |
| + SkColorGetG(c), SkColorGetB(c), |
| + DITHER_VALUE(x)); |
| + } |
| + } |
| } else { |
| // if the src has alpha, we have to clear the dst first |
| if (!src->isOpaque()) { |