aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmap.cpp
diff options
context:
space:
mode:
authorGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-22 15:00:05 +0000
committerGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-22 15:00:05 +0000
commitd5764e8ab731dd12df9293e52ce644eaa45333bd (patch)
tree6e727b0e389ac92469019cad7321f69847f7a662 /src/core/SkBitmap.cpp
parente8e7d5f2753fe93b96cba46be589744caf8af62e (diff)
When copying a bitmap, copy the generation ID.
Review URL: https://codereview.appspot.com/6462084 git-svn-id: http://skia.googlecode.com/svn/trunk@5227 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkBitmap.cpp')
-rw-r--r--src/core/SkBitmap.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index e59c506983..382d6a1dce 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -892,6 +892,9 @@ bool SkBitmap::copyTo(SkBitmap* dst, Config dstConfig, Allocator* alloc) const {
// did we get lucky and we can just return tmpSrc?
if (tmpSrc.config() == dstConfig && NULL == alloc) {
dst->swap(tmpSrc);
+ if (dst->pixelRef()) {
+ dst->pixelRef()->fGenerationID = fPixelRef->getGenerationID();
+ }
return true;
}
@@ -926,6 +929,10 @@ bool SkBitmap::copyTo(SkBitmap* dst, Config dstConfig, Allocator* alloc) const {
if (src->config() == dstConfig) {
if (tmpDst.getSize() == src->getSize()) {
memcpy(tmpDst.getPixels(), src->getPixels(), src->getSafeSize());
+ SkPixelRef* pixelRef = tmpDst.pixelRef();
+ if (pixelRef != NULL) {
+ pixelRef->fGenerationID = this->getGenerationID();
+ }
} else {
const char* srcP = reinterpret_cast<const char*>(src->getPixels());
char* dstP = reinterpret_cast<char*>(tmpDst.getPixels());
@@ -966,6 +973,9 @@ bool SkBitmap::deepCopyTo(SkBitmap* dst, Config dstConfig) const {
if (fPixelRef) {
SkPixelRef* pixelRef = fPixelRef->deepCopy(dstConfig);
if (pixelRef) {
+ if (dstConfig == fConfig) {
+ pixelRef->fGenerationID = fPixelRef->getGenerationID();
+ }
dst->setConfig(dstConfig, fWidth, fHeight);
dst->setPixelRef(pixelRef)->unref();
return true;