aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-07 19:16:05 +0000
committerGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-07 19:16:05 +0000
commit8dc8bc55479eb7895b3f0cf4fb42d9d917b21ee1 (patch)
tree7e35b96b7d9a817114efbd5faf9c21229a8275ae /src/core
parent0b39619e4bf3c528d70ff459914f0438b3ce22ac (diff)
Add downsample from 8888 to 4444.
Extend SkBitmap::copyTo to copy from a source with SkARGB_8888_Config to a destination bitmap with SkARGB_4444_Config. BUG=http://code.google.com/p/chromium/issues/detail?id=245774 R=reed@google.com Review URL: https://codereview.chromium.org/22350003 git-svn-id: http://skia.googlecode.com/svn/trunk@10621 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkBitmap.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 9a116dfc2e..d3bbecd706 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,19 @@ 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) {
+ dstRow[x] = SkDitherARGB32To4444(srcRow[x],
+ DITHER_VALUE(x));
+ }
+ }
} else {
// if the src has alpha, we have to clear the dst first
if (!src->isOpaque()) {