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