OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "Sk1DPathEffect.h" | 10 #include "Sk1DPathEffect.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 return fInitialOffset; | 146 return fInitialOffset; |
147 } | 147 } |
148 | 148 |
149 SkFlattenable* SkPath1DPathEffect::CreateProc(SkReadBuffer& buffer) { | 149 SkFlattenable* SkPath1DPathEffect::CreateProc(SkReadBuffer& buffer) { |
150 SkScalar advance = buffer.readScalar(); | 150 SkScalar advance = buffer.readScalar(); |
151 if (advance > 0) { | 151 if (advance > 0) { |
152 SkPath path; | 152 SkPath path; |
153 buffer.readPath(&path); | 153 buffer.readPath(&path); |
154 SkScalar phase = buffer.readScalar(); | 154 SkScalar phase = buffer.readScalar(); |
155 Style style = (Style)buffer.readUInt(); | 155 Style style = (Style)buffer.readUInt(); |
156 return SkPath1DPathEffect::Create(path, advance, phase, style); | 156 return SkPath1DPathEffect::Make(path, advance, phase, style).release(); |
157 } | 157 } |
158 return nullptr; | 158 return nullptr; |
159 } | 159 } |
160 | 160 |
161 void SkPath1DPathEffect::flatten(SkWriteBuffer& buffer) const { | 161 void SkPath1DPathEffect::flatten(SkWriteBuffer& buffer) const { |
162 buffer.writeScalar(fAdvance); | 162 buffer.writeScalar(fAdvance); |
163 if (fAdvance > 0) { | 163 if (fAdvance > 0) { |
164 buffer.writePath(fPath); | 164 buffer.writePath(fPath); |
165 buffer.writeScalar(fInitialOffset); | 165 buffer.writeScalar(fInitialOffset); |
166 buffer.writeUInt(fStyle); | 166 buffer.writeUInt(fStyle); |
(...skipping 30 matching lines...) Expand all Loading... |
197 void SkPath1DPathEffect::toString(SkString* str) const { | 197 void SkPath1DPathEffect::toString(SkString* str) const { |
198 str->appendf("SkPath1DPathEffect: ("); | 198 str->appendf("SkPath1DPathEffect: ("); |
199 // TODO: add path and style | 199 // TODO: add path and style |
200 str->appendf("advance: %.2f phase %.2f", fAdvance, fInitialOffset); | 200 str->appendf("advance: %.2f phase %.2f", fAdvance, fInitialOffset); |
201 str->appendf(")"); | 201 str->appendf(")"); |
202 } | 202 } |
203 #endif | 203 #endif |
204 | 204 |
205 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 205 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
206 | 206 |
207 SkPathEffect* SkPath1DPathEffect::Create(const SkPath& path, SkScalar advance, S
kScalar phase, | 207 sk_sp<SkPathEffect> SkPath1DPathEffect::Make(const SkPath& path, SkScalar advanc
e, SkScalar phase, |
208 Style style) { | 208 Style style) { |
209 if (advance <= 0 || path.isEmpty()) { | 209 if (advance <= 0 || path.isEmpty()) { |
210 return nullptr; | 210 return nullptr; |
211 } | 211 } |
212 return new SkPath1DPathEffect(path, advance, phase, style); | 212 return sk_sp<SkPathEffect>(new SkPath1DPathEffect(path, advance, phase, styl
e)); |
213 } | 213 } |
OLD | NEW |