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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 SET_PTR(Typeface) | 372 SET_PTR(Typeface) |
| 373 #ifdef SK_SUPPORT_LEGACY_MINOR_EFFECT_PTR |
373 SET_PTR(Rasterizer) | 374 SET_PTR(Rasterizer) |
| 375 #endif |
374 SET_PTR(ImageFilter) | 376 SET_PTR(ImageFilter) |
375 SET_PTR(Shader) | 377 SET_PTR(Shader) |
376 SET_PTR(ColorFilter) | 378 SET_PTR(ColorFilter) |
377 SET_PTR(Xfermode) | 379 SET_PTR(Xfermode) |
378 #ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR | 380 #ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR |
379 SET_PTR(PathEffect) | 381 SET_PTR(PathEffect) |
380 #endif | 382 #endif |
381 SET_PTR(MaskFilter) | 383 SET_PTR(MaskFilter) |
382 #undef SET_PTR | 384 #undef SET_PTR |
383 | 385 |
| 386 #ifdef SK_SUPPORT_LEGACY_MINOR_EFFECT_PTR |
384 SkDrawLooper* SkPaint::setLooper(SkDrawLooper* looper) { | 387 SkDrawLooper* SkPaint::setLooper(SkDrawLooper* looper) { |
385 fLooper.reset(SkSafeRef(looper)); | 388 fLooper.reset(SkSafeRef(looper)); |
386 return looper; | 389 return looper; |
387 } | 390 } |
| 391 #endif |
388 | 392 |
389 SkXfermode* SkPaint::setXfermodeMode(SkXfermode::Mode mode) { | 393 SkXfermode* SkPaint::setXfermodeMode(SkXfermode::Mode mode) { |
390 fXfermode.reset(SkXfermode::Create(mode)); | 394 fXfermode.reset(SkXfermode::Create(mode)); |
391 return fXfermode.get(); | 395 return fXfermode.get(); |
392 } | 396 } |
393 | 397 |
394 /////////////////////////////////////////////////////////////////////////////// | 398 /////////////////////////////////////////////////////////////////////////////// |
395 | 399 |
396 static SkScalar mag2(SkScalar x, SkScalar y) { | 400 static SkScalar mag2(SkScalar x, SkScalar y) { |
397 return x * x + y * y; | 401 return x * x + y * y; |
(...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1930 } else { | 1934 } else { |
1931 this->setTypeface(nullptr); | 1935 this->setTypeface(nullptr); |
1932 } | 1936 } |
1933 | 1937 |
1934 if (flatFlags & kHasEffects_FlatFlag) { | 1938 if (flatFlags & kHasEffects_FlatFlag) { |
1935 this->setPathEffect(buffer.readPathEffect()); | 1939 this->setPathEffect(buffer.readPathEffect()); |
1936 this->setShader(buffer.readShader()); | 1940 this->setShader(buffer.readShader()); |
1937 SkSafeUnref(this->setXfermode(buffer.readXfermode())); | 1941 SkSafeUnref(this->setXfermode(buffer.readXfermode())); |
1938 SkSafeUnref(this->setMaskFilter(buffer.readMaskFilter())); | 1942 SkSafeUnref(this->setMaskFilter(buffer.readMaskFilter())); |
1939 SkSafeUnref(this->setColorFilter(buffer.readColorFilter())); | 1943 SkSafeUnref(this->setColorFilter(buffer.readColorFilter())); |
1940 SkSafeUnref(this->setRasterizer(buffer.readRasterizer())); | 1944 this->setRasterizer(buffer.readRasterizer()); |
1941 SkSafeUnref(this->setLooper(buffer.readDrawLooper())); | 1945 this->setLooper(buffer.readDrawLooper()); |
1942 SkSafeUnref(this->setImageFilter(buffer.readImageFilter())); | 1946 SkSafeUnref(this->setImageFilter(buffer.readImageFilter())); |
1943 | 1947 |
1944 if (buffer.isVersionLT(SkReadBuffer::kAnnotationsMovedToCanvas_Version))
{ | 1948 if (buffer.isVersionLT(SkReadBuffer::kAnnotationsMovedToCanvas_Version))
{ |
1945 // We used to store annotations here (string+skdata) if this bool wa
s true | 1949 // We used to store annotations here (string+skdata) if this bool wa
s true |
1946 if (buffer.readBool()) { | 1950 if (buffer.readBool()) { |
1947 // Annotations have moved to drawAnnotation, so we just drop thi
s one on the floor. | 1951 // Annotations have moved to drawAnnotation, so we just drop thi
s one on the floor. |
1948 SkString key; | 1952 SkString key; |
1949 buffer.readString(&key); | 1953 buffer.readString(&key); |
1950 (void)buffer.readByteArrayAsData(); | 1954 (void)buffer.readByteArrayAsData(); |
1951 } | 1955 } |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2362 } | 2366 } |
2363 | 2367 |
2364 uint32_t SkPaint::getHash() const { | 2368 uint32_t SkPaint::getHash() const { |
2365 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, | 2369 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, |
2366 // so fBitfields should be 10 pointers and 6 32-bit values from the start. | 2370 // so fBitfields should be 10 pointers and 6 32-bit values from the start. |
2367 static_assert(offsetof(SkPaint, fBitfields) == 9 * sizeof(void*) + 6 * sizeo
f(uint32_t), | 2371 static_assert(offsetof(SkPaint, fBitfields) == 9 * sizeof(void*) + 6 * sizeo
f(uint32_t), |
2368 "SkPaint_notPackedTightly"); | 2372 "SkPaint_notPackedTightly"); |
2369 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), | 2373 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), |
2370 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); | 2374 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); |
2371 } | 2375 } |
OLD | NEW |