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 "SkAutoKern.h" | 9 #include "SkAutoKern.h" |
10 #include "SkChecksum.h" | 10 #include "SkChecksum.h" |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 MOVE_FIELD(PathEffect) | 362 MOVE_FIELD(PathEffect) |
363 MOVE_FIELD(MaskFilter) | 363 MOVE_FIELD(MaskFilter) |
364 #undef MOVE_FIELD | 364 #undef MOVE_FIELD |
365 void SkPaint::setLooper(sk_sp<SkDrawLooper> looper) { fLooper = std::move(looper
); } | 365 void SkPaint::setLooper(sk_sp<SkDrawLooper> looper) { fLooper = std::move(looper
); } |
366 | 366 |
367 #define SET_PTR(Field) \ | 367 #define SET_PTR(Field) \ |
368 Sk##Field* SkPaint::set##Field(Sk##Field* f) { \ | 368 Sk##Field* SkPaint::set##Field(Sk##Field* f) { \ |
369 this->f##Field.reset(SkSafeRef(f)); \ | 369 this->f##Field.reset(SkSafeRef(f)); \ |
370 return f; \ | 370 return f; \ |
371 } | 371 } |
| 372 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR |
372 SET_PTR(Typeface) | 373 SET_PTR(Typeface) |
| 374 #endif |
373 #ifdef SK_SUPPORT_LEGACY_MINOR_EFFECT_PTR | 375 #ifdef SK_SUPPORT_LEGACY_MINOR_EFFECT_PTR |
374 SET_PTR(Rasterizer) | 376 SET_PTR(Rasterizer) |
375 #endif | 377 #endif |
376 SET_PTR(ImageFilter) | 378 SET_PTR(ImageFilter) |
377 #ifdef SK_SUPPORT_LEGACY_CREATESHADER_PTR | 379 #ifdef SK_SUPPORT_LEGACY_CREATESHADER_PTR |
378 SET_PTR(Shader) | 380 SET_PTR(Shader) |
379 #endif | 381 #endif |
380 #ifdef SK_SUPPORT_LEGACY_COLORFILTER_PTR | 382 #ifdef SK_SUPPORT_LEGACY_COLORFILTER_PTR |
381 SET_PTR(ColorFilter) | 383 SET_PTR(ColorFilter) |
382 #endif | 384 #endif |
(...skipping 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1889 | 1891 |
1890 unsigned flatFlags = unpack_paint_flags(this, buffer.readUInt()); | 1892 unsigned flatFlags = unpack_paint_flags(this, buffer.readUInt()); |
1891 | 1893 |
1892 uint32_t tmp = buffer.readUInt(); | 1894 uint32_t tmp = buffer.readUInt(); |
1893 this->setStrokeCap(static_cast<Cap>((tmp >> 24) & 0xFF)); | 1895 this->setStrokeCap(static_cast<Cap>((tmp >> 24) & 0xFF)); |
1894 this->setStrokeJoin(static_cast<Join>((tmp >> 16) & 0xFF)); | 1896 this->setStrokeJoin(static_cast<Join>((tmp >> 16) & 0xFF)); |
1895 this->setStyle(static_cast<Style>((tmp >> 8) & 0xFF)); | 1897 this->setStyle(static_cast<Style>((tmp >> 8) & 0xFF)); |
1896 this->setTextEncoding(static_cast<TextEncoding>((tmp >> 0) & 0xFF)); | 1898 this->setTextEncoding(static_cast<TextEncoding>((tmp >> 0) & 0xFF)); |
1897 | 1899 |
1898 if (flatFlags & kHasTypeface_FlatFlag) { | 1900 if (flatFlags & kHasTypeface_FlatFlag) { |
1899 this->setTypeface(buffer.readTypeface()); | 1901 this->setTypeface(sk_ref_sp(buffer.readTypeface())); |
1900 } else { | 1902 } else { |
1901 this->setTypeface(nullptr); | 1903 this->setTypeface(nullptr); |
1902 } | 1904 } |
1903 | 1905 |
1904 if (flatFlags & kHasEffects_FlatFlag) { | 1906 if (flatFlags & kHasEffects_FlatFlag) { |
1905 this->setPathEffect(buffer.readPathEffect()); | 1907 this->setPathEffect(buffer.readPathEffect()); |
1906 this->setShader(buffer.readShader()); | 1908 this->setShader(buffer.readShader()); |
1907 this->setXfermode(buffer.readXfermode()); | 1909 this->setXfermode(buffer.readXfermode()); |
1908 this->setMaskFilter(buffer.readMaskFilter()); | 1910 this->setMaskFilter(buffer.readMaskFilter()); |
1909 this->setColorFilter(buffer.readColorFilter()); | 1911 this->setColorFilter(buffer.readColorFilter()); |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2320 } | 2322 } |
2321 | 2323 |
2322 uint32_t SkPaint::getHash() const { | 2324 uint32_t SkPaint::getHash() const { |
2323 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, | 2325 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, |
2324 // so fBitfields should be 10 pointers and 6 32-bit values from the start. | 2326 // so fBitfields should be 10 pointers and 6 32-bit values from the start. |
2325 static_assert(offsetof(SkPaint, fBitfields) == 9 * sizeof(void*) + 6 * sizeo
f(uint32_t), | 2327 static_assert(offsetof(SkPaint, fBitfields) == 9 * sizeof(void*) + 6 * sizeo
f(uint32_t), |
2326 "SkPaint_notPackedTightly"); | 2328 "SkPaint_notPackedTightly"); |
2327 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), | 2329 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), |
2328 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); | 2330 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); |
2329 } | 2331 } |
OLD | NEW |