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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « include/core/SkPaint.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkPaint.h" 8 #include "SkPaint.h"
9 #include "SkAnnotation.h" 9 #include "SkAnnotation.h"
10 #include "SkAutoKern.h" 10 #include "SkAutoKern.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 COPY(fTextSkewX); 94 COPY(fTextSkewX);
95 COPY(fColor); 95 COPY(fColor);
96 COPY(fWidth); 96 COPY(fWidth);
97 COPY(fMiterLimit); 97 COPY(fMiterLimit);
98 COPY(fBitfields); 98 COPY(fBitfields);
99 99
100 #undef COPY 100 #undef COPY
101 #undef REF_COPY 101 #undef REF_COPY
102 } 102 }
103 103
104 SkPaint::SkPaint(SkPaint&& src) {
105 #define MOVE(field) field = std::move(src.field)
106 #define REF_MOVE(field) field = src.field; src.field = nullptr
107
108 REF_MOVE(fTypeface);
109 REF_MOVE(fPathEffect);
110 REF_MOVE(fShader);
111 REF_MOVE(fXfermode);
112 REF_MOVE(fMaskFilter);
113 REF_MOVE(fColorFilter);
114 REF_MOVE(fRasterizer);
115 REF_MOVE(fLooper);
116 REF_MOVE(fImageFilter);
117 REF_MOVE(fAnnotation);
118
119 MOVE(fTextSize);
120 MOVE(fTextScaleX);
121 MOVE(fTextSkewX);
122 MOVE(fColor);
123 MOVE(fWidth);
124 MOVE(fMiterLimit);
125 MOVE(fBitfields);
126
127 #undef MOVE
128 #undef REF_MOVE
129 }
130
104 SkPaint::~SkPaint() { 131 SkPaint::~SkPaint() {
105 SkSafeUnref(fTypeface); 132 SkSafeUnref(fTypeface);
106 SkSafeUnref(fPathEffect); 133 SkSafeUnref(fPathEffect);
107 SkSafeUnref(fShader); 134 SkSafeUnref(fShader);
108 SkSafeUnref(fXfermode); 135 SkSafeUnref(fXfermode);
109 SkSafeUnref(fMaskFilter); 136 SkSafeUnref(fMaskFilter);
110 SkSafeUnref(fColorFilter); 137 SkSafeUnref(fColorFilter);
111 SkSafeUnref(fRasterizer); 138 SkSafeUnref(fRasterizer);
112 SkSafeUnref(fLooper); 139 SkSafeUnref(fLooper);
113 SkSafeUnref(fImageFilter); 140 SkSafeUnref(fImageFilter);
(...skipping 26 matching lines...) Expand all
140 COPY(fWidth); 167 COPY(fWidth);
141 COPY(fMiterLimit); 168 COPY(fMiterLimit);
142 COPY(fBitfields); 169 COPY(fBitfields);
143 170
144 return *this; 171 return *this;
145 172
146 #undef COPY 173 #undef COPY
147 #undef REF_COPY 174 #undef REF_COPY
148 } 175 }
149 176
177 SkPaint& SkPaint::operator=(SkPaint&& src) {
178 if (this == &src) {
179 return *this;
180 }
181
182 #define MOVE(field) field = std::move(src.field)
183 #define REF_MOVE(field) SkSafeUnref(field); field = src.field; src.field = nullp tr
184
185 REF_MOVE(fTypeface);
186 REF_MOVE(fPathEffect);
187 REF_MOVE(fShader);
188 REF_MOVE(fXfermode);
189 REF_MOVE(fMaskFilter);
190 REF_MOVE(fColorFilter);
191 REF_MOVE(fRasterizer);
192 REF_MOVE(fLooper);
193 REF_MOVE(fImageFilter);
194 REF_MOVE(fAnnotation);
195
196 MOVE(fTextSize);
197 MOVE(fTextScaleX);
198 MOVE(fTextSkewX);
199 MOVE(fColor);
200 MOVE(fWidth);
201 MOVE(fMiterLimit);
202 MOVE(fBitfields);
203
204 return *this;
205
206 #undef MOVE
207 #undef REF_MOVE
208 }
209
150 bool operator==(const SkPaint& a, const SkPaint& b) { 210 bool operator==(const SkPaint& a, const SkPaint& b) {
151 #define EQUAL(field) (a.field == b.field) 211 #define EQUAL(field) (a.field == b.field)
152 return EQUAL(fTypeface) 212 return EQUAL(fTypeface)
153 && EQUAL(fPathEffect) 213 && EQUAL(fPathEffect)
154 && EQUAL(fShader) 214 && EQUAL(fShader)
155 && EQUAL(fXfermode) 215 && EQUAL(fXfermode)
156 && EQUAL(fMaskFilter) 216 && EQUAL(fMaskFilter)
157 && EQUAL(fColorFilter) 217 && EQUAL(fColorFilter)
158 && EQUAL(fRasterizer) 218 && EQUAL(fRasterizer)
159 && EQUAL(fLooper) 219 && EQUAL(fLooper)
(...skipping 2263 matching lines...) Expand 10 before | Expand all | Expand 10 after
2423 } 2483 }
2424 2484
2425 uint32_t SkPaint::getHash() const { 2485 uint32_t SkPaint::getHash() const {
2426 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB itfields, 2486 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB itfields,
2427 // so fBitfields should be 10 pointers and 6 32-bit values from the start. 2487 // so fBitfields should be 10 pointers and 6 32-bit values from the start.
2428 static_assert(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * size of(uint32_t), 2488 static_assert(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * size of(uint32_t),
2429 "SkPaint_notPackedTightly"); 2489 "SkPaint_notPackedTightly");
2430 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), 2490 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this),
2431 offsetof(SkPaint, fBitfields) + sizeof(fBitfields )); 2491 offsetof(SkPaint, fBitfields) + sizeof(fBitfields ));
2432 } 2492 }
OLDNEW
« 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