Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: src/core/SkPaint.cpp

Issue 1813553005: switch patheffects over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: try to fix xpsdevice Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkDraw.cpp ('k') | src/core/SkPathEffect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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)
379 SET_PTR(MaskFilter) 378 SET_PTR(MaskFilter)
380 #undef SET_PTR 379 #undef SET_PTR
381 380
382 SkDrawLooper* SkPaint::setLooper(SkDrawLooper* looper) { 381 SkDrawLooper* SkPaint::setLooper(SkDrawLooper* looper) {
383 fLooper.reset(SkSafeRef(looper)); 382 fLooper.reset(SkSafeRef(looper));
384 return looper; 383 return looper;
385 } 384 }
386 385
387 SkXfermode* SkPaint::setXfermodeMode(SkXfermode::Mode mode) { 386 SkXfermode* SkPaint::setXfermodeMode(SkXfermode::Mode mode) {
388 fXfermode.reset(SkXfermode::Create(mode)); 387 fXfermode.reset(SkXfermode::Create(mode));
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 this->setStyle(static_cast<Style>((tmp >> 8) & 0xFF)); 1922 this->setStyle(static_cast<Style>((tmp >> 8) & 0xFF));
1924 this->setTextEncoding(static_cast<TextEncoding>((tmp >> 0) & 0xFF)); 1923 this->setTextEncoding(static_cast<TextEncoding>((tmp >> 0) & 0xFF));
1925 1924
1926 if (flatFlags & kHasTypeface_FlatFlag) { 1925 if (flatFlags & kHasTypeface_FlatFlag) {
1927 this->setTypeface(buffer.readTypeface()); 1926 this->setTypeface(buffer.readTypeface());
1928 } else { 1927 } else {
1929 this->setTypeface(nullptr); 1928 this->setTypeface(nullptr);
1930 } 1929 }
1931 1930
1932 if (flatFlags & kHasEffects_FlatFlag) { 1931 if (flatFlags & kHasEffects_FlatFlag) {
1933 SkSafeUnref(this->setPathEffect(buffer.readPathEffect())); 1932 this->setPathEffect(buffer.readPathEffect());
1934 this->setShader(buffer.readShader()); 1933 this->setShader(buffer.readShader());
1935 SkSafeUnref(this->setXfermode(buffer.readXfermode())); 1934 SkSafeUnref(this->setXfermode(buffer.readXfermode()));
1936 SkSafeUnref(this->setMaskFilter(buffer.readMaskFilter())); 1935 SkSafeUnref(this->setMaskFilter(buffer.readMaskFilter()));
1937 SkSafeUnref(this->setColorFilter(buffer.readColorFilter())); 1936 SkSafeUnref(this->setColorFilter(buffer.readColorFilter()));
1938 SkSafeUnref(this->setRasterizer(buffer.readRasterizer())); 1937 SkSafeUnref(this->setRasterizer(buffer.readRasterizer()));
1939 SkSafeUnref(this->setLooper(buffer.readDrawLooper())); 1938 SkSafeUnref(this->setLooper(buffer.readDrawLooper()));
1940 SkSafeUnref(this->setImageFilter(buffer.readImageFilter())); 1939 SkSafeUnref(this->setImageFilter(buffer.readImageFilter()));
1941 1940
1942 if (buffer.isVersionLT(SkReadBuffer::kAnnotationsMovedToCanvas_Version)) { 1941 if (buffer.isVersionLT(SkReadBuffer::kAnnotationsMovedToCanvas_Version)) {
1943 // We used to store annotations here (string+skdata) if this bool wa s true 1942 // 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
2243 } 2242 }
2244 2243
2245 if (!applyStrokeAndPathEffects) { 2244 if (!applyStrokeAndPathEffects) {
2246 fPaint.setStyle(SkPaint::kFill_Style); 2245 fPaint.setStyle(SkPaint::kFill_Style);
2247 fPaint.setPathEffect(nullptr); 2246 fPaint.setPathEffect(nullptr);
2248 } 2247 }
2249 2248
2250 fCache = fPaint.detachCache(nullptr, SkPaint::FakeGamma::On, nullptr); 2249 fCache = fPaint.detachCache(nullptr, SkPaint::FakeGamma::On, nullptr);
2251 2250
2252 SkPaint::Style style = SkPaint::kFill_Style; 2251 SkPaint::Style style = SkPaint::kFill_Style;
2253 SkPathEffect* pe = nullptr; 2252 sk_sp<SkPathEffect> pe;
2254 2253
2255 if (!applyStrokeAndPathEffects) { 2254 if (!applyStrokeAndPathEffects) {
2256 style = paint.getStyle(); // restore 2255 style = paint.getStyle(); // restore
2257 pe = paint.getPathEffect(); // restore 2256 pe = sk_ref_sp(paint.getPathEffect()); // restore
2258 } 2257 }
2259 fPaint.setStyle(style); 2258 fPaint.setStyle(style);
2260 fPaint.setPathEffect(pe); 2259 fPaint.setPathEffect(pe);
2261 fPaint.setMaskFilter(paint.getMaskFilter()); // restore 2260 fPaint.setMaskFilter(paint.getMaskFilter()); // restore
2262 2261
2263 // now compute fXOffset if needed 2262 // now compute fXOffset if needed
2264 2263
2265 SkScalar xOffset = 0; 2264 SkScalar xOffset = 0;
2266 if (paint.getTextAlign() != SkPaint::kLeft_Align) { // need to measure first 2265 if (paint.getTextAlign() != SkPaint::kLeft_Align) { // need to measure first
2267 int count; 2266 int count;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 } 2359 }
2361 2360
2362 uint32_t SkPaint::getHash() const { 2361 uint32_t SkPaint::getHash() const {
2363 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB itfields, 2362 // 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. 2363 // 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), 2364 static_assert(offsetof(SkPaint, fBitfields) == 9 * sizeof(void*) + 6 * sizeo f(uint32_t),
2366 "SkPaint_notPackedTightly"); 2365 "SkPaint_notPackedTightly");
2367 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), 2366 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this),
2368 offsetof(SkPaint, fBitfields) + sizeof(fBitfields )); 2367 offsetof(SkPaint, fBitfields) + sizeof(fBitfields ));
2369 } 2368 }
OLDNEW
« no previous file with comments | « src/core/SkDraw.cpp ('k') | src/core/SkPathEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698