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

Unified Diff: src/core/SkBitmap.cpp

Issue 22350003: Add downsample from 8888 to 4444. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()) {
« 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