aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmap.cpp
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2015-12-14 10:19:17 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-12-14 10:19:17 -0800
commit023bda0d836834eb1f98ceec15b169a492ab78ad (patch)
tree1dc817f5fa326a6bb943aa1bb10f3ac1e6714ede /src/core/SkBitmap.cpp
parentc9730831fcff6016279b304f246740b3cf53f9e4 (diff)
SkBitmap move
Running `Release/dm --gpu 0`, the number of times we call SkBitmap::operator=(const SkBitmap&) (which refs the pixelref) is reduced from ~214929 to ~214626. Review URL: https://codereview.chromium.org/1514503004
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 8997f2b014..661dca3ea5 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -39,6 +39,8 @@ SkBitmap::SkBitmap(const SkBitmap& src) {
SkDEBUGCODE(this->validate();)
}
+SkBitmap::SkBitmap(SkBitmap&& other) : SkBitmap() { this->swap(other); }
+
SkBitmap::~SkBitmap() {
SkDEBUGCODE(this->validate();)
this->freePixels();
@@ -72,6 +74,14 @@ SkBitmap& SkBitmap::operator=(const SkBitmap& src) {
return *this;
}
+SkBitmap& SkBitmap::operator=(SkBitmap&& other) {
+ if (this != &other) {
+ this->swap(other);
+ other.reset();
+ }
+ return *this;
+}
+
void SkBitmap::swap(SkBitmap& other) {
SkTSwap(fColorTable, other.fColorTable);
SkTSwap(fPixelRef, other.fPixelRef);