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

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 | « gyp/gmslides.gypi ('k') | 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..d3bbecd7066dfe4d826d5bd778e635c1e5215910 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()) {
« no previous file with comments | « gyp/gmslides.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698