aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-09-10 16:08:27 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-09-10 16:08:28 -0700
commit99d6a9ee8b3516de892d118c71aa5e6e5c865efd (patch)
treedb1f93c0fb435d1eac274d302d65eac45a9abf88 /src/core
parentf91c47d91d72a1d85e2d6701864b8d7accc81647 (diff)
Fix a bug in Save-Restore no-op optimization.
We optimize Save SaveLayer Restore Restore into NoOp NoOp NoOp Restore I'm considering skipping the call to SkRecordOptimize again just to eliminate this extra variable from landing SkRecord. Thoughts? BUG=skia: R=robertphillips@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/560163002
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkRecordOpts.cpp4
-rw-r--r--src/core/SkRecordPattern.h4
2 files changed, 7 insertions, 1 deletions
diff --git a/src/core/SkRecordOpts.cpp b/src/core/SkRecordOpts.cpp
index 3302d0cb4d..47718e102c 100644
--- a/src/core/SkRecordOpts.cpp
+++ b/src/core/SkRecordOpts.cpp
@@ -55,8 +55,10 @@ struct SaveOnlyDrawsRestoreNooper {
// Turns logical no-op Save-[non-drawing command]*-Restore patterns into actual no-ops.
struct SaveNoDrawsRestoreNooper {
// Star matches greedily, so we also have to exclude Save and Restore.
+ // Nested SaveLayers need to be excluded, or we'll match their Restore!
typedef Pattern3<Is<Save>,
- Star<Not<Or3<Is<Save>,
+ Star<Not<Or4<Is<Save>,
+ Is<SaveLayer>,
Is<Restore>,
IsDraw> > >,
Is<Restore> >
diff --git a/src/core/SkRecordPattern.h b/src/core/SkRecordPattern.h
index 57779ffd76..68a3aa315e 100644
--- a/src/core/SkRecordPattern.h
+++ b/src/core/SkRecordPattern.h
@@ -85,6 +85,10 @@ struct Or {
template <typename A, typename B, typename C>
struct Or3 : Or<A, Or<B, C> > {};
+// Matches if any of A, B, C or D does. Stores nothing.
+template <typename A, typename B, typename C, typename D>
+struct Or4 : Or<A, Or<B, Or<C, D> > > {};
+
// Star is a special matcher that greedily matches Matcher 0 or more times. Stores nothing.
template <typename Matcher>
struct Star {