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

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

Issue 79313003: Disable the save/clip/restore peephole optimization when a bounding hierarchy is used (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 1 month 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 | 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 /* 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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 return true; 515 return true;
516 } 516 }
517 517
518 typedef bool (*PictureRecordOptProc)(SkWriter32* writer, int32_t offset, 518 typedef bool (*PictureRecordOptProc)(SkWriter32* writer, int32_t offset,
519 SkPaintDictionary* paintDict); 519 SkPaintDictionary* paintDict);
520 enum PictureRecordOptType { 520 enum PictureRecordOptType {
521 kRewind_OptType, // Optimization rewinds the command stream 521 kRewind_OptType, // Optimization rewinds the command stream
522 kCollapseSaveLayer_OptType, // Optimization eliminates a save/restore pair 522 kCollapseSaveLayer_OptType, // Optimization eliminates a save/restore pair
523 }; 523 };
524 524
525 enum PictureRecordOptFlags {
526 kSkipIfBBoxHierarchy_Flag = 0x1, // Optimization should be skipped if the
reed1 2013/11/20 21:08:52 Lets augment the comment to explain why (which you
527 // SkPicture has a bounding box hierarchy.
528 };
529
525 struct PictureRecordOpt { 530 struct PictureRecordOpt {
526 PictureRecordOptProc fProc; 531 PictureRecordOptProc fProc;
527 PictureRecordOptType fType; 532 PictureRecordOptType fType;
533 unsigned fFlags;
528 }; 534 };
529 /* 535 /*
530 * A list of the optimizations that are tried upon seeing a restore 536 * A list of the optimizations that are tried upon seeing a restore
531 * TODO: add a real API for such optimizations 537 * TODO: add a real API for such optimizations
532 * Add the ability to fire optimizations on any op (not just RESTORE) 538 * Add the ability to fire optimizations on any op (not just RESTORE)
533 */ 539 */
534 static const PictureRecordOpt gPictureRecordOpts[] = { 540 static const PictureRecordOpt gPictureRecordOpts[] = {
535 { collapse_save_clip_restore, kRewind_OptType }, 541 { collapse_save_clip_restore, kRewind_OptType, kSkipIfBBoxHierarchy_Flag },
536 { remove_save_layer1, kCollapseSaveLayer_OptType }, 542 { remove_save_layer1, kCollapseSaveLayer_OptType, 0 },
537 { remove_save_layer2, kCollapseSaveLayer_OptType } 543 { remove_save_layer2, kCollapseSaveLayer_OptType, 0 }
538 }; 544 };
539 545
540 // This is called after an optimization has been applied to the command stream 546 // This is called after an optimization has been applied to the command stream
541 // in order to adjust the contents and state of the bounding box hierarchy and 547 // in order to adjust the contents and state of the bounding box hierarchy and
542 // state tree to reflect the optimization. 548 // state tree to reflect the optimization.
543 static void apply_optimization_to_bbh(PictureRecordOptType opt, SkPictureStateTr ee* stateTree, 549 static void apply_optimization_to_bbh(PictureRecordOptType opt, SkPictureStateTr ee* stateTree,
544 SkBBoxHierarchy* boundingHierarchy) { 550 SkBBoxHierarchy* boundingHierarchy) {
545 switch (opt) { 551 switch (opt) {
546 case kCollapseSaveLayer_OptType: 552 case kCollapseSaveLayer_OptType:
547 if (NULL != stateTree) { 553 if (NULL != stateTree) {
(...skipping 27 matching lines...) Expand all
575 } 581 }
576 582
577 if (fRestoreOffsetStack.count() == fFirstSavedLayerIndex) { 583 if (fRestoreOffsetStack.count() == fFirstSavedLayerIndex) {
578 fFirstSavedLayerIndex = kNoSavedLayerIndex; 584 fFirstSavedLayerIndex = kNoSavedLayerIndex;
579 } 585 }
580 586
581 uint32_t initialOffset, size; 587 uint32_t initialOffset, size;
582 size_t opt = 0; 588 size_t opt = 0;
583 if (!(fRecordFlags & SkPicture::kDisableRecordOptimizations_RecordingFlag)) { 589 if (!(fRecordFlags & SkPicture::kDisableRecordOptimizations_RecordingFlag)) {
584 for (opt = 0; opt < SK_ARRAY_COUNT(gPictureRecordOpts); ++opt) { 590 for (opt = 0; opt < SK_ARRAY_COUNT(gPictureRecordOpts); ++opt) {
591 if (0 != gPictureRecordOpts[opt].fFlags & kSkipIfBBoxHierarchy_Flag
592 && NULL != fBoundingHierarchy) {
593 continue;
594 }
585 if ((*gPictureRecordOpts[opt].fProc)(&fWriter, fRestoreOffsetStack.t op(), &fPaints)) { 595 if ((*gPictureRecordOpts[opt].fProc)(&fWriter, fRestoreOffsetStack.t op(), &fPaints)) {
586 // Some optimization fired so don't add the RESTORE 596 // Some optimization fired so don't add the RESTORE
587 size = 0; 597 size = 0;
588 initialOffset = fWriter.bytesWritten(); 598 initialOffset = fWriter.bytesWritten();
589 apply_optimization_to_bbh(gPictureRecordOpts[opt].fType, 599 apply_optimization_to_bbh(gPictureRecordOpts[opt].fType,
590 fStateTree, fBoundingHierarchy); 600 fStateTree, fBoundingHierarchy);
591 break; 601 break;
592 } 602 }
593 } 603 }
594 } 604 }
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 void SkPictureRecord::validateRegions() const { 1511 void SkPictureRecord::validateRegions() const {
1502 int count = fRegions.count(); 1512 int count = fRegions.count();
1503 SkASSERT((unsigned) count < 0x1000); 1513 SkASSERT((unsigned) count < 0x1000);
1504 for (int index = 0; index < count; index++) { 1514 for (int index = 0; index < count; index++) {
1505 const SkFlatData* region = fRegions[index]; 1515 const SkFlatData* region = fRegions[index];
1506 SkASSERT(region); 1516 SkASSERT(region);
1507 // region->validate(); 1517 // region->validate();
1508 } 1518 }
1509 } 1519 }
1510 #endif 1520 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698