Index: src/record/SkRecordOpts.cpp |
diff --git a/src/record/SkRecordOpts.cpp b/src/record/SkRecordOpts.cpp |
index bfc45bda5a4c425e097b01ba61c4eaa6bc4d6d17..1322c0f1e57eb295f2981f3e8d785cb2e7ce766f 100644 |
--- a/src/record/SkRecordOpts.cpp |
+++ b/src/record/SkRecordOpts.cpp |
@@ -15,8 +15,10 @@ using namespace SkRecords; |
void SkRecordOptimize(SkRecord* record) { |
// TODO(mtklein): fuse independent optimizations to reduce number of passes? |
+ SkRecordNoopCulls(record); |
SkRecordNoopSaveRestores(record); |
SkRecordNoopSaveLayerDrawRestores(record); |
+ |
SkRecordAnnotateCullingPairs(record); |
SkRecordReduceDrawPosTextStrength(record); // Helpful to run this before BoundDrawPosTextH. |
SkRecordBoundDrawPosTextH(record); |
@@ -42,6 +44,21 @@ static bool apply(Pass* pass, SkRecord* record) { |
return changed; |
} |
+struct CullNooper { |
+ typedef Pattern3<Is<PushCull>, Star<Is<NoOp> >, Is<PopCull> > Pattern; |
+ |
+ bool onMatch(SkRecord* record, Pattern* pattern, unsigned begin, unsigned end) { |
+ record->replace<NoOp>(begin); // PushCull |
+ record->replace<NoOp>(end-1); // PopCull |
+ return true; |
+ } |
+}; |
+ |
+void SkRecordNoopCulls(SkRecord* record) { |
+ CullNooper pass; |
+ while (apply(&pass, record)); |
+} |
+ |
// Turns the logical NoOp Save and Restore in Save-Draw*-Restore patterns into actual NoOps. |
struct SaveOnlyDrawsRestoreNooper { |
typedef Pattern3<Is<Save>, |