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

Unified Diff: src/core/SkPaint.cpp

Issue 1676843002: Make SkPaint movable. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 10 months 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/SkPaint.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPaint.cpp
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index e5fe975bcd7db719b5ef7e4018919e4bbc36f74e..b9f5cedc1531c7115b64f31eaef5d9b46f6c67b5 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -101,6 +101,33 @@ SkPaint::SkPaint(const SkPaint& src) {
#undef REF_COPY
}
+SkPaint::SkPaint(SkPaint&& src) {
+#define MOVE(field) field = std::move(src.field)
+#define REF_MOVE(field) field = src.field; src.field = nullptr
+
+ REF_MOVE(fTypeface);
+ REF_MOVE(fPathEffect);
+ REF_MOVE(fShader);
+ REF_MOVE(fXfermode);
+ REF_MOVE(fMaskFilter);
+ REF_MOVE(fColorFilter);
+ REF_MOVE(fRasterizer);
+ REF_MOVE(fLooper);
+ REF_MOVE(fImageFilter);
+ REF_MOVE(fAnnotation);
+
+ MOVE(fTextSize);
+ MOVE(fTextScaleX);
+ MOVE(fTextSkewX);
+ MOVE(fColor);
+ MOVE(fWidth);
+ MOVE(fMiterLimit);
+ MOVE(fBitfields);
+
+#undef MOVE
+#undef REF_MOVE
+}
+
SkPaint::~SkPaint() {
SkSafeUnref(fTypeface);
SkSafeUnref(fPathEffect);
@@ -147,6 +174,39 @@ SkPaint& SkPaint::operator=(const SkPaint& src) {
#undef REF_COPY
}
+SkPaint& SkPaint::operator=(SkPaint&& src) {
+ if (this == &src) {
+ return *this;
+ }
+
+#define MOVE(field) field = std::move(src.field)
+#define REF_MOVE(field) SkSafeUnref(field); field = src.field; src.field = nullptr
+
+ REF_MOVE(fTypeface);
+ REF_MOVE(fPathEffect);
+ REF_MOVE(fShader);
+ REF_MOVE(fXfermode);
+ REF_MOVE(fMaskFilter);
+ REF_MOVE(fColorFilter);
+ REF_MOVE(fRasterizer);
+ REF_MOVE(fLooper);
+ REF_MOVE(fImageFilter);
+ REF_MOVE(fAnnotation);
+
+ MOVE(fTextSize);
+ MOVE(fTextScaleX);
+ MOVE(fTextSkewX);
+ MOVE(fColor);
+ MOVE(fWidth);
+ MOVE(fMiterLimit);
+ MOVE(fBitfields);
+
+ return *this;
+
+#undef MOVE
+#undef REF_MOVE
+}
+
bool operator==(const SkPaint& a, const SkPaint& b) {
#define EQUAL(field) (a.field == b.field)
return EQUAL(fTypeface)
« no previous file with comments | « include/core/SkPaint.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698