aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmap.cpp
diff options
context:
space:
mode:
authorGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-12-02 19:11:17 +0000
committerGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-12-02 19:11:17 +0000
commitef843cdcd1be858fe55cc99ff134ffbd080c9a51 (patch)
tree7444455a3085d02aa86e3c5c3b0c2e0df2f264f8 /src/core/SkBitmap.cpp
parentc62b0f8fd0cfaee1791e7bb4f349ad165df4f86b (diff)
When a bitmap is texture-backed, change SkBitmap::copyTo() to do a deep
copy of the texels in VRAM rather than a readback and re-upload. This gives a 3-10X speedup on recursive canvas-to-canvas draws. N.B.: This introduces a new GM test, which will need new baselines. git-svn-id: http://skia.googlecode.com/svn/trunk@2790 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkBitmap.cpp')
-rw-r--r--src/core/SkBitmap.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 760bab7d8a..24a1839ff2 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -938,6 +938,29 @@ bool SkBitmap::copyTo(SkBitmap* dst, Config dstConfig, Allocator* alloc) const {
return true;
}
+bool SkBitmap::deepCopyTo(SkBitmap* dst, Config dstConfig) const {
+ if (!this->canCopyTo(dstConfig)) {
+ return false;
+ }
+
+ // 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(dstConfig);
+ if (pixelRef) {
+ dst->setConfig(dstConfig, fWidth, fHeight);
+ dst->setPixelRef(pixelRef)->unref();
+ return true;
+ }
+ }
+
+ if (this->getTexture()) {
+ return false;
+ } else {
+ return this->copyTo(dst, dstConfig, NULL);
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////