Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: src/core/SkPictureRecord.cpp

Issue 22987003: Fix clip expansion in SkPictureRecord::recordRestoreOffsetPlaceholder() (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Updated per comments. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/PictureTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
732 // Reset the pointer back to the previous clip so that subsequent
733 // restores don't overwrite the offsets we just cleared.
734 prevOffset = 0;
724 } 735 }
725 736
726 size_t offset = fWriter.size(); 737 size_t offset = fWriter.size();
727 // The RestoreOffset field is initially filled with a placeholder 738 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; 739 fRestoreOffsetStack.top() = offset;
734 } 740 }
735 741
736 bool SkPictureRecord::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { 742 bool SkPictureRecord::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
737 // id + rect + clip params 743 // id + rect + clip params
738 uint32_t size = 1 * kUInt32Size + sizeof(rect) + 1 * kUInt32Size; 744 uint32_t size = 1 * kUInt32Size + sizeof(rect) + 1 * kUInt32Size;
739 // recordRestoreOffsetPlaceholder doesn't always write an offset 745 // recordRestoreOffsetPlaceholder doesn't always write an offset
740 if (!fRestoreOffsetStack.isEmpty()) { 746 if (!fRestoreOffsetStack.isEmpty()) {
741 // + restore offset 747 // + restore offset
742 size += kUInt32Size; 748 size += kUInt32Size;
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 void SkPictureRecord::validateRegions() const { 1501 void SkPictureRecord::validateRegions() const {
1496 int count = fRegions.count(); 1502 int count = fRegions.count();
1497 SkASSERT((unsigned) count < 0x1000); 1503 SkASSERT((unsigned) count < 0x1000);
1498 for (int index = 0; index < count; index++) { 1504 for (int index = 0; index < count; index++) {
1499 const SkFlatData* region = fRegions[index]; 1505 const SkFlatData* region = fRegions[index];
1500 SkASSERT(region); 1506 SkASSERT(region);
1501 // region->validate(); 1507 // region->validate();
1502 } 1508 }
1503 } 1509 }
1504 #endif 1510 #endif
OLDNEW
« no previous file with comments | « no previous file | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698