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

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

Issue 186813003: Refactor method used to disable peephole optimizations (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 9 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 | « src/core/SkPictureRecord.h ('k') | no next file » | 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 * 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 16 matching lines...) Expand all
27 static const uint32_t kSaveSize = 2 * kUInt32Size; 27 static const uint32_t kSaveSize = 2 * kUInt32Size;
28 static const uint32_t kSaveLayerNoBoundsSize = 4 * kUInt32Size; 28 static const uint32_t kSaveLayerNoBoundsSize = 4 * kUInt32Size;
29 static const uint32_t kSaveLayerWithBoundsSize = 4 * kUInt32Size + sizeof(SkRect ); 29 static const uint32_t kSaveLayerWithBoundsSize = 4 * kUInt32Size + sizeof(SkRect );
30 30
31 SkPictureRecord::SkPictureRecord(const SkISize& dimensions, uint32_t flags) 31 SkPictureRecord::SkPictureRecord(const SkISize& dimensions, uint32_t flags)
32 : INHERITED(dimensions.width(), dimensions.height()) 32 : INHERITED(dimensions.width(), dimensions.height())
33 , fBoundingHierarchy(NULL) 33 , fBoundingHierarchy(NULL)
34 , fStateTree(NULL) 34 , fStateTree(NULL)
35 , fFlattenableHeap(HEAP_BLOCK_SIZE) 35 , fFlattenableHeap(HEAP_BLOCK_SIZE)
36 , fPaints(&fFlattenableHeap) 36 , fPaints(&fFlattenableHeap)
37 , fRecordFlags(flags) { 37 , fRecordFlags(flags)
38 , fOptsEnabled(true) {
38 #ifdef SK_DEBUG_SIZE 39 #ifdef SK_DEBUG_SIZE
39 fPointBytes = fRectBytes = fTextBytes = 0; 40 fPointBytes = fRectBytes = fTextBytes = 0;
40 fPointWrites = fRectWrites = fTextWrites = 0; 41 fPointWrites = fRectWrites = fTextWrites = 0;
41 #endif 42 #endif
42 43
43 fBitmapHeap = SkNEW(SkBitmapHeap); 44 fBitmapHeap = SkNEW(SkBitmapHeap);
44 fFlattenableHeap.setBitmapStorage(fBitmapHeap); 45 fFlattenableHeap.setBitmapStorage(fBitmapHeap);
45 fPathHeap = NULL; // lazy allocate 46 fPathHeap = NULL; // lazy allocate
46 #ifndef SK_COLLAPSE_MATRIX_CLIP_STATE 47 #ifndef SK_COLLAPSE_MATRIX_CLIP_STATE
47 fFirstSavedLayerIndex = kNoSavedLayerIndex; 48 fFirstSavedLayerIndex = kNoSavedLayerIndex;
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 // check for underflow 621 // check for underflow
621 if (fRestoreOffsetStack.count() == 0) { 622 if (fRestoreOffsetStack.count() == 0) {
622 return; 623 return;
623 } 624 }
624 625
625 if (fRestoreOffsetStack.count() == fFirstSavedLayerIndex) { 626 if (fRestoreOffsetStack.count() == fFirstSavedLayerIndex) {
626 fFirstSavedLayerIndex = kNoSavedLayerIndex; 627 fFirstSavedLayerIndex = kNoSavedLayerIndex;
627 } 628 }
628 629
629 size_t opt = 0; 630 size_t opt = 0;
630 if (!(fRecordFlags & SkPicture::kDisableRecordOptimizations_RecordingFlag)) { 631 if (fOptsEnabled) {
631 for (opt = 0; opt < SK_ARRAY_COUNT(gPictureRecordOpts); ++opt) { 632 for (opt = 0; opt < SK_ARRAY_COUNT(gPictureRecordOpts); ++opt) {
632 if (0 != (gPictureRecordOpts[opt].fFlags & kSkipIfBBoxHierarchy_Flag ) 633 if (0 != (gPictureRecordOpts[opt].fFlags & kSkipIfBBoxHierarchy_Flag )
633 && NULL != fBoundingHierarchy) { 634 && NULL != fBoundingHierarchy) {
634 continue; 635 continue;
635 } 636 }
636 if ((*gPictureRecordOpts[opt].fProc)(&fWriter, fRestoreOffsetStack.t op(), &fPaints)) { 637 if ((*gPictureRecordOpts[opt].fProc)(&fWriter, fRestoreOffsetStack.t op(), &fPaints)) {
637 // Some optimization fired so don't add the RESTORE 638 // Some optimization fired so don't add the RESTORE
638 apply_optimization_to_bbh(gPictureRecordOpts[opt].fType, 639 apply_optimization_to_bbh(gPictureRecordOpts[opt].fType,
639 fStateTree, fBoundingHierarchy); 640 fStateTree, fBoundingHierarchy);
640 break; 641 break;
641 } 642 }
642 } 643 }
643 } 644 }
644 645
645 if ((fRecordFlags & SkPicture::kDisableRecordOptimizations_RecordingFlag) || 646 if (!fOptsEnabled || SK_ARRAY_COUNT(gPictureRecordOpts) == opt) {
646 SK_ARRAY_COUNT(gPictureRecordOpts) == opt) {
647 // No optimization fired so add the RESTORE 647 // No optimization fired so add the RESTORE
648 this->recordRestore(); 648 this->recordRestore();
649 } 649 }
650 650
651 fRestoreOffsetStack.pop(); 651 fRestoreOffsetStack.pop();
652 #endif 652 #endif
653 653
654 return this->INHERITED::restore(); 654 return this->INHERITED::restore();
655 } 655 }
656 656
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 void SkPictureRecord::validateRegions() const { 1854 void SkPictureRecord::validateRegions() const {
1855 int count = fRegions.count(); 1855 int count = fRegions.count();
1856 SkASSERT((unsigned) count < 0x1000); 1856 SkASSERT((unsigned) count < 0x1000);
1857 for (int index = 0; index < count; index++) { 1857 for (int index = 0; index < count; index++) {
1858 const SkFlatData* region = fRegions[index]; 1858 const SkFlatData* region = fRegions[index];
1859 SkASSERT(region); 1859 SkASSERT(region);
1860 // region->validate(); 1860 // region->validate();
1861 } 1861 }
1862 } 1862 }
1863 #endif 1863 #endif
OLDNEW
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698