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

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

Issue 239163002: WIP -- separate out Parts from SkPaint (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: links and runs Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « include/core/SkPaintParts.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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkPaint.h" 9 #include "SkPaint.h"
10 #include "SkAnnotation.h" 10 #include "SkAnnotation.h"
(...skipping 17 matching lines...) Expand all
28 #include "SkScalerContext.h" 28 #include "SkScalerContext.h"
29 #include "SkShader.h" 29 #include "SkShader.h"
30 #include "SkStringUtils.h" 30 #include "SkStringUtils.h"
31 #include "SkStroke.h" 31 #include "SkStroke.h"
32 #include "SkTextFormatParams.h" 32 #include "SkTextFormatParams.h"
33 #include "SkTextToPathIter.h" 33 #include "SkTextToPathIter.h"
34 #include "SkTLazy.h" 34 #include "SkTLazy.h"
35 #include "SkTypeface.h" 35 #include "SkTypeface.h"
36 #include "SkXfermode.h" 36 #include "SkXfermode.h"
37 37
38 #define SkPaintParts_SafeAssign(field, value) SkRefCnt_SafeAssign(fParts.field , value)
39
40 bool SkPaintParts::operator==(const SkPaintParts& other) const {
41 #define EQUAL(field) (this->field == other.field)
42 return EQUAL(fTypeface)
43 && EQUAL(fPathEffect)
44 && EQUAL(fShader)
45 && EQUAL(fXfermode)
46 && EQUAL(fMaskFilter)
47 && EQUAL(fColorFilter)
48 && EQUAL(fRasterizer)
49 && EQUAL(fLooper)
50 && EQUAL(fImageFilter)
51 && EQUAL(fAnnotation)
52 && EQUAL(fTextSize)
53 && EQUAL(fTextScaleX)
54 && EQUAL(fTextSkewX)
55 && EQUAL(fColor)
56 && EQUAL(fWidth)
57 && EQUAL(fMiterLimit)
58 && EQUAL(fBitfields)
59 ;
60 #undef EQUAL
61 }
62
63 ///////////
64
65
38 enum { 66 enum {
39 kColor_DirtyBit = 1 << 0, 67 kColor_DirtyBit = 1 << 0,
40 kTextSize_DirtyBit = 1 << 1, 68 kTextSize_DirtyBit = 1 << 1,
41 kTextScaleX_DirtyBit = 1 << 2, 69 kTextScaleX_DirtyBit = 1 << 2,
42 kTextSkewX_DirtyBit = 1 << 3, 70 kTextSkewX_DirtyBit = 1 << 3,
43 kStrokeWidth_DirtyBit = 1 << 4, 71 kStrokeWidth_DirtyBit = 1 << 4,
44 kStrokeMiter_DirtyBit = 1 << 5, 72 kStrokeMiter_DirtyBit = 1 << 5,
45 73
46 kPOD_DirtyBitMask = 63, 74 kPOD_DirtyBitMask = 63,
47 75
(...skipping 16 matching lines...) Expand all
64 92
65 #ifdef SK_BUILD_FOR_ANDROID 93 #ifdef SK_BUILD_FOR_ANDROID
66 #define GEN_ID_INC fGenerationID++ 94 #define GEN_ID_INC fGenerationID++
67 #define GEN_ID_INC_EVAL(expression) if (expression) { fGenerationID++; } 95 #define GEN_ID_INC_EVAL(expression) if (expression) { fGenerationID++; }
68 #else 96 #else
69 #define GEN_ID_INC 97 #define GEN_ID_INC
70 #define GEN_ID_INC_EVAL(expression) 98 #define GEN_ID_INC_EVAL(expression)
71 #endif 99 #endif
72 100
73 SkPaint::SkPaint() { 101 SkPaint::SkPaint() {
74 fTypeface = NULL; 102 // set any non-zero values in fParts
75 fPathEffect = NULL;
76 fShader = NULL;
77 fXfermode = NULL;
78 fMaskFilter = NULL;
79 fColorFilter = NULL;
80 fRasterizer = NULL;
81 fLooper = NULL;
82 fImageFilter = NULL;
83 fAnnotation = NULL;
84 103
85 fTextSize = SkPaintDefaults_TextSize; 104 fParts.fTextSize = SkPaintDefaults_TextSize;
86 fTextScaleX = SK_Scalar1; 105 fParts.fTextScaleX = SK_Scalar1;
87 fTextSkewX = 0; 106 fParts.fColor = SK_ColorBLACK;
88 fColor = SK_ColorBLACK; 107 fParts.fMiterLimit = SkPaintDefaults_MiterLimit;
89 fWidth = 0;
90 fMiterLimit = SkPaintDefaults_MiterLimit;
91 108
92 // Zero all bitfields, then set some non-zero defaults. 109 fParts.fFlags = SkPaintDefaults_Flags;
93 fBitfields = 0; 110 fParts.fCapType = SkPaintParts::kDefault_Cap;
94 fFlags = SkPaintDefaults_Flags; 111 fParts.fJoinType = SkPaintParts::kDefault_Join;
95 fCapType = kDefault_Cap; 112 fParts.fTextAlign = SkPaintParts::kLeft_Align;
96 fJoinType = kDefault_Join; 113 fParts.fStyle = SkPaintParts::kFill_Style;
97 fTextAlign = kLeft_Align; 114 fParts.fTextEncoding = kUTF8_TextEncoding;
98 fStyle = kFill_Style; 115 fParts.fHinting = SkPaintDefaults_Hinting;
99 fTextEncoding = kUTF8_TextEncoding;
100 fHinting = SkPaintDefaults_Hinting;
101 116
102 fDirtyBits = 0; 117 fDirtyBits = 0;
103 #ifdef SK_BUILD_FOR_ANDROID 118 #ifdef SK_BUILD_FOR_ANDROID
104 new (&fPaintOptionsAndroid) SkPaintOptionsAndroid; 119 new (&fPaintOptionsAndroid) SkPaintOptionsAndroid;
105 fGenerationID = 0; 120 fGenerationID = 0;
106 #endif 121 #endif
107 } 122 }
108 123
109 SkPaint::SkPaint(const SkPaint& src) { 124 SkPaint::SkPaint(const SkPaint& src) {
110 #define COPY(field) field = src.field 125 #define COPY(field) fParts.field = src.fParts.field
111 #define REF_COPY(field) field = SkSafeRef(src.field) 126 #define REF_COPY(field) fParts.field = SkSafeRef(src.fParts.field)
112 127
113 REF_COPY(fTypeface); 128 REF_COPY(fTypeface);
114 REF_COPY(fPathEffect); 129 REF_COPY(fPathEffect);
115 REF_COPY(fShader); 130 REF_COPY(fShader);
116 REF_COPY(fXfermode); 131 REF_COPY(fXfermode);
117 REF_COPY(fMaskFilter); 132 REF_COPY(fMaskFilter);
118 REF_COPY(fColorFilter); 133 REF_COPY(fColorFilter);
119 REF_COPY(fRasterizer); 134 REF_COPY(fRasterizer);
120 REF_COPY(fLooper); 135 REF_COPY(fLooper);
121 REF_COPY(fImageFilter); 136 REF_COPY(fImageFilter);
122 REF_COPY(fAnnotation); 137 REF_COPY(fAnnotation);
123 138
124 COPY(fTextSize); 139 COPY(fTextSize);
125 COPY(fTextScaleX); 140 COPY(fTextScaleX);
126 COPY(fTextSkewX); 141 COPY(fTextSkewX);
127 COPY(fColor); 142 COPY(fColor);
128 COPY(fWidth); 143 COPY(fWidth);
129 COPY(fMiterLimit); 144 COPY(fMiterLimit);
130 COPY(fBitfields); 145 COPY(fBitfields);
131 COPY(fDirtyBits); 146
147 fDirtyBits = src.fDirtyBits;
132 148
133 #ifdef SK_BUILD_FOR_ANDROID 149 #ifdef SK_BUILD_FOR_ANDROID
134 new (&fPaintOptionsAndroid) SkPaintOptionsAndroid(src.fPaintOptionsAndroid); 150 new (&fPaintOptionsAndroid) SkPaintOptionsAndroid(src.fPaintOptionsAndroid);
135 COPY(fGenerationID); 151 COPY(fGenerationID);
136 #endif 152 #endif
137 153
138 #undef COPY 154 #undef COPY
139 #undef REF_COPY 155 #undef REF_COPY
140 } 156 }
141 157
142 SkPaint::~SkPaint() { 158 SkPaint::~SkPaint() {
143 SkSafeUnref(fTypeface); 159 SkSafeUnref(fParts.fTypeface);
144 SkSafeUnref(fPathEffect); 160 SkSafeUnref(fParts.fPathEffect);
145 SkSafeUnref(fShader); 161 SkSafeUnref(fParts.fShader);
146 SkSafeUnref(fXfermode); 162 SkSafeUnref(fParts.fXfermode);
147 SkSafeUnref(fMaskFilter); 163 SkSafeUnref(fParts.fMaskFilter);
148 SkSafeUnref(fColorFilter); 164 SkSafeUnref(fParts.fColorFilter);
149 SkSafeUnref(fRasterizer); 165 SkSafeUnref(fParts.fRasterizer);
150 SkSafeUnref(fLooper); 166 SkSafeUnref(fParts.fLooper);
151 SkSafeUnref(fImageFilter); 167 SkSafeUnref(fParts.fImageFilter);
152 SkSafeUnref(fAnnotation); 168 SkSafeUnref(fParts.fAnnotation);
153 } 169 }
154 170
155 SkPaint& SkPaint::operator=(const SkPaint& src) { 171 SkPaint& SkPaint::operator=(const SkPaint& src) {
156 #define COPY(field) field = src.field 172 #define COPY(field) fParts.field = src.fParts.field
157 #define REF_COPY(field) SkSafeUnref(field); field = SkSafeRef(src.field) 173 #define REF_COPY(field) SkSafeUnref(fParts.field); fParts.field = SkSafeRef(src. fParts.field)
158 174
159 SkASSERT(&src); 175 SkASSERT(&src);
160 176
161 REF_COPY(fTypeface); 177 REF_COPY(fTypeface);
162 REF_COPY(fPathEffect); 178 REF_COPY(fPathEffect);
163 REF_COPY(fShader); 179 REF_COPY(fShader);
164 REF_COPY(fXfermode); 180 REF_COPY(fXfermode);
165 REF_COPY(fMaskFilter); 181 REF_COPY(fMaskFilter);
166 REF_COPY(fColorFilter); 182 REF_COPY(fColorFilter);
167 REF_COPY(fRasterizer); 183 REF_COPY(fRasterizer);
168 REF_COPY(fLooper); 184 REF_COPY(fLooper);
169 REF_COPY(fImageFilter); 185 REF_COPY(fImageFilter);
170 REF_COPY(fAnnotation); 186 REF_COPY(fAnnotation);
171 187
172 COPY(fTextSize); 188 COPY(fTextSize);
173 COPY(fTextScaleX); 189 COPY(fTextScaleX);
174 COPY(fTextSkewX); 190 COPY(fTextSkewX);
175 COPY(fColor); 191 COPY(fColor);
176 COPY(fWidth); 192 COPY(fWidth);
177 COPY(fMiterLimit); 193 COPY(fMiterLimit);
178 COPY(fBitfields); 194 COPY(fBitfields);
179 COPY(fDirtyBits); 195
196 fDirtyBits = src.fDirtyBits;
180 197
181 #ifdef SK_BUILD_FOR_ANDROID 198 #ifdef SK_BUILD_FOR_ANDROID
182 fPaintOptionsAndroid.~SkPaintOptionsAndroid(); 199 fPaintOptionsAndroid.~SkPaintOptionsAndroid();
183 new (&fPaintOptionsAndroid) SkPaintOptionsAndroid(src.fPaintOptionsAndroid); 200 new (&fPaintOptionsAndroid) SkPaintOptionsAndroid(src.fPaintOptionsAndroid);
184 ++fGenerationID; 201 ++fGenerationID;
185 #endif 202 #endif
186 203
187 return *this; 204 return *this;
188 205
189 #undef COPY 206 #undef COPY
190 #undef REF_COPY 207 #undef REF_COPY
191 } 208 }
192 209
193 bool operator==(const SkPaint& a, const SkPaint& b) { 210 bool operator==(const SkPaint& a, const SkPaint& b) {
194 #define EQUAL(field) (a.field == b.field) 211 if (a.fParts != b.fParts) {
195 // Don't check fGenerationID or fDirtyBits, which can be different for logic ally equal paints. 212 return false;
196 return EQUAL(fTypeface) 213 }
197 && EQUAL(fPathEffect)
198 && EQUAL(fShader)
199 && EQUAL(fXfermode)
200 && EQUAL(fMaskFilter)
201 && EQUAL(fColorFilter)
202 && EQUAL(fRasterizer)
203 && EQUAL(fLooper)
204 && EQUAL(fImageFilter)
205 && EQUAL(fAnnotation)
206 && EQUAL(fTextSize)
207 && EQUAL(fTextScaleX)
208 && EQUAL(fTextSkewX)
209 && EQUAL(fColor)
210 && EQUAL(fWidth)
211 && EQUAL(fMiterLimit)
212 && EQUAL(fBitfields)
213 #ifdef SK_BUILD_FOR_ANDROID 214 #ifdef SK_BUILD_FOR_ANDROID
214 && EQUAL(fPaintOptionsAndroid) 215 if (fPaintOptionsAndroid != b.fPaintOptionsAndroid) {
216 return false;
217 }
215 #endif 218 #endif
216 ; 219 return true;
217 #undef EQUAL
218 } 220 }
219 221
220 void SkPaint::reset() { 222 void SkPaint::reset() {
221 SkPaint init; 223 SkPaint init;
222 224
223 #ifdef SK_BUILD_FOR_ANDROID 225 #ifdef SK_BUILD_FOR_ANDROID
224 uint32_t oldGenerationID = fGenerationID; 226 uint32_t oldGenerationID = fGenerationID;
225 #endif 227 #endif
226 *this = init; 228 *this = init;
227 #ifdef SK_BUILD_FOR_ANDROID 229 #ifdef SK_BUILD_FOR_ANDROID
(...skipping 20 matching lines...) Expand all
248 if (options != fPaintOptionsAndroid) { 250 if (options != fPaintOptionsAndroid) {
249 fPaintOptionsAndroid = options; 251 fPaintOptionsAndroid = options;
250 GEN_ID_INC; 252 GEN_ID_INC;
251 fDirtyBits |= kPaintOptionsAndroid_DirtyBit; 253 fDirtyBits |= kPaintOptionsAndroid_DirtyBit;
252 } 254 }
253 } 255 }
254 #endif 256 #endif
255 257
256 void SkPaint::setFilterLevel(FilterLevel level) { 258 void SkPaint::setFilterLevel(FilterLevel level) {
257 GEN_ID_INC_EVAL((unsigned) level != fFilterLevel); 259 GEN_ID_INC_EVAL((unsigned) level != fFilterLevel);
258 fFilterLevel = level; 260 fParts.setFilterLevel(static_cast<SkPaintParts::FilterLevel>(level));
259 } 261 }
260 262
261 void SkPaint::setHinting(Hinting hintingLevel) { 263 void SkPaint::setHinting(Hinting hintingLevel) {
262 GEN_ID_INC_EVAL((unsigned) hintingLevel != fHinting); 264 GEN_ID_INC_EVAL((unsigned) hintingLevel != fHinting);
263 fHinting = hintingLevel; 265 fParts.setHinting(static_cast<SkPaintParts::Hinting>(hintingLevel));
264 } 266 }
265 267
266 void SkPaint::setFlags(uint32_t flags) { 268 void SkPaint::setFlags(uint32_t flags) {
267 GEN_ID_INC_EVAL(fFlags != flags); 269 GEN_ID_INC_EVAL(fFlags != flags);
268 fFlags = flags; 270 fParts.setFlags(flags);
269 } 271 }
270 272
271 void SkPaint::setAntiAlias(bool doAA) { 273 void SkPaint::setAntiAlias(bool doAA) {
272 this->setFlags(SkSetClearMask(fFlags, doAA, kAntiAlias_Flag)); 274 this->setFlags(SkSetClearMask(fParts.getFlags(), doAA, kAntiAlias_Flag));
273 } 275 }
274 276
275 void SkPaint::setDither(bool doDither) { 277 void SkPaint::setDither(bool doDither) {
276 this->setFlags(SkSetClearMask(fFlags, doDither, kDither_Flag)); 278 this->setFlags(SkSetClearMask(fParts.getFlags(), doDither, kDither_Flag));
277 } 279 }
278 280
279 void SkPaint::setSubpixelText(bool doSubpixel) { 281 void SkPaint::setSubpixelText(bool doSubpixel) {
280 this->setFlags(SkSetClearMask(fFlags, doSubpixel, kSubpixelText_Flag)); 282 this->setFlags(SkSetClearMask(fParts.getFlags(), doSubpixel, kSubpixelText_F lag));
281 } 283 }
282 284
283 void SkPaint::setLCDRenderText(bool doLCDRender) { 285 void SkPaint::setLCDRenderText(bool doLCDRender) {
284 this->setFlags(SkSetClearMask(fFlags, doLCDRender, kLCDRenderText_Flag)); 286 this->setFlags(SkSetClearMask(fParts.getFlags(), doLCDRender, kLCDRenderText _Flag));
285 } 287 }
286 288
287 void SkPaint::setEmbeddedBitmapText(bool doEmbeddedBitmapText) { 289 void SkPaint::setEmbeddedBitmapText(bool doEmbeddedBitmapText) {
288 this->setFlags(SkSetClearMask(fFlags, doEmbeddedBitmapText, kEmbeddedBitmapT ext_Flag)); 290 this->setFlags(SkSetClearMask(fParts.getFlags(), doEmbeddedBitmapText, kEmbe ddedBitmapText_Flag));
289 } 291 }
290 292
291 void SkPaint::setAutohinted(bool useAutohinter) { 293 void SkPaint::setAutohinted(bool useAutohinter) {
292 this->setFlags(SkSetClearMask(fFlags, useAutohinter, kAutoHinting_Flag)); 294 this->setFlags(SkSetClearMask(fParts.getFlags(), useAutohinter, kAutoHinting _Flag));
293 } 295 }
294 296
295 void SkPaint::setLinearText(bool doLinearText) { 297 void SkPaint::setLinearText(bool doLinearText) {
296 this->setFlags(SkSetClearMask(fFlags, doLinearText, kLinearText_Flag)); 298 this->setFlags(SkSetClearMask(fParts.getFlags(), doLinearText, kLinearText_F lag));
297 } 299 }
298 300
299 void SkPaint::setVerticalText(bool doVertical) { 301 void SkPaint::setVerticalText(bool doVertical) {
300 this->setFlags(SkSetClearMask(fFlags, doVertical, kVerticalText_Flag)); 302 this->setFlags(SkSetClearMask(fParts.getFlags(), doVertical, kVerticalText_F lag));
301 } 303 }
302 304
303 void SkPaint::setUnderlineText(bool doUnderline) { 305 void SkPaint::setUnderlineText(bool doUnderline) {
304 this->setFlags(SkSetClearMask(fFlags, doUnderline, kUnderlineText_Flag)); 306 this->setFlags(SkSetClearMask(fParts.getFlags(), doUnderline, kUnderlineText _Flag));
305 } 307 }
306 308
307 void SkPaint::setStrikeThruText(bool doStrikeThru) { 309 void SkPaint::setStrikeThruText(bool doStrikeThru) {
308 this->setFlags(SkSetClearMask(fFlags, doStrikeThru, kStrikeThruText_Flag)); 310 this->setFlags(SkSetClearMask(fParts.getFlags(), doStrikeThru, kStrikeThruTe xt_Flag));
309 } 311 }
310 312
311 void SkPaint::setFakeBoldText(bool doFakeBold) { 313 void SkPaint::setFakeBoldText(bool doFakeBold) {
312 this->setFlags(SkSetClearMask(fFlags, doFakeBold, kFakeBoldText_Flag)); 314 this->setFlags(SkSetClearMask(fParts.getFlags(), doFakeBold, kFakeBoldText_F lag));
313 } 315 }
314 316
315 void SkPaint::setDevKernText(bool doDevKern) { 317 void SkPaint::setDevKernText(bool doDevKern) {
316 this->setFlags(SkSetClearMask(fFlags, doDevKern, kDevKernText_Flag)); 318 this->setFlags(SkSetClearMask(fParts.getFlags(), doDevKern, kDevKernText_Fla g));
317 } 319 }
318 320
319 void SkPaint::setDistanceFieldTextTEMP(bool doDistanceFieldText) { 321 void SkPaint::setDistanceFieldTextTEMP(bool doDistanceFieldText) {
320 this->setFlags(SkSetClearMask(fFlags, doDistanceFieldText, kDistanceFieldTex tTEMP_Flag)); 322 this->setFlags(SkSetClearMask(fParts.getFlags(), doDistanceFieldText, kDista nceFieldTextTEMP_Flag));
321 } 323 }
322 324
323 void SkPaint::setStyle(Style style) { 325 void SkPaint::setStyle(Style style) {
324 if ((unsigned)style < kStyleCount) { 326 if ((unsigned)style < kStyleCount) {
325 GEN_ID_INC_EVAL((unsigned)style != fStyle); 327 GEN_ID_INC_EVAL((unsigned)style != fStyle);
326 fStyle = style; 328 fParts.setStyle(static_cast<SkPaintParts::Style>(style));
327 } else { 329 } else {
328 #ifdef SK_REPORT_API_RANGE_CHECK 330 #ifdef SK_REPORT_API_RANGE_CHECK
329 SkDebugf("SkPaint::setStyle(%d) out of range\n", style); 331 SkDebugf("SkPaint::setStyle(%d) out of range\n", style);
330 #endif 332 #endif
331 } 333 }
332 } 334 }
333 335
334 void SkPaint::setColor(SkColor color) { 336 void SkPaint::setColor(SkColor color) {
335 GEN_ID_INC_EVAL(color != fColor); 337 GEN_ID_INC_EVAL(color != fColor);
336 fColor = color; 338 fParts.setColor(color);
337 fDirtyBits |= kColor_DirtyBit; 339 fDirtyBits |= kColor_DirtyBit;
338 } 340 }
339 341
340 void SkPaint::setAlpha(U8CPU a) { 342 void SkPaint::setAlpha(U8CPU a) {
341 this->setColor(SkColorSetARGB(a, SkColorGetR(fColor), 343 const SkColor c = fParts.getColor();
342 SkColorGetG(fColor), SkColorGetB(fColor))); 344 this->setColor(SkColorSetARGB(a, SkColorGetR(c), SkColorGetG(c), SkColorGetB (c)));
343 } 345 }
344 346
345 void SkPaint::setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) { 347 void SkPaint::setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
346 this->setColor(SkColorSetARGB(a, r, g, b)); 348 this->setColor(SkColorSetARGB(a, r, g, b));
347 } 349 }
348 350
349 void SkPaint::setStrokeWidth(SkScalar width) { 351 void SkPaint::setStrokeWidth(SkScalar width) {
350 if (width >= 0) { 352 if (width >= 0) {
351 GEN_ID_INC_EVAL(width != fWidth); 353 GEN_ID_INC_EVAL(width != fWidth);
352 fWidth = width; 354 fParts.setStrokeWidth(width);
353 fDirtyBits |= kStrokeWidth_DirtyBit; 355 fDirtyBits |= kStrokeWidth_DirtyBit;
354 } else { 356 } else {
355 #ifdef SK_REPORT_API_RANGE_CHECK 357 #ifdef SK_REPORT_API_RANGE_CHECK
356 SkDebugf("SkPaint::setStrokeWidth() called with negative value\n"); 358 SkDebugf("SkPaint::setStrokeWidth() called with negative value\n");
357 #endif 359 #endif
358 } 360 }
359 } 361 }
360 362
361 void SkPaint::setStrokeMiter(SkScalar limit) { 363 void SkPaint::setStrokeMiter(SkScalar limit) {
362 if (limit >= 0) { 364 if (limit >= 0) {
363 GEN_ID_INC_EVAL(limit != fMiterLimit); 365 GEN_ID_INC_EVAL(limit != fMiterLimit);
364 fMiterLimit = limit; 366 fParts.setStrokeMiter(limit);
365 fDirtyBits |= kStrokeMiter_DirtyBit; 367 fDirtyBits |= kStrokeMiter_DirtyBit;
366 } else { 368 } else {
367 #ifdef SK_REPORT_API_RANGE_CHECK 369 #ifdef SK_REPORT_API_RANGE_CHECK
368 SkDebugf("SkPaint::setStrokeMiter() called with negative value\n"); 370 SkDebugf("SkPaint::setStrokeMiter() called with negative value\n");
369 #endif 371 #endif
370 } 372 }
371 } 373 }
372 374
373 void SkPaint::setStrokeCap(Cap ct) { 375 void SkPaint::setStrokeCap(Cap ct) {
374 if ((unsigned)ct < kCapCount) { 376 if ((unsigned)ct < kCapCount) {
375 GEN_ID_INC_EVAL((unsigned)ct != fCapType); 377 GEN_ID_INC_EVAL((unsigned)ct != fCapType);
376 fCapType = SkToU8(ct); 378 fParts.setStrokeCap(static_cast<SkPaintParts::Cap>(ct));
377 } else { 379 } else {
378 #ifdef SK_REPORT_API_RANGE_CHECK 380 #ifdef SK_REPORT_API_RANGE_CHECK
379 SkDebugf("SkPaint::setStrokeCap(%d) out of range\n", ct); 381 SkDebugf("SkPaint::setStrokeCap(%d) out of range\n", ct);
380 #endif 382 #endif
381 } 383 }
382 } 384 }
383 385
384 void SkPaint::setStrokeJoin(Join jt) { 386 void SkPaint::setStrokeJoin(Join jt) {
385 if ((unsigned)jt < kJoinCount) { 387 if ((unsigned)jt < kJoinCount) {
386 GEN_ID_INC_EVAL((unsigned)jt != fJoinType); 388 GEN_ID_INC_EVAL((unsigned)jt != fJoinType);
387 fJoinType = SkToU8(jt); 389 fParts.setStrokeJoin(static_cast<SkPaintParts::Join>(jt));
388 } else { 390 } else {
389 #ifdef SK_REPORT_API_RANGE_CHECK 391 #ifdef SK_REPORT_API_RANGE_CHECK
390 SkDebugf("SkPaint::setStrokeJoin(%d) out of range\n", jt); 392 SkDebugf("SkPaint::setStrokeJoin(%d) out of range\n", jt);
391 #endif 393 #endif
392 } 394 }
393 } 395 }
394 396
395 /////////////////////////////////////////////////////////////////////////////// 397 ///////////////////////////////////////////////////////////////////////////////
396 398
397 void SkPaint::setTextAlign(Align align) { 399 void SkPaint::setTextAlign(Align align) {
398 if ((unsigned)align < kAlignCount) { 400 if ((unsigned)align < kAlignCount) {
399 GEN_ID_INC_EVAL((unsigned)align != fTextAlign); 401 GEN_ID_INC_EVAL((unsigned)align != fTextAlign);
400 fTextAlign = SkToU8(align); 402 fParts.setTextAlign(static_cast<SkPaintParts::Align>(align));
401 } else { 403 } else {
402 #ifdef SK_REPORT_API_RANGE_CHECK 404 #ifdef SK_REPORT_API_RANGE_CHECK
403 SkDebugf("SkPaint::setTextAlign(%d) out of range\n", align); 405 SkDebugf("SkPaint::setTextAlign(%d) out of range\n", align);
404 #endif 406 #endif
405 } 407 }
406 } 408 }
407 409
408 void SkPaint::setTextSize(SkScalar ts) { 410 void SkPaint::setTextSize(SkScalar ts) {
409 if (ts >= 0) { 411 if (ts >= 0) {
410 GEN_ID_INC_EVAL(ts != fTextSize); 412 GEN_ID_INC_EVAL(ts != fTextSize);
411 fTextSize = ts; 413 fParts.setTextSize(ts);
412 fDirtyBits |= kTextSize_DirtyBit; 414 fDirtyBits |= kTextSize_DirtyBit;
413 } else { 415 } else {
414 #ifdef SK_REPORT_API_RANGE_CHECK 416 #ifdef SK_REPORT_API_RANGE_CHECK
415 SkDebugf("SkPaint::setTextSize() called with negative value\n"); 417 SkDebugf("SkPaint::setTextSize() called with negative value\n");
416 #endif 418 #endif
417 } 419 }
418 } 420 }
419 421
420 void SkPaint::setTextScaleX(SkScalar scaleX) { 422 void SkPaint::setTextScaleX(SkScalar scaleX) {
421 GEN_ID_INC_EVAL(scaleX != fTextScaleX); 423 GEN_ID_INC_EVAL(scaleX != fTextScaleX);
422 fTextScaleX = scaleX; 424 fParts.setTextScaleX(scaleX);
423 fDirtyBits |= kTextScaleX_DirtyBit; 425 fDirtyBits |= kTextScaleX_DirtyBit;
424 } 426 }
425 427
426 void SkPaint::setTextSkewX(SkScalar skewX) { 428 void SkPaint::setTextSkewX(SkScalar skewX) {
427 GEN_ID_INC_EVAL(skewX != fTextSkewX); 429 GEN_ID_INC_EVAL(skewX != fTextSkewX);
428 fTextSkewX = skewX; 430 fParts.setTextSkewX(skewX);
429 fDirtyBits |= kTextSkewX_DirtyBit; 431 fDirtyBits |= kTextSkewX_DirtyBit;
430 } 432 }
431 433
432 void SkPaint::setTextEncoding(TextEncoding encoding) { 434 void SkPaint::setTextEncoding(TextEncoding encoding) {
433 if ((unsigned)encoding <= kGlyphID_TextEncoding) { 435 if ((unsigned)encoding <= kGlyphID_TextEncoding) {
434 GEN_ID_INC_EVAL((unsigned)encoding != fTextEncoding); 436 GEN_ID_INC_EVAL((unsigned)encoding != fTextEncoding);
435 fTextEncoding = encoding; 437 fParts.setTextEncoding(static_cast<SkPaintParts::TextEncoding>(encoding) );
436 } else { 438 } else {
437 #ifdef SK_REPORT_API_RANGE_CHECK 439 #ifdef SK_REPORT_API_RANGE_CHECK
438 SkDebugf("SkPaint::setTextEncoding(%d) out of range\n", encoding); 440 SkDebugf("SkPaint::setTextEncoding(%d) out of range\n", encoding);
439 #endif 441 #endif
440 } 442 }
441 } 443 }
442 444
443 /////////////////////////////////////////////////////////////////////////////// 445 ///////////////////////////////////////////////////////////////////////////////
444 446
445 // Returns dst with the given bitmask enabled or disabled, depending on value. 447 // Returns dst with the given bitmask enabled or disabled, depending on value.
446 inline static uint32_t set_mask(uint32_t dst, uint32_t bitmask, bool value) { 448 inline static uint32_t set_mask(uint32_t dst, uint32_t bitmask, bool value) {
447 return value ? (dst | bitmask) : (dst & ~bitmask); 449 return value ? (dst | bitmask) : (dst & ~bitmask);
448 } 450 }
449 451
450 SkTypeface* SkPaint::setTypeface(SkTypeface* font) { 452 SkTypeface* SkPaint::setTypeface(SkTypeface* font) {
451 SkRefCnt_SafeAssign(fTypeface, font);
452 GEN_ID_INC; 453 GEN_ID_INC;
454 SkPaintParts_SafeAssign(fTypeface, font);
453 fDirtyBits = set_mask(fDirtyBits, kTypeface_DirtyBit, font != NULL); 455 fDirtyBits = set_mask(fDirtyBits, kTypeface_DirtyBit, font != NULL);
454 return font; 456 return font;
455 } 457 }
456 458
457 SkRasterizer* SkPaint::setRasterizer(SkRasterizer* r) { 459 SkRasterizer* SkPaint::setRasterizer(SkRasterizer* r) {
458 SkRefCnt_SafeAssign(fRasterizer, r);
459 GEN_ID_INC; 460 GEN_ID_INC;
461 SkPaintParts_SafeAssign(fRasterizer, r);
460 fDirtyBits = set_mask(fDirtyBits, kRasterizer_DirtyBit, r != NULL); 462 fDirtyBits = set_mask(fDirtyBits, kRasterizer_DirtyBit, r != NULL);
461 return r; 463 return r;
462 } 464 }
463 465
464 SkDrawLooper* SkPaint::setLooper(SkDrawLooper* looper) { 466 SkDrawLooper* SkPaint::setLooper(SkDrawLooper* looper) {
465 SkRefCnt_SafeAssign(fLooper, looper);
466 GEN_ID_INC; 467 GEN_ID_INC;
468 SkPaintParts_SafeAssign(fLooper, looper);
467 fDirtyBits = set_mask(fDirtyBits, kLooper_DirtyBit, looper != NULL); 469 fDirtyBits = set_mask(fDirtyBits, kLooper_DirtyBit, looper != NULL);
468 return looper; 470 return looper;
469 } 471 }
470 472
471 SkImageFilter* SkPaint::setImageFilter(SkImageFilter* imageFilter) { 473 SkImageFilter* SkPaint::setImageFilter(SkImageFilter* imageFilter) {
472 SkRefCnt_SafeAssign(fImageFilter, imageFilter);
473 GEN_ID_INC; 474 GEN_ID_INC;
475 SkPaintParts_SafeAssign(fImageFilter, imageFilter);
474 fDirtyBits = set_mask(fDirtyBits, kImageFilter_DirtyBit, imageFilter != NULL ); 476 fDirtyBits = set_mask(fDirtyBits, kImageFilter_DirtyBit, imageFilter != NULL );
475 return imageFilter; 477 return imageFilter;
476 } 478 }
477 479
478 SkAnnotation* SkPaint::setAnnotation(SkAnnotation* annotation) { 480 SkAnnotation* SkPaint::setAnnotation(SkAnnotation* annotation) {
479 SkRefCnt_SafeAssign(fAnnotation, annotation);
480 GEN_ID_INC; 481 GEN_ID_INC;
482 SkPaintParts_SafeAssign(fAnnotation, annotation);
481 fDirtyBits = set_mask(fDirtyBits, kAnnotation_DirtyBit, annotation != NULL); 483 fDirtyBits = set_mask(fDirtyBits, kAnnotation_DirtyBit, annotation != NULL);
482 return annotation; 484 return annotation;
483 } 485 }
484 486
485 /////////////////////////////////////////////////////////////////////////////// 487 ///////////////////////////////////////////////////////////////////////////////
486 488
487 static SkScalar mag2(SkScalar x, SkScalar y) { 489 static SkScalar mag2(SkScalar x, SkScalar y) {
488 return x * x + y * y; 490 return x * x + y * y;
489 } 491 }
490 492
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 sk_getMetrics_utf32_00, 954 sk_getMetrics_utf32_00,
953 sk_getMetrics_glyph_00, 955 sk_getMetrics_glyph_00,
954 956
955 sk_getMetrics_utf8_xy, 957 sk_getMetrics_utf8_xy,
956 sk_getMetrics_utf16_xy, 958 sk_getMetrics_utf16_xy,
957 sk_getMetrics_utf32_xy, 959 sk_getMetrics_utf32_xy,
958 sk_getMetrics_glyph_xy 960 sk_getMetrics_glyph_xy
959 }; 961 };
960 962
961 unsigned index = this->getTextEncoding(); 963 unsigned index = this->getTextEncoding();
962 if (fFlags & kSubpixelText_Flag) { 964 if (this->getFlags() & kSubpixelText_Flag) {
963 index += 4; 965 index += 4;
964 } 966 }
965 967
966 SkASSERT(index < SK_ARRAY_COUNT(gDrawCacheProcs)); 968 SkASSERT(index < SK_ARRAY_COUNT(gDrawCacheProcs));
967 return gDrawCacheProcs[index]; 969 return gDrawCacheProcs[index];
968 } 970 }
969 971
970 /////////////////////////////////////////////////////////////////////////////// 972 ///////////////////////////////////////////////////////////////////////////////
971 973
972 #define TEXT_AS_PATHS_PAINT_FLAGS_TO_IGNORE ( \ 974 #define TEXT_AS_PATHS_PAINT_FLAGS_TO_IGNORE ( \
973 SkPaint::kDevKernText_Flag | \ 975 SkPaint::kDevKernText_Flag | \
974 SkPaint::kLinearText_Flag | \ 976 SkPaint::kLinearText_Flag | \
975 SkPaint::kLCDRenderText_Flag | \ 977 SkPaint::kLCDRenderText_Flag | \
976 SkPaint::kEmbeddedBitmapText_Flag | \ 978 SkPaint::kEmbeddedBitmapText_Flag | \
977 SkPaint::kAutoHinting_Flag | \ 979 SkPaint::kAutoHinting_Flag | \
978 SkPaint::kGenA8FromLCD_Flag ) 980 SkPaint::kGenA8FromLCD_Flag )
979 981
980 SkScalar SkPaint::setupForAsPaths() { 982 SkScalar SkPaint::setupForAsPaths() {
981 uint32_t flags = this->getFlags(); 983 uint32_t flags = this->getFlags();
982 // clear the flags we don't care about 984 // clear the flags we don't care about
983 flags &= ~TEXT_AS_PATHS_PAINT_FLAGS_TO_IGNORE; 985 flags &= ~TEXT_AS_PATHS_PAINT_FLAGS_TO_IGNORE;
984 // set the flags we do care about 986 // set the flags we do care about
985 flags |= SkPaint::kSubpixelText_Flag; 987 flags |= SkPaint::kSubpixelText_Flag;
986 988
987 this->setFlags(flags); 989 this->setFlags(flags);
988 this->setHinting(SkPaint::kNo_Hinting); 990 this->setHinting(SkPaint::kNo_Hinting);
989 991
990 SkScalar textSize = fTextSize; 992 SkScalar textSize = this->getTextSize();
991 this->setTextSize(kCanonicalTextSizeForPaths); 993 this->setTextSize(kCanonicalTextSizeForPaths);
992 return textSize / kCanonicalTextSizeForPaths; 994 return textSize / kCanonicalTextSizeForPaths;
993 } 995 }
994 996
995 class SkCanonicalizePaint { 997 class SkCanonicalizePaint {
996 public: 998 public:
997 SkCanonicalizePaint(const SkPaint& paint) : fPaint(&paint), fScale(0) { 999 SkCanonicalizePaint(const SkPaint& paint) : fPaint(&paint), fScale(0) {
998 if (paint.isLinearText() || paint.tooBigToUseCache()) { 1000 if (paint.isLinearText() || paint.tooBigToUseCache()) {
999 SkPaint* p = fLazy.set(paint); 1001 SkPaint* p = fLazy.set(paint);
1000 fScale = p->setupForAsPaths(); 1002 fScale = p->setupForAsPaths();
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 size_t SkPaint::breakText(const void* textD, size_t length, SkScalar maxWidth, 1198 size_t SkPaint::breakText(const void* textD, size_t length, SkScalar maxWidth,
1197 SkScalar* measuredWidth, 1199 SkScalar* measuredWidth,
1198 TextBufferDirection tbd) const { 1200 TextBufferDirection tbd) const {
1199 if (0 == length || 0 >= maxWidth) { 1201 if (0 == length || 0 >= maxWidth) {
1200 if (measuredWidth) { 1202 if (measuredWidth) {
1201 *measuredWidth = 0; 1203 *measuredWidth = 0;
1202 } 1204 }
1203 return 0; 1205 return 0;
1204 } 1206 }
1205 1207
1206 if (0 == fTextSize) { 1208 if (0 == this->getTextSize()) {
1207 if (measuredWidth) { 1209 if (measuredWidth) {
1208 *measuredWidth = 0; 1210 *measuredWidth = 0;
1209 } 1211 }
1210 return length; 1212 return length;
1211 } 1213 }
1212 1214
1213 SkASSERT(textD != NULL); 1215 SkASSERT(textD != NULL);
1214 const char* text = (const char*)textD; 1216 const char* text = (const char*)textD;
1215 1217
1216 SkCanonicalizePaint canon(*this); 1218 SkCanonicalizePaint canon(*this);
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1938 1940
1939 SkASSERT(descSize == desc1->getLength()); 1941 SkASSERT(descSize == desc1->getLength());
1940 SkASSERT(descSize == desc2->getLength()); 1942 SkASSERT(descSize == desc2->getLength());
1941 desc1->computeChecksum(); 1943 desc1->computeChecksum();
1942 desc2->computeChecksum(); 1944 desc2->computeChecksum();
1943 SkASSERT(!memcmp(desc, desc1, descSize)); 1945 SkASSERT(!memcmp(desc, desc1, descSize));
1944 SkASSERT(!memcmp(desc, desc2, descSize)); 1946 SkASSERT(!memcmp(desc, desc2, descSize));
1945 } 1947 }
1946 #endif 1948 #endif
1947 1949
1948 proc(fTypeface, desc, context); 1950 proc(this->getTypeface(), desc, context);
1949 } 1951 }
1950 1952
1951 SkGlyphCache* SkPaint::detachCache(const SkDeviceProperties* deviceProperties, 1953 SkGlyphCache* SkPaint::detachCache(const SkDeviceProperties* deviceProperties,
1952 const SkMatrix* deviceMatrix) const { 1954 const SkMatrix* deviceMatrix) const {
1953 SkGlyphCache* cache; 1955 SkGlyphCache* cache;
1954 this->descriptorProc(deviceProperties, deviceMatrix, DetachDescProc, &cache, false); 1956 this->descriptorProc(deviceProperties, deviceMatrix, DetachDescProc, &cache, false);
1955 return cache; 1957 return cache;
1956 } 1958 }
1957 1959
1958 /** 1960 /**
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 if (flatFlags & kHasEffects_FlatFlag) { 2142 if (flatFlags & kHasEffects_FlatFlag) {
2141 buffer.writeFlattenable(this->getPathEffect()); 2143 buffer.writeFlattenable(this->getPathEffect());
2142 buffer.writeFlattenable(this->getShader()); 2144 buffer.writeFlattenable(this->getShader());
2143 buffer.writeFlattenable(this->getXfermode()); 2145 buffer.writeFlattenable(this->getXfermode());
2144 buffer.writeFlattenable(this->getMaskFilter()); 2146 buffer.writeFlattenable(this->getMaskFilter());
2145 buffer.writeFlattenable(this->getColorFilter()); 2147 buffer.writeFlattenable(this->getColorFilter());
2146 buffer.writeFlattenable(this->getRasterizer()); 2148 buffer.writeFlattenable(this->getRasterizer());
2147 buffer.writeFlattenable(this->getLooper()); 2149 buffer.writeFlattenable(this->getLooper());
2148 buffer.writeFlattenable(this->getImageFilter()); 2150 buffer.writeFlattenable(this->getImageFilter());
2149 2151
2150 if (fAnnotation) { 2152 if (this->getAnnotation()) {
2151 buffer.writeBool(true); 2153 buffer.writeBool(true);
2152 fAnnotation->writeToBuffer(buffer); 2154 this->getAnnotation()->writeToBuffer(buffer);
2153 } else { 2155 } else {
2154 buffer.writeBool(false); 2156 buffer.writeBool(false);
2155 } 2157 }
2156 } 2158 }
2157 #ifdef SK_BUILD_FOR_ANDROID 2159 #ifdef SK_BUILD_FOR_ANDROID
2158 if (flatFlags & kHasNonDefaultPaintOptionsAndroid_FlatFlag) { 2160 if (flatFlags & kHasNonDefaultPaintOptionsAndroid_FlatFlag) {
2159 this->getPaintOptionsAndroid().flatten(buffer); 2161 this->getPaintOptionsAndroid().flatten(buffer);
2160 } 2162 }
2161 #endif 2163 #endif
2162 } 2164 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2227 #ifdef SK_BUILD_FOR_ANDROID 2229 #ifdef SK_BUILD_FOR_ANDROID
2228 this->setPaintOptionsAndroid(options); 2230 this->setPaintOptionsAndroid(options);
2229 #endif 2231 #endif
2230 } 2232 }
2231 } 2233 }
2232 2234
2233 /////////////////////////////////////////////////////////////////////////////// 2235 ///////////////////////////////////////////////////////////////////////////////
2234 2236
2235 SkShader* SkPaint::setShader(SkShader* shader) { 2237 SkShader* SkPaint::setShader(SkShader* shader) {
2236 GEN_ID_INC_EVAL(shader != fShader); 2238 GEN_ID_INC_EVAL(shader != fShader);
2237 SkRefCnt_SafeAssign(fShader, shader); 2239 SkPaintParts_SafeAssign(fShader, shader);
2238 fDirtyBits = set_mask(fDirtyBits, kShader_DirtyBit, shader != NULL); 2240 fDirtyBits = set_mask(fDirtyBits, kShader_DirtyBit, shader != NULL);
2239 return shader; 2241 return shader;
2240 } 2242 }
2241 2243
2242 SkColorFilter* SkPaint::setColorFilter(SkColorFilter* filter) { 2244 SkColorFilter* SkPaint::setColorFilter(SkColorFilter* filter) {
2243 GEN_ID_INC_EVAL(filter != fColorFilter); 2245 GEN_ID_INC_EVAL(filter != fColorFilter);
2244 SkRefCnt_SafeAssign(fColorFilter, filter); 2246 SkPaintParts_SafeAssign(fColorFilter, filter);
2245 fDirtyBits = set_mask(fDirtyBits, kColorFilter_DirtyBit, filter != NULL); 2247 fDirtyBits = set_mask(fDirtyBits, kColorFilter_DirtyBit, filter != NULL);
2246 return filter; 2248 return filter;
2247 } 2249 }
2248 2250
2249 SkXfermode* SkPaint::setXfermode(SkXfermode* mode) { 2251 SkXfermode* SkPaint::setXfermode(SkXfermode* mode) {
2250 GEN_ID_INC_EVAL(mode != fXfermode); 2252 GEN_ID_INC_EVAL(mode != fXfermode);
2251 SkRefCnt_SafeAssign(fXfermode, mode); 2253 SkPaintParts_SafeAssign(fXfermode, mode);
2252 fDirtyBits = set_mask(fDirtyBits, kXfermode_DirtyBit, mode != NULL); 2254 fDirtyBits = set_mask(fDirtyBits, kXfermode_DirtyBit, mode != NULL);
2253 return mode; 2255 return mode;
2254 } 2256 }
2255 2257
2256 SkXfermode* SkPaint::setXfermodeMode(SkXfermode::Mode mode) { 2258 SkXfermode* SkPaint::setXfermodeMode(SkXfermode::Mode mode) {
2257 SkSafeUnref(fXfermode); 2259 SkSafeUnref(fParts.fXfermode);
2258 fXfermode = SkXfermode::Create(mode); 2260 fParts.fXfermode = SkXfermode::Create(mode);
2259 GEN_ID_INC; 2261 GEN_ID_INC;
2260 fDirtyBits = set_mask(fDirtyBits, kXfermode_DirtyBit, fXfermode != NULL); 2262 fDirtyBits = set_mask(fDirtyBits, kXfermode_DirtyBit, fParts.fXfermode != NU LL);
2261 return fXfermode; 2263 return fParts.fXfermode;
2262 } 2264 }
2263 2265
2264 SkPathEffect* SkPaint::setPathEffect(SkPathEffect* effect) { 2266 SkPathEffect* SkPaint::setPathEffect(SkPathEffect* effect) {
2265 GEN_ID_INC_EVAL(effect != fPathEffect); 2267 GEN_ID_INC_EVAL(effect != fPathEffect);
2266 SkRefCnt_SafeAssign(fPathEffect, effect); 2268 SkPaintParts_SafeAssign(fPathEffect, effect);
2267 fDirtyBits = set_mask(fDirtyBits, kPathEffect_DirtyBit, effect != NULL); 2269 fDirtyBits = set_mask(fDirtyBits, kPathEffect_DirtyBit, effect != NULL);
2268 return effect; 2270 return effect;
2269 } 2271 }
2270 2272
2271 SkMaskFilter* SkPaint::setMaskFilter(SkMaskFilter* filter) { 2273 SkMaskFilter* SkPaint::setMaskFilter(SkMaskFilter* filter) {
2272 GEN_ID_INC_EVAL(filter != fMaskFilter); 2274 GEN_ID_INC_EVAL(filter != fMaskFilter);
2273 SkRefCnt_SafeAssign(fMaskFilter, filter); 2275 SkPaintParts_SafeAssign(fMaskFilter, filter);
2274 fDirtyBits = set_mask(fDirtyBits, kMaskFilter_DirtyBit, filter != NULL); 2276 fDirtyBits = set_mask(fDirtyBits, kMaskFilter_DirtyBit, filter != NULL);
2275 return filter; 2277 return filter;
2276 } 2278 }
2277 2279
2278 /////////////////////////////////////////////////////////////////////////////// 2280 ///////////////////////////////////////////////////////////////////////////////
2279 2281
2280 bool SkPaint::getFillPath(const SkPath& src, SkPath* dst, 2282 bool SkPaint::getFillPath(const SkPath& src, SkPath* dst,
2281 const SkRect* cullRect) const { 2283 const SkRect* cullRect) const {
2282 SkStrokeRec rec(*this); 2284 SkStrokeRec rec(*this);
2283 2285
2284 const SkPath* srcPtr = &src; 2286 const SkPath* srcPtr = &src;
2285 SkPath tmpPath; 2287 SkPath tmpPath;
2286 2288
2287 if (fPathEffect && fPathEffect->filterPath(&tmpPath, src, &rec, cullRect)) { 2289 SkPathEffect* pe = this->getPathEffect();
2290 if (pe && pe->filterPath(&tmpPath, src, &rec, cullRect)) {
2288 srcPtr = &tmpPath; 2291 srcPtr = &tmpPath;
2289 } 2292 }
2290 2293
2291 if (!rec.applyToPath(dst, *srcPtr)) { 2294 if (!rec.applyToPath(dst, *srcPtr)) {
2292 if (srcPtr == &tmpPath) { 2295 if (srcPtr == &tmpPath) {
2293 // If path's were copy-on-write, this trick would not be needed. 2296 // If path's were copy-on-write, this trick would not be needed.
2294 // As it is, we want to save making a deep-copy from tmpPath -> dst 2297 // As it is, we want to save making a deep-copy from tmpPath -> dst
2295 // since we know we're just going to delete tmpPath when we return, 2298 // since we know we're just going to delete tmpPath when we return,
2296 // so the swap saves that copy. 2299 // so the swap saves that copy.
2297 dst->swap(tmpPath); 2300 dst->swap(tmpPath);
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
2614 *xpos = fXPos; 2617 *xpos = fXPos;
2615 } 2618 }
2616 return true; 2619 return true;
2617 } 2620 }
2618 return false; 2621 return false;
2619 } 2622 }
2620 2623
2621 /////////////////////////////////////////////////////////////////////////////// 2624 ///////////////////////////////////////////////////////////////////////////////
2622 2625
2623 bool SkPaint::nothingToDraw() const { 2626 bool SkPaint::nothingToDraw() const {
2624 if (fLooper) { 2627 if (this->getLooper()) {
2625 return false; 2628 return false;
2626 } 2629 }
2627 SkXfermode::Mode mode; 2630 SkXfermode::Mode mode;
2628 if (SkXfermode::AsMode(fXfermode, &mode)) { 2631 if (SkXfermode::AsMode(this->getXfermode(), &mode)) {
2629 switch (mode) { 2632 switch (mode) {
2630 case SkXfermode::kSrcOver_Mode: 2633 case SkXfermode::kSrcOver_Mode:
2631 case SkXfermode::kSrcATop_Mode: 2634 case SkXfermode::kSrcATop_Mode:
2632 case SkXfermode::kDstOut_Mode: 2635 case SkXfermode::kDstOut_Mode:
2633 case SkXfermode::kDstOver_Mode: 2636 case SkXfermode::kDstOver_Mode:
2634 case SkXfermode::kPlus_Mode: 2637 case SkXfermode::kPlus_Mode:
2635 return 0 == this->getAlpha(); 2638 return 0 == this->getAlpha();
2636 case SkXfermode::kDst_Mode: 2639 case SkXfermode::kDst_Mode:
2637 return true; 2640 return true;
2638 default: 2641 default:
2639 break; 2642 break;
2640 } 2643 }
2641 } 2644 }
2642 return false; 2645 return false;
2643 } 2646 }
2644 2647
2645 void SkPaint::setBitfields(uint32_t bitfields) { 2648 void SkPaint::setBitfields(uint32_t bitfields) {
2646 fBitfields = bitfields; 2649 fParts.fBitfields = bitfields;
2647 } 2650 }
2648 2651
2649 inline static unsigned popcount(uint8_t x) { 2652 inline static unsigned popcount(uint8_t x) {
2650 // As in Hacker's delight, adapted for just 8 bits. 2653 // As in Hacker's delight, adapted for just 8 bits.
2651 x = (x & 0x55) + ((x >> 1) & 0x55); // a b c d w x y z -> a+b c+d w+x y+z 2654 x = (x & 0x55) + ((x >> 1) & 0x55); // a b c d w x y z -> a+b c+d w+x y+z
2652 x = (x & 0x33) + ((x >> 2) & 0x33); // a+b c+d w+x y+z -> a+b+c+d w+x+y+z 2655 x = (x & 0x33) + ((x >> 2) & 0x33); // a+b c+d w+x y+z -> a+b+c+d w+x+y+z
2653 x = (x & 0x0F) + ((x >> 4) & 0x0F); // a+b+c+d w+x+y+z -> a+b+c+d+w+x+y+z 2656 x = (x & 0x0F) + ((x >> 4) & 0x0F); // a+b+c+d w+x+y+z -> a+b+c+d+w+x+y+z
2654 return x; 2657 return x;
2655 } 2658 }
2656 2659
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2728 } 2731 }
2729 #ifdef SK_BUILD_FOR_ANDROID 2732 #ifdef SK_BUILD_FOR_ANDROID
2730 if (dirty & kPaintOptionsAndroid_DirtyBit) { 2733 if (dirty & kPaintOptionsAndroid_DirtyBit) {
2731 SkPaintOptionsAndroid options; 2734 SkPaintOptionsAndroid options;
2732 options.unflatten(buffer); 2735 options.unflatten(buffer);
2733 paint->setPaintOptionsAndroid(options); 2736 paint->setPaintOptionsAndroid(options);
2734 } 2737 }
2735 #endif 2738 #endif
2736 SkASSERT(dirty == paint->fDirtyBits); 2739 SkASSERT(dirty == paint->fDirtyBits);
2737 } 2740 }
OLDNEW
« no previous file with comments | « include/core/SkPaintParts.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698