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

Side by Side Diff: src/core/SkPaint.cpp

Issue 2326173002: use expected name for setDrawLooper/getDrawLooper (Closed)
Patch Set: Created 4 years, 3 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 "SkAutoKern.h" 9 #include "SkAutoKern.h"
10 #include "SkColorFilter.h" 10 #include "SkColorFilter.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 SkPaint::SkPaint(const SkPaint& src) 67 SkPaint::SkPaint(const SkPaint& src)
68 #define COPY(field) field(src.field) 68 #define COPY(field) field(src.field)
69 : COPY(fTypeface) 69 : COPY(fTypeface)
70 , COPY(fPathEffect) 70 , COPY(fPathEffect)
71 , COPY(fShader) 71 , COPY(fShader)
72 , COPY(fXfermode) 72 , COPY(fXfermode)
73 , COPY(fMaskFilter) 73 , COPY(fMaskFilter)
74 , COPY(fColorFilter) 74 , COPY(fColorFilter)
75 , COPY(fRasterizer) 75 , COPY(fRasterizer)
76 , COPY(fLooper) 76 , COPY(fDrawLooper)
77 , COPY(fImageFilter) 77 , COPY(fImageFilter)
78 , COPY(fTextSize) 78 , COPY(fTextSize)
79 , COPY(fTextScaleX) 79 , COPY(fTextScaleX)
80 , COPY(fTextSkewX) 80 , COPY(fTextSkewX)
81 , COPY(fColor) 81 , COPY(fColor)
82 , COPY(fWidth) 82 , COPY(fWidth)
83 , COPY(fMiterLimit) 83 , COPY(fMiterLimit)
84 , COPY(fBitfields) 84 , COPY(fBitfields)
85 #undef COPY 85 #undef COPY
86 {} 86 {}
87 87
88 SkPaint::SkPaint(SkPaint&& src) { 88 SkPaint::SkPaint(SkPaint&& src) {
89 #define MOVE(field) field = std::move(src.field) 89 #define MOVE(field) field = std::move(src.field)
90 MOVE(fTypeface); 90 MOVE(fTypeface);
91 MOVE(fPathEffect); 91 MOVE(fPathEffect);
92 MOVE(fShader); 92 MOVE(fShader);
93 MOVE(fXfermode); 93 MOVE(fXfermode);
94 MOVE(fMaskFilter); 94 MOVE(fMaskFilter);
95 MOVE(fColorFilter); 95 MOVE(fColorFilter);
96 MOVE(fRasterizer); 96 MOVE(fRasterizer);
97 MOVE(fLooper); 97 MOVE(fDrawLooper);
98 MOVE(fImageFilter); 98 MOVE(fImageFilter);
99 MOVE(fTextSize); 99 MOVE(fTextSize);
100 MOVE(fTextScaleX); 100 MOVE(fTextScaleX);
101 MOVE(fTextSkewX); 101 MOVE(fTextSkewX);
102 MOVE(fColor); 102 MOVE(fColor);
103 MOVE(fWidth); 103 MOVE(fWidth);
104 MOVE(fMiterLimit); 104 MOVE(fMiterLimit);
105 MOVE(fBitfields); 105 MOVE(fBitfields);
106 #undef MOVE 106 #undef MOVE
107 } 107 }
108 108
109 SkPaint::~SkPaint() {} 109 SkPaint::~SkPaint() {}
110 110
111 SkPaint& SkPaint::operator=(const SkPaint& src) { 111 SkPaint& SkPaint::operator=(const SkPaint& src) {
112 if (this == &src) { 112 if (this == &src) {
113 return *this; 113 return *this;
114 } 114 }
115 115
116 #define ASSIGN(field) field = src.field 116 #define ASSIGN(field) field = src.field
117 ASSIGN(fTypeface); 117 ASSIGN(fTypeface);
118 ASSIGN(fPathEffect); 118 ASSIGN(fPathEffect);
119 ASSIGN(fShader); 119 ASSIGN(fShader);
120 ASSIGN(fXfermode); 120 ASSIGN(fXfermode);
121 ASSIGN(fMaskFilter); 121 ASSIGN(fMaskFilter);
122 ASSIGN(fColorFilter); 122 ASSIGN(fColorFilter);
123 ASSIGN(fRasterizer); 123 ASSIGN(fRasterizer);
124 ASSIGN(fLooper); 124 ASSIGN(fDrawLooper);
125 ASSIGN(fImageFilter); 125 ASSIGN(fImageFilter);
126 ASSIGN(fTextSize); 126 ASSIGN(fTextSize);
127 ASSIGN(fTextScaleX); 127 ASSIGN(fTextScaleX);
128 ASSIGN(fTextSkewX); 128 ASSIGN(fTextSkewX);
129 ASSIGN(fColor); 129 ASSIGN(fColor);
130 ASSIGN(fWidth); 130 ASSIGN(fWidth);
131 ASSIGN(fMiterLimit); 131 ASSIGN(fMiterLimit);
132 ASSIGN(fBitfields); 132 ASSIGN(fBitfields);
133 #undef ASSIGN 133 #undef ASSIGN
134 134
135 return *this; 135 return *this;
136 } 136 }
137 137
138 SkPaint& SkPaint::operator=(SkPaint&& src) { 138 SkPaint& SkPaint::operator=(SkPaint&& src) {
139 if (this == &src) { 139 if (this == &src) {
140 return *this; 140 return *this;
141 } 141 }
142 142
143 #define MOVE(field) field = std::move(src.field) 143 #define MOVE(field) field = std::move(src.field)
144 MOVE(fTypeface); 144 MOVE(fTypeface);
145 MOVE(fPathEffect); 145 MOVE(fPathEffect);
146 MOVE(fShader); 146 MOVE(fShader);
147 MOVE(fXfermode); 147 MOVE(fXfermode);
148 MOVE(fMaskFilter); 148 MOVE(fMaskFilter);
149 MOVE(fColorFilter); 149 MOVE(fColorFilter);
150 MOVE(fRasterizer); 150 MOVE(fRasterizer);
151 MOVE(fLooper); 151 MOVE(fDrawLooper);
152 MOVE(fImageFilter); 152 MOVE(fImageFilter);
153 MOVE(fTextSize); 153 MOVE(fTextSize);
154 MOVE(fTextScaleX); 154 MOVE(fTextScaleX);
155 MOVE(fTextSkewX); 155 MOVE(fTextSkewX);
156 MOVE(fColor); 156 MOVE(fColor);
157 MOVE(fWidth); 157 MOVE(fWidth);
158 MOVE(fMiterLimit); 158 MOVE(fMiterLimit);
159 MOVE(fBitfields); 159 MOVE(fBitfields);
160 #undef MOVE 160 #undef MOVE
161 161
162 return *this; 162 return *this;
163 } 163 }
164 164
165 bool operator==(const SkPaint& a, const SkPaint& b) { 165 bool operator==(const SkPaint& a, const SkPaint& b) {
166 #define EQUAL(field) (a.field == b.field) 166 #define EQUAL(field) (a.field == b.field)
167 return EQUAL(fTypeface) 167 return EQUAL(fTypeface)
168 && EQUAL(fPathEffect) 168 && EQUAL(fPathEffect)
169 && EQUAL(fShader) 169 && EQUAL(fShader)
170 && EQUAL(fXfermode) 170 && EQUAL(fXfermode)
171 && EQUAL(fMaskFilter) 171 && EQUAL(fMaskFilter)
172 && EQUAL(fColorFilter) 172 && EQUAL(fColorFilter)
173 && EQUAL(fRasterizer) 173 && EQUAL(fRasterizer)
174 && EQUAL(fLooper) 174 && EQUAL(fDrawLooper)
175 && EQUAL(fImageFilter) 175 && EQUAL(fImageFilter)
176 && EQUAL(fTextSize) 176 && EQUAL(fTextSize)
177 && EQUAL(fTextScaleX) 177 && EQUAL(fTextScaleX)
178 && EQUAL(fTextSkewX) 178 && EQUAL(fTextSkewX)
179 && EQUAL(fColor) 179 && EQUAL(fColor)
180 && EQUAL(fWidth) 180 && EQUAL(fWidth)
181 && EQUAL(fMiterLimit) 181 && EQUAL(fMiterLimit)
182 && EQUAL(fBitfieldsUInt) 182 && EQUAL(fBitfieldsUInt)
183 ; 183 ;
184 #undef EQUAL 184 #undef EQUAL
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 356
357 #define MOVE_FIELD(Field) void SkPaint::set##Field(sk_sp<Sk##Field> f) { f##Fiel d = std::move(f); } 357 #define MOVE_FIELD(Field) void SkPaint::set##Field(sk_sp<Sk##Field> f) { f##Fiel d = std::move(f); }
358 MOVE_FIELD(Typeface) 358 MOVE_FIELD(Typeface)
359 MOVE_FIELD(Rasterizer) 359 MOVE_FIELD(Rasterizer)
360 MOVE_FIELD(ImageFilter) 360 MOVE_FIELD(ImageFilter)
361 MOVE_FIELD(Shader) 361 MOVE_FIELD(Shader)
362 MOVE_FIELD(ColorFilter) 362 MOVE_FIELD(ColorFilter)
363 MOVE_FIELD(Xfermode) 363 MOVE_FIELD(Xfermode)
364 MOVE_FIELD(PathEffect) 364 MOVE_FIELD(PathEffect)
365 MOVE_FIELD(MaskFilter) 365 MOVE_FIELD(MaskFilter)
366 MOVE_FIELD(DrawLooper)
366 #undef MOVE_FIELD 367 #undef MOVE_FIELD
367 void SkPaint::setLooper(sk_sp<SkDrawLooper> looper) { fLooper = std::move(looper ); } 368 void SkPaint::setLooper(sk_sp<SkDrawLooper> looper) { fDrawLooper = std::move(lo oper); }
368 369
369 #define SET_PTR(Field) \ 370 #define SET_PTR(Field) \
370 Sk##Field* SkPaint::set##Field(Sk##Field* f) { \ 371 Sk##Field* SkPaint::set##Field(Sk##Field* f) { \
371 this->f##Field.reset(SkSafeRef(f)); \ 372 this->f##Field.reset(SkSafeRef(f)); \
372 return f; \ 373 return f; \
373 } 374 }
374 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR 375 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR
375 SET_PTR(Typeface) 376 SET_PTR(Typeface)
376 #endif 377 #endif
377 #ifdef SK_SUPPORT_LEGACY_MINOR_EFFECT_PTR 378 #ifdef SK_SUPPORT_LEGACY_MINOR_EFFECT_PTR
(...skipping 1974 matching lines...) Expand 10 before | Expand all | Expand 10 after
2352 } 2353 }
2353 2354
2354 // return true if the filter exists, and may affect alpha 2355 // return true if the filter exists, and may affect alpha
2355 static bool affects_alpha(const SkImageFilter* imf) { 2356 static bool affects_alpha(const SkImageFilter* imf) {
2356 // TODO: check if we should allow imagefilters to broadcast that they don't affect alpha 2357 // TODO: check if we should allow imagefilters to broadcast that they don't affect alpha
2357 // ala colorfilters 2358 // ala colorfilters
2358 return imf != nullptr; 2359 return imf != nullptr;
2359 } 2360 }
2360 2361
2361 bool SkPaint::nothingToDraw() const { 2362 bool SkPaint::nothingToDraw() const {
2362 if (fLooper) { 2363 if (fDrawLooper) {
2363 return false; 2364 return false;
2364 } 2365 }
2365 SkXfermode::Mode mode; 2366 SkXfermode::Mode mode;
2366 if (SkXfermode::AsMode(fXfermode.get(), &mode)) { 2367 if (SkXfermode::AsMode(fXfermode.get(), &mode)) {
2367 switch (mode) { 2368 switch (mode) {
2368 case SkXfermode::kSrcOver_Mode: 2369 case SkXfermode::kSrcOver_Mode:
2369 case SkXfermode::kSrcATop_Mode: 2370 case SkXfermode::kSrcATop_Mode:
2370 case SkXfermode::kDstOut_Mode: 2371 case SkXfermode::kDstOut_Mode:
2371 case SkXfermode::kDstOver_Mode: 2372 case SkXfermode::kDstOver_Mode:
2372 case SkXfermode::kPlus_Mode: 2373 case SkXfermode::kPlus_Mode:
(...skipping 11 matching lines...) Expand all
2384 } 2385 }
2385 2386
2386 uint32_t SkPaint::getHash() const { 2387 uint32_t SkPaint::getHash() const {
2387 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB itfields, 2388 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB itfields,
2388 // so fBitfields should be 10 pointers and 6 32-bit values from the start. 2389 // so fBitfields should be 10 pointers and 6 32-bit values from the start.
2389 static_assert(offsetof(SkPaint, fBitfields) == 9 * sizeof(void*) + 6 * sizeo f(uint32_t), 2390 static_assert(offsetof(SkPaint, fBitfields) == 9 * sizeof(void*) + 6 * sizeo f(uint32_t),
2390 "SkPaint_notPackedTightly"); 2391 "SkPaint_notPackedTightly");
2391 return SkOpts::hash(reinterpret_cast<const uint32_t*>(this), 2392 return SkOpts::hash(reinterpret_cast<const uint32_t*>(this),
2392 offsetof(SkPaint, fBitfields) + sizeof(fBitfields)); 2393 offsetof(SkPaint, fBitfields) + sizeof(fBitfields));
2393 } 2394 }
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