Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Unified Diff: src/core/SkBitmap.cpp

Issue 1514503004: SkBitmap move (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-12-10 (Thursday) 17:55:13 EST Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkBitmap.h ('k') | src/core/SkCanvas.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmap.cpp
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 8997f2b0140b41f62d1096e847f10b03a4cfaaa8..2e1f810524aea0eff4d74e30061a27402c181aa2 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -39,6 +39,13 @@ SkBitmap::SkBitmap(const SkBitmap& src) {
SkDEBUGCODE(this->validate();)
}
+SkBitmap::SkBitmap(SkBitmap&& other) {
+ if (this != &other) {
+ memcpy(this, &other, sizeof(other));
mtklein 2015/12/10 23:09:58 Can't this just be this->swap(other)?
hal.canary 2015/12/14 17:30:37 Done. need to initialize all variables first.
+ sk_bzero(&other, sizeof(other));
+ }
+}
+
SkBitmap::~SkBitmap() {
SkDEBUGCODE(this->validate();)
this->freePixels();
@@ -72,6 +79,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);
« no previous file with comments | « include/core/SkBitmap.h ('k') | src/core/SkCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698