| 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 "SkDashPathEffect.h" | 10 #include "SkDashPathEffect.h" |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 x + halfWidth, y + halfHeight); | 523 x + halfWidth, y + halfHeight); |
| 524 } | 524 } |
| 525 | 525 |
| 526 SkASSERT(curPt == results->fNumPoints); | 526 SkASSERT(curPt == results->fNumPoints); |
| 527 } | 527 } |
| 528 | 528 |
| 529 return true; | 529 return true; |
| 530 } | 530 } |
| 531 | 531 |
| 532 SkFlattenable::Factory SkDashPathEffect::getFactory() const { | 532 SkFlattenable::Factory SkDashPathEffect::getFactory() const { |
| 533 return fInitialDashLength < 0 ? NULL : CreateProc; | 533 return CreateProc; |
| 534 } | 534 } |
| 535 | 535 |
| 536 void SkDashPathEffect::flatten(SkWriteBuffer& buffer) const { | 536 void SkDashPathEffect::flatten(SkWriteBuffer& buffer) const { |
| 537 SkASSERT(fInitialDashLength >= 0); | |
| 538 | |
| 539 this->INHERITED::flatten(buffer); | 537 this->INHERITED::flatten(buffer); |
| 540 buffer.writeInt(fInitialDashIndex); | 538 buffer.writeInt(fInitialDashIndex); |
| 541 buffer.writeScalar(fInitialDashLength); | 539 buffer.writeScalar(fInitialDashLength); |
| 542 buffer.writeScalar(fIntervalLength); | 540 buffer.writeScalar(fIntervalLength); |
| 543 buffer.writeBool(fScaleToFit); | 541 buffer.writeBool(fScaleToFit); |
| 544 buffer.writeScalarArray(fIntervals, fCount); | 542 buffer.writeScalarArray(fIntervals, fCount); |
| 545 } | 543 } |
| 546 | 544 |
| 547 SkFlattenable* SkDashPathEffect::CreateProc(SkReadBuffer& buffer) { | 545 SkFlattenable* SkDashPathEffect::CreateProc(SkReadBuffer& buffer) { |
| 548 return SkNEW_ARGS(SkDashPathEffect, (buffer)); | 546 return SkNEW_ARGS(SkDashPathEffect, (buffer)); |
| 549 } | 547 } |
| 550 | 548 |
| 551 SkDashPathEffect::SkDashPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) { | 549 SkDashPathEffect::SkDashPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) { |
| 552 fInitialDashIndex = buffer.readInt(); | 550 fInitialDashIndex = buffer.readInt(); |
| 553 fInitialDashLength = buffer.readScalar(); | 551 fInitialDashLength = buffer.readScalar(); |
| 554 fIntervalLength = buffer.readScalar(); | 552 fIntervalLength = buffer.readScalar(); |
| 555 fScaleToFit = buffer.readBool(); | 553 fScaleToFit = buffer.readBool(); |
| 556 | 554 |
| 557 fCount = buffer.getArrayCount(); | 555 fCount = buffer.getArrayCount(); |
| 558 size_t allocSize = sizeof(SkScalar) * fCount; | 556 size_t allocSize = sizeof(SkScalar) * fCount; |
| 559 if (buffer.validateAvailable(allocSize)) { | 557 if (buffer.validateAvailable(allocSize)) { |
| 560 fIntervals = (SkScalar*)sk_malloc_throw(allocSize); | 558 fIntervals = (SkScalar*)sk_malloc_throw(allocSize); |
| 561 buffer.readScalarArray(fIntervals, fCount); | 559 buffer.readScalarArray(fIntervals, fCount); |
| 562 } else { | 560 } else { |
| 563 fIntervals = NULL; | 561 fIntervals = NULL; |
| 564 } | 562 } |
| 565 } | 563 } |
| OLD | NEW |