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 "SkDashPathEffect.h" | 8 #include "SkDashPathEffect.h" |
9 | 9 |
10 #include "SkDashPathPriv.h" | 10 #include "SkDashPathPriv.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 info->fPhase = fPhase; | 236 info->fPhase = fPhase; |
237 } | 237 } |
238 return kDash_DashType; | 238 return kDash_DashType; |
239 } | 239 } |
240 | 240 |
241 SkFlattenable::Factory SkDashPathEffect::getFactory() const { | 241 SkFlattenable::Factory SkDashPathEffect::getFactory() const { |
242 return CreateProc; | 242 return CreateProc; |
243 } | 243 } |
244 | 244 |
245 void SkDashPathEffect::flatten(SkWriteBuffer& buffer) const { | 245 void SkDashPathEffect::flatten(SkWriteBuffer& buffer) const { |
246 this->INHERITED::flatten(buffer); | |
247 buffer.writeScalar(fPhase); | 246 buffer.writeScalar(fPhase); |
248 buffer.writeScalarArray(fIntervals, fCount); | 247 buffer.writeScalarArray(fIntervals, fCount); |
249 } | 248 } |
250 | 249 |
251 SkFlattenable* SkDashPathEffect::CreateProc(SkReadBuffer& buffer) { | 250 SkFlattenable* SkDashPathEffect::CreateProc(SkReadBuffer& buffer) { |
252 return SkNEW_ARGS(SkDashPathEffect, (buffer)); | 251 const SkScalar phase = buffer.readScalar(); |
| 252 uint32_t count = buffer.getArrayCount(); |
| 253 SkAutoSTArray<32, SkScalar> intervals(count); |
| 254 if (buffer.readScalarArray(intervals.get(), count)) { |
| 255 return Create(intervals.get(), SkToInt(count), phase); |
| 256 } |
| 257 return NULL; |
| 258 } |
| 259 |
| 260 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 261 SkFlattenable* SkDashPathEffect::DeepCreateProc(SkReadBuffer& buffer) { |
| 262 if (buffer.pictureVersion() <= kNewFlattenVersion) { |
| 263 return SkNEW_ARGS(SkDashPathEffect, (buffer)); |
| 264 } |
| 265 return CreateProc(buffer); |
253 } | 266 } |
254 | 267 |
255 SkDashPathEffect::SkDashPathEffect(SkReadBuffer& buffer) | 268 SkDashPathEffect::SkDashPathEffect(SkReadBuffer& buffer) |
256 : INHERITED(buffer) | 269 : INHERITED(buffer) |
257 , fPhase(0) | 270 , fPhase(0) |
258 , fInitialDashLength(0) | 271 , fInitialDashLength(0) |
259 , fInitialDashIndex(0) | 272 , fInitialDashIndex(0) |
260 , fIntervalLength(0) { | 273 , fIntervalLength(0) { |
261 bool useOldPic = buffer.isVersionLT(SkReadBuffer::kDashWritesPhaseIntervals_
Version); | 274 bool useOldPic = buffer.isVersionLT(SkReadBuffer::kDashWritesPhaseIntervals_
Version); |
262 if (useOldPic) { | 275 if (useOldPic) { |
(...skipping 22 matching lines...) Expand all Loading... |
285 } | 298 } |
286 fPhase += fIntervals[fInitialDashIndex] - fInitialDashLength; | 299 fPhase += fIntervals[fInitialDashIndex] - fInitialDashLength; |
287 } | 300 } |
288 } else { | 301 } else { |
289 // set the internal data members, fPhase should have been between 0 and
intervalLength | 302 // set the internal data members, fPhase should have been between 0 and
intervalLength |
290 // when written to buffer so no need to adjust it | 303 // when written to buffer so no need to adjust it |
291 SkDashPath::CalcDashParameters(fPhase, fIntervals, fCount, | 304 SkDashPath::CalcDashParameters(fPhase, fIntervals, fCount, |
292 &fInitialDashLength, &fInitialDashIndex, &fIntervalLength); | 305 &fInitialDashLength, &fInitialDashIndex, &fIntervalLength); |
293 } | 306 } |
294 } | 307 } |
| 308 #endif |
| 309 |
OLD | NEW |