aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmap.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-20 12:39:37 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-20 12:39:37 +0000
commit555e74f6fbd9acad79411f72342759ba2ee51b16 (patch)
tree49aca3b2dce42c5f088700893c4f58d414227c44 /src/core/SkBitmap.cpp
parent61830df198e7b0de0c494d3e847ccc549d10c8b7 (diff)
"Revert of eliminate config param -- it was always self's config (https://codereview.chromium.org/246513002/)""
This reverts commit 65b9f33cab9f53821720f982667412e56a340093. git-svn-id: http://skia.googlecode.com/svn/trunk@14795 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkBitmap.cpp')
-rw-r--r--src/core/SkBitmap.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 2d3391f11f..84f363e564 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -885,7 +885,7 @@ bool SkBitmap::extractSubset(SkBitmap* result, const SkIRect& subset) const {
if (fPixelRef->getTexture() != NULL) {
// Do a deep copy
- SkPixelRef* pixelRef = fPixelRef->deepCopy(&subset);
+ SkPixelRef* pixelRef = fPixelRef->deepCopy(this->config(), &subset);
if (pixelRef != NULL) {
SkBitmap dst;
dst.setConfig(this->config(), subset.width(), subset.height(), 0,
@@ -1085,7 +1085,8 @@ bool SkBitmap::copyTo(SkBitmap* dst, SkColorType dstColorType,
}
bool SkBitmap::deepCopyTo(SkBitmap* dst) const {
- const SkColorType dstCT = this->colorType();
+ const SkBitmap::Config dstConfig = this->config();
+ const SkColorType dstCT = SkBitmapConfigToColorType(dstConfig);
if (!this->canCopyTo(dstCT)) {
return false;
@@ -1094,15 +1095,24 @@ bool SkBitmap::deepCopyTo(SkBitmap* dst) const {
// If we have a PixelRef, and it supports deep copy, use it.
// Currently supported only by texture-backed bitmaps.
if (fPixelRef) {
- SkPixelRef* pixelRef = fPixelRef->deepCopy();
+ SkPixelRef* pixelRef = fPixelRef->deepCopy(dstConfig);
if (pixelRef) {
- // Since there is no subset to pass to deepCopy, and deepCopy
- // succeeded, the new pixel ref must be identical.
- SkASSERT(fPixelRef->info() == pixelRef->info());
- pixelRef->cloneGenID(*fPixelRef);
+ uint32_t rowBytes;
+ if (this->colorType() == dstCT) {
+ // Since there is no subset to pass to deepCopy, and deepCopy
+ // succeeded, the new pixel ref must be identical.
+ SkASSERT(fPixelRef->info() == pixelRef->info());
+ pixelRef->cloneGenID(*fPixelRef);
+ // Use the same rowBytes as the original.
+ rowBytes = fRowBytes;
+ } else {
+ // With the new config, an appropriate fRowBytes will be computed by setConfig.
+ rowBytes = 0;
+ }
SkImageInfo info = fInfo;
- if (!dst->setConfig(info, fRowBytes)) {
+ info.fColorType = dstCT;
+ if (!dst->setConfig(info, rowBytes)) {
return false;
}
dst->setPixelRef(pixelRef, fPixelRefOrigin)->unref();