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

Side by Side Diff: src/core/SkBitmap.cpp

Issue 235523003: Revert of Revert of Rename kPMColor_SkColorType to kN32_SkColorType. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 8 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 unified diff | Download patch
« no previous file with comments | « samplecode/SampleTiling.cpp ('k') | src/core/SkBitmapDevice.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 case SkBitmap::kIndex8_Config: 339 case SkBitmap::kIndex8_Config:
340 ct = kIndex_8_SkColorType; 340 ct = kIndex_8_SkColorType;
341 break; 341 break;
342 case SkBitmap::kRGB_565_Config: 342 case SkBitmap::kRGB_565_Config:
343 ct = kRGB_565_SkColorType; 343 ct = kRGB_565_SkColorType;
344 break; 344 break;
345 case SkBitmap::kARGB_4444_Config: 345 case SkBitmap::kARGB_4444_Config:
346 ct = kARGB_4444_SkColorType; 346 ct = kARGB_4444_SkColorType;
347 break; 347 break;
348 case SkBitmap::kARGB_8888_Config: 348 case SkBitmap::kARGB_8888_Config:
349 ct = kPMColor_SkColorType; 349 ct = kN32_SkColorType;
350 break; 350 break;
351 case SkBitmap::kNo_Config: 351 case SkBitmap::kNo_Config:
352 default: 352 default:
353 return false; 353 return false;
354 } 354 }
355 if (ctOut) { 355 if (ctOut) {
356 *ctOut = ct; 356 *ctOut = ct;
357 } 357 }
358 return true; 358 return true;
359 } 359 }
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 990
991 bool SkBitmap::canCopyTo(SkColorType dstColorType) const { 991 bool SkBitmap::canCopyTo(SkColorType dstColorType) const {
992 if (this->colorType() == kUnknown_SkColorType) { 992 if (this->colorType() == kUnknown_SkColorType) {
993 return false; 993 return false;
994 } 994 }
995 995
996 bool sameConfigs = (this->colorType() == dstColorType); 996 bool sameConfigs = (this->colorType() == dstColorType);
997 switch (dstColorType) { 997 switch (dstColorType) {
998 case kAlpha_8_SkColorType: 998 case kAlpha_8_SkColorType:
999 case kRGB_565_SkColorType: 999 case kRGB_565_SkColorType:
1000 case kPMColor_SkColorType: 1000 case kN32_SkColorType:
1001 break; 1001 break;
1002 case kIndex_8_SkColorType: 1002 case kIndex_8_SkColorType:
1003 if (!sameConfigs) { 1003 if (!sameConfigs) {
1004 return false; 1004 return false;
1005 } 1005 }
1006 break; 1006 break;
1007 case kARGB_4444_SkColorType: 1007 case kARGB_4444_SkColorType:
1008 return sameConfigs || kPMColor_SkColorType == this->colorType(); 1008 return sameConfigs || kN32_SkColorType == this->colorType();
1009 default: 1009 default:
1010 return false; 1010 return false;
1011 } 1011 }
1012 return true; 1012 return true;
1013 } 1013 }
1014 1014
1015 bool SkBitmap::copyTo(SkBitmap* dst, SkColorType dstColorType, 1015 bool SkBitmap::copyTo(SkBitmap* dst, SkColorType dstColorType,
1016 Allocator* alloc) const { 1016 Allocator* alloc) const {
1017 if (!this->canCopyTo(dstColorType)) { 1017 if (!this->canCopyTo(dstColorType)) {
1018 return false; 1018 return false;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 char* dstP = reinterpret_cast<char*>(tmpDst.getPixels()); 1109 char* dstP = reinterpret_cast<char*>(tmpDst.getPixels());
1110 // to be sure we don't read too much, only copy our logical pixels 1110 // to be sure we don't read too much, only copy our logical pixels
1111 size_t bytesToCopy = tmpDst.width() * tmpDst.bytesPerPixel(); 1111 size_t bytesToCopy = tmpDst.width() * tmpDst.bytesPerPixel();
1112 for (int y = 0; y < tmpDst.height(); y++) { 1112 for (int y = 0; y < tmpDst.height(); y++) {
1113 memcpy(dstP, srcP, bytesToCopy); 1113 memcpy(dstP, srcP, bytesToCopy);
1114 srcP += src->rowBytes(); 1114 srcP += src->rowBytes();
1115 dstP += tmpDst.rowBytes(); 1115 dstP += tmpDst.rowBytes();
1116 } 1116 }
1117 } 1117 }
1118 } else if (kARGB_4444_SkColorType == dstColorType 1118 } else if (kARGB_4444_SkColorType == dstColorType
1119 && kPMColor_SkColorType == src->colorType()) { 1119 && kN32_SkColorType == src->colorType()) {
1120 SkASSERT(src->height() == tmpDst.height()); 1120 SkASSERT(src->height() == tmpDst.height());
1121 SkASSERT(src->width() == tmpDst.width()); 1121 SkASSERT(src->width() == tmpDst.width());
1122 for (int y = 0; y < src->height(); ++y) { 1122 for (int y = 0; y < src->height(); ++y) {
1123 SkPMColor16* SK_RESTRICT dstRow = (SkPMColor16*) tmpDst.getAddr16(0, y); 1123 SkPMColor16* SK_RESTRICT dstRow = (SkPMColor16*) tmpDst.getAddr16(0, y);
1124 SkPMColor* SK_RESTRICT srcRow = (SkPMColor*) src->getAddr32(0, y); 1124 SkPMColor* SK_RESTRICT srcRow = (SkPMColor*) src->getAddr32(0, y);
1125 DITHER_4444_SCAN(y); 1125 DITHER_4444_SCAN(y);
1126 for (int x = 0; x < src->width(); ++x) { 1126 for (int x = 0; x < src->width(); ++x) {
1127 dstRow[x] = SkDitherARGB32To4444(srcRow[x], 1127 dstRow[x] = SkDitherARGB32To4444(srcRow[x],
1128 DITHER_VALUE(x)); 1128 DITHER_VALUE(x));
1129 } 1129 }
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 /////////////////////////////////////////////////////////////////////////////// 1728 ///////////////////////////////////////////////////////////////////////////////
1729 1729
1730 #ifdef SK_DEBUG 1730 #ifdef SK_DEBUG
1731 void SkImageInfo::validate() const { 1731 void SkImageInfo::validate() const {
1732 SkASSERT(fWidth >= 0); 1732 SkASSERT(fWidth >= 0);
1733 SkASSERT(fHeight >= 0); 1733 SkASSERT(fHeight >= 0);
1734 SkASSERT(SkColorTypeIsValid(fColorType)); 1734 SkASSERT(SkColorTypeIsValid(fColorType));
1735 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); 1735 SkASSERT(SkAlphaTypeIsValid(fAlphaType));
1736 } 1736 }
1737 #endif 1737 #endif
OLDNEW
« no previous file with comments | « samplecode/SampleTiling.cpp ('k') | src/core/SkBitmapDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698