aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/ir/SkSLExpression.h
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-04-25 14:42:11 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-25 19:39:13 +0000
commit3deaeb2dc0cfddfdf2e3b64736c860132619a051 (patch)
tree9349c336d5d6802de58e326dc89557047f631739 /src/sksl/ir/SkSLExpression.h
parent7ab6a7f40b23610577bd64fbcb6121a2a715469b (diff)
sksl can now fold constant vector or matrix equality expressions
Bug: skia: Change-Id: Icaddae68e53ed3629bcdc04b5f0b541d9e4398e2 Reviewed-on: https://skia-review.googlesource.com/14260 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Ben Wagner <benjaminwagner@google.com>
Diffstat (limited to 'src/sksl/ir/SkSLExpression.h')
-rw-r--r--src/sksl/ir/SkSLExpression.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/sksl/ir/SkSLExpression.h b/src/sksl/ir/SkSLExpression.h
index 5db9ddf96f..07dad1d7df 100644
--- a/src/sksl/ir/SkSLExpression.h
+++ b/src/sksl/ir/SkSLExpression.h
@@ -48,11 +48,24 @@ struct Expression : public IRNode {
, fKind(kind)
, fType(std::move(type)) {}
+ /**
+ * Returns true if this expression is constant. compareConstant must be implemented for all
+ * constants!
+ */
virtual bool isConstant() const {
return false;
}
/**
+ * Compares this constant expression against another constant expression of the same type. It is
+ * an error to call this on non-constant expressions, or if the types of the expressions do not
+ * match.
+ */
+ virtual bool compareConstant(const Context& context, const Expression& other) const {
+ ABORT("cannot call compareConstant on this type");
+ }
+
+ /**
* Returns true if evaluating the expression potentially has side effects. Expressions may never
* return false if they actually have side effects, but it is legal (though suboptimal) to
* return true if there are not actually any side effects.