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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 if (info) { | 231 if (info) { |
232 if (info->fCount >= fCount && NULL != info->fIntervals) { | 232 if (info->fCount >= fCount && NULL != info->fIntervals) { |
233 memcpy(info->fIntervals, fIntervals, fCount * sizeof(SkScalar)); | 233 memcpy(info->fIntervals, fIntervals, fCount * sizeof(SkScalar)); |
234 } | 234 } |
235 info->fCount = fCount; | 235 info->fCount = fCount; |
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 { | |
242 return CreateProc; | |
243 } | |
244 | |
245 void SkDashPathEffect::flatten(SkWriteBuffer& buffer) const { | 241 void SkDashPathEffect::flatten(SkWriteBuffer& buffer) const { |
246 this->INHERITED::flatten(buffer); | |
247 buffer.writeScalar(fPhase); | 242 buffer.writeScalar(fPhase); |
248 buffer.writeScalarArray(fIntervals, fCount); | 243 buffer.writeScalarArray(fIntervals, fCount); |
249 } | 244 } |
250 | 245 |
251 SkFlattenable* SkDashPathEffect::CreateProc(SkReadBuffer& buffer) { | 246 SkFlattenable* SkDashPathEffect::CreateProc(SkReadBuffer& buffer) { |
252 return SkNEW_ARGS(SkDashPathEffect, (buffer)); | 247 const SkScalar phase = buffer.readScalar(); |
| 248 uint32_t count = buffer.getArrayCount(); |
| 249 SkAutoSTArray<32, SkScalar> intervals(count); |
| 250 if (buffer.readScalarArray(intervals.get(), count)) { |
| 251 return Create(intervals.get(), SkToInt(count), phase); |
| 252 } |
| 253 return NULL; |
253 } | 254 } |
254 | 255 |
| 256 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
255 SkDashPathEffect::SkDashPathEffect(SkReadBuffer& buffer) | 257 SkDashPathEffect::SkDashPathEffect(SkReadBuffer& buffer) |
256 : INHERITED(buffer) | 258 : INHERITED(buffer) |
257 , fPhase(0) | 259 , fPhase(0) |
258 , fInitialDashLength(0) | 260 , fInitialDashLength(0) |
259 , fInitialDashIndex(0) | 261 , fInitialDashIndex(0) |
260 , fIntervalLength(0) { | 262 , fIntervalLength(0) { |
261 bool useOldPic = buffer.isVersionLT(SkReadBuffer::kDashWritesPhaseIntervals_
Version); | 263 bool useOldPic = buffer.isVersionLT(SkReadBuffer::kDashWritesPhaseIntervals_
Version); |
262 if (useOldPic) { | 264 if (useOldPic) { |
263 fInitialDashIndex = buffer.readInt(); | 265 fInitialDashIndex = buffer.readInt(); |
264 fInitialDashLength = buffer.readScalar(); | 266 fInitialDashLength = buffer.readScalar(); |
(...skipping 20 matching lines...) Expand all Loading... |
285 } | 287 } |
286 fPhase += fIntervals[fInitialDashIndex] - fInitialDashLength; | 288 fPhase += fIntervals[fInitialDashIndex] - fInitialDashLength; |
287 } | 289 } |
288 } else { | 290 } else { |
289 // set the internal data members, fPhase should have been between 0 and
intervalLength | 291 // set the internal data members, fPhase should have been between 0 and
intervalLength |
290 // when written to buffer so no need to adjust it | 292 // when written to buffer so no need to adjust it |
291 SkDashPath::CalcDashParameters(fPhase, fIntervals, fCount, | 293 SkDashPath::CalcDashParameters(fPhase, fIntervals, fCount, |
292 &fInitialDashLength, &fInitialDashIndex, &fIntervalLength); | 294 &fInitialDashLength, &fInitialDashIndex, &fIntervalLength); |
293 } | 295 } |
294 } | 296 } |
| 297 #endif |
| 298 |
OLD | NEW |