| 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 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 SkPaint paint; | 1141 SkPaint paint; |
| 1142 | 1142 |
| 1143 paint.setDither(true); | 1143 paint.setDither(true); |
| 1144 canvas.drawBitmap(*src, 0, 0, &paint); | 1144 canvas.drawBitmap(*src, 0, 0, &paint); |
| 1145 } | 1145 } |
| 1146 | 1146 |
| 1147 dst->swap(tmpDst); | 1147 dst->swap(tmpDst); |
| 1148 return true; | 1148 return true; |
| 1149 } | 1149 } |
| 1150 | 1150 |
| 1151 bool SkBitmap::deepCopyTo(SkBitmap* dst, Config dstConfig) const { | 1151 bool SkBitmap::deepCopyTo(SkBitmap* dst) const { |
| 1152 const SkBitmap::Config dstConfig = this->config(); |
| 1152 const SkColorType dstCT = SkBitmapConfigToColorType(dstConfig); | 1153 const SkColorType dstCT = SkBitmapConfigToColorType(dstConfig); |
| 1153 | 1154 |
| 1154 if (!this->canCopyTo(dstCT)) { | 1155 if (!this->canCopyTo(dstCT)) { |
| 1155 return false; | 1156 return false; |
| 1156 } | 1157 } |
| 1157 | 1158 |
| 1158 // If we have a PixelRef, and it supports deep copy, use it. | 1159 // If we have a PixelRef, and it supports deep copy, use it. |
| 1159 // Currently supported only by texture-backed bitmaps. | 1160 // Currently supported only by texture-backed bitmaps. |
| 1160 if (fPixelRef) { | 1161 if (fPixelRef) { |
| 1161 SkPixelRef* pixelRef = fPixelRef->deepCopy(dstConfig); | 1162 SkPixelRef* pixelRef = fPixelRef->deepCopy(dstConfig); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1183 } | 1184 } |
| 1184 } | 1185 } |
| 1185 | 1186 |
| 1186 if (this->getTexture()) { | 1187 if (this->getTexture()) { |
| 1187 return false; | 1188 return false; |
| 1188 } else { | 1189 } else { |
| 1189 return this->copyTo(dst, dstCT, NULL); | 1190 return this->copyTo(dst, dstCT, NULL); |
| 1190 } | 1191 } |
| 1191 } | 1192 } |
| 1192 | 1193 |
| 1193 bool SkBitmap::deepCopyTo(SkBitmap* dst) const { | |
| 1194 return this->deepCopyTo(dst, this->config()); | |
| 1195 } | |
| 1196 | |
| 1197 /////////////////////////////////////////////////////////////////////////////// | 1194 /////////////////////////////////////////////////////////////////////////////// |
| 1198 /////////////////////////////////////////////////////////////////////////////// | 1195 /////////////////////////////////////////////////////////////////////////////// |
| 1199 | 1196 |
| 1200 static void downsampleby2_proc32(SkBitmap* dst, int x, int y, | 1197 static void downsampleby2_proc32(SkBitmap* dst, int x, int y, |
| 1201 const SkBitmap& src) { | 1198 const SkBitmap& src) { |
| 1202 x <<= 1; | 1199 x <<= 1; |
| 1203 y <<= 1; | 1200 y <<= 1; |
| 1204 const SkPMColor* p = src.getAddr32(x, y); | 1201 const SkPMColor* p = src.getAddr32(x, y); |
| 1205 const SkPMColor* baseP = p; | 1202 const SkPMColor* baseP = p; |
| 1206 SkPMColor c, ag, rb; | 1203 SkPMColor c, ag, rb; |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1735 /////////////////////////////////////////////////////////////////////////////// | 1732 /////////////////////////////////////////////////////////////////////////////// |
| 1736 | 1733 |
| 1737 #ifdef SK_DEBUG | 1734 #ifdef SK_DEBUG |
| 1738 void SkImageInfo::validate() const { | 1735 void SkImageInfo::validate() const { |
| 1739 SkASSERT(fWidth >= 0); | 1736 SkASSERT(fWidth >= 0); |
| 1740 SkASSERT(fHeight >= 0); | 1737 SkASSERT(fHeight >= 0); |
| 1741 SkASSERT(SkColorTypeIsValid(fColorType)); | 1738 SkASSERT(SkColorTypeIsValid(fColorType)); |
| 1742 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); | 1739 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); |
| 1743 } | 1740 } |
| 1744 #endif | 1741 #endif |
| OLD | NEW |