aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmap.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-23 14:52:14 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-23 14:52:14 +0000
commit6e332f768f873323b418ee7b028f28662bfb43c6 (patch)
treedb155655fdcea960b034f3bd1422118500480998 /src/core/SkBitmap.cpp
parentbc2f1dc85e458af7bdb87873e60207f9f7299e4a (diff)
Revert of eliminate config param -- it was always self's config (https://codereview.chromium.org/246513002/)
Reason for revert: Causes some layout_test failures around texture backed bitmaps. Test names and crash logs accessible via: https://storage.googleapis.com/chromium-layout-test-archives/linux_layout/13845/layout-test-results/results.html Original issue's description: > eliminate config param -- it was always self's config > > BUG=skia: > R=bsalomon@google.com > > Committed: https://code.google.com/p/skia/source/detail?r=14303 R=reed@google.com TBR=reed@google.com NOTREECHECKS=true NOTRY=true BUG=skia: Author: bsalomon@google.com Review URL: https://codereview.chromium.org/249373003 git-svn-id: http://skia.googlecode.com/svn/trunk@14324 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 d19e9ca8b9..b8c7fc7a4c 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -946,7 +946,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,
@@ -1146,7 +1146,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;
@@ -1155,15 +1156,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();