| 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 SET_PTR(Rasterizer) | 373 SET_PTR(Rasterizer) |
| 374 SET_PTR(ImageFilter) | 374 SET_PTR(ImageFilter) |
| 375 SET_PTR(Shader) | 375 SET_PTR(Shader) |
| 376 SET_PTR(ColorFilter) | 376 SET_PTR(ColorFilter) |
| 377 SET_PTR(Xfermode) | 377 SET_PTR(Xfermode) |
| 378 #ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR |
| 378 SET_PTR(PathEffect) | 379 SET_PTR(PathEffect) |
| 380 #endif |
| 379 SET_PTR(MaskFilter) | 381 SET_PTR(MaskFilter) |
| 380 #undef SET_PTR | 382 #undef SET_PTR |
| 381 | 383 |
| 382 SkDrawLooper* SkPaint::setLooper(SkDrawLooper* looper) { | 384 SkDrawLooper* SkPaint::setLooper(SkDrawLooper* looper) { |
| 383 fLooper.reset(SkSafeRef(looper)); | 385 fLooper.reset(SkSafeRef(looper)); |
| 384 return looper; | 386 return looper; |
| 385 } | 387 } |
| 386 | 388 |
| 387 SkXfermode* SkPaint::setXfermodeMode(SkXfermode::Mode mode) { | 389 SkXfermode* SkPaint::setXfermodeMode(SkXfermode::Mode mode) { |
| 388 fXfermode.reset(SkXfermode::Create(mode)); | 390 fXfermode.reset(SkXfermode::Create(mode)); |
| (...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1923 this->setStyle(static_cast<Style>((tmp >> 8) & 0xFF)); | 1925 this->setStyle(static_cast<Style>((tmp >> 8) & 0xFF)); |
| 1924 this->setTextEncoding(static_cast<TextEncoding>((tmp >> 0) & 0xFF)); | 1926 this->setTextEncoding(static_cast<TextEncoding>((tmp >> 0) & 0xFF)); |
| 1925 | 1927 |
| 1926 if (flatFlags & kHasTypeface_FlatFlag) { | 1928 if (flatFlags & kHasTypeface_FlatFlag) { |
| 1927 this->setTypeface(buffer.readTypeface()); | 1929 this->setTypeface(buffer.readTypeface()); |
| 1928 } else { | 1930 } else { |
| 1929 this->setTypeface(nullptr); | 1931 this->setTypeface(nullptr); |
| 1930 } | 1932 } |
| 1931 | 1933 |
| 1932 if (flatFlags & kHasEffects_FlatFlag) { | 1934 if (flatFlags & kHasEffects_FlatFlag) { |
| 1933 SkSafeUnref(this->setPathEffect(buffer.readPathEffect())); | 1935 this->setPathEffect(buffer.readPathEffect()); |
| 1934 this->setShader(buffer.readShader()); | 1936 this->setShader(buffer.readShader()); |
| 1935 SkSafeUnref(this->setXfermode(buffer.readXfermode())); | 1937 SkSafeUnref(this->setXfermode(buffer.readXfermode())); |
| 1936 SkSafeUnref(this->setMaskFilter(buffer.readMaskFilter())); | 1938 SkSafeUnref(this->setMaskFilter(buffer.readMaskFilter())); |
| 1937 SkSafeUnref(this->setColorFilter(buffer.readColorFilter())); | 1939 SkSafeUnref(this->setColorFilter(buffer.readColorFilter())); |
| 1938 SkSafeUnref(this->setRasterizer(buffer.readRasterizer())); | 1940 SkSafeUnref(this->setRasterizer(buffer.readRasterizer())); |
| 1939 SkSafeUnref(this->setLooper(buffer.readDrawLooper())); | 1941 SkSafeUnref(this->setLooper(buffer.readDrawLooper())); |
| 1940 SkSafeUnref(this->setImageFilter(buffer.readImageFilter())); | 1942 SkSafeUnref(this->setImageFilter(buffer.readImageFilter())); |
| 1941 | 1943 |
| 1942 if (buffer.isVersionLT(SkReadBuffer::kAnnotationsMovedToCanvas_Version))
{ | 1944 if (buffer.isVersionLT(SkReadBuffer::kAnnotationsMovedToCanvas_Version))
{ |
| 1943 // We used to store annotations here (string+skdata) if this bool wa
s true | 1945 // We used to store annotations here (string+skdata) if this bool wa
s true |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2243 } | 2245 } |
| 2244 | 2246 |
| 2245 if (!applyStrokeAndPathEffects) { | 2247 if (!applyStrokeAndPathEffects) { |
| 2246 fPaint.setStyle(SkPaint::kFill_Style); | 2248 fPaint.setStyle(SkPaint::kFill_Style); |
| 2247 fPaint.setPathEffect(nullptr); | 2249 fPaint.setPathEffect(nullptr); |
| 2248 } | 2250 } |
| 2249 | 2251 |
| 2250 fCache = fPaint.detachCache(nullptr, SkPaint::FakeGamma::On, nullptr); | 2252 fCache = fPaint.detachCache(nullptr, SkPaint::FakeGamma::On, nullptr); |
| 2251 | 2253 |
| 2252 SkPaint::Style style = SkPaint::kFill_Style; | 2254 SkPaint::Style style = SkPaint::kFill_Style; |
| 2253 SkPathEffect* pe = nullptr; | 2255 sk_sp<SkPathEffect> pe; |
| 2254 | 2256 |
| 2255 if (!applyStrokeAndPathEffects) { | 2257 if (!applyStrokeAndPathEffects) { |
| 2256 style = paint.getStyle(); // restore | 2258 style = paint.getStyle(); // restore |
| 2257 pe = paint.getPathEffect(); // restore | 2259 pe = sk_ref_sp(paint.getPathEffect()); // restore |
| 2258 } | 2260 } |
| 2259 fPaint.setStyle(style); | 2261 fPaint.setStyle(style); |
| 2260 fPaint.setPathEffect(pe); | 2262 fPaint.setPathEffect(pe); |
| 2261 fPaint.setMaskFilter(paint.getMaskFilter()); // restore | 2263 fPaint.setMaskFilter(paint.getMaskFilter()); // restore |
| 2262 | 2264 |
| 2263 // now compute fXOffset if needed | 2265 // now compute fXOffset if needed |
| 2264 | 2266 |
| 2265 SkScalar xOffset = 0; | 2267 SkScalar xOffset = 0; |
| 2266 if (paint.getTextAlign() != SkPaint::kLeft_Align) { // need to measure first | 2268 if (paint.getTextAlign() != SkPaint::kLeft_Align) { // need to measure first |
| 2267 int count; | 2269 int count; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2360 } | 2362 } |
| 2361 | 2363 |
| 2362 uint32_t SkPaint::getHash() const { | 2364 uint32_t SkPaint::getHash() const { |
| 2363 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, | 2365 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, |
| 2364 // so fBitfields should be 10 pointers and 6 32-bit values from the start. | 2366 // so fBitfields should be 10 pointers and 6 32-bit values from the start. |
| 2365 static_assert(offsetof(SkPaint, fBitfields) == 9 * sizeof(void*) + 6 * sizeo
f(uint32_t), | 2367 static_assert(offsetof(SkPaint, fBitfields) == 9 * sizeof(void*) + 6 * sizeo
f(uint32_t), |
| 2366 "SkPaint_notPackedTightly"); | 2368 "SkPaint_notPackedTightly"); |
| 2367 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), | 2369 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), |
| 2368 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); | 2370 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); |
| 2369 } | 2371 } |
| OLD | NEW |