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

Side by Side Diff: src/core/SkPathEffect.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/SkPaint.cpp ('k') | src/core/SkReadBuffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1
2 /* 1 /*
3 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
4 * 3 *
5 * 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
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 7
9 #include "SkPathEffect.h" 8 #include "SkPathEffect.h"
10 #include "SkPath.h" 9 #include "SkPath.h"
11 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
12 #include "SkWriteBuffer.h" 11 #include "SkWriteBuffer.h"
13 12
14 /////////////////////////////////////////////////////////////////////////////// 13 ///////////////////////////////////////////////////////////////////////////////
15 14
16 void SkPathEffect::computeFastBounds(SkRect* dst, const SkRect& src) const { 15 void SkPathEffect::computeFastBounds(SkRect* dst, const SkRect& src) const {
17 *dst = src; 16 *dst = src;
18 } 17 }
19 18
20 bool SkPathEffect::asPoints(PointData* results, const SkPath& src, 19 bool SkPathEffect::asPoints(PointData* results, const SkPath& src,
21 const SkStrokeRec&, const SkMatrix&, const SkRect*) const { 20 const SkStrokeRec&, const SkMatrix&, const SkRect*) const {
22 return false; 21 return false;
23 } 22 }
24 23
25 SkPathEffect::DashType SkPathEffect::asADash(DashInfo* info) const { 24 SkPathEffect::DashType SkPathEffect::asADash(DashInfo* info) const {
26 return kNone_DashType; 25 return kNone_DashType;
27 } 26 }
28 27
29 /////////////////////////////////////////////////////////////////////////////// 28 ///////////////////////////////////////////////////////////////////////////////
30 29
31 SkPairPathEffect::SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1) 30 SkPairPathEffect::SkPairPathEffect(sk_sp<SkPathEffect> pe0, sk_sp<SkPathEffect> pe1)
32 : fPE0(pe0), fPE1(pe1) { 31 : fPE0(std::move(pe0)), fPE1(std::move(pe1))
33 SkASSERT(pe0); 32 {
34 SkASSERT(pe1); 33 SkASSERT(fPE0.get());
35 fPE0->ref(); 34 SkASSERT(fPE1.get());
36 fPE1->ref();
37 }
38
39 SkPairPathEffect::~SkPairPathEffect() {
40 SkSafeUnref(fPE0);
41 SkSafeUnref(fPE1);
42 } 35 }
43 36
44 /* 37 /*
45 Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data] 38 Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data]
46 */ 39 */
47 void SkPairPathEffect::flatten(SkWriteBuffer& buffer) const { 40 void SkPairPathEffect::flatten(SkWriteBuffer& buffer) const {
48 buffer.writeFlattenable(fPE0); 41 buffer.writeFlattenable(fPE0.get());
49 buffer.writeFlattenable(fPE1); 42 buffer.writeFlattenable(fPE1.get());
50 } 43 }
51 44
52 #ifndef SK_IGNORE_TO_STRING 45 #ifndef SK_IGNORE_TO_STRING
53 void SkPairPathEffect::toString(SkString* str) const { 46 void SkPairPathEffect::toString(SkString* str) const {
54 str->appendf("first: "); 47 str->appendf("first: ");
55 if (fPE0) { 48 if (fPE0) {
56 fPE0->toString(str); 49 fPE0->toString(str);
57 } 50 }
58 str->appendf(" second: "); 51 str->appendf(" second: ");
59 if (fPE1) { 52 if (fPE1) {
60 fPE1->toString(str); 53 fPE1->toString(str);
61 } 54 }
62 } 55 }
63 #endif 56 #endif
64 57
65 /////////////////////////////////////////////////////////////////////////////// 58 ///////////////////////////////////////////////////////////////////////////////
66 59
67 SkFlattenable* SkComposePathEffect::CreateProc(SkReadBuffer& buffer) { 60 SkFlattenable* SkComposePathEffect::CreateProc(SkReadBuffer& buffer) {
68 SkAutoTUnref<SkPathEffect> pe0(buffer.readPathEffect()); 61 sk_sp<SkPathEffect> pe0(buffer.readPathEffect());
69 SkAutoTUnref<SkPathEffect> pe1(buffer.readPathEffect()); 62 sk_sp<SkPathEffect> pe1(buffer.readPathEffect());
70 if (pe0 && pe1) { 63 return SkComposePathEffect::Make(std::move(pe0), std::move(pe1)).release();
71 return SkComposePathEffect::Create(pe0, pe1);
72 } else {
73 return nullptr;
74 }
75 } 64 }
76 65
77 bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src, 66 bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src,
78 SkStrokeRec* rec, const SkRect* cullRect) const { 67 SkStrokeRec* rec, const SkRect* cullRect) const {
79 // we may have failed to unflatten these, so we have to check
80 if (!fPE0 || !fPE1) {
81 return false;
82 }
83
84 SkPath tmp; 68 SkPath tmp;
85 const SkPath* ptr = &src; 69 const SkPath* ptr = &src;
86 70
87 if (fPE1->filterPath(&tmp, src, rec, cullRect)) { 71 if (fPE1->filterPath(&tmp, src, rec, cullRect)) {
88 ptr = &tmp; 72 ptr = &tmp;
89 } 73 }
90 return fPE0->filterPath(dst, *ptr, rec, cullRect); 74 return fPE0->filterPath(dst, *ptr, rec, cullRect);
91 } 75 }
92 76
93 77
94 #ifndef SK_IGNORE_TO_STRING 78 #ifndef SK_IGNORE_TO_STRING
95 void SkComposePathEffect::toString(SkString* str) const { 79 void SkComposePathEffect::toString(SkString* str) const {
96 str->appendf("SkComposePathEffect: ("); 80 str->appendf("SkComposePathEffect: (");
97 this->INHERITED::toString(str); 81 this->INHERITED::toString(str);
98 str->appendf(")"); 82 str->appendf(")");
99 } 83 }
100 #endif 84 #endif
101 85
102 /////////////////////////////////////////////////////////////////////////////// 86 ///////////////////////////////////////////////////////////////////////////////
103 87
104 SkFlattenable* SkSumPathEffect::CreateProc(SkReadBuffer& buffer) { 88 SkFlattenable* SkSumPathEffect::CreateProc(SkReadBuffer& buffer) {
105 SkAutoTUnref<SkPathEffect> pe0(buffer.readPathEffect()); 89 sk_sp<SkPathEffect> pe0(buffer.readPathEffect());
106 SkAutoTUnref<SkPathEffect> pe1(buffer.readPathEffect()); 90 sk_sp<SkPathEffect> pe1(buffer.readPathEffect());
107 if (pe0 && pe1) { 91 return SkSumPathEffect::Make(pe0, pe1).release();
108 return SkSumPathEffect::Create(pe0, pe1);
109 } else {
110 return nullptr;
111 }
112 } 92 }
113 93
114 bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src, 94 bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src,
115 SkStrokeRec* rec, const SkRect* cullRect) const { 95 SkStrokeRec* rec, const SkRect* cullRect) const {
116 // use bit-or so that we always call both, even if the first one succeeds 96 // use bit-or so that we always call both, even if the first one succeeds
117 return fPE0->filterPath(dst, src, rec, cullRect) | 97 return fPE0->filterPath(dst, src, rec, cullRect) |
118 fPE1->filterPath(dst, src, rec, cullRect); 98 fPE1->filterPath(dst, src, rec, cullRect);
119 } 99 }
120 100
121 101
122 #ifndef SK_IGNORE_TO_STRING 102 #ifndef SK_IGNORE_TO_STRING
123 void SkSumPathEffect::toString(SkString* str) const { 103 void SkSumPathEffect::toString(SkString* str) const {
124 str->appendf("SkSumPathEffect: ("); 104 str->appendf("SkSumPathEffect: (");
125 this->INHERITED::toString(str); 105 this->INHERITED::toString(str);
126 str->appendf(")"); 106 str->appendf(")");
127 } 107 }
128 #endif 108 #endif
OLDNEW
« no previous file with comments | « src/core/SkPaint.cpp ('k') | src/core/SkReadBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698