OLD | NEW |
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 21 matching lines...) Expand all Loading... |
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 this to get a printf for out-of-range parameter in setters | 38 // define this to get a printf for out-of-range parameter in setters |
39 // e.g. setTextSize(-1) | 39 // e.g. setTextSize(-1) |
40 //#define SK_REPORT_API_RANGE_CHECK | 40 //#define SK_REPORT_API_RANGE_CHECK |
41 | 41 |
42 #ifdef SK_BUILD_FOR_ANDROID | |
43 #define GEN_ID_INC fGenerationID++ | |
44 #define GEN_ID_INC_EVAL(expression) if (expression) { fGenerationID++; } | |
45 #else | |
46 #define GEN_ID_INC | |
47 #define GEN_ID_INC_EVAL(expression) | |
48 #endif | |
49 | |
50 SkPaint::SkPaint() { | 42 SkPaint::SkPaint() { |
51 fTypeface = NULL; | 43 fTypeface = NULL; |
52 fPathEffect = NULL; | 44 fPathEffect = NULL; |
53 fShader = NULL; | 45 fShader = NULL; |
54 fXfermode = NULL; | 46 fXfermode = NULL; |
55 fMaskFilter = NULL; | 47 fMaskFilter = NULL; |
56 fColorFilter = NULL; | 48 fColorFilter = NULL; |
57 fRasterizer = NULL; | 49 fRasterizer = NULL; |
58 fLooper = NULL; | 50 fLooper = NULL; |
59 fImageFilter = NULL; | 51 fImageFilter = NULL; |
60 fAnnotation = NULL; | 52 fAnnotation = NULL; |
61 | 53 |
62 fTextSize = SkPaintDefaults_TextSize; | 54 fTextSize = SkPaintDefaults_TextSize; |
63 fTextScaleX = SK_Scalar1; | 55 fTextScaleX = SK_Scalar1; |
64 fTextSkewX = 0; | 56 fTextSkewX = 0; |
65 fColor = SK_ColorBLACK; | 57 fColor = SK_ColorBLACK; |
66 fWidth = 0; | 58 fWidth = 0; |
67 fMiterLimit = SkPaintDefaults_MiterLimit; | 59 fMiterLimit = SkPaintDefaults_MiterLimit; |
68 | 60 |
69 // Zero all bitfields, then set some non-zero defaults. | 61 // Zero all bitfields, then set some non-zero defaults. |
70 fBitfieldsUInt = 0; | 62 fBitfieldsUInt = 0; |
71 fBitfields.fFlags = SkPaintDefaults_Flags; | 63 fBitfields.fFlags = SkPaintDefaults_Flags; |
72 fBitfields.fCapType = kDefault_Cap; | 64 fBitfields.fCapType = kDefault_Cap; |
73 fBitfields.fJoinType = kDefault_Join; | 65 fBitfields.fJoinType = kDefault_Join; |
74 fBitfields.fTextAlign = kLeft_Align; | 66 fBitfields.fTextAlign = kLeft_Align; |
75 fBitfields.fStyle = kFill_Style; | 67 fBitfields.fStyle = kFill_Style; |
76 fBitfields.fTextEncoding = kUTF8_TextEncoding; | 68 fBitfields.fTextEncoding = kUTF8_TextEncoding; |
77 fBitfields.fHinting = SkPaintDefaults_Hinting; | 69 fBitfields.fHinting = SkPaintDefaults_Hinting; |
78 | |
79 #ifdef SK_BUILD_FOR_ANDROID | |
80 fGenerationID = 0; | |
81 #endif | |
82 } | 70 } |
83 | 71 |
84 SkPaint::SkPaint(const SkPaint& src) { | 72 SkPaint::SkPaint(const SkPaint& src) { |
85 #define COPY(field) field = src.field | 73 #define COPY(field) field = src.field |
86 #define REF_COPY(field) field = SkSafeRef(src.field) | 74 #define REF_COPY(field) field = SkSafeRef(src.field) |
87 | 75 |
88 REF_COPY(fTypeface); | 76 REF_COPY(fTypeface); |
89 REF_COPY(fPathEffect); | 77 REF_COPY(fPathEffect); |
90 REF_COPY(fShader); | 78 REF_COPY(fShader); |
91 REF_COPY(fXfermode); | 79 REF_COPY(fXfermode); |
92 REF_COPY(fMaskFilter); | 80 REF_COPY(fMaskFilter); |
93 REF_COPY(fColorFilter); | 81 REF_COPY(fColorFilter); |
94 REF_COPY(fRasterizer); | 82 REF_COPY(fRasterizer); |
95 REF_COPY(fLooper); | 83 REF_COPY(fLooper); |
96 REF_COPY(fImageFilter); | 84 REF_COPY(fImageFilter); |
97 REF_COPY(fAnnotation); | 85 REF_COPY(fAnnotation); |
98 | 86 |
99 COPY(fTextSize); | 87 COPY(fTextSize); |
100 COPY(fTextScaleX); | 88 COPY(fTextScaleX); |
101 COPY(fTextSkewX); | 89 COPY(fTextSkewX); |
102 COPY(fColor); | 90 COPY(fColor); |
103 COPY(fWidth); | 91 COPY(fWidth); |
104 COPY(fMiterLimit); | 92 COPY(fMiterLimit); |
105 COPY(fBitfields); | 93 COPY(fBitfields); |
106 | 94 |
107 #ifdef SK_BUILD_FOR_ANDROID | |
108 COPY(fGenerationID); | |
109 #endif | |
110 | |
111 #undef COPY | 95 #undef COPY |
112 #undef REF_COPY | 96 #undef REF_COPY |
113 } | 97 } |
114 | 98 |
115 SkPaint::~SkPaint() { | 99 SkPaint::~SkPaint() { |
116 SkSafeUnref(fTypeface); | 100 SkSafeUnref(fTypeface); |
117 SkSafeUnref(fPathEffect); | 101 SkSafeUnref(fPathEffect); |
118 SkSafeUnref(fShader); | 102 SkSafeUnref(fShader); |
119 SkSafeUnref(fXfermode); | 103 SkSafeUnref(fXfermode); |
120 SkSafeUnref(fMaskFilter); | 104 SkSafeUnref(fMaskFilter); |
(...skipping 25 matching lines...) Expand all Loading... |
146 REF_COPY(fImageFilter); | 130 REF_COPY(fImageFilter); |
147 REF_COPY(fAnnotation); | 131 REF_COPY(fAnnotation); |
148 | 132 |
149 COPY(fTextSize); | 133 COPY(fTextSize); |
150 COPY(fTextScaleX); | 134 COPY(fTextScaleX); |
151 COPY(fTextSkewX); | 135 COPY(fTextSkewX); |
152 COPY(fColor); | 136 COPY(fColor); |
153 COPY(fWidth); | 137 COPY(fWidth); |
154 COPY(fMiterLimit); | 138 COPY(fMiterLimit); |
155 COPY(fBitfields); | 139 COPY(fBitfields); |
156 #ifdef SK_BUILD_FOR_ANDROID | |
157 ++fGenerationID; | |
158 #endif | |
159 | 140 |
160 return *this; | 141 return *this; |
161 | 142 |
162 #undef COPY | 143 #undef COPY |
163 #undef REF_COPY | 144 #undef REF_COPY |
164 } | 145 } |
165 | 146 |
166 bool operator==(const SkPaint& a, const SkPaint& b) { | 147 bool operator==(const SkPaint& a, const SkPaint& b) { |
167 #define EQUAL(field) (a.field == b.field) | 148 #define EQUAL(field) (a.field == b.field) |
168 // Don't check fGenerationID, which can be different for logically equal pai
nts. | |
169 return EQUAL(fTypeface) | 149 return EQUAL(fTypeface) |
170 && EQUAL(fPathEffect) | 150 && EQUAL(fPathEffect) |
171 && EQUAL(fShader) | 151 && EQUAL(fShader) |
172 && EQUAL(fXfermode) | 152 && EQUAL(fXfermode) |
173 && EQUAL(fMaskFilter) | 153 && EQUAL(fMaskFilter) |
174 && EQUAL(fColorFilter) | 154 && EQUAL(fColorFilter) |
175 && EQUAL(fRasterizer) | 155 && EQUAL(fRasterizer) |
176 && EQUAL(fLooper) | 156 && EQUAL(fLooper) |
177 && EQUAL(fImageFilter) | 157 && EQUAL(fImageFilter) |
178 && EQUAL(fAnnotation) | 158 && EQUAL(fAnnotation) |
179 && EQUAL(fTextSize) | 159 && EQUAL(fTextSize) |
180 && EQUAL(fTextScaleX) | 160 && EQUAL(fTextScaleX) |
181 && EQUAL(fTextSkewX) | 161 && EQUAL(fTextSkewX) |
182 && EQUAL(fColor) | 162 && EQUAL(fColor) |
183 && EQUAL(fWidth) | 163 && EQUAL(fWidth) |
184 && EQUAL(fMiterLimit) | 164 && EQUAL(fMiterLimit) |
185 && EQUAL(fBitfieldsUInt) | 165 && EQUAL(fBitfieldsUInt) |
186 ; | 166 ; |
187 #undef EQUAL | 167 #undef EQUAL |
188 } | 168 } |
189 | 169 |
190 void SkPaint::reset() { | 170 void SkPaint::reset() { |
191 SkPaint init; | 171 SkPaint init; |
192 | |
193 #ifdef SK_BUILD_FOR_ANDROID | |
194 uint32_t oldGenerationID = fGenerationID; | |
195 #endif | |
196 *this = init; | 172 *this = init; |
197 #ifdef SK_BUILD_FOR_ANDROID | |
198 fGenerationID = oldGenerationID + 1; | |
199 #endif | |
200 } | 173 } |
201 | 174 |
202 #ifdef SK_BUILD_FOR_ANDROID | |
203 uint32_t SkPaint::getGenerationID() const { | |
204 return fGenerationID; | |
205 } | |
206 | |
207 void SkPaint::setGenerationID(uint32_t generationID) { | |
208 fGenerationID = generationID; | |
209 } | |
210 #endif | |
211 | |
212 void SkPaint::setFilterLevel(FilterLevel level) { | 175 void SkPaint::setFilterLevel(FilterLevel level) { |
213 GEN_ID_INC_EVAL((unsigned) level != fBitfields.fFilterLevel); | |
214 fBitfields.fFilterLevel = level; | 176 fBitfields.fFilterLevel = level; |
215 } | 177 } |
216 | 178 |
217 void SkPaint::setHinting(Hinting hintingLevel) { | 179 void SkPaint::setHinting(Hinting hintingLevel) { |
218 GEN_ID_INC_EVAL((unsigned) hintingLevel != fBitfields.fHinting); | |
219 fBitfields.fHinting = hintingLevel; | 180 fBitfields.fHinting = hintingLevel; |
220 } | 181 } |
221 | 182 |
222 void SkPaint::setFlags(uint32_t flags) { | 183 void SkPaint::setFlags(uint32_t flags) { |
223 GEN_ID_INC_EVAL(flags != fBitfields.fFlags); | |
224 fBitfields.fFlags = flags; | 184 fBitfields.fFlags = flags; |
225 } | 185 } |
226 | 186 |
227 void SkPaint::setAntiAlias(bool doAA) { | 187 void SkPaint::setAntiAlias(bool doAA) { |
228 this->setFlags(SkSetClearMask(fBitfields.fFlags, doAA, kAntiAlias_Flag)); | 188 this->setFlags(SkSetClearMask(fBitfields.fFlags, doAA, kAntiAlias_Flag)); |
229 } | 189 } |
230 | 190 |
231 void SkPaint::setDither(bool doDither) { | 191 void SkPaint::setDither(bool doDither) { |
232 this->setFlags(SkSetClearMask(fBitfields.fFlags, doDither, kDither_Flag)); | 192 this->setFlags(SkSetClearMask(fBitfields.fFlags, doDither, kDither_Flag)); |
233 } | 193 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 void SkPaint::setDevKernText(bool doDevKern) { | 231 void SkPaint::setDevKernText(bool doDevKern) { |
272 this->setFlags(SkSetClearMask(fBitfields.fFlags, doDevKern, kDevKernText_Fla
g)); | 232 this->setFlags(SkSetClearMask(fBitfields.fFlags, doDevKern, kDevKernText_Fla
g)); |
273 } | 233 } |
274 | 234 |
275 void SkPaint::setDistanceFieldTextTEMP(bool doDistanceFieldText) { | 235 void SkPaint::setDistanceFieldTextTEMP(bool doDistanceFieldText) { |
276 this->setFlags(SkSetClearMask(fBitfields.fFlags, doDistanceFieldText, kDista
nceFieldTextTEMP_Flag)); | 236 this->setFlags(SkSetClearMask(fBitfields.fFlags, doDistanceFieldText, kDista
nceFieldTextTEMP_Flag)); |
277 } | 237 } |
278 | 238 |
279 void SkPaint::setStyle(Style style) { | 239 void SkPaint::setStyle(Style style) { |
280 if ((unsigned)style < kStyleCount) { | 240 if ((unsigned)style < kStyleCount) { |
281 GEN_ID_INC_EVAL((unsigned)style != fBitfields.fStyle); | |
282 fBitfields.fStyle = style; | 241 fBitfields.fStyle = style; |
283 } else { | 242 } else { |
284 #ifdef SK_REPORT_API_RANGE_CHECK | 243 #ifdef SK_REPORT_API_RANGE_CHECK |
285 SkDebugf("SkPaint::setStyle(%d) out of range\n", style); | 244 SkDebugf("SkPaint::setStyle(%d) out of range\n", style); |
286 #endif | 245 #endif |
287 } | 246 } |
288 } | 247 } |
289 | 248 |
290 void SkPaint::setColor(SkColor color) { | 249 void SkPaint::setColor(SkColor color) { |
291 GEN_ID_INC_EVAL(color != fColor); | |
292 fColor = color; | 250 fColor = color; |
293 } | 251 } |
294 | 252 |
295 void SkPaint::setAlpha(U8CPU a) { | 253 void SkPaint::setAlpha(U8CPU a) { |
296 this->setColor(SkColorSetARGB(a, SkColorGetR(fColor), | 254 this->setColor(SkColorSetARGB(a, SkColorGetR(fColor), |
297 SkColorGetG(fColor), SkColorGetB(fColor))); | 255 SkColorGetG(fColor), SkColorGetB(fColor))); |
298 } | 256 } |
299 | 257 |
300 void SkPaint::setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) { | 258 void SkPaint::setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) { |
301 this->setColor(SkColorSetARGB(a, r, g, b)); | 259 this->setColor(SkColorSetARGB(a, r, g, b)); |
302 } | 260 } |
303 | 261 |
304 void SkPaint::setStrokeWidth(SkScalar width) { | 262 void SkPaint::setStrokeWidth(SkScalar width) { |
305 if (width >= 0) { | 263 if (width >= 0) { |
306 GEN_ID_INC_EVAL(width != fWidth); | |
307 fWidth = width; | 264 fWidth = width; |
308 } else { | 265 } else { |
309 #ifdef SK_REPORT_API_RANGE_CHECK | 266 #ifdef SK_REPORT_API_RANGE_CHECK |
310 SkDebugf("SkPaint::setStrokeWidth() called with negative value\n"); | 267 SkDebugf("SkPaint::setStrokeWidth() called with negative value\n"); |
311 #endif | 268 #endif |
312 } | 269 } |
313 } | 270 } |
314 | 271 |
315 void SkPaint::setStrokeMiter(SkScalar limit) { | 272 void SkPaint::setStrokeMiter(SkScalar limit) { |
316 if (limit >= 0) { | 273 if (limit >= 0) { |
317 GEN_ID_INC_EVAL(limit != fMiterLimit); | |
318 fMiterLimit = limit; | 274 fMiterLimit = limit; |
319 } else { | 275 } else { |
320 #ifdef SK_REPORT_API_RANGE_CHECK | 276 #ifdef SK_REPORT_API_RANGE_CHECK |
321 SkDebugf("SkPaint::setStrokeMiter() called with negative value\n"); | 277 SkDebugf("SkPaint::setStrokeMiter() called with negative value\n"); |
322 #endif | 278 #endif |
323 } | 279 } |
324 } | 280 } |
325 | 281 |
326 void SkPaint::setStrokeCap(Cap ct) { | 282 void SkPaint::setStrokeCap(Cap ct) { |
327 if ((unsigned)ct < kCapCount) { | 283 if ((unsigned)ct < kCapCount) { |
328 GEN_ID_INC_EVAL((unsigned)ct != fBitfields.fCapType); | |
329 fBitfields.fCapType = SkToU8(ct); | 284 fBitfields.fCapType = SkToU8(ct); |
330 } else { | 285 } else { |
331 #ifdef SK_REPORT_API_RANGE_CHECK | 286 #ifdef SK_REPORT_API_RANGE_CHECK |
332 SkDebugf("SkPaint::setStrokeCap(%d) out of range\n", ct); | 287 SkDebugf("SkPaint::setStrokeCap(%d) out of range\n", ct); |
333 #endif | 288 #endif |
334 } | 289 } |
335 } | 290 } |
336 | 291 |
337 void SkPaint::setStrokeJoin(Join jt) { | 292 void SkPaint::setStrokeJoin(Join jt) { |
338 if ((unsigned)jt < kJoinCount) { | 293 if ((unsigned)jt < kJoinCount) { |
339 GEN_ID_INC_EVAL((unsigned)jt != fBitfields.fJoinType); | |
340 fBitfields.fJoinType = SkToU8(jt); | 294 fBitfields.fJoinType = SkToU8(jt); |
341 } else { | 295 } else { |
342 #ifdef SK_REPORT_API_RANGE_CHECK | 296 #ifdef SK_REPORT_API_RANGE_CHECK |
343 SkDebugf("SkPaint::setStrokeJoin(%d) out of range\n", jt); | 297 SkDebugf("SkPaint::setStrokeJoin(%d) out of range\n", jt); |
344 #endif | 298 #endif |
345 } | 299 } |
346 } | 300 } |
347 | 301 |
348 /////////////////////////////////////////////////////////////////////////////// | 302 /////////////////////////////////////////////////////////////////////////////// |
349 | 303 |
350 void SkPaint::setTextAlign(Align align) { | 304 void SkPaint::setTextAlign(Align align) { |
351 if ((unsigned)align < kAlignCount) { | 305 if ((unsigned)align < kAlignCount) { |
352 GEN_ID_INC_EVAL((unsigned)align != fBitfields.fTextAlign); | |
353 fBitfields.fTextAlign = SkToU8(align); | 306 fBitfields.fTextAlign = SkToU8(align); |
354 } else { | 307 } else { |
355 #ifdef SK_REPORT_API_RANGE_CHECK | 308 #ifdef SK_REPORT_API_RANGE_CHECK |
356 SkDebugf("SkPaint::setTextAlign(%d) out of range\n", align); | 309 SkDebugf("SkPaint::setTextAlign(%d) out of range\n", align); |
357 #endif | 310 #endif |
358 } | 311 } |
359 } | 312 } |
360 | 313 |
361 void SkPaint::setTextSize(SkScalar ts) { | 314 void SkPaint::setTextSize(SkScalar ts) { |
362 if (ts >= 0) { | 315 if (ts >= 0) { |
363 GEN_ID_INC_EVAL(ts != fTextSize); | |
364 fTextSize = ts; | 316 fTextSize = ts; |
365 } else { | 317 } else { |
366 #ifdef SK_REPORT_API_RANGE_CHECK | 318 #ifdef SK_REPORT_API_RANGE_CHECK |
367 SkDebugf("SkPaint::setTextSize() called with negative value\n"); | 319 SkDebugf("SkPaint::setTextSize() called with negative value\n"); |
368 #endif | 320 #endif |
369 } | 321 } |
370 } | 322 } |
371 | 323 |
372 void SkPaint::setTextScaleX(SkScalar scaleX) { | 324 void SkPaint::setTextScaleX(SkScalar scaleX) { |
373 GEN_ID_INC_EVAL(scaleX != fTextScaleX); | |
374 fTextScaleX = scaleX; | 325 fTextScaleX = scaleX; |
375 } | 326 } |
376 | 327 |
377 void SkPaint::setTextSkewX(SkScalar skewX) { | 328 void SkPaint::setTextSkewX(SkScalar skewX) { |
378 GEN_ID_INC_EVAL(skewX != fTextSkewX); | |
379 fTextSkewX = skewX; | 329 fTextSkewX = skewX; |
380 } | 330 } |
381 | 331 |
382 void SkPaint::setTextEncoding(TextEncoding encoding) { | 332 void SkPaint::setTextEncoding(TextEncoding encoding) { |
383 if ((unsigned)encoding <= kGlyphID_TextEncoding) { | 333 if ((unsigned)encoding <= kGlyphID_TextEncoding) { |
384 GEN_ID_INC_EVAL((unsigned)encoding != fBitfields.fTextEncoding); | |
385 fBitfields.fTextEncoding = encoding; | 334 fBitfields.fTextEncoding = encoding; |
386 } else { | 335 } else { |
387 #ifdef SK_REPORT_API_RANGE_CHECK | 336 #ifdef SK_REPORT_API_RANGE_CHECK |
388 SkDebugf("SkPaint::setTextEncoding(%d) out of range\n", encoding); | 337 SkDebugf("SkPaint::setTextEncoding(%d) out of range\n", encoding); |
389 #endif | 338 #endif |
390 } | 339 } |
391 } | 340 } |
392 | 341 |
393 /////////////////////////////////////////////////////////////////////////////// | 342 /////////////////////////////////////////////////////////////////////////////// |
394 | 343 |
395 SkTypeface* SkPaint::setTypeface(SkTypeface* font) { | 344 SkTypeface* SkPaint::setTypeface(SkTypeface* font) { |
396 SkRefCnt_SafeAssign(fTypeface, font); | 345 SkRefCnt_SafeAssign(fTypeface, font); |
397 GEN_ID_INC; | |
398 return font; | 346 return font; |
399 } | 347 } |
400 | 348 |
401 SkRasterizer* SkPaint::setRasterizer(SkRasterizer* r) { | 349 SkRasterizer* SkPaint::setRasterizer(SkRasterizer* r) { |
402 SkRefCnt_SafeAssign(fRasterizer, r); | 350 SkRefCnt_SafeAssign(fRasterizer, r); |
403 GEN_ID_INC; | |
404 return r; | 351 return r; |
405 } | 352 } |
406 | 353 |
407 SkDrawLooper* SkPaint::setLooper(SkDrawLooper* looper) { | 354 SkDrawLooper* SkPaint::setLooper(SkDrawLooper* looper) { |
408 SkRefCnt_SafeAssign(fLooper, looper); | 355 SkRefCnt_SafeAssign(fLooper, looper); |
409 GEN_ID_INC; | |
410 return looper; | 356 return looper; |
411 } | 357 } |
412 | 358 |
413 SkImageFilter* SkPaint::setImageFilter(SkImageFilter* imageFilter) { | 359 SkImageFilter* SkPaint::setImageFilter(SkImageFilter* imageFilter) { |
414 SkRefCnt_SafeAssign(fImageFilter, imageFilter); | 360 SkRefCnt_SafeAssign(fImageFilter, imageFilter); |
415 GEN_ID_INC; | |
416 return imageFilter; | 361 return imageFilter; |
417 } | 362 } |
418 | 363 |
419 SkAnnotation* SkPaint::setAnnotation(SkAnnotation* annotation) { | 364 SkAnnotation* SkPaint::setAnnotation(SkAnnotation* annotation) { |
420 SkRefCnt_SafeAssign(fAnnotation, annotation); | 365 SkRefCnt_SafeAssign(fAnnotation, annotation); |
421 GEN_ID_INC; | |
422 return annotation; | 366 return annotation; |
423 } | 367 } |
424 | 368 |
425 /////////////////////////////////////////////////////////////////////////////// | 369 /////////////////////////////////////////////////////////////////////////////// |
426 | 370 |
427 static SkScalar mag2(SkScalar x, SkScalar y) { | 371 static SkScalar mag2(SkScalar x, SkScalar y) { |
428 return x * x + y * y; | 372 return x * x + y * y; |
429 } | 373 } |
430 | 374 |
431 static bool tooBig(const SkMatrix& m, SkScalar ma2max) { | 375 static bool tooBig(const SkMatrix& m, SkScalar ma2max) { |
(...skipping 1621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2053 SkString tag; | 1997 SkString tag; |
2054 buffer.readUInt(); | 1998 buffer.readUInt(); |
2055 buffer.readString(&tag); | 1999 buffer.readString(&tag); |
2056 buffer.readBool(); | 2000 buffer.readBool(); |
2057 } | 2001 } |
2058 } | 2002 } |
2059 | 2003 |
2060 /////////////////////////////////////////////////////////////////////////////// | 2004 /////////////////////////////////////////////////////////////////////////////// |
2061 | 2005 |
2062 SkShader* SkPaint::setShader(SkShader* shader) { | 2006 SkShader* SkPaint::setShader(SkShader* shader) { |
2063 GEN_ID_INC_EVAL(shader != fShader); | |
2064 SkRefCnt_SafeAssign(fShader, shader); | 2007 SkRefCnt_SafeAssign(fShader, shader); |
2065 return shader; | 2008 return shader; |
2066 } | 2009 } |
2067 | 2010 |
2068 SkColorFilter* SkPaint::setColorFilter(SkColorFilter* filter) { | 2011 SkColorFilter* SkPaint::setColorFilter(SkColorFilter* filter) { |
2069 GEN_ID_INC_EVAL(filter != fColorFilter); | |
2070 SkRefCnt_SafeAssign(fColorFilter, filter); | 2012 SkRefCnt_SafeAssign(fColorFilter, filter); |
2071 return filter; | 2013 return filter; |
2072 } | 2014 } |
2073 | 2015 |
2074 SkXfermode* SkPaint::setXfermode(SkXfermode* mode) { | 2016 SkXfermode* SkPaint::setXfermode(SkXfermode* mode) { |
2075 GEN_ID_INC_EVAL(mode != fXfermode); | |
2076 SkRefCnt_SafeAssign(fXfermode, mode); | 2017 SkRefCnt_SafeAssign(fXfermode, mode); |
2077 return mode; | 2018 return mode; |
2078 } | 2019 } |
2079 | 2020 |
2080 SkXfermode* SkPaint::setXfermodeMode(SkXfermode::Mode mode) { | 2021 SkXfermode* SkPaint::setXfermodeMode(SkXfermode::Mode mode) { |
2081 SkSafeUnref(fXfermode); | 2022 SkSafeUnref(fXfermode); |
2082 fXfermode = SkXfermode::Create(mode); | 2023 fXfermode = SkXfermode::Create(mode); |
2083 GEN_ID_INC; | |
2084 return fXfermode; | 2024 return fXfermode; |
2085 } | 2025 } |
2086 | 2026 |
2087 SkPathEffect* SkPaint::setPathEffect(SkPathEffect* effect) { | 2027 SkPathEffect* SkPaint::setPathEffect(SkPathEffect* effect) { |
2088 GEN_ID_INC_EVAL(effect != fPathEffect); | |
2089 SkRefCnt_SafeAssign(fPathEffect, effect); | 2028 SkRefCnt_SafeAssign(fPathEffect, effect); |
2090 return effect; | 2029 return effect; |
2091 } | 2030 } |
2092 | 2031 |
2093 SkMaskFilter* SkPaint::setMaskFilter(SkMaskFilter* filter) { | 2032 SkMaskFilter* SkPaint::setMaskFilter(SkMaskFilter* filter) { |
2094 GEN_ID_INC_EVAL(filter != fMaskFilter); | |
2095 SkRefCnt_SafeAssign(fMaskFilter, filter); | 2033 SkRefCnt_SafeAssign(fMaskFilter, filter); |
2096 return filter; | 2034 return filter; |
2097 } | 2035 } |
2098 | 2036 |
2099 /////////////////////////////////////////////////////////////////////////////// | 2037 /////////////////////////////////////////////////////////////////////////////// |
2100 | 2038 |
2101 bool SkPaint::getFillPath(const SkPath& src, SkPath* dst, | 2039 bool SkPaint::getFillPath(const SkPath& src, SkPath* dst, |
2102 const SkRect* cullRect) const { | 2040 const SkRect* cullRect) const { |
2103 SkStrokeRec rec(*this); | 2041 SkStrokeRec rec(*this); |
2104 | 2042 |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2462 } | 2400 } |
2463 | 2401 |
2464 uint32_t SkPaint::getHash() const { | 2402 uint32_t SkPaint::getHash() const { |
2465 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, | 2403 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, |
2466 // so fBitfields should be 10 pointers and 6 32-bit values from the start. | 2404 // so fBitfields should be 10 pointers and 6 32-bit values from the start. |
2467 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 *
sizeof(uint32_t), | 2405 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 *
sizeof(uint32_t), |
2468 SkPaint_notPackedTightly); | 2406 SkPaint_notPackedTightly); |
2469 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), | 2407 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), |
2470 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); | 2408 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); |
2471 } | 2409 } |
OLD | NEW |