OLD | NEW |
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" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 struct SaveNoDrawsRestoreNooper { | 77 struct SaveNoDrawsRestoreNooper { |
78 // Star matches greedily, so we also have to exclude Save and Restore. | 78 // Star matches greedily, so we also have to exclude Save and Restore. |
79 typedef Pattern3<Is<Save>, | 79 typedef Pattern3<Is<Save>, |
80 Star<Not<Or3<Is<Save>, | 80 Star<Not<Or3<Is<Save>, |
81 Is<Restore>, | 81 Is<Restore>, |
82 IsDraw> > >, | 82 IsDraw> > >, |
83 Is<Restore> > | 83 Is<Restore> > |
84 Pattern; | 84 Pattern; |
85 | 85 |
86 bool onMatch(SkRecord* record, Pattern* pattern, unsigned begin, unsigned en
d) { | 86 bool onMatch(SkRecord* record, Pattern* pattern, unsigned begin, unsigned en
d) { |
87 // If restore doesn't revert both matrix and clip, this isn't safe to no
op away. | |
88 if (pattern->first<Save>()->flags != SkCanvas::kMatrixClip_SaveFlag) { | |
89 return false; | |
90 } | |
91 | |
92 // The entire span between Save and Restore (inclusively) does nothing. | 87 // The entire span between Save and Restore (inclusively) does nothing. |
93 for (unsigned i = begin; i < end; i++) { | 88 for (unsigned i = begin; i < end; i++) { |
94 record->replace<NoOp>(i); | 89 record->replace<NoOp>(i); |
95 } | 90 } |
96 return true; | 91 return true; |
97 } | 92 } |
98 }; | 93 }; |
99 void SkRecordNoopSaveRestores(SkRecord* record) { | 94 void SkRecordNoopSaveRestores(SkRecord* record) { |
100 SaveOnlyDrawsRestoreNooper onlyDraws; | 95 SaveOnlyDrawsRestoreNooper onlyDraws; |
101 SaveNoDrawsRestoreNooper noDraws; | 96 SaveNoDrawsRestoreNooper noDraws; |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 }; | 289 }; |
295 | 290 |
296 SkTDArray<Pair> fPushStack; | 291 SkTDArray<Pair> fPushStack; |
297 SkRecord* fRecord; | 292 SkRecord* fRecord; |
298 unsigned fIndex; | 293 unsigned fIndex; |
299 }; | 294 }; |
300 void SkRecordAnnotateCullingPairs(SkRecord* record) { | 295 void SkRecordAnnotateCullingPairs(SkRecord* record) { |
301 CullAnnotator pass; | 296 CullAnnotator pass; |
302 pass.apply(record); | 297 pass.apply(record); |
303 } | 298 } |
OLD | NEW |