OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
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 #include "SkPictureRecord.h" | 8 #include "SkPictureRecord.h" |
9 #include "SkTSearch.h" | 9 #include "SkTSearch.h" |
10 #include "SkPixelRef.h" | 10 #include "SkPixelRef.h" |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
708 void SkPictureRecord::endRecording() { | 708 void SkPictureRecord::endRecording() { |
709 SkASSERT(kNoInitialSave != fInitialSaveCount); | 709 SkASSERT(kNoInitialSave != fInitialSaveCount); |
710 this->restoreToCount(fInitialSaveCount); | 710 this->restoreToCount(fInitialSaveCount); |
711 } | 711 } |
712 | 712 |
713 void SkPictureRecord::recordRestoreOffsetPlaceholder(SkRegion::Op op) { | 713 void SkPictureRecord::recordRestoreOffsetPlaceholder(SkRegion::Op op) { |
714 if (fRestoreOffsetStack.isEmpty()) { | 714 if (fRestoreOffsetStack.isEmpty()) { |
715 return; | 715 return; |
716 } | 716 } |
717 | 717 |
718 // The RestoreOffset field is initially filled with a placeholder | |
719 // value that points to the offset of the previous RestoreOffset | |
720 // in the current stack level, thus forming a linked list so that | |
721 // the restore offsets can be filled in when the corresponding | |
722 // restore command is recorded. | |
723 int32_t prevOffset = fRestoreOffsetStack.top(); | |
724 | |
718 if (regionOpExpands(op)) { | 725 if (regionOpExpands(op)) { |
719 // Run back through any previous clip ops, and mark their offset to | 726 // Run back through any previous clip ops, and mark their offset to |
720 // be 0, disabling their ability to trigger a jump-to-restore, otherwise | 727 // be 0, disabling their ability to trigger a jump-to-restore, otherwise |
721 // they could hide this clips ability to expand the clip (i.e. go from | 728 // they could hide this clips ability to expand the clip (i.e. go from |
722 // empty to non-empty). | 729 // empty to non-empty). |
723 fillRestoreOffsetPlaceholdersForCurrentStackLevel(0); | 730 fillRestoreOffsetPlaceholdersForCurrentStackLevel(0); |
731 | |
robertphillips
2013/08/27 15:08:56
Reset the pointer back to the previous clip so tha
| |
732 // Avoid linking to the previous RestoreOffset - otherwise a | |
733 // subsequent restore() will simply overwrite the offsets we just | |
734 // cleared. | |
735 prevOffset = 0; | |
724 } | 736 } |
725 | 737 |
726 size_t offset = fWriter.size(); | 738 size_t offset = fWriter.size(); |
727 // The RestoreOffset field is initially filled with a placeholder | 739 addInt(prevOffset); |
728 // value that points to the offset of the previous RestoreOffset | |
729 // in the current stack level, thus forming a linked list so that | |
730 // the restore offsets can be filled in when the corresponding | |
731 // restore command is recorded. | |
732 addInt(fRestoreOffsetStack.top()); | |
733 fRestoreOffsetStack.top() = offset; | 740 fRestoreOffsetStack.top() = offset; |
734 } | 741 } |
735 | 742 |
736 bool SkPictureRecord::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { | 743 bool SkPictureRecord::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { |
737 // id + rect + clip params | 744 // id + rect + clip params |
738 uint32_t size = 1 * kUInt32Size + sizeof(rect) + 1 * kUInt32Size; | 745 uint32_t size = 1 * kUInt32Size + sizeof(rect) + 1 * kUInt32Size; |
739 // recordRestoreOffsetPlaceholder doesn't always write an offset | 746 // recordRestoreOffsetPlaceholder doesn't always write an offset |
740 if (!fRestoreOffsetStack.isEmpty()) { | 747 if (!fRestoreOffsetStack.isEmpty()) { |
741 // + restore offset | 748 // + restore offset |
742 size += kUInt32Size; | 749 size += kUInt32Size; |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1483 void SkPictureRecord::validateRegions() const { | 1490 void SkPictureRecord::validateRegions() const { |
1484 int count = fRegions.count(); | 1491 int count = fRegions.count(); |
1485 SkASSERT((unsigned) count < 0x1000); | 1492 SkASSERT((unsigned) count < 0x1000); |
1486 for (int index = 0; index < count; index++) { | 1493 for (int index = 0; index < count; index++) { |
1487 const SkFlatData* region = fRegions[index]; | 1494 const SkFlatData* region = fRegions[index]; |
1488 SkASSERT(region); | 1495 SkASSERT(region); |
1489 // region->validate(); | 1496 // region->validate(); |
1490 } | 1497 } |
1491 } | 1498 } |
1492 #endif | 1499 #endif |
OLD | NEW |