OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
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 "SkPictureRecord.h" | 8 #include "SkPictureRecord.h" |
9 #include "SkTSearch.h" | 9 #include "SkTSearch.h" |
10 #include "SkPixelRef.h" | 10 #include "SkPixelRef.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 , fRecordFlags(flags) | 45 , fRecordFlags(flags) |
46 , fOptsEnabled(kBeClever) { | 46 , fOptsEnabled(kBeClever) { |
47 #ifdef SK_DEBUG_SIZE | 47 #ifdef SK_DEBUG_SIZE |
48 fPointBytes = fRectBytes = fTextBytes = 0; | 48 fPointBytes = fRectBytes = fTextBytes = 0; |
49 fPointWrites = fRectWrites = fTextWrites = 0; | 49 fPointWrites = fRectWrites = fTextWrites = 0; |
50 #endif | 50 #endif |
51 | 51 |
52 fBitmapHeap = SkNEW(SkBitmapHeap); | 52 fBitmapHeap = SkNEW(SkBitmapHeap); |
53 fFlattenableHeap.setBitmapStorage(fBitmapHeap); | 53 fFlattenableHeap.setBitmapStorage(fBitmapHeap); |
54 | 54 |
55 #ifndef SK_COLLAPSE_MATRIX_CLIP_STATE | |
56 fFirstSavedLayerIndex = kNoSavedLayerIndex; | 55 fFirstSavedLayerIndex = kNoSavedLayerIndex; |
57 #endif | |
58 | |
59 fInitialSaveCount = kNoInitialSave; | 56 fInitialSaveCount = kNoInitialSave; |
60 | |
61 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
62 fMCMgr.init(this); | |
63 #endif | |
64 } | 57 } |
65 | 58 |
66 SkPictureRecord::~SkPictureRecord() { | 59 SkPictureRecord::~SkPictureRecord() { |
67 SkSafeUnref(fBitmapHeap); | 60 SkSafeUnref(fBitmapHeap); |
68 SkSafeUnref(fBoundingHierarchy); | 61 SkSafeUnref(fBoundingHierarchy); |
69 SkSafeUnref(fStateTree); | 62 SkSafeUnref(fStateTree); |
70 fFlattenableHeap.setBitmapStorage(NULL); | 63 fFlattenableHeap.setBitmapStorage(NULL); |
71 fPictureRefs.unrefAll(); | 64 fPictureRefs.unrefAll(); |
72 } | 65 } |
73 | 66 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 SkASSERT(kSaveLayerWithBoundsSize == opSize); | 139 SkASSERT(kSaveLayerWithBoundsSize == opSize); |
147 return kSaveLayerWithBoundsPaintOffset + overflow; | 140 return kSaveLayerWithBoundsPaintOffset + overflow; |
148 } | 141 } |
149 } | 142 } |
150 | 143 |
151 SkASSERT(0 != gPaintOffsets[op]); // really shouldn't be calling this meth
od | 144 SkASSERT(0 != gPaintOffsets[op]); // really shouldn't be calling this meth
od |
152 return gPaintOffsets[op] * sizeof(uint32_t) + overflow; | 145 return gPaintOffsets[op] * sizeof(uint32_t) + overflow; |
153 } | 146 } |
154 | 147 |
155 void SkPictureRecord::willSave() { | 148 void SkPictureRecord::willSave() { |
156 | |
157 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
158 fMCMgr.save(); | |
159 #else | |
160 // record the offset to us, making it non-positive to distinguish a save | 149 // record the offset to us, making it non-positive to distinguish a save |
161 // from a clip entry. | 150 // from a clip entry. |
162 fRestoreOffsetStack.push(-(int32_t)fWriter.bytesWritten()); | 151 fRestoreOffsetStack.push(-(int32_t)fWriter.bytesWritten()); |
163 this->recordSave(); | 152 this->recordSave(); |
164 #endif | |
165 | 153 |
166 this->INHERITED::willSave(); | 154 this->INHERITED::willSave(); |
167 } | 155 } |
168 | 156 |
169 void SkPictureRecord::recordSave() { | 157 void SkPictureRecord::recordSave() { |
170 // op only | 158 // op only |
171 size_t size = kSaveSize; | 159 size_t size = kSaveSize; |
172 size_t initialOffset = this->addDraw(SAVE, &size); | 160 size_t initialOffset = this->addDraw(SAVE, &size); |
173 | 161 |
174 this->validate(initialOffset, size); | 162 this->validate(initialOffset, size); |
175 } | 163 } |
176 | 164 |
177 SkCanvas::SaveLayerStrategy SkPictureRecord::willSaveLayer(const SkRect* bounds, | 165 SkCanvas::SaveLayerStrategy SkPictureRecord::willSaveLayer(const SkRect* bounds, |
178 const SkPaint* paint,
SaveFlags flags) { | 166 const SkPaint* paint,
SaveFlags flags) { |
179 | |
180 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
181 fMCMgr.saveLayer(bounds, paint, flags); | |
182 #else | |
183 // record the offset to us, making it non-positive to distinguish a save | 167 // record the offset to us, making it non-positive to distinguish a save |
184 // from a clip entry. | 168 // from a clip entry. |
185 fRestoreOffsetStack.push(-(int32_t)fWriter.bytesWritten()); | 169 fRestoreOffsetStack.push(-(int32_t)fWriter.bytesWritten()); |
186 this->recordSaveLayer(bounds, paint, flags); | 170 this->recordSaveLayer(bounds, paint, flags); |
187 if (kNoSavedLayerIndex == fFirstSavedLayerIndex) { | 171 if (kNoSavedLayerIndex == fFirstSavedLayerIndex) { |
188 fFirstSavedLayerIndex = fRestoreOffsetStack.count(); | 172 fFirstSavedLayerIndex = fRestoreOffsetStack.count(); |
189 } | 173 } |
190 #endif | |
191 | 174 |
192 this->INHERITED::willSaveLayer(bounds, paint, flags); | 175 this->INHERITED::willSaveLayer(bounds, paint, flags); |
193 /* No need for a (potentially very big) layer which we don't actually need | 176 /* No need for a (potentially very big) layer which we don't actually need |
194 at this time (and may not be able to afford since during record our | 177 at this time (and may not be able to afford since during record our |
195 clip starts out the size of the picture, which is often much larger | 178 clip starts out the size of the picture, which is often much larger |
196 than the size of the actual device we'll use during playback). | 179 than the size of the actual device we'll use during playback). |
197 */ | 180 */ |
198 return kNoLayer_SaveLayerStrategy; | 181 return kNoLayer_SaveLayerStrategy; |
199 } | 182 } |
200 | 183 |
(...skipping 12 matching lines...) Expand all Loading... |
213 size_t initialOffset = this->addDraw(SAVE_LAYER, &size); | 196 size_t initialOffset = this->addDraw(SAVE_LAYER, &size); |
214 this->addRectPtr(bounds); | 197 this->addRectPtr(bounds); |
215 SkASSERT(initialOffset+getPaintOffset(SAVE_LAYER, size) == fWriter.bytesWrit
ten()); | 198 SkASSERT(initialOffset+getPaintOffset(SAVE_LAYER, size) == fWriter.bytesWrit
ten()); |
216 this->addPaintPtr(paint); | 199 this->addPaintPtr(paint); |
217 this->addInt(flags); | 200 this->addInt(flags); |
218 | 201 |
219 this->validate(initialOffset, size); | 202 this->validate(initialOffset, size); |
220 } | 203 } |
221 | 204 |
222 bool SkPictureRecord::isDrawingToLayer() const { | 205 bool SkPictureRecord::isDrawingToLayer() const { |
223 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
224 return fMCMgr.isDrawingToLayer(); | |
225 #else | |
226 return fFirstSavedLayerIndex != kNoSavedLayerIndex; | 206 return fFirstSavedLayerIndex != kNoSavedLayerIndex; |
227 #endif | |
228 } | 207 } |
229 | 208 |
230 /* | 209 /* |
231 * Read the op code from 'offset' in 'writer'. | 210 * Read the op code from 'offset' in 'writer'. |
232 */ | 211 */ |
233 #ifdef SK_DEBUG | 212 #ifdef SK_DEBUG |
234 static DrawType peek_op(SkWriter32* writer, size_t offset) { | 213 static DrawType peek_op(SkWriter32* writer, size_t offset) { |
235 return (DrawType)(writer->readTAt<uint32_t>(offset) >> 24); | 214 return (DrawType)(writer->readTAt<uint32_t>(offset) >> 24); |
236 } | 215 } |
237 #endif | 216 #endif |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 * SAVE_LAYER (with NULL == bounds) | 429 * SAVE_LAYER (with NULL == bounds) |
451 * SAVE | 430 * SAVE |
452 * CLIP_RECT | 431 * CLIP_RECT |
453 * DRAW_BITMAP|DRAW_BITMAP_MATRIX|DRAW_BITMAP_NINE|DRAW_BITMAP_RECT_TO_R
ECT | 432 * DRAW_BITMAP|DRAW_BITMAP_MATRIX|DRAW_BITMAP_NINE|DRAW_BITMAP_RECT_TO_R
ECT |
454 * RESTORE | 433 * RESTORE |
455 * RESTORE | 434 * RESTORE |
456 * where the saveLayer's color can be moved into the drawBitmap*'s paint | 435 * where the saveLayer's color can be moved into the drawBitmap*'s paint |
457 */ | 436 */ |
458 static bool remove_save_layer2(SkWriter32* writer, int32_t offset, | 437 static bool remove_save_layer2(SkWriter32* writer, int32_t offset, |
459 SkPaintDictionary* paintDict) { | 438 SkPaintDictionary* paintDict) { |
460 | |
461 // back up to the save block | 439 // back up to the save block |
462 // TODO: add a stack to track save*/restore offsets rather than searching ba
ckwards | 440 // TODO: add a stack to track save*/restore offsets rather than searching ba
ckwards |
463 while (offset > 0) { | 441 while (offset > 0) { |
464 offset = writer->readTAt<uint32_t>(offset); | 442 offset = writer->readTAt<uint32_t>(offset); |
465 } | 443 } |
466 | 444 |
467 int pattern[] = { SAVE_LAYER, SAVE, CLIP_RECT, kDRAW_BITMAP_FLAVOR, RESTORE,
/* RESTORE */ }; | 445 int pattern[] = { SAVE_LAYER, SAVE, CLIP_RECT, kDRAW_BITMAP_FLAVOR, RESTORE,
/* RESTORE */ }; |
468 CommandInfo result[SK_ARRAY_COUNT(pattern)]; | 446 CommandInfo result[SK_ARRAY_COUNT(pattern)]; |
469 | 447 |
470 if (!match(writer, -offset, pattern, result, SK_ARRAY_COUNT(pattern))) { | 448 if (!match(writer, -offset, pattern, result, SK_ARRAY_COUNT(pattern))) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 } | 576 } |
599 | 577 |
600 void SkPictureRecord::willRestore() { | 578 void SkPictureRecord::willRestore() { |
601 // FIXME: SkDeferredCanvas needs to be refactored to respect | 579 // FIXME: SkDeferredCanvas needs to be refactored to respect |
602 // save/restore balancing so that the following test can be | 580 // save/restore balancing so that the following test can be |
603 // turned on permanently. | 581 // turned on permanently. |
604 #if 0 | 582 #if 0 |
605 SkASSERT(fRestoreOffsetStack.count() > 1); | 583 SkASSERT(fRestoreOffsetStack.count() > 1); |
606 #endif | 584 #endif |
607 | 585 |
608 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
609 if (fMCMgr.getSaveCount() == 1) { | |
610 return; | |
611 } | |
612 | |
613 fMCMgr.restore(); | |
614 #else | |
615 // check for underflow | 586 // check for underflow |
616 if (fRestoreOffsetStack.count() == 0) { | 587 if (fRestoreOffsetStack.count() == 0) { |
617 return; | 588 return; |
618 } | 589 } |
619 | 590 |
620 if (fRestoreOffsetStack.count() == fFirstSavedLayerIndex) { | 591 if (fRestoreOffsetStack.count() == fFirstSavedLayerIndex) { |
621 fFirstSavedLayerIndex = kNoSavedLayerIndex; | 592 fFirstSavedLayerIndex = kNoSavedLayerIndex; |
622 } | 593 } |
623 | 594 |
624 size_t opt = 0; | 595 size_t opt = 0; |
(...skipping 11 matching lines...) Expand all Loading... |
636 } | 607 } |
637 } | 608 } |
638 } | 609 } |
639 | 610 |
640 if (!fOptsEnabled || SK_ARRAY_COUNT(gPictureRecordOpts) == opt) { | 611 if (!fOptsEnabled || SK_ARRAY_COUNT(gPictureRecordOpts) == opt) { |
641 // No optimization fired so add the RESTORE | 612 // No optimization fired so add the RESTORE |
642 this->recordRestore(); | 613 this->recordRestore(); |
643 } | 614 } |
644 | 615 |
645 fRestoreOffsetStack.pop(); | 616 fRestoreOffsetStack.pop(); |
646 #endif | |
647 | 617 |
648 this->INHERITED::willRestore(); | 618 this->INHERITED::willRestore(); |
649 } | 619 } |
650 | 620 |
651 void SkPictureRecord::recordRestore(bool fillInSkips) { | 621 void SkPictureRecord::recordRestore(bool fillInSkips) { |
652 if (fillInSkips) { | 622 if (fillInSkips) { |
653 this->fillRestoreOffsetPlaceholdersForCurrentStackLevel((uint32_t)fWrite
r.bytesWritten()); | 623 this->fillRestoreOffsetPlaceholdersForCurrentStackLevel((uint32_t)fWrite
r.bytesWritten()); |
654 } | 624 } |
655 size_t size = 1 * kUInt32Size; // RESTORE consists solely of 1 op code | 625 size_t size = 1 * kUInt32Size; // RESTORE consists solely of 1 op code |
656 size_t initialOffset = this->addDraw(RESTORE, &size); | 626 size_t initialOffset = this->addDraw(RESTORE, &size); |
(...skipping 16 matching lines...) Expand all Loading... |
673 | 643 |
674 // op + sx + sy | 644 // op + sx + sy |
675 size_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar); | 645 size_t size = 1 * kUInt32Size + 2 * sizeof(SkScalar); |
676 size_t initialOffset = this->addDraw(SCALE, &size); | 646 size_t initialOffset = this->addDraw(SCALE, &size); |
677 this->addScalar(m.getScaleX()); | 647 this->addScalar(m.getScaleX()); |
678 this->addScalar(m.getScaleY()); | 648 this->addScalar(m.getScaleY()); |
679 this->validate(initialOffset, size); | 649 this->validate(initialOffset, size); |
680 } | 650 } |
681 | 651 |
682 void SkPictureRecord::didConcat(const SkMatrix& matrix) { | 652 void SkPictureRecord::didConcat(const SkMatrix& matrix) { |
683 | |
684 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
685 fMCMgr.concat(matrix); | |
686 #else | |
687 switch (matrix.getType()) { | 653 switch (matrix.getType()) { |
688 case SkMatrix::kTranslate_Mask: | 654 case SkMatrix::kTranslate_Mask: |
689 this->recordTranslate(matrix); | 655 this->recordTranslate(matrix); |
690 break; | 656 break; |
691 case SkMatrix::kScale_Mask: | 657 case SkMatrix::kScale_Mask: |
692 this->recordScale(matrix); | 658 this->recordScale(matrix); |
693 break; | 659 break; |
694 default: | 660 default: |
695 this->recordConcat(matrix); | 661 this->recordConcat(matrix); |
696 break; | 662 break; |
697 } | 663 } |
698 #endif | |
699 this->INHERITED::didConcat(matrix); | 664 this->INHERITED::didConcat(matrix); |
700 } | 665 } |
701 | 666 |
702 void SkPictureRecord::recordConcat(const SkMatrix& matrix) { | 667 void SkPictureRecord::recordConcat(const SkMatrix& matrix) { |
703 this->validate(fWriter.bytesWritten(), 0); | 668 this->validate(fWriter.bytesWritten(), 0); |
704 // op + matrix | 669 // op + matrix |
705 size_t size = kUInt32Size + matrix.writeToMemory(NULL); | 670 size_t size = kUInt32Size + matrix.writeToMemory(NULL); |
706 size_t initialOffset = this->addDraw(CONCAT, &size); | 671 size_t initialOffset = this->addDraw(CONCAT, &size); |
707 this->addMatrix(matrix); | 672 this->addMatrix(matrix); |
708 this->validate(initialOffset, size); | 673 this->validate(initialOffset, size); |
709 } | 674 } |
710 | 675 |
711 void SkPictureRecord::didSetMatrix(const SkMatrix& matrix) { | 676 void SkPictureRecord::didSetMatrix(const SkMatrix& matrix) { |
712 | |
713 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
714 fMCMgr.setMatrix(matrix); | |
715 #else | |
716 this->validate(fWriter.bytesWritten(), 0); | 677 this->validate(fWriter.bytesWritten(), 0); |
717 // op + matrix | 678 // op + matrix |
718 size_t size = kUInt32Size + matrix.writeToMemory(NULL); | 679 size_t size = kUInt32Size + matrix.writeToMemory(NULL); |
719 size_t initialOffset = this->addDraw(SET_MATRIX, &size); | 680 size_t initialOffset = this->addDraw(SET_MATRIX, &size); |
720 this->addMatrix(matrix); | 681 this->addMatrix(matrix); |
721 this->validate(initialOffset, size); | 682 this->validate(initialOffset, size); |
722 #endif | |
723 this->INHERITED::didSetMatrix(matrix); | 683 this->INHERITED::didSetMatrix(matrix); |
724 } | 684 } |
725 | 685 |
726 static bool regionOpExpands(SkRegion::Op op) { | 686 static bool regionOpExpands(SkRegion::Op op) { |
727 switch (op) { | 687 switch (op) { |
728 case SkRegion::kUnion_Op: | 688 case SkRegion::kUnion_Op: |
729 case SkRegion::kXOR_Op: | 689 case SkRegion::kXOR_Op: |
730 case SkRegion::kReverseDifference_Op: | 690 case SkRegion::kReverseDifference_Op: |
731 case SkRegion::kReplace_Op: | 691 case SkRegion::kReplace_Op: |
732 return true; | 692 return true; |
733 case SkRegion::kIntersect_Op: | 693 case SkRegion::kIntersect_Op: |
734 case SkRegion::kDifference_Op: | 694 case SkRegion::kDifference_Op: |
735 return false; | 695 return false; |
736 default: | 696 default: |
737 SkDEBUGFAIL("unknown region op"); | 697 SkDEBUGFAIL("unknown region op"); |
738 return false; | 698 return false; |
739 } | 699 } |
740 } | 700 } |
741 | 701 |
742 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
743 void SkPictureRecord::fillRestoreOffsetPlaceholdersForCurrentStackLevel(uint32_t
restoreOffset) { | |
744 fMCMgr.fillInSkips(&fWriter, restoreOffset); | |
745 } | |
746 #else | |
747 void SkPictureRecord::fillRestoreOffsetPlaceholdersForCurrentStackLevel(uint32_t
restoreOffset) { | 702 void SkPictureRecord::fillRestoreOffsetPlaceholdersForCurrentStackLevel(uint32_t
restoreOffset) { |
748 int32_t offset = fRestoreOffsetStack.top(); | 703 int32_t offset = fRestoreOffsetStack.top(); |
749 while (offset > 0) { | 704 while (offset > 0) { |
750 uint32_t peek = fWriter.readTAt<uint32_t>(offset); | 705 uint32_t peek = fWriter.readTAt<uint32_t>(offset); |
751 fWriter.overwriteTAt(offset, restoreOffset); | 706 fWriter.overwriteTAt(offset, restoreOffset); |
752 offset = peek; | 707 offset = peek; |
753 } | 708 } |
754 | 709 |
755 #ifdef SK_DEBUG | 710 #ifdef SK_DEBUG |
756 // assert that the final offset value points to a save verb | 711 // assert that the final offset value points to a save verb |
757 uint32_t opSize; | 712 uint32_t opSize; |
758 DrawType drawOp = peek_op_and_size(&fWriter, -offset, &opSize); | 713 DrawType drawOp = peek_op_and_size(&fWriter, -offset, &opSize); |
759 SkASSERT(SAVE == drawOp || SAVE_LAYER == drawOp); | 714 SkASSERT(SAVE == drawOp || SAVE_LAYER == drawOp); |
760 #endif | 715 #endif |
761 } | 716 } |
762 #endif | |
763 | 717 |
764 void SkPictureRecord::beginRecording() { | 718 void SkPictureRecord::beginRecording() { |
765 // we have to call this *after* our constructor, to ensure that it gets | 719 // we have to call this *after* our constructor, to ensure that it gets |
766 // recorded. This is balanced by restoreToCount() call from endRecording, | 720 // recorded. This is balanced by restoreToCount() call from endRecording, |
767 // which in-turn calls our overridden restore(), so those get recorded too. | 721 // which in-turn calls our overridden restore(), so those get recorded too. |
768 fInitialSaveCount = this->save(); | 722 fInitialSaveCount = this->save(); |
769 } | 723 } |
770 | 724 |
771 void SkPictureRecord::endRecording() { | 725 void SkPictureRecord::endRecording() { |
772 SkASSERT(kNoInitialSave != fInitialSaveCount); | 726 SkASSERT(kNoInitialSave != fInitialSaveCount); |
773 this->restoreToCount(fInitialSaveCount); | 727 this->restoreToCount(fInitialSaveCount); |
774 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
775 fMCMgr.finish(); | |
776 #endif | |
777 } | 728 } |
778 | 729 |
779 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
780 int SkPictureRecord::recordRestoreOffsetPlaceholder(SkRegion::Op op) { | |
781 size_t offset = fWriter.bytesWritten(); | |
782 this->addInt(-1); | |
783 return offset; | |
784 } | |
785 #else | |
786 size_t SkPictureRecord::recordRestoreOffsetPlaceholder(SkRegion::Op op) { | 730 size_t SkPictureRecord::recordRestoreOffsetPlaceholder(SkRegion::Op op) { |
787 if (fRestoreOffsetStack.isEmpty()) { | 731 if (fRestoreOffsetStack.isEmpty()) { |
788 return -1; | 732 return -1; |
789 } | 733 } |
790 | 734 |
791 // The RestoreOffset field is initially filled with a placeholder | 735 // The RestoreOffset field is initially filled with a placeholder |
792 // value that points to the offset of the previous RestoreOffset | 736 // value that points to the offset of the previous RestoreOffset |
793 // in the current stack level, thus forming a linked list so that | 737 // in the current stack level, thus forming a linked list so that |
794 // the restore offsets can be filled in when the corresponding | 738 // the restore offsets can be filled in when the corresponding |
795 // restore command is recorded. | 739 // restore command is recorded. |
796 int32_t prevOffset = fRestoreOffsetStack.top(); | 740 int32_t prevOffset = fRestoreOffsetStack.top(); |
797 | 741 |
798 if (regionOpExpands(op)) { | 742 if (regionOpExpands(op)) { |
799 // Run back through any previous clip ops, and mark their offset to | 743 // Run back through any previous clip ops, and mark their offset to |
800 // be 0, disabling their ability to trigger a jump-to-restore, otherwise | 744 // be 0, disabling their ability to trigger a jump-to-restore, otherwise |
801 // they could hide this clips ability to expand the clip (i.e. go from | 745 // they could hide this clips ability to expand the clip (i.e. go from |
802 // empty to non-empty). | 746 // empty to non-empty). |
803 this->fillRestoreOffsetPlaceholdersForCurrentStackLevel(0); | 747 this->fillRestoreOffsetPlaceholdersForCurrentStackLevel(0); |
804 | 748 |
805 // Reset the pointer back to the previous clip so that subsequent | 749 // Reset the pointer back to the previous clip so that subsequent |
806 // restores don't overwrite the offsets we just cleared. | 750 // restores don't overwrite the offsets we just cleared. |
807 prevOffset = 0; | 751 prevOffset = 0; |
808 } | 752 } |
809 | 753 |
810 size_t offset = fWriter.bytesWritten(); | 754 size_t offset = fWriter.bytesWritten(); |
811 this->addInt(prevOffset); | 755 this->addInt(prevOffset); |
812 fRestoreOffsetStack.top() = SkToU32(offset); | 756 fRestoreOffsetStack.top() = SkToU32(offset); |
813 return offset; | 757 return offset; |
814 } | 758 } |
815 #endif | |
816 | 759 |
817 void SkPictureRecord::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeSt
yle edgeStyle) { | 760 void SkPictureRecord::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeSt
yle edgeStyle) { |
818 | |
819 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
820 fMCMgr.clipRect(rect, op, doAA); | |
821 #else | |
822 this->recordClipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle); | 761 this->recordClipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle); |
823 #endif | |
824 this->INHERITED::onClipRect(rect, op, edgeStyle); | 762 this->INHERITED::onClipRect(rect, op, edgeStyle); |
825 } | 763 } |
826 | 764 |
827 size_t SkPictureRecord::recordClipRect(const SkRect& rect, SkRegion::Op op, bool
doAA) { | 765 size_t SkPictureRecord::recordClipRect(const SkRect& rect, SkRegion::Op op, bool
doAA) { |
828 // id + rect + clip params | 766 // id + rect + clip params |
829 size_t size = 1 * kUInt32Size + sizeof(rect) + 1 * kUInt32Size; | 767 size_t size = 1 * kUInt32Size + sizeof(rect) + 1 * kUInt32Size; |
830 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
831 size += kUInt32Size; // + restore offset | |
832 #else | |
833 // recordRestoreOffsetPlaceholder doesn't always write an offset | 768 // recordRestoreOffsetPlaceholder doesn't always write an offset |
834 if (!fRestoreOffsetStack.isEmpty()) { | 769 if (!fRestoreOffsetStack.isEmpty()) { |
835 // + restore offset | 770 // + restore offset |
836 size += kUInt32Size; | 771 size += kUInt32Size; |
837 } | 772 } |
838 #endif | |
839 size_t initialOffset = this->addDraw(CLIP_RECT, &size); | 773 size_t initialOffset = this->addDraw(CLIP_RECT, &size); |
840 this->addRect(rect); | 774 this->addRect(rect); |
841 this->addInt(ClipParams_pack(op, doAA)); | 775 this->addInt(ClipParams_pack(op, doAA)); |
842 size_t offset = this->recordRestoreOffsetPlaceholder(op); | 776 size_t offset = this->recordRestoreOffsetPlaceholder(op); |
843 | 777 |
844 this->validate(initialOffset, size); | 778 this->validate(initialOffset, size); |
845 return offset; | 779 return offset; |
846 } | 780 } |
847 | 781 |
848 void SkPictureRecord::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdg
eStyle edgeStyle) { | 782 void SkPictureRecord::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdg
eStyle edgeStyle) { |
849 | |
850 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
851 fMCMgr.clipRRect(rrect, op, doAA); | |
852 #else | |
853 this->recordClipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle); | 783 this->recordClipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle); |
854 #endif | |
855 this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false); | 784 this->updateClipConservativelyUsingBounds(rrect.getBounds(), op, false); |
856 } | 785 } |
857 | 786 |
858 size_t SkPictureRecord::recordClipRRect(const SkRRect& rrect, SkRegion::Op op, b
ool doAA) { | 787 size_t SkPictureRecord::recordClipRRect(const SkRRect& rrect, SkRegion::Op op, b
ool doAA) { |
859 // op + rrect + clip params | 788 // op + rrect + clip params |
860 size_t size = 1 * kUInt32Size + SkRRect::kSizeInMemory + 1 * kUInt32Size; | 789 size_t size = 1 * kUInt32Size + SkRRect::kSizeInMemory + 1 * kUInt32Size; |
861 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
862 size += kUInt32Size; // + restore offset | |
863 #else | |
864 // recordRestoreOffsetPlaceholder doesn't always write an offset | 790 // recordRestoreOffsetPlaceholder doesn't always write an offset |
865 if (!fRestoreOffsetStack.isEmpty()) { | 791 if (!fRestoreOffsetStack.isEmpty()) { |
866 // + restore offset | 792 // + restore offset |
867 size += kUInt32Size; | 793 size += kUInt32Size; |
868 } | 794 } |
869 #endif | |
870 size_t initialOffset = this->addDraw(CLIP_RRECT, &size); | 795 size_t initialOffset = this->addDraw(CLIP_RRECT, &size); |
871 this->addRRect(rrect); | 796 this->addRRect(rrect); |
872 this->addInt(ClipParams_pack(op, doAA)); | 797 this->addInt(ClipParams_pack(op, doAA)); |
873 size_t offset = recordRestoreOffsetPlaceholder(op); | 798 size_t offset = recordRestoreOffsetPlaceholder(op); |
874 this->validate(initialOffset, size); | 799 this->validate(initialOffset, size); |
875 return offset; | 800 return offset; |
876 } | 801 } |
877 | 802 |
878 void SkPictureRecord::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeSt
yle edgeStyle) { | 803 void SkPictureRecord::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeSt
yle edgeStyle) { |
879 | |
880 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
881 fMCMgr.clipPath(path, op, doAA); | |
882 #else | |
883 int pathID = this->addPathToHeap(path); | 804 int pathID = this->addPathToHeap(path); |
884 this->recordClipPath(pathID, op, kSoft_ClipEdgeStyle == edgeStyle); | 805 this->recordClipPath(pathID, op, kSoft_ClipEdgeStyle == edgeStyle); |
885 #endif | |
886 | 806 |
887 this->updateClipConservativelyUsingBounds(path.getBounds(), op, | 807 this->updateClipConservativelyUsingBounds(path.getBounds(), op, |
888 path.isInverseFillType()); | 808 path.isInverseFillType()); |
889 } | 809 } |
890 | 810 |
891 size_t SkPictureRecord::recordClipPath(int pathID, SkRegion::Op op, bool doAA) { | 811 size_t SkPictureRecord::recordClipPath(int pathID, SkRegion::Op op, bool doAA) { |
892 // op + path index + clip params | 812 // op + path index + clip params |
893 size_t size = 3 * kUInt32Size; | 813 size_t size = 3 * kUInt32Size; |
894 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
895 size += kUInt32Size; // + restore offset | |
896 #else | |
897 // recordRestoreOffsetPlaceholder doesn't always write an offset | 814 // recordRestoreOffsetPlaceholder doesn't always write an offset |
898 if (!fRestoreOffsetStack.isEmpty()) { | 815 if (!fRestoreOffsetStack.isEmpty()) { |
899 // + restore offset | 816 // + restore offset |
900 size += kUInt32Size; | 817 size += kUInt32Size; |
901 } | 818 } |
902 #endif | |
903 size_t initialOffset = this->addDraw(CLIP_PATH, &size); | 819 size_t initialOffset = this->addDraw(CLIP_PATH, &size); |
904 this->addInt(pathID); | 820 this->addInt(pathID); |
905 this->addInt(ClipParams_pack(op, doAA)); | 821 this->addInt(ClipParams_pack(op, doAA)); |
906 size_t offset = recordRestoreOffsetPlaceholder(op); | 822 size_t offset = recordRestoreOffsetPlaceholder(op); |
907 this->validate(initialOffset, size); | 823 this->validate(initialOffset, size); |
908 return offset; | 824 return offset; |
909 } | 825 } |
910 | 826 |
911 void SkPictureRecord::onClipRegion(const SkRegion& region, SkRegion::Op op) { | 827 void SkPictureRecord::onClipRegion(const SkRegion& region, SkRegion::Op op) { |
912 | |
913 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
914 fMCMgr.clipRegion(region, op); | |
915 #else | |
916 this->recordClipRegion(region, op); | 828 this->recordClipRegion(region, op); |
917 #endif | |
918 this->INHERITED::onClipRegion(region, op); | 829 this->INHERITED::onClipRegion(region, op); |
919 } | 830 } |
920 | 831 |
921 size_t SkPictureRecord::recordClipRegion(const SkRegion& region, SkRegion::Op op
) { | 832 size_t SkPictureRecord::recordClipRegion(const SkRegion& region, SkRegion::Op op
) { |
922 // op + clip params + region | 833 // op + clip params + region |
923 size_t size = 2 * kUInt32Size + region.writeToMemory(NULL); | 834 size_t size = 2 * kUInt32Size + region.writeToMemory(NULL); |
924 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
925 size += kUInt32Size; // + restore offset | |
926 #else | |
927 // recordRestoreOffsetPlaceholder doesn't always write an offset | 835 // recordRestoreOffsetPlaceholder doesn't always write an offset |
928 if (!fRestoreOffsetStack.isEmpty()) { | 836 if (!fRestoreOffsetStack.isEmpty()) { |
929 // + restore offset | 837 // + restore offset |
930 size += kUInt32Size; | 838 size += kUInt32Size; |
931 } | 839 } |
932 #endif | |
933 size_t initialOffset = this->addDraw(CLIP_REGION, &size); | 840 size_t initialOffset = this->addDraw(CLIP_REGION, &size); |
934 this->addRegion(region); | 841 this->addRegion(region); |
935 this->addInt(ClipParams_pack(op, false)); | 842 this->addInt(ClipParams_pack(op, false)); |
936 size_t offset = this->recordRestoreOffsetPlaceholder(op); | 843 size_t offset = this->recordRestoreOffsetPlaceholder(op); |
937 | 844 |
938 this->validate(initialOffset, size); | 845 this->validate(initialOffset, size); |
939 return offset; | 846 return offset; |
940 } | 847 } |
941 | 848 |
942 void SkPictureRecord::clear(SkColor color) { | 849 void SkPictureRecord::clear(SkColor color) { |
943 | |
944 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
945 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
946 #endif | |
947 | |
948 // op + color | 850 // op + color |
949 size_t size = 2 * kUInt32Size; | 851 size_t size = 2 * kUInt32Size; |
950 size_t initialOffset = this->addDraw(DRAW_CLEAR, &size); | 852 size_t initialOffset = this->addDraw(DRAW_CLEAR, &size); |
951 this->addInt(color); | 853 this->addInt(color); |
952 this->validate(initialOffset, size); | 854 this->validate(initialOffset, size); |
953 } | 855 } |
954 | 856 |
955 void SkPictureRecord::drawPaint(const SkPaint& paint) { | 857 void SkPictureRecord::drawPaint(const SkPaint& paint) { |
956 | |
957 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
958 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
959 #endif | |
960 | |
961 // op + paint index | 858 // op + paint index |
962 size_t size = 2 * kUInt32Size; | 859 size_t size = 2 * kUInt32Size; |
963 size_t initialOffset = this->addDraw(DRAW_PAINT, &size); | 860 size_t initialOffset = this->addDraw(DRAW_PAINT, &size); |
964 SkASSERT(initialOffset+getPaintOffset(DRAW_PAINT, size) == fWriter.bytesWrit
ten()); | 861 SkASSERT(initialOffset+getPaintOffset(DRAW_PAINT, size) == fWriter.bytesWrit
ten()); |
965 this->addPaint(paint); | 862 this->addPaint(paint); |
966 this->validate(initialOffset, size); | 863 this->validate(initialOffset, size); |
967 } | 864 } |
968 | 865 |
969 void SkPictureRecord::drawPoints(PointMode mode, size_t count, const SkPoint pts
[], | 866 void SkPictureRecord::drawPoints(PointMode mode, size_t count, const SkPoint pts
[], |
970 const SkPaint& paint) { | 867 const SkPaint& paint) { |
971 | |
972 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
973 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
974 #endif | |
975 fContentInfo.onDrawPoints(count, paint); | 868 fContentInfo.onDrawPoints(count, paint); |
976 | 869 |
977 // op + paint index + mode + count + point data | 870 // op + paint index + mode + count + point data |
978 size_t size = 4 * kUInt32Size + count * sizeof(SkPoint); | 871 size_t size = 4 * kUInt32Size + count * sizeof(SkPoint); |
979 size_t initialOffset = this->addDraw(DRAW_POINTS, &size); | 872 size_t initialOffset = this->addDraw(DRAW_POINTS, &size); |
980 SkASSERT(initialOffset+getPaintOffset(DRAW_POINTS, size) == fWriter.bytesWri
tten()); | 873 SkASSERT(initialOffset+getPaintOffset(DRAW_POINTS, size) == fWriter.bytesWri
tten()); |
981 this->addPaint(paint); | 874 this->addPaint(paint); |
982 | 875 |
983 this->addInt(mode); | 876 this->addInt(mode); |
984 this->addInt(SkToInt(count)); | 877 this->addInt(SkToInt(count)); |
985 fWriter.writeMul4(pts, count * sizeof(SkPoint)); | 878 fWriter.writeMul4(pts, count * sizeof(SkPoint)); |
986 this->validate(initialOffset, size); | 879 this->validate(initialOffset, size); |
987 } | 880 } |
988 | 881 |
989 void SkPictureRecord::drawOval(const SkRect& oval, const SkPaint& paint) { | 882 void SkPictureRecord::drawOval(const SkRect& oval, const SkPaint& paint) { |
990 | |
991 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
992 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
993 #endif | |
994 | |
995 // op + paint index + rect | 883 // op + paint index + rect |
996 size_t size = 2 * kUInt32Size + sizeof(oval); | 884 size_t size = 2 * kUInt32Size + sizeof(oval); |
997 size_t initialOffset = this->addDraw(DRAW_OVAL, &size); | 885 size_t initialOffset = this->addDraw(DRAW_OVAL, &size); |
998 SkASSERT(initialOffset+getPaintOffset(DRAW_OVAL, size) == fWriter.bytesWritt
en()); | 886 SkASSERT(initialOffset+getPaintOffset(DRAW_OVAL, size) == fWriter.bytesWritt
en()); |
999 this->addPaint(paint); | 887 this->addPaint(paint); |
1000 this->addRect(oval); | 888 this->addRect(oval); |
1001 this->validate(initialOffset, size); | 889 this->validate(initialOffset, size); |
1002 } | 890 } |
1003 | 891 |
1004 void SkPictureRecord::drawRect(const SkRect& rect, const SkPaint& paint) { | 892 void SkPictureRecord::drawRect(const SkRect& rect, const SkPaint& paint) { |
1005 | |
1006 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
1007 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
1008 #endif | |
1009 | |
1010 // op + paint index + rect | 893 // op + paint index + rect |
1011 size_t size = 2 * kUInt32Size + sizeof(rect); | 894 size_t size = 2 * kUInt32Size + sizeof(rect); |
1012 size_t initialOffset = this->addDraw(DRAW_RECT, &size); | 895 size_t initialOffset = this->addDraw(DRAW_RECT, &size); |
1013 SkASSERT(initialOffset+getPaintOffset(DRAW_RECT, size) == fWriter.bytesWritt
en()); | 896 SkASSERT(initialOffset+getPaintOffset(DRAW_RECT, size) == fWriter.bytesWritt
en()); |
1014 this->addPaint(paint); | 897 this->addPaint(paint); |
1015 this->addRect(rect); | 898 this->addRect(rect); |
1016 this->validate(initialOffset, size); | 899 this->validate(initialOffset, size); |
1017 } | 900 } |
1018 | 901 |
1019 void SkPictureRecord::drawRRect(const SkRRect& rrect, const SkPaint& paint) { | 902 void SkPictureRecord::drawRRect(const SkRRect& rrect, const SkPaint& paint) { |
1020 | |
1021 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
1022 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
1023 #endif | |
1024 | |
1025 if (rrect.isRect() && kBeClever) { | 903 if (rrect.isRect() && kBeClever) { |
1026 this->SkPictureRecord::drawRect(rrect.getBounds(), paint); | 904 this->SkPictureRecord::drawRect(rrect.getBounds(), paint); |
1027 } else if (rrect.isOval() && kBeClever) { | 905 } else if (rrect.isOval() && kBeClever) { |
1028 this->SkPictureRecord::drawOval(rrect.getBounds(), paint); | 906 this->SkPictureRecord::drawOval(rrect.getBounds(), paint); |
1029 } else { | 907 } else { |
1030 // op + paint index + rrect | 908 // op + paint index + rrect |
1031 size_t size = 2 * kUInt32Size + SkRRect::kSizeInMemory; | 909 size_t size = 2 * kUInt32Size + SkRRect::kSizeInMemory; |
1032 size_t initialOffset = this->addDraw(DRAW_RRECT, &size); | 910 size_t initialOffset = this->addDraw(DRAW_RRECT, &size); |
1033 SkASSERT(initialOffset+getPaintOffset(DRAW_RRECT, size) == fWriter.bytes
Written()); | 911 SkASSERT(initialOffset+getPaintOffset(DRAW_RRECT, size) == fWriter.bytes
Written()); |
1034 this->addPaint(paint); | 912 this->addPaint(paint); |
1035 this->addRRect(rrect); | 913 this->addRRect(rrect); |
1036 this->validate(initialOffset, size); | 914 this->validate(initialOffset, size); |
1037 } | 915 } |
1038 } | 916 } |
1039 | 917 |
1040 void SkPictureRecord::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, | 918 void SkPictureRecord::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, |
1041 const SkPaint& paint) { | 919 const SkPaint& paint) { |
1042 | |
1043 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
1044 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
1045 #endif | |
1046 | |
1047 // op + paint index + rrects | 920 // op + paint index + rrects |
1048 size_t size = 2 * kUInt32Size + SkRRect::kSizeInMemory * 2; | 921 size_t size = 2 * kUInt32Size + SkRRect::kSizeInMemory * 2; |
1049 size_t initialOffset = this->addDraw(DRAW_DRRECT, &size); | 922 size_t initialOffset = this->addDraw(DRAW_DRRECT, &size); |
1050 SkASSERT(initialOffset+getPaintOffset(DRAW_DRRECT, size) == fWriter.bytesWri
tten()); | 923 SkASSERT(initialOffset+getPaintOffset(DRAW_DRRECT, size) == fWriter.bytesWri
tten()); |
1051 this->addPaint(paint); | 924 this->addPaint(paint); |
1052 this->addRRect(outer); | 925 this->addRRect(outer); |
1053 this->addRRect(inner); | 926 this->addRRect(inner); |
1054 this->validate(initialOffset, size); | 927 this->validate(initialOffset, size); |
1055 } | 928 } |
1056 | 929 |
1057 void SkPictureRecord::drawPath(const SkPath& path, const SkPaint& paint) { | 930 void SkPictureRecord::drawPath(const SkPath& path, const SkPaint& paint) { |
1058 | |
1059 fContentInfo.onDrawPath(path, paint); | 931 fContentInfo.onDrawPath(path, paint); |
1060 | 932 |
1061 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
1062 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
1063 #endif | |
1064 | |
1065 // op + paint index + path index | 933 // op + paint index + path index |
1066 size_t size = 3 * kUInt32Size; | 934 size_t size = 3 * kUInt32Size; |
1067 size_t initialOffset = this->addDraw(DRAW_PATH, &size); | 935 size_t initialOffset = this->addDraw(DRAW_PATH, &size); |
1068 SkASSERT(initialOffset+getPaintOffset(DRAW_PATH, size) == fWriter.bytesWritt
en()); | 936 SkASSERT(initialOffset+getPaintOffset(DRAW_PATH, size) == fWriter.bytesWritt
en()); |
1069 this->addPaint(paint); | 937 this->addPaint(paint); |
1070 this->addPath(path); | 938 this->addPath(path); |
1071 this->validate(initialOffset, size); | 939 this->validate(initialOffset, size); |
1072 } | 940 } |
1073 | 941 |
1074 void SkPictureRecord::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar
top, | 942 void SkPictureRecord::drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar
top, |
1075 const SkPaint* paint = NULL) { | 943 const SkPaint* paint = NULL) { |
1076 if (bitmap.drawsNothing() && kBeClever) { | 944 if (bitmap.drawsNothing() && kBeClever) { |
1077 return; | 945 return; |
1078 } | 946 } |
1079 | 947 |
1080 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
1081 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
1082 #endif | |
1083 | |
1084 // op + paint index + bitmap index + left + top | 948 // op + paint index + bitmap index + left + top |
1085 size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar); | 949 size_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar); |
1086 size_t initialOffset = this->addDraw(DRAW_BITMAP, &size); | 950 size_t initialOffset = this->addDraw(DRAW_BITMAP, &size); |
1087 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP, size) == fWriter.bytesWri
tten()); | 951 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP, size) == fWriter.bytesWri
tten()); |
1088 this->addPaintPtr(paint); | 952 this->addPaintPtr(paint); |
1089 this->addBitmap(bitmap); | 953 this->addBitmap(bitmap); |
1090 this->addScalar(left); | 954 this->addScalar(left); |
1091 this->addScalar(top); | 955 this->addScalar(top); |
1092 this->validate(initialOffset, size); | 956 this->validate(initialOffset, size); |
1093 } | 957 } |
1094 | 958 |
1095 void SkPictureRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect*
src, | 959 void SkPictureRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect*
src, |
1096 const SkRect& dst, const SkPaint* pai
nt, | 960 const SkRect& dst, const SkPaint* pai
nt, |
1097 DrawBitmapRectFlags flags) { | 961 DrawBitmapRectFlags flags) { |
1098 if (bitmap.drawsNothing() && kBeClever) { | 962 if (bitmap.drawsNothing() && kBeClever) { |
1099 return; | 963 return; |
1100 } | 964 } |
1101 | 965 |
1102 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
1103 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
1104 #endif | |
1105 // id + paint index + bitmap index + bool for 'src' + flags | 966 // id + paint index + bitmap index + bool for 'src' + flags |
1106 size_t size = 5 * kUInt32Size; | 967 size_t size = 5 * kUInt32Size; |
1107 if (NULL != src) { | 968 if (NULL != src) { |
1108 size += sizeof(*src); // + rect | 969 size += sizeof(*src); // + rect |
1109 } | 970 } |
1110 size += sizeof(dst); // + rect | 971 size += sizeof(dst); // + rect |
1111 | 972 |
1112 size_t initialOffset = this->addDraw(DRAW_BITMAP_RECT_TO_RECT, &size); | 973 size_t initialOffset = this->addDraw(DRAW_BITMAP_RECT_TO_RECT, &size); |
1113 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_RECT_TO_RECT, size) | 974 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_RECT_TO_RECT, size) |
1114 == fWriter.bytesWritten()); | 975 == fWriter.bytesWritten()); |
1115 this->addPaintPtr(paint); | 976 this->addPaintPtr(paint); |
1116 this->addBitmap(bitmap); | 977 this->addBitmap(bitmap); |
1117 this->addRectPtr(src); // may be null | 978 this->addRectPtr(src); // may be null |
1118 this->addRect(dst); | 979 this->addRect(dst); |
1119 this->addInt(flags); | 980 this->addInt(flags); |
1120 this->validate(initialOffset, size); | 981 this->validate(initialOffset, size); |
1121 } | 982 } |
1122 | 983 |
1123 void SkPictureRecord::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m
atrix, | 984 void SkPictureRecord::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m
atrix, |
1124 const SkPaint* paint) { | 985 const SkPaint* paint) { |
1125 if (bitmap.drawsNothing() && kBeClever) { | 986 if (bitmap.drawsNothing() && kBeClever) { |
1126 return; | 987 return; |
1127 } | 988 } |
1128 | 989 |
1129 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
1130 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
1131 #endif | |
1132 | |
1133 // id + paint index + bitmap index + matrix | 990 // id + paint index + bitmap index + matrix |
1134 size_t size = 3 * kUInt32Size + matrix.writeToMemory(NULL); | 991 size_t size = 3 * kUInt32Size + matrix.writeToMemory(NULL); |
1135 size_t initialOffset = this->addDraw(DRAW_BITMAP_MATRIX, &size); | 992 size_t initialOffset = this->addDraw(DRAW_BITMAP_MATRIX, &size); |
1136 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_MATRIX, size) == fWriter.b
ytesWritten()); | 993 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_MATRIX, size) == fWriter.b
ytesWritten()); |
1137 this->addPaintPtr(paint); | 994 this->addPaintPtr(paint); |
1138 this->addBitmap(bitmap); | 995 this->addBitmap(bitmap); |
1139 this->addMatrix(matrix); | 996 this->addMatrix(matrix); |
1140 this->validate(initialOffset, size); | 997 this->validate(initialOffset, size); |
1141 } | 998 } |
1142 | 999 |
1143 void SkPictureRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& cent
er, | 1000 void SkPictureRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& cent
er, |
1144 const SkRect& dst, const SkPaint* paint) { | 1001 const SkRect& dst, const SkPaint* paint) { |
1145 if (bitmap.drawsNothing() && kBeClever) { | 1002 if (bitmap.drawsNothing() && kBeClever) { |
1146 return; | 1003 return; |
1147 } | 1004 } |
1148 | 1005 |
1149 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
1150 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
1151 #endif | |
1152 | |
1153 // op + paint index + bitmap id + center + dst rect | 1006 // op + paint index + bitmap id + center + dst rect |
1154 size_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst); | 1007 size_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst); |
1155 size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size); | 1008 size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size); |
1156 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_NINE, size) == fWriter.byt
esWritten()); | 1009 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_NINE, size) == fWriter.byt
esWritten()); |
1157 this->addPaintPtr(paint); | 1010 this->addPaintPtr(paint); |
1158 this->addBitmap(bitmap); | 1011 this->addBitmap(bitmap); |
1159 this->addIRect(center); | 1012 this->addIRect(center); |
1160 this->addRect(dst); | 1013 this->addRect(dst); |
1161 this->validate(initialOffset, size); | 1014 this->validate(initialOffset, size); |
1162 } | 1015 } |
1163 | 1016 |
1164 void SkPictureRecord::drawSprite(const SkBitmap& bitmap, int left, int top, | 1017 void SkPictureRecord::drawSprite(const SkBitmap& bitmap, int left, int top, |
1165 const SkPaint* paint = NULL) { | 1018 const SkPaint* paint = NULL) { |
1166 if (bitmap.drawsNothing() && kBeClever) { | 1019 if (bitmap.drawsNothing() && kBeClever) { |
1167 return; | 1020 return; |
1168 } | 1021 } |
1169 | 1022 |
1170 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
1171 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
1172 #endif | |
1173 | |
1174 // op + paint index + bitmap index + left + top | 1023 // op + paint index + bitmap index + left + top |
1175 size_t size = 5 * kUInt32Size; | 1024 size_t size = 5 * kUInt32Size; |
1176 size_t initialOffset = this->addDraw(DRAW_SPRITE, &size); | 1025 size_t initialOffset = this->addDraw(DRAW_SPRITE, &size); |
1177 SkASSERT(initialOffset+getPaintOffset(DRAW_SPRITE, size) == fWriter.bytesWri
tten()); | 1026 SkASSERT(initialOffset+getPaintOffset(DRAW_SPRITE, size) == fWriter.bytesWri
tten()); |
1178 this->addPaintPtr(paint); | 1027 this->addPaintPtr(paint); |
1179 this->addBitmap(bitmap); | 1028 this->addBitmap(bitmap); |
1180 this->addInt(left); | 1029 this->addInt(left); |
1181 this->addInt(top); | 1030 this->addInt(top); |
1182 this->validate(initialOffset, size); | 1031 this->validate(initialOffset, size); |
1183 } | 1032 } |
(...skipping 12 matching lines...) Expand all Loading... |
1196 | 1045 |
1197 void SkPictureRecord::addFontMetricsTopBottom(const SkPaint& paint, const SkFlat
Data& flat, | 1046 void SkPictureRecord::addFontMetricsTopBottom(const SkPaint& paint, const SkFlat
Data& flat, |
1198 SkScalar minY, SkScalar maxY) { | 1047 SkScalar minY, SkScalar maxY) { |
1199 WriteTopBot(paint, flat); | 1048 WriteTopBot(paint, flat); |
1200 this->addScalar(flat.topBot()[0] + minY); | 1049 this->addScalar(flat.topBot()[0] + minY); |
1201 this->addScalar(flat.topBot()[1] + maxY); | 1050 this->addScalar(flat.topBot()[1] + maxY); |
1202 } | 1051 } |
1203 | 1052 |
1204 void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x
, SkScalar y, | 1053 void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x
, SkScalar y, |
1205 const SkPaint& paint) { | 1054 const SkPaint& paint) { |
1206 | |
1207 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
1208 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
1209 #endif | |
1210 | |
1211 bool fast = !paint.isVerticalText() && paint.canComputeFastBounds() && kBeCl
ever; | 1055 bool fast = !paint.isVerticalText() && paint.canComputeFastBounds() && kBeCl
ever; |
1212 | 1056 |
1213 // op + paint index + length + 'length' worth of chars + x + y | 1057 // op + paint index + length + 'length' worth of chars + x + y |
1214 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar); | 1058 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar); |
1215 if (fast) { | 1059 if (fast) { |
1216 size += 2 * sizeof(SkScalar); // + top & bottom | 1060 size += 2 * sizeof(SkScalar); // + top & bottom |
1217 } | 1061 } |
1218 | 1062 |
1219 DrawType op = fast ? DRAW_TEXT_TOP_BOTTOM : DRAW_TEXT; | 1063 DrawType op = fast ? DRAW_TEXT_TOP_BOTTOM : DRAW_TEXT; |
1220 size_t initialOffset = this->addDraw(op, &size); | 1064 size_t initialOffset = this->addDraw(op, &size); |
1221 SkASSERT(initialOffset+getPaintOffset(op, size) == fWriter.bytesWritten()); | 1065 SkASSERT(initialOffset+getPaintOffset(op, size) == fWriter.bytesWritten()); |
1222 const SkFlatData* flatPaintData = addPaint(paint); | 1066 const SkFlatData* flatPaintData = addPaint(paint); |
1223 SkASSERT(flatPaintData); | 1067 SkASSERT(flatPaintData); |
1224 this->addText(text, byteLength); | 1068 this->addText(text, byteLength); |
1225 this->addScalar(x); | 1069 this->addScalar(x); |
1226 this->addScalar(y); | 1070 this->addScalar(y); |
1227 if (fast) { | 1071 if (fast) { |
1228 this->addFontMetricsTopBottom(paint, *flatPaintData, y, y); | 1072 this->addFontMetricsTopBottom(paint, *flatPaintData, y, y); |
1229 } | 1073 } |
1230 this->validate(initialOffset, size); | 1074 this->validate(initialOffset, size); |
1231 } | 1075 } |
1232 | 1076 |
1233 void SkPictureRecord::onDrawPosText(const void* text, size_t byteLength, const S
kPoint pos[], | 1077 void SkPictureRecord::onDrawPosText(const void* text, size_t byteLength, const S
kPoint pos[], |
1234 const SkPaint& paint) { | 1078 const SkPaint& paint) { |
1235 | |
1236 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
1237 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
1238 #endif | |
1239 | |
1240 int points = paint.countText(text, byteLength); | 1079 int points = paint.countText(text, byteLength); |
1241 if (0 == points) | 1080 if (0 == points) |
1242 return; | 1081 return; |
1243 | 1082 |
1244 bool canUseDrawH = true; | 1083 bool canUseDrawH = true; |
1245 SkScalar minY = pos[0].fY; | 1084 SkScalar minY = pos[0].fY; |
1246 SkScalar maxY = pos[0].fY; | 1085 SkScalar maxY = pos[0].fY; |
1247 // check if the caller really should have used drawPosTextH() | 1086 // check if the caller really should have used drawPosTextH() |
1248 { | 1087 { |
1249 const SkScalar firstY = pos[0].fY; | 1088 const SkScalar firstY = pos[0].fY; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 } | 1153 } |
1315 #ifdef SK_DEBUG_SIZE | 1154 #ifdef SK_DEBUG_SIZE |
1316 fPointBytes += fWriter.bytesWritten() - start; | 1155 fPointBytes += fWriter.bytesWritten() - start; |
1317 fPointWrites += points; | 1156 fPointWrites += points; |
1318 #endif | 1157 #endif |
1319 this->validate(initialOffset, size); | 1158 this->validate(initialOffset, size); |
1320 } | 1159 } |
1321 | 1160 |
1322 void SkPictureRecord::onDrawPosTextH(const void* text, size_t byteLength, const
SkScalar xpos[], | 1161 void SkPictureRecord::onDrawPosTextH(const void* text, size_t byteLength, const
SkScalar xpos[], |
1323 SkScalar constY, const SkPaint& paint) { | 1162 SkScalar constY, const SkPaint& paint) { |
1324 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
1325 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
1326 #endif | |
1327 | |
1328 const SkFlatData* flatPaintData = this->getFlatPaintData(paint); | 1163 const SkFlatData* flatPaintData = this->getFlatPaintData(paint); |
1329 this->drawPosTextHImpl(text, byteLength, xpos, constY, paint, flatPaintData)
; | 1164 this->drawPosTextHImpl(text, byteLength, xpos, constY, paint, flatPaintData)
; |
1330 } | 1165 } |
1331 | 1166 |
1332 void SkPictureRecord::drawPosTextHImpl(const void* text, size_t byteLength, | 1167 void SkPictureRecord::drawPosTextHImpl(const void* text, size_t byteLength, |
1333 const SkScalar xpos[], SkScalar constY, | 1168 const SkScalar xpos[], SkScalar constY, |
1334 const SkPaint& paint, const SkFlatData* flatPaintData)
{ | 1169 const SkPaint& paint, const SkFlatData* flatPaintData)
{ |
1335 int points = paint.countText(text, byteLength); | 1170 int points = paint.countText(text, byteLength); |
1336 if (0 == points && kBeClever) { | 1171 if (0 == points && kBeClever) { |
1337 return; | 1172 return; |
(...skipping 26 matching lines...) Expand all Loading... |
1364 fWriter.writeMul4(xpos, points * sizeof(SkScalar)); | 1199 fWriter.writeMul4(xpos, points * sizeof(SkScalar)); |
1365 #ifdef SK_DEBUG_SIZE | 1200 #ifdef SK_DEBUG_SIZE |
1366 fPointBytes += fWriter.bytesWritten() - start; | 1201 fPointBytes += fWriter.bytesWritten() - start; |
1367 fPointWrites += points; | 1202 fPointWrites += points; |
1368 #endif | 1203 #endif |
1369 this->validate(initialOffset, size); | 1204 this->validate(initialOffset, size); |
1370 } | 1205 } |
1371 | 1206 |
1372 void SkPictureRecord::onDrawTextOnPath(const void* text, size_t byteLength, cons
t SkPath& path, | 1207 void SkPictureRecord::onDrawTextOnPath(const void* text, size_t byteLength, cons
t SkPath& path, |
1373 const SkMatrix* matrix, const SkPaint& pa
int) { | 1208 const SkMatrix* matrix, const SkPaint& pa
int) { |
1374 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
1375 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
1376 #endif | |
1377 | |
1378 // op + paint index + length + 'length' worth of data + path index + matrix | 1209 // op + paint index + length + 'length' worth of data + path index + matrix |
1379 const SkMatrix& m = matrix ? *matrix : SkMatrix::I(); | 1210 const SkMatrix& m = matrix ? *matrix : SkMatrix::I(); |
1380 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + kUInt32Size + m.write
ToMemory(NULL); | 1211 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + kUInt32Size + m.write
ToMemory(NULL); |
1381 size_t initialOffset = this->addDraw(DRAW_TEXT_ON_PATH, &size); | 1212 size_t initialOffset = this->addDraw(DRAW_TEXT_ON_PATH, &size); |
1382 SkASSERT(initialOffset+getPaintOffset(DRAW_TEXT_ON_PATH, size) == fWriter.by
tesWritten()); | 1213 SkASSERT(initialOffset+getPaintOffset(DRAW_TEXT_ON_PATH, size) == fWriter.by
tesWritten()); |
1383 this->addPaint(paint); | 1214 this->addPaint(paint); |
1384 this->addText(text, byteLength); | 1215 this->addText(text, byteLength); |
1385 this->addPath(path); | 1216 this->addPath(path); |
1386 this->addMatrix(m); | 1217 this->addMatrix(m); |
1387 this->validate(initialOffset, size); | 1218 this->validate(initialOffset, size); |
1388 } | 1219 } |
1389 | 1220 |
1390 void SkPictureRecord::onDrawPicture(const SkPicture* picture, const SkMatrix* ma
trix, | 1221 void SkPictureRecord::onDrawPicture(const SkPicture* picture, const SkMatrix* ma
trix, |
1391 const SkPaint* paint) { | 1222 const SkPaint* paint) { |
1392 | |
1393 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
1394 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
1395 #endif | |
1396 | |
1397 // op + picture index | 1223 // op + picture index |
1398 size_t size = 2 * kUInt32Size; | 1224 size_t size = 2 * kUInt32Size; |
1399 size_t initialOffset; | 1225 size_t initialOffset; |
1400 | 1226 |
1401 if (NULL == matrix && NULL == paint) { | 1227 if (NULL == matrix && NULL == paint) { |
1402 initialOffset = this->addDraw(DRAW_PICTURE, &size); | 1228 initialOffset = this->addDraw(DRAW_PICTURE, &size); |
1403 this->addPicture(picture); | 1229 this->addPicture(picture); |
1404 } else { | 1230 } else { |
1405 const SkMatrix& m = matrix ? *matrix : SkMatrix::I(); | 1231 const SkMatrix& m = matrix ? *matrix : SkMatrix::I(); |
1406 size += m.writeToMemory(NULL) + kUInt32Size; // matrix + paint | 1232 size += m.writeToMemory(NULL) + kUInt32Size; // matrix + paint |
1407 initialOffset = this->addDraw(DRAW_PICTURE_MATRIX_PAINT, &size); | 1233 initialOffset = this->addDraw(DRAW_PICTURE_MATRIX_PAINT, &size); |
1408 this->addPicture(picture); | 1234 this->addPicture(picture); |
1409 this->addMatrix(m); | 1235 this->addMatrix(m); |
1410 this->addPaintPtr(paint); | 1236 this->addPaintPtr(paint); |
1411 } | 1237 } |
1412 this->validate(initialOffset, size); | 1238 this->validate(initialOffset, size); |
1413 } | 1239 } |
1414 | 1240 |
1415 void SkPictureRecord::drawVertices(VertexMode vmode, int vertexCount, | 1241 void SkPictureRecord::drawVertices(VertexMode vmode, int vertexCount, |
1416 const SkPoint vertices[], const SkPoint texs[], | 1242 const SkPoint vertices[], const SkPoint texs[], |
1417 const SkColor colors[], SkXfermode* xfer, | 1243 const SkColor colors[], SkXfermode* xfer, |
1418 const uint16_t indices[], int indexCount, | 1244 const uint16_t indices[], int indexCount, |
1419 const SkPaint& paint) { | 1245 const SkPaint& paint) { |
1420 | |
1421 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
1422 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
1423 #endif | |
1424 | |
1425 uint32_t flags = 0; | 1246 uint32_t flags = 0; |
1426 if (texs) { | 1247 if (texs) { |
1427 flags |= DRAW_VERTICES_HAS_TEXS; | 1248 flags |= DRAW_VERTICES_HAS_TEXS; |
1428 } | 1249 } |
1429 if (colors) { | 1250 if (colors) { |
1430 flags |= DRAW_VERTICES_HAS_COLORS; | 1251 flags |= DRAW_VERTICES_HAS_COLORS; |
1431 } | 1252 } |
1432 if (indexCount > 0) { | 1253 if (indexCount > 0) { |
1433 flags |= DRAW_VERTICES_HAS_INDICES; | 1254 flags |= DRAW_VERTICES_HAS_INDICES; |
1434 } | 1255 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1474 } | 1295 } |
1475 if (flags & DRAW_VERTICES_HAS_XFER) { | 1296 if (flags & DRAW_VERTICES_HAS_XFER) { |
1476 SkXfermode::Mode mode = SkXfermode::kModulate_Mode; | 1297 SkXfermode::Mode mode = SkXfermode::kModulate_Mode; |
1477 (void)xfer->asMode(&mode); | 1298 (void)xfer->asMode(&mode); |
1478 this->addInt(mode); | 1299 this->addInt(mode); |
1479 } | 1300 } |
1480 this->validate(initialOffset, size); | 1301 this->validate(initialOffset, size); |
1481 } | 1302 } |
1482 | 1303 |
1483 void SkPictureRecord::drawPatch(const SkPatch& patch, const SkPaint& paint) { | 1304 void SkPictureRecord::drawPatch(const SkPatch& patch, const SkPaint& paint) { |
1484 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
1485 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
1486 #endif | |
1487 | |
1488 // op + paint index + patch 12 control points + patch 4 colors | 1305 // op + paint index + patch 12 control points + patch 4 colors |
1489 size_t size = 2 * kUInt32Size + SkPatch::kNumCtrlPts * sizeof(SkPoint) + | 1306 size_t size = 2 * kUInt32Size + SkPatch::kNumCtrlPts * sizeof(SkPoint) + |
1490 SkPatch::kNumColors * sizeof(SkColor); | 1307 SkPatch::kNumColors * sizeof(SkColor); |
1491 size_t initialOffset = this->addDraw(DRAW_PATCH, &size); | 1308 size_t initialOffset = this->addDraw(DRAW_PATCH, &size); |
1492 SkASSERT(initialOffset+getPaintOffset(DRAW_PATCH, size) == fWriter.bytesWrit
ten()); | 1309 SkASSERT(initialOffset+getPaintOffset(DRAW_PATCH, size) == fWriter.bytesWrit
ten()); |
1493 this->addPaint(paint); | 1310 this->addPaint(paint); |
1494 this->addPatch(patch); | 1311 this->addPatch(patch); |
1495 this->validate(initialOffset, size); | 1312 this->validate(initialOffset, size); |
1496 } | 1313 } |
1497 | 1314 |
1498 void SkPictureRecord::drawData(const void* data, size_t length) { | 1315 void SkPictureRecord::drawData(const void* data, size_t length) { |
1499 | |
1500 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | |
1501 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | |
1502 #endif | |
1503 | |
1504 // op + length + 'length' worth of data | 1316 // op + length + 'length' worth of data |
1505 size_t size = 2 * kUInt32Size + SkAlign4(length); | 1317 size_t size = 2 * kUInt32Size + SkAlign4(length); |
1506 size_t initialOffset = this->addDraw(DRAW_DATA, &size); | 1318 size_t initialOffset = this->addDraw(DRAW_DATA, &size); |
1507 this->addInt(SkToInt(length)); | 1319 this->addInt(SkToInt(length)); |
1508 fWriter.writePad(data, length); | 1320 fWriter.writePad(data, length); |
1509 this->validate(initialOffset, size); | 1321 this->validate(initialOffset, size); |
1510 } | 1322 } |
1511 | 1323 |
1512 void SkPictureRecord::beginCommentGroup(const char* description) { | 1324 void SkPictureRecord::beginCommentGroup(const char* description) { |
1513 // op/size + length of string + \0 terminated chars | 1325 // op/size + length of string + \0 terminated chars |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1839 void SkPictureRecord::validateRegions() const { | 1651 void SkPictureRecord::validateRegions() const { |
1840 int count = fRegions.count(); | 1652 int count = fRegions.count(); |
1841 SkASSERT((unsigned) count < 0x1000); | 1653 SkASSERT((unsigned) count < 0x1000); |
1842 for (int index = 0; index < count; index++) { | 1654 for (int index = 0; index < count; index++) { |
1843 const SkFlatData* region = fRegions[index]; | 1655 const SkFlatData* region = fRegions[index]; |
1844 SkASSERT(region); | 1656 SkASSERT(region); |
1845 // region->validate(); | 1657 // region->validate(); |
1846 } | 1658 } |
1847 } | 1659 } |
1848 #endif | 1660 #endif |
OLD | NEW |