diff options
author | 2015-12-14 10:19:17 -0800 | |
---|---|---|
committer | 2015-12-14 10:19:17 -0800 | |
commit | 023bda0d836834eb1f98ceec15b169a492ab78ad (patch) | |
tree | 1dc817f5fa326a6bb943aa1bb10f3ac1e6714ede /src/core/SkBitmap.cpp | |
parent | c9730831fcff6016279b304f246740b3cf53f9e4 (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.cpp | 10 |
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); |