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

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

Issue 249373003: Revert of eliminate config param -- it was always self's config (Closed) Base URL: https://skia.googlecode.com/svn/trunk
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 | Annotate | Revision Log
« no previous file with comments | « include/gpu/SkGrPixelRef.h ('k') | src/gpu/SkGrPixelRef.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 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 } 939 }
940 940
941 SkIRect srcRect, r; 941 SkIRect srcRect, r;
942 srcRect.set(0, 0, this->width(), this->height()); 942 srcRect.set(0, 0, this->width(), this->height());
943 if (!r.intersect(srcRect, subset)) { 943 if (!r.intersect(srcRect, subset)) {
944 return false; // r is empty (i.e. no intersection) 944 return false; // r is empty (i.e. no intersection)
945 } 945 }
946 946
947 if (fPixelRef->getTexture() != NULL) { 947 if (fPixelRef->getTexture() != NULL) {
948 // Do a deep copy 948 // Do a deep copy
949 SkPixelRef* pixelRef = fPixelRef->deepCopy(&subset); 949 SkPixelRef* pixelRef = fPixelRef->deepCopy(this->config(), &subset);
950 if (pixelRef != NULL) { 950 if (pixelRef != NULL) {
951 SkBitmap dst; 951 SkBitmap dst;
952 dst.setConfig(this->config(), subset.width(), subset.height(), 0, 952 dst.setConfig(this->config(), subset.width(), subset.height(), 0,
953 this->alphaType()); 953 this->alphaType());
954 dst.setIsVolatile(this->isVolatile()); 954 dst.setIsVolatile(this->isVolatile());
955 dst.setPixelRef(pixelRef)->unref(); 955 dst.setPixelRef(pixelRef)->unref();
956 SkDEBUGCODE(dst.validate()); 956 SkDEBUGCODE(dst.validate());
957 result->swap(dst); 957 result->swap(dst);
958 return true; 958 return true;
959 } 959 }
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 1138
1139 paint.setDither(true); 1139 paint.setDither(true);
1140 canvas.drawBitmap(*src, 0, 0, &paint); 1140 canvas.drawBitmap(*src, 0, 0, &paint);
1141 } 1141 }
1142 1142
1143 dst->swap(tmpDst); 1143 dst->swap(tmpDst);
1144 return true; 1144 return true;
1145 } 1145 }
1146 1146
1147 bool SkBitmap::deepCopyTo(SkBitmap* dst) const { 1147 bool SkBitmap::deepCopyTo(SkBitmap* dst) const {
1148 const SkColorType dstCT = this->colorType(); 1148 const SkBitmap::Config dstConfig = this->config();
1149 const SkColorType dstCT = SkBitmapConfigToColorType(dstConfig);
1149 1150
1150 if (!this->canCopyTo(dstCT)) { 1151 if (!this->canCopyTo(dstCT)) {
1151 return false; 1152 return false;
1152 } 1153 }
1153 1154
1154 // If we have a PixelRef, and it supports deep copy, use it. 1155 // If we have a PixelRef, and it supports deep copy, use it.
1155 // Currently supported only by texture-backed bitmaps. 1156 // Currently supported only by texture-backed bitmaps.
1156 if (fPixelRef) { 1157 if (fPixelRef) {
1157 SkPixelRef* pixelRef = fPixelRef->deepCopy(); 1158 SkPixelRef* pixelRef = fPixelRef->deepCopy(dstConfig);
1158 if (pixelRef) { 1159 if (pixelRef) {
1159 // Since there is no subset to pass to deepCopy, and deepCopy 1160 uint32_t rowBytes;
1160 // succeeded, the new pixel ref must be identical. 1161 if (this->colorType() == dstCT) {
1161 SkASSERT(fPixelRef->info() == pixelRef->info()); 1162 // Since there is no subset to pass to deepCopy, and deepCopy
1162 pixelRef->cloneGenID(*fPixelRef); 1163 // succeeded, the new pixel ref must be identical.
1164 SkASSERT(fPixelRef->info() == pixelRef->info());
1165 pixelRef->cloneGenID(*fPixelRef);
1166 // Use the same rowBytes as the original.
1167 rowBytes = fRowBytes;
1168 } else {
1169 // With the new config, an appropriate fRowBytes will be compute d by setConfig.
1170 rowBytes = 0;
1171 }
1163 1172
1164 SkImageInfo info = fInfo; 1173 SkImageInfo info = fInfo;
1165 if (!dst->setConfig(info, fRowBytes)) { 1174 info.fColorType = dstCT;
1175 if (!dst->setConfig(info, rowBytes)) {
1166 return false; 1176 return false;
1167 } 1177 }
1168 dst->setPixelRef(pixelRef, fPixelRefOrigin)->unref(); 1178 dst->setPixelRef(pixelRef, fPixelRefOrigin)->unref();
1169 return true; 1179 return true;
1170 } 1180 }
1171 } 1181 }
1172 1182
1173 if (this->getTexture()) { 1183 if (this->getTexture()) {
1174 return false; 1184 return false;
1175 } else { 1185 } else {
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1718 /////////////////////////////////////////////////////////////////////////////// 1728 ///////////////////////////////////////////////////////////////////////////////
1719 1729
1720 #ifdef SK_DEBUG 1730 #ifdef SK_DEBUG
1721 void SkImageInfo::validate() const { 1731 void SkImageInfo::validate() const {
1722 SkASSERT(fWidth >= 0); 1732 SkASSERT(fWidth >= 0);
1723 SkASSERT(fHeight >= 0); 1733 SkASSERT(fHeight >= 0);
1724 SkASSERT(SkColorTypeIsValid(fColorType)); 1734 SkASSERT(SkColorTypeIsValid(fColorType));
1725 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); 1735 SkASSERT(SkAlphaTypeIsValid(fAlphaType));
1726 } 1736 }
1727 #endif 1737 #endif
OLDNEW
« no previous file with comments | « include/gpu/SkGrPixelRef.h ('k') | src/gpu/SkGrPixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698