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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 fPathEffect = NULL; | 75 fPathEffect = NULL; |
76 fShader = NULL; | 76 fShader = NULL; |
77 fXfermode = NULL; | 77 fXfermode = NULL; |
78 fMaskFilter = NULL; | 78 fMaskFilter = NULL; |
79 fColorFilter = NULL; | 79 fColorFilter = NULL; |
80 fRasterizer = NULL; | 80 fRasterizer = NULL; |
81 fLooper = NULL; | 81 fLooper = NULL; |
82 fImageFilter = NULL; | 82 fImageFilter = NULL; |
83 fAnnotation = NULL; | 83 fAnnotation = NULL; |
84 | 84 |
85 fTextSize = SkPaintDefaults_TextSize; | 85 fTextSize = SkPaintDefaults_TextSize; |
86 fTextScaleX = SK_Scalar1; | 86 fTextScaleX = SK_Scalar1; |
87 fTextSkewX = 0; | 87 fTextSkewX = 0; |
88 fColor = SK_ColorBLACK; | 88 fColor = SK_ColorBLACK; |
89 fWidth = 0; | 89 fWidth = 0; |
90 fMiterLimit = SkPaintDefaults_MiterLimit; | 90 fMiterLimit = SkPaintDefaults_MiterLimit; |
91 | 91 |
92 // Zero all bitfields, then set some non-zero defaults. | 92 // Zero all bitfields, then set some non-zero defaults. |
93 fBitfields = 0; | 93 fBitfieldsUInt = 0; |
94 fFlags = SkPaintDefaults_Flags; | 94 fBitfields.fFlags = SkPaintDefaults_Flags; |
95 fCapType = kDefault_Cap; | 95 fBitfields.fCapType = kDefault_Cap; |
96 fJoinType = kDefault_Join; | 96 fBitfields.fJoinType = kDefault_Join; |
97 fTextAlign = kLeft_Align; | 97 fBitfields.fTextAlign = kLeft_Align; |
98 fStyle = kFill_Style; | 98 fBitfields.fStyle = kFill_Style; |
99 fTextEncoding = kUTF8_TextEncoding; | 99 fBitfields.fTextEncoding = kUTF8_TextEncoding; |
100 fHinting = SkPaintDefaults_Hinting; | 100 fBitfields.fHinting = SkPaintDefaults_Hinting; |
101 | 101 |
102 fDirtyBits = 0; | 102 fDirtyBits = 0; |
103 #ifdef SK_BUILD_FOR_ANDROID | 103 #ifdef SK_BUILD_FOR_ANDROID |
104 new (&fPaintOptionsAndroid) SkPaintOptionsAndroid; | 104 new (&fPaintOptionsAndroid) SkPaintOptionsAndroid; |
105 fGenerationID = 0; | 105 fGenerationID = 0; |
106 #endif | 106 #endif |
107 } | 107 } |
108 | 108 |
109 SkPaint::SkPaint(const SkPaint& src) { | 109 SkPaint::SkPaint(const SkPaint& src) { |
110 #define COPY(field) field = src.field | 110 #define COPY(field) field = src.field |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 && EQUAL(fRasterizer) | 206 && EQUAL(fRasterizer) |
207 && EQUAL(fLooper) | 207 && EQUAL(fLooper) |
208 && EQUAL(fImageFilter) | 208 && EQUAL(fImageFilter) |
209 && EQUAL(fAnnotation) | 209 && EQUAL(fAnnotation) |
210 && EQUAL(fTextSize) | 210 && EQUAL(fTextSize) |
211 && EQUAL(fTextScaleX) | 211 && EQUAL(fTextScaleX) |
212 && EQUAL(fTextSkewX) | 212 && EQUAL(fTextSkewX) |
213 && EQUAL(fColor) | 213 && EQUAL(fColor) |
214 && EQUAL(fWidth) | 214 && EQUAL(fWidth) |
215 && EQUAL(fMiterLimit) | 215 && EQUAL(fMiterLimit) |
216 && EQUAL(fBitfields) | 216 && EQUAL(fBitfieldsUInt) |
217 #ifdef SK_BUILD_FOR_ANDROID | 217 #ifdef SK_BUILD_FOR_ANDROID |
218 && EQUAL(fPaintOptionsAndroid) | 218 && EQUAL(fPaintOptionsAndroid) |
219 #endif | 219 #endif |
220 ; | 220 ; |
221 #undef EQUAL | 221 #undef EQUAL |
222 } | 222 } |
223 | 223 |
224 void SkPaint::reset() { | 224 void SkPaint::reset() { |
225 SkPaint init; | 225 SkPaint init; |
226 | 226 |
(...skipping 24 matching lines...) Expand all Loading... |
251 void SkPaint::setPaintOptionsAndroid(const SkPaintOptionsAndroid& options) { | 251 void SkPaint::setPaintOptionsAndroid(const SkPaintOptionsAndroid& options) { |
252 if (options != fPaintOptionsAndroid) { | 252 if (options != fPaintOptionsAndroid) { |
253 fPaintOptionsAndroid = options; | 253 fPaintOptionsAndroid = options; |
254 GEN_ID_INC; | 254 GEN_ID_INC; |
255 fDirtyBits |= kPaintOptionsAndroid_DirtyBit; | 255 fDirtyBits |= kPaintOptionsAndroid_DirtyBit; |
256 } | 256 } |
257 } | 257 } |
258 #endif | 258 #endif |
259 | 259 |
260 void SkPaint::setFilterLevel(FilterLevel level) { | 260 void SkPaint::setFilterLevel(FilterLevel level) { |
261 GEN_ID_INC_EVAL((unsigned) level != fFilterLevel); | 261 GEN_ID_INC_EVAL((unsigned) level != fBitfields.fFilterLevel); |
262 fFilterLevel = level; | 262 fBitfields.fFilterLevel = level; |
263 } | 263 } |
264 | 264 |
265 void SkPaint::setHinting(Hinting hintingLevel) { | 265 void SkPaint::setHinting(Hinting hintingLevel) { |
266 GEN_ID_INC_EVAL((unsigned) hintingLevel != fHinting); | 266 GEN_ID_INC_EVAL((unsigned) hintingLevel != fBitfields.fHinting); |
267 fHinting = hintingLevel; | 267 fBitfields.fHinting = hintingLevel; |
268 } | 268 } |
269 | 269 |
270 void SkPaint::setFlags(uint32_t flags) { | 270 void SkPaint::setFlags(uint32_t flags) { |
271 GEN_ID_INC_EVAL(fFlags != flags); | 271 GEN_ID_INC_EVAL(flags != fBitfields.fFlags); |
272 fFlags = flags; | 272 fBitfields.fFlags = flags; |
273 } | 273 } |
274 | 274 |
275 void SkPaint::setAntiAlias(bool doAA) { | 275 void SkPaint::setAntiAlias(bool doAA) { |
276 this->setFlags(SkSetClearMask(fFlags, doAA, kAntiAlias_Flag)); | 276 this->setFlags(SkSetClearMask(fBitfields.fFlags, doAA, kAntiAlias_Flag)); |
277 } | 277 } |
278 | 278 |
279 void SkPaint::setDither(bool doDither) { | 279 void SkPaint::setDither(bool doDither) { |
280 this->setFlags(SkSetClearMask(fFlags, doDither, kDither_Flag)); | 280 this->setFlags(SkSetClearMask(fBitfields.fFlags, doDither, kDither_Flag)); |
281 } | 281 } |
282 | 282 |
283 void SkPaint::setSubpixelText(bool doSubpixel) { | 283 void SkPaint::setSubpixelText(bool doSubpixel) { |
284 this->setFlags(SkSetClearMask(fFlags, doSubpixel, kSubpixelText_Flag)); | 284 this->setFlags(SkSetClearMask(fBitfields.fFlags, doSubpixel, kSubpixelText_F
lag)); |
285 } | 285 } |
286 | 286 |
287 void SkPaint::setLCDRenderText(bool doLCDRender) { | 287 void SkPaint::setLCDRenderText(bool doLCDRender) { |
288 this->setFlags(SkSetClearMask(fFlags, doLCDRender, kLCDRenderText_Flag)); | 288 this->setFlags(SkSetClearMask(fBitfields.fFlags, doLCDRender, kLCDRenderText
_Flag)); |
289 } | 289 } |
290 | 290 |
291 void SkPaint::setEmbeddedBitmapText(bool doEmbeddedBitmapText) { | 291 void SkPaint::setEmbeddedBitmapText(bool doEmbeddedBitmapText) { |
292 this->setFlags(SkSetClearMask(fFlags, doEmbeddedBitmapText, kEmbeddedBitmapT
ext_Flag)); | 292 this->setFlags(SkSetClearMask(fBitfields.fFlags, doEmbeddedBitmapText, kEmbe
ddedBitmapText_Flag)); |
293 } | 293 } |
294 | 294 |
295 void SkPaint::setAutohinted(bool useAutohinter) { | 295 void SkPaint::setAutohinted(bool useAutohinter) { |
296 this->setFlags(SkSetClearMask(fFlags, useAutohinter, kAutoHinting_Flag)); | 296 this->setFlags(SkSetClearMask(fBitfields.fFlags, useAutohinter, kAutoHinting
_Flag)); |
297 } | 297 } |
298 | 298 |
299 void SkPaint::setLinearText(bool doLinearText) { | 299 void SkPaint::setLinearText(bool doLinearText) { |
300 this->setFlags(SkSetClearMask(fFlags, doLinearText, kLinearText_Flag)); | 300 this->setFlags(SkSetClearMask(fBitfields.fFlags, doLinearText, kLinearText_F
lag)); |
301 } | 301 } |
302 | 302 |
303 void SkPaint::setVerticalText(bool doVertical) { | 303 void SkPaint::setVerticalText(bool doVertical) { |
304 this->setFlags(SkSetClearMask(fFlags, doVertical, kVerticalText_Flag)); | 304 this->setFlags(SkSetClearMask(fBitfields.fFlags, doVertical, kVerticalText_F
lag)); |
305 } | 305 } |
306 | 306 |
307 void SkPaint::setUnderlineText(bool doUnderline) { | 307 void SkPaint::setUnderlineText(bool doUnderline) { |
308 this->setFlags(SkSetClearMask(fFlags, doUnderline, kUnderlineText_Flag)); | 308 this->setFlags(SkSetClearMask(fBitfields.fFlags, doUnderline, kUnderlineText
_Flag)); |
309 } | 309 } |
310 | 310 |
311 void SkPaint::setStrikeThruText(bool doStrikeThru) { | 311 void SkPaint::setStrikeThruText(bool doStrikeThru) { |
312 this->setFlags(SkSetClearMask(fFlags, doStrikeThru, kStrikeThruText_Flag)); | 312 this->setFlags(SkSetClearMask(fBitfields.fFlags, doStrikeThru, kStrikeThruTe
xt_Flag)); |
313 } | 313 } |
314 | 314 |
315 void SkPaint::setFakeBoldText(bool doFakeBold) { | 315 void SkPaint::setFakeBoldText(bool doFakeBold) { |
316 this->setFlags(SkSetClearMask(fFlags, doFakeBold, kFakeBoldText_Flag)); | 316 this->setFlags(SkSetClearMask(fBitfields.fFlags, doFakeBold, kFakeBoldText_F
lag)); |
317 } | 317 } |
318 | 318 |
319 void SkPaint::setDevKernText(bool doDevKern) { | 319 void SkPaint::setDevKernText(bool doDevKern) { |
320 this->setFlags(SkSetClearMask(fFlags, doDevKern, kDevKernText_Flag)); | 320 this->setFlags(SkSetClearMask(fBitfields.fFlags, doDevKern, kDevKernText_Fla
g)); |
321 } | 321 } |
322 | 322 |
323 void SkPaint::setDistanceFieldTextTEMP(bool doDistanceFieldText) { | 323 void SkPaint::setDistanceFieldTextTEMP(bool doDistanceFieldText) { |
324 this->setFlags(SkSetClearMask(fFlags, doDistanceFieldText, kDistanceFieldTex
tTEMP_Flag)); | 324 this->setFlags(SkSetClearMask(fBitfields.fFlags, doDistanceFieldText, kDista
nceFieldTextTEMP_Flag)); |
325 } | 325 } |
326 | 326 |
327 void SkPaint::setStyle(Style style) { | 327 void SkPaint::setStyle(Style style) { |
328 if ((unsigned)style < kStyleCount) { | 328 if ((unsigned)style < kStyleCount) { |
329 GEN_ID_INC_EVAL((unsigned)style != fStyle); | 329 GEN_ID_INC_EVAL((unsigned)style != fBitfields.fStyle); |
330 fStyle = style; | 330 fBitfields.fStyle = style; |
331 } else { | 331 } else { |
332 #ifdef SK_REPORT_API_RANGE_CHECK | 332 #ifdef SK_REPORT_API_RANGE_CHECK |
333 SkDebugf("SkPaint::setStyle(%d) out of range\n", style); | 333 SkDebugf("SkPaint::setStyle(%d) out of range\n", style); |
334 #endif | 334 #endif |
335 } | 335 } |
336 } | 336 } |
337 | 337 |
338 void SkPaint::setColor(SkColor color) { | 338 void SkPaint::setColor(SkColor color) { |
339 GEN_ID_INC_EVAL(color != fColor); | 339 GEN_ID_INC_EVAL(color != fColor); |
340 fColor = color; | 340 fColor = color; |
(...skipping 28 matching lines...) Expand all Loading... |
369 fDirtyBits |= kStrokeMiter_DirtyBit; | 369 fDirtyBits |= kStrokeMiter_DirtyBit; |
370 } else { | 370 } else { |
371 #ifdef SK_REPORT_API_RANGE_CHECK | 371 #ifdef SK_REPORT_API_RANGE_CHECK |
372 SkDebugf("SkPaint::setStrokeMiter() called with negative value\n"); | 372 SkDebugf("SkPaint::setStrokeMiter() called with negative value\n"); |
373 #endif | 373 #endif |
374 } | 374 } |
375 } | 375 } |
376 | 376 |
377 void SkPaint::setStrokeCap(Cap ct) { | 377 void SkPaint::setStrokeCap(Cap ct) { |
378 if ((unsigned)ct < kCapCount) { | 378 if ((unsigned)ct < kCapCount) { |
379 GEN_ID_INC_EVAL((unsigned)ct != fCapType); | 379 GEN_ID_INC_EVAL((unsigned)ct != fBitfields.fCapType); |
380 fCapType = SkToU8(ct); | 380 fBitfields.fCapType = SkToU8(ct); |
381 } else { | 381 } else { |
382 #ifdef SK_REPORT_API_RANGE_CHECK | 382 #ifdef SK_REPORT_API_RANGE_CHECK |
383 SkDebugf("SkPaint::setStrokeCap(%d) out of range\n", ct); | 383 SkDebugf("SkPaint::setStrokeCap(%d) out of range\n", ct); |
384 #endif | 384 #endif |
385 } | 385 } |
386 } | 386 } |
387 | 387 |
388 void SkPaint::setStrokeJoin(Join jt) { | 388 void SkPaint::setStrokeJoin(Join jt) { |
389 if ((unsigned)jt < kJoinCount) { | 389 if ((unsigned)jt < kJoinCount) { |
390 GEN_ID_INC_EVAL((unsigned)jt != fJoinType); | 390 GEN_ID_INC_EVAL((unsigned)jt != fBitfields.fJoinType); |
391 fJoinType = SkToU8(jt); | 391 fBitfields.fJoinType = SkToU8(jt); |
392 } else { | 392 } else { |
393 #ifdef SK_REPORT_API_RANGE_CHECK | 393 #ifdef SK_REPORT_API_RANGE_CHECK |
394 SkDebugf("SkPaint::setStrokeJoin(%d) out of range\n", jt); | 394 SkDebugf("SkPaint::setStrokeJoin(%d) out of range\n", jt); |
395 #endif | 395 #endif |
396 } | 396 } |
397 } | 397 } |
398 | 398 |
399 /////////////////////////////////////////////////////////////////////////////// | 399 /////////////////////////////////////////////////////////////////////////////// |
400 | 400 |
401 void SkPaint::setTextAlign(Align align) { | 401 void SkPaint::setTextAlign(Align align) { |
402 if ((unsigned)align < kAlignCount) { | 402 if ((unsigned)align < kAlignCount) { |
403 GEN_ID_INC_EVAL((unsigned)align != fTextAlign); | 403 GEN_ID_INC_EVAL((unsigned)align != fBitfields.fTextAlign); |
404 fTextAlign = SkToU8(align); | 404 fBitfields.fTextAlign = SkToU8(align); |
405 } else { | 405 } else { |
406 #ifdef SK_REPORT_API_RANGE_CHECK | 406 #ifdef SK_REPORT_API_RANGE_CHECK |
407 SkDebugf("SkPaint::setTextAlign(%d) out of range\n", align); | 407 SkDebugf("SkPaint::setTextAlign(%d) out of range\n", align); |
408 #endif | 408 #endif |
409 } | 409 } |
410 } | 410 } |
411 | 411 |
412 void SkPaint::setTextSize(SkScalar ts) { | 412 void SkPaint::setTextSize(SkScalar ts) { |
413 if (ts >= 0) { | 413 if (ts >= 0) { |
414 GEN_ID_INC_EVAL(ts != fTextSize); | 414 GEN_ID_INC_EVAL(ts != fTextSize); |
(...skipping 13 matching lines...) Expand all Loading... |
428 } | 428 } |
429 | 429 |
430 void SkPaint::setTextSkewX(SkScalar skewX) { | 430 void SkPaint::setTextSkewX(SkScalar skewX) { |
431 GEN_ID_INC_EVAL(skewX != fTextSkewX); | 431 GEN_ID_INC_EVAL(skewX != fTextSkewX); |
432 fTextSkewX = skewX; | 432 fTextSkewX = skewX; |
433 fDirtyBits |= kTextSkewX_DirtyBit; | 433 fDirtyBits |= kTextSkewX_DirtyBit; |
434 } | 434 } |
435 | 435 |
436 void SkPaint::setTextEncoding(TextEncoding encoding) { | 436 void SkPaint::setTextEncoding(TextEncoding encoding) { |
437 if ((unsigned)encoding <= kGlyphID_TextEncoding) { | 437 if ((unsigned)encoding <= kGlyphID_TextEncoding) { |
438 GEN_ID_INC_EVAL((unsigned)encoding != fTextEncoding); | 438 GEN_ID_INC_EVAL((unsigned)encoding != fBitfields.fTextEncoding); |
439 fTextEncoding = encoding; | 439 fBitfields.fTextEncoding = encoding; |
440 } else { | 440 } else { |
441 #ifdef SK_REPORT_API_RANGE_CHECK | 441 #ifdef SK_REPORT_API_RANGE_CHECK |
442 SkDebugf("SkPaint::setTextEncoding(%d) out of range\n", encoding); | 442 SkDebugf("SkPaint::setTextEncoding(%d) out of range\n", encoding); |
443 #endif | 443 #endif |
444 } | 444 } |
445 } | 445 } |
446 | 446 |
447 /////////////////////////////////////////////////////////////////////////////// | 447 /////////////////////////////////////////////////////////////////////////////// |
448 | 448 |
449 // Returns dst with the given bitmask enabled or disabled, depending on value. | 449 // Returns dst with the given bitmask enabled or disabled, depending on value. |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 sk_getMetrics_utf32_00, | 946 sk_getMetrics_utf32_00, |
947 sk_getMetrics_glyph_00, | 947 sk_getMetrics_glyph_00, |
948 | 948 |
949 sk_getMetrics_utf8_xy, | 949 sk_getMetrics_utf8_xy, |
950 sk_getMetrics_utf16_xy, | 950 sk_getMetrics_utf16_xy, |
951 sk_getMetrics_utf32_xy, | 951 sk_getMetrics_utf32_xy, |
952 sk_getMetrics_glyph_xy | 952 sk_getMetrics_glyph_xy |
953 }; | 953 }; |
954 | 954 |
955 unsigned index = this->getTextEncoding(); | 955 unsigned index = this->getTextEncoding(); |
956 if (fFlags & kSubpixelText_Flag) { | 956 if (fBitfields.fFlags & kSubpixelText_Flag) { |
957 index += 4; | 957 index += 4; |
958 } | 958 } |
959 | 959 |
960 SkASSERT(index < SK_ARRAY_COUNT(gDrawCacheProcs)); | 960 SkASSERT(index < SK_ARRAY_COUNT(gDrawCacheProcs)); |
961 return gDrawCacheProcs[index]; | 961 return gDrawCacheProcs[index]; |
962 } | 962 } |
963 | 963 |
964 /////////////////////////////////////////////////////////////////////////////// | 964 /////////////////////////////////////////////////////////////////////////////// |
965 | 965 |
966 #define TEXT_AS_PATHS_PAINT_FLAGS_TO_IGNORE ( \ | 966 #define TEXT_AS_PATHS_PAINT_FLAGS_TO_IGNORE ( \ |
(...skipping 1684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2651 return 0 == this->getAlpha(); | 2651 return 0 == this->getAlpha(); |
2652 case SkXfermode::kDst_Mode: | 2652 case SkXfermode::kDst_Mode: |
2653 return true; | 2653 return true; |
2654 default: | 2654 default: |
2655 break; | 2655 break; |
2656 } | 2656 } |
2657 } | 2657 } |
2658 return false; | 2658 return false; |
2659 } | 2659 } |
2660 | 2660 |
2661 void SkPaint::setBitfields(uint32_t bitfields) { | |
2662 fBitfields = bitfields; | |
2663 } | |
2664 | |
2665 inline static unsigned popcount(uint8_t x) { | 2661 inline static unsigned popcount(uint8_t x) { |
2666 // As in Hacker's delight, adapted for just 8 bits. | 2662 // As in Hacker's delight, adapted for just 8 bits. |
2667 x = (x & 0x55) + ((x >> 1) & 0x55); // a b c d w x y z -> a+b c+d w+x y+z | 2663 x = (x & 0x55) + ((x >> 1) & 0x55); // a b c d w x y z -> a+b c+d w+x y+z |
2668 x = (x & 0x33) + ((x >> 2) & 0x33); // a+b c+d w+x y+z -> a+b+c+d w+x+y+z | 2664 x = (x & 0x33) + ((x >> 2) & 0x33); // a+b c+d w+x y+z -> a+b+c+d w+x+y+z |
2669 x = (x & 0x0F) + ((x >> 4) & 0x0F); // a+b+c+d w+x+y+z -> a+b+c+d+w+x+y+z | 2665 x = (x & 0x0F) + ((x >> 4) & 0x0F); // a+b+c+d w+x+y+z -> a+b+c+d+w+x+y+z |
2670 return x; | 2666 return x; |
2671 } | 2667 } |
2672 | 2668 |
2673 void SkPaint::FlatteningTraits::Flatten(SkWriteBuffer& buffer, const SkPaint& pa
int) { | 2669 void SkPaint::FlatteningTraits::Flatten(SkWriteBuffer& buffer, const SkPaint& pa
int) { |
2674 const uint32_t dirty = paint.fDirtyBits; | 2670 const uint32_t dirty = paint.fDirtyBits; |
2675 | 2671 |
2676 // Each of the low 7 dirty bits corresponds to a 4-byte flat value, | 2672 // Each of the low 7 dirty bits corresponds to a 4-byte flat value, |
2677 // plus one for the dirty bits and one for the bitfields | 2673 // plus one for the dirty bits and one for the bitfields |
2678 const size_t flatBytes = 4 * (popcount(dirty & kPOD_DirtyBitMask) + 2); | 2674 const size_t flatBytes = 4 * (popcount(dirty & kPOD_DirtyBitMask) + 2); |
2679 SkASSERT(flatBytes <= 32); | 2675 SkASSERT(flatBytes <= 32); |
2680 uint32_t* u32 = buffer.reserve(flatBytes); | 2676 uint32_t* u32 = buffer.reserve(flatBytes); |
2681 *u32++ = dirty; | 2677 *u32++ = dirty; |
2682 *u32++ = paint.getBitfields(); | 2678 *u32++ = paint.fBitfieldsUInt; |
2683 if (0 == dirty) { | 2679 if (0 == dirty) { |
2684 return; | 2680 return; |
2685 } | 2681 } |
2686 | 2682 |
2687 #define F(dst, field) if (dirty & k##field##_DirtyBit) *dst++ = paint.get##field
() | 2683 #define F(dst, field) if (dirty & k##field##_DirtyBit) *dst++ = paint.get##field
() |
2688 F(u32, Color); | 2684 F(u32, Color); |
2689 SkScalar* f32 = reinterpret_cast<SkScalar*>(u32); | 2685 SkScalar* f32 = reinterpret_cast<SkScalar*>(u32); |
2690 F(f32, TextSize); | 2686 F(f32, TextSize); |
2691 F(f32, TextScaleX); | 2687 F(f32, TextScaleX); |
2692 F(f32, TextSkewX); | 2688 F(f32, TextSkewX); |
(...skipping 12 matching lines...) Expand all Loading... |
2705 #undef F | 2701 #undef F |
2706 if (dirty & kTypeface_DirtyBit) buffer.writeTypeface(paint.getTypeface()); | 2702 if (dirty & kTypeface_DirtyBit) buffer.writeTypeface(paint.getTypeface()); |
2707 if (dirty & kAnnotation_DirtyBit) paint.getAnnotation()->writeToBuffer(buffe
r); | 2703 if (dirty & kAnnotation_DirtyBit) paint.getAnnotation()->writeToBuffer(buffe
r); |
2708 #ifdef SK_BUILD_FOR_ANDROID | 2704 #ifdef SK_BUILD_FOR_ANDROID |
2709 if (dirty & kPaintOptionsAndroid_DirtyBit) paint.getPaintOptionsAndroid().fl
atten(buffer); | 2705 if (dirty & kPaintOptionsAndroid_DirtyBit) paint.getPaintOptionsAndroid().fl
atten(buffer); |
2710 #endif | 2706 #endif |
2711 } | 2707 } |
2712 | 2708 |
2713 void SkPaint::FlatteningTraits::Unflatten(SkReadBuffer& buffer, SkPaint* paint)
{ | 2709 void SkPaint::FlatteningTraits::Unflatten(SkReadBuffer& buffer, SkPaint* paint)
{ |
2714 const uint32_t dirty = buffer.readUInt(); | 2710 const uint32_t dirty = buffer.readUInt(); |
2715 paint->setBitfields(buffer.readUInt()); | 2711 paint->fBitfieldsUInt = buffer.readUInt(); |
2716 if (dirty == 0) { | 2712 if (dirty == 0) { |
2717 return; | 2713 return; |
2718 } | 2714 } |
2719 #define F(field, reader) if (dirty & k##field##_DirtyBit) paint->set##field(buff
er.reader()) | 2715 #define F(field, reader) if (dirty & k##field##_DirtyBit) paint->set##field(buff
er.reader()) |
2720 // Same function, except it unrefs the object newly set on the paint: | 2716 // Same function, except it unrefs the object newly set on the paint: |
2721 #define F_UNREF(field, reader) \ | 2717 #define F_UNREF(field, reader) \ |
2722 if (dirty & k##field##_DirtyBit) \ | 2718 if (dirty & k##field##_DirtyBit) \ |
2723 paint->set##field(buffer.reader())->unref() | 2719 paint->set##field(buffer.reader())->unref() |
2724 | 2720 |
2725 F(Color, readUInt); | 2721 F(Color, readUInt); |
(...skipping 18 matching lines...) Expand all Loading... |
2744 } | 2740 } |
2745 #ifdef SK_BUILD_FOR_ANDROID | 2741 #ifdef SK_BUILD_FOR_ANDROID |
2746 if (dirty & kPaintOptionsAndroid_DirtyBit) { | 2742 if (dirty & kPaintOptionsAndroid_DirtyBit) { |
2747 SkPaintOptionsAndroid options; | 2743 SkPaintOptionsAndroid options; |
2748 options.unflatten(buffer); | 2744 options.unflatten(buffer); |
2749 paint->setPaintOptionsAndroid(options); | 2745 paint->setPaintOptionsAndroid(options); |
2750 } | 2746 } |
2751 #endif | 2747 #endif |
2752 SkASSERT(dirty == paint->fDirtyBits); | 2748 SkASSERT(dirty == paint->fDirtyBits); |
2753 } | 2749 } |
OLD | NEW |