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

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

Issue 1461663003: Add SkRecord::defrag(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: simplify Created 5 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
« no previous file with comments | « src/core/SkRecord.cpp ('k') | tests/RecordTest.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 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 "SkRecordOpts.h" 8 #include "SkRecordOpts.h"
9 9
10 #include "SkRecordPattern.h" 10 #include "SkRecordPattern.h"
11 #include "SkRecords.h" 11 #include "SkRecords.h"
12 #include "SkTDArray.h" 12 #include "SkTDArray.h"
13 13
14 using namespace SkRecords; 14 using namespace SkRecords;
15 15
16 void SkRecordOptimize(SkRecord* record) { 16 void SkRecordOptimize(SkRecord* record) {
17 // This might be useful as a first pass in the future if we want to weed 17 // This might be useful as a first pass in the future if we want to weed
18 // out junk for other optimization passes. Right now, nothing needs it, 18 // out junk for other optimization passes. Right now, nothing needs it,
19 // and the bounding box hierarchy will do the work of skipping no-op 19 // and the bounding box hierarchy will do the work of skipping no-op
20 // Save-NoDraw-Restore sequences better than we can here. 20 // Save-NoDraw-Restore sequences better than we can here.
21 //SkRecordNoopSaveRestores(record); 21 //SkRecordNoopSaveRestores(record);
22 22
23 SkRecordNoopSaveLayerDrawRestores(record); 23 SkRecordNoopSaveLayerDrawRestores(record);
24 SkRecordMergeSvgOpacityAndFilterLayers(record); 24 SkRecordMergeSvgOpacityAndFilterLayers(record);
25
26 record->defrag();
25 } 27 }
26 28
27 // Most of the optimizations in this file are pattern-based. These are all defi ned as structs with: 29 // Most of the optimizations in this file are pattern-based. These are all defi ned as structs with:
28 // - a Pattern typedef 30 // - a Pattern typedef
29 // - a bool onMatch(SkRceord*, Pattern*, int begin, int end) method, 31 // - a bool onMatch(SkRceord*, Pattern*, int begin, int end) method,
30 // which returns true if it made changes and false if not. 32 // which returns true if it made changes and false if not.
31 33
32 // Run a pattern-based optimization once across the SkRecord, returning true if it made any changes. 34 // Run a pattern-based optimization once across the SkRecord, returning true if it made any changes.
33 // It looks for spans which match Pass::Pattern, and when found calls onMatch() with the pattern, 35 // It looks for spans which match Pass::Pattern, and when found calls onMatch() with the pattern,
34 // record, and [begin,end) span of the commands that matched. 36 // record, and [begin,end) span of the commands that matched.
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 record->replace<NoOp>(saveLayerIndex); // SaveLayer 225 record->replace<NoOp>(saveLayerIndex); // SaveLayer
224 record->replace<NoOp>(saveLayerIndex + 6); // Restore 226 record->replace<NoOp>(saveLayerIndex + 6); // Restore
225 return true; 227 return true;
226 } 228 }
227 }; 229 };
228 230
229 void SkRecordMergeSvgOpacityAndFilterLayers(SkRecord* record) { 231 void SkRecordMergeSvgOpacityAndFilterLayers(SkRecord* record) {
230 SvgOpacityAndFilterLayerMergePass pass; 232 SvgOpacityAndFilterLayerMergePass pass;
231 apply(&pass, record); 233 apply(&pass, record);
232 } 234 }
OLDNEW
« no previous file with comments | « src/core/SkRecord.cpp ('k') | tests/RecordTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698