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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 results->fLast.addRect(x - halfWidth, y - halfHeight, | 522 results->fLast.addRect(x - halfWidth, y - halfHeight, |
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 SkPathEffect::DashType SkDashPathEffect::asADash(DashInfo* info) const { |
| 533 if (info) { |
| 534 if (info->fCount >= fCount) { |
| 535 if (info->fIntervals) { |
| 536 memcpy(info->fIntervals, fIntervals, fCount * sizeof(SkScalar)); |
| 537 } |
| 538 } |
| 539 info->fCount = fCount; |
| 540 info->fInitialDashLength = fInitialDashLength; |
| 541 info->fInitialDashIndex = fInitialDashIndex; |
| 542 info->fIntervalLength = fIntervalLength; |
| 543 info->fScaleToFit = fScaleToFit; |
| 544 } |
| 545 if (2 == fCount) { |
| 546 return kTwoInterval_DashType; |
| 547 } else { |
| 548 return kMultipleInterval_DashType; |
| 549 } |
| 550 } |
| 551 |
532 SkFlattenable::Factory SkDashPathEffect::getFactory() const { | 552 SkFlattenable::Factory SkDashPathEffect::getFactory() const { |
533 return CreateProc; | 553 return CreateProc; |
534 } | 554 } |
535 | 555 |
536 void SkDashPathEffect::flatten(SkWriteBuffer& buffer) const { | 556 void SkDashPathEffect::flatten(SkWriteBuffer& buffer) const { |
537 this->INHERITED::flatten(buffer); | 557 this->INHERITED::flatten(buffer); |
538 buffer.writeInt(fInitialDashIndex); | 558 buffer.writeInt(fInitialDashIndex); |
539 buffer.writeScalar(fInitialDashLength); | 559 buffer.writeScalar(fInitialDashLength); |
540 buffer.writeScalar(fIntervalLength); | 560 buffer.writeScalar(fIntervalLength); |
541 buffer.writeBool(fScaleToFit); | 561 buffer.writeBool(fScaleToFit); |
(...skipping 12 matching lines...) Expand all Loading... |
554 | 574 |
555 fCount = buffer.getArrayCount(); | 575 fCount = buffer.getArrayCount(); |
556 size_t allocSize = sizeof(SkScalar) * fCount; | 576 size_t allocSize = sizeof(SkScalar) * fCount; |
557 if (buffer.validateAvailable(allocSize)) { | 577 if (buffer.validateAvailable(allocSize)) { |
558 fIntervals = (SkScalar*)sk_malloc_throw(allocSize); | 578 fIntervals = (SkScalar*)sk_malloc_throw(allocSize); |
559 buffer.readScalarArray(fIntervals, fCount); | 579 buffer.readScalarArray(fIntervals, fCount); |
560 } else { | 580 } else { |
561 fIntervals = NULL; | 581 fIntervals = NULL; |
562 } | 582 } |
563 } | 583 } |
OLD | NEW |