OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1010 } | 1010 } |
1011 | 1011 |
1012 bool sameConfigs = (this->config() == dstConfig); | 1012 bool sameConfigs = (this->config() == dstConfig); |
1013 switch (dstConfig) { | 1013 switch (dstConfig) { |
1014 case kA8_Config: | 1014 case kA8_Config: |
1015 case kRGB_565_Config: | 1015 case kRGB_565_Config: |
1016 case kARGB_8888_Config: | 1016 case kARGB_8888_Config: |
1017 break; | 1017 break; |
1018 case kA1_Config: | 1018 case kA1_Config: |
1019 case kIndex8_Config: | 1019 case kIndex8_Config: |
1020 case kARGB_4444_Config: | |
1021 if (!sameConfigs) { | 1020 if (!sameConfigs) { |
1022 return false; | 1021 return false; |
1023 } | 1022 } |
1024 break; | 1023 break; |
1024 case kARGB_4444_Config: | |
1025 return sameConfigs || kARGB_8888_Config == this->config(); | |
1025 default: | 1026 default: |
1026 return false; | 1027 return false; |
1027 } | 1028 } |
1028 | 1029 |
1029 // do not copy src if srcConfig == kA1_Config while dstConfig != kA1_Config | 1030 // do not copy src if srcConfig == kA1_Config while dstConfig != kA1_Config |
1030 if (this->getConfig() == kA1_Config && !sameConfigs) { | 1031 if (this->getConfig() == kA1_Config && !sameConfigs) { |
1031 return false; | 1032 return false; |
1032 } | 1033 } |
1033 | 1034 |
1034 return true; | 1035 return true; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1102 const char* srcP = reinterpret_cast<const char*>(src->getPixels()); | 1103 const char* srcP = reinterpret_cast<const char*>(src->getPixels()); |
1103 char* dstP = reinterpret_cast<char*>(tmpDst.getPixels()); | 1104 char* dstP = reinterpret_cast<char*>(tmpDst.getPixels()); |
1104 // to be sure we don't read too much, only copy our logical pixels | 1105 // to be sure we don't read too much, only copy our logical pixels |
1105 size_t bytesToCopy = tmpDst.width() * tmpDst.bytesPerPixel(); | 1106 size_t bytesToCopy = tmpDst.width() * tmpDst.bytesPerPixel(); |
1106 for (int y = 0; y < tmpDst.height(); y++) { | 1107 for (int y = 0; y < tmpDst.height(); y++) { |
1107 memcpy(dstP, srcP, bytesToCopy); | 1108 memcpy(dstP, srcP, bytesToCopy); |
1108 srcP += src->rowBytes(); | 1109 srcP += src->rowBytes(); |
1109 dstP += tmpDst.rowBytes(); | 1110 dstP += tmpDst.rowBytes(); |
1110 } | 1111 } |
1111 } | 1112 } |
1113 } else if (SkBitmap::kARGB_4444_Config == dstConfig | |
1114 && SkBitmap::kARGB_8888_Config == src->config()) { | |
1115 SkASSERT(src->height() == tmpDst.height()); | |
1116 SkASSERT(src->width() == tmpDst.width()); | |
1117 for (int y = 0; y < src->height(); ++y) { | |
1118 SkPMColor16* SK_RESTRICT dstRow = (SkPMColor16*) tmpDst.getAddr16(0, y); | |
1119 SkPMColor* SK_RESTRICT srcRow = (SkPMColor*) src->getAddr32(0, y); | |
1120 DITHER_4444_SCAN(y); | |
1121 for (int x = 0; x < src->width(); ++x) { | |
1122 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
| |
1123 dstRow[x] = SkDitherARGB32To4444(SkColorGetA(c), SkColorGetR(c), | |
1124 SkColorGetG(c), SkColorGetB(c), | |
1125 DITHER_VALUE(x)); | |
1126 } | |
1127 } | |
1112 } else { | 1128 } else { |
1113 // if the src has alpha, we have to clear the dst first | 1129 // if the src has alpha, we have to clear the dst first |
1114 if (!src->isOpaque()) { | 1130 if (!src->isOpaque()) { |
1115 tmpDst.eraseColor(SK_ColorTRANSPARENT); | 1131 tmpDst.eraseColor(SK_ColorTRANSPARENT); |
1116 } | 1132 } |
1117 | 1133 |
1118 SkCanvas canvas(tmpDst); | 1134 SkCanvas canvas(tmpDst); |
1119 SkPaint paint; | 1135 SkPaint paint; |
1120 | 1136 |
1121 paint.setDither(true); | 1137 paint.setDither(true); |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1686 if (NULL != uri) { | 1702 if (NULL != uri) { |
1687 str->appendf(" uri:\"%s\"", uri); | 1703 str->appendf(" uri:\"%s\"", uri); |
1688 } else { | 1704 } else { |
1689 str->appendf(" pixelref:%p", pr); | 1705 str->appendf(" pixelref:%p", pr); |
1690 } | 1706 } |
1691 } | 1707 } |
1692 | 1708 |
1693 str->append(")"); | 1709 str->append(")"); |
1694 } | 1710 } |
1695 #endif | 1711 #endif |
OLD | NEW |