aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLCPPCodeGenerator.cpp
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-07-14 10:12:15 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-14 14:41:04 +0000
commit6e1cbc012b10e99d9caed19eef43939778d1d8ff (patch)
tree94a884a96e8412ab0e852f6489321fd83de4b2a6 /src/sksl/SkSLCPPCodeGenerator.cpp
parent9a03642ad2fce5805642783f68078a0a6bf03554 (diff)
fixed sksl static ifs to work for CircleEffect
static ifs (and switches) in .fp files are a bit tricky, because they aren't necessarily static when the CPP file is being produced. They become static when the CPP file produces the final SkSL; at this point the final values of the 'in' variables are known. This change permits 'deferred' static ifs and switches. The initial compilation (.fp -> .cpp) passes the @if / @switch through, and then the final compilation (.cpp's generated SkSL -> GLSL or whatever) enforces the static test. Bug: skia: Change-Id: I0087dfe1725c8fd350507ac77f64db1d82659cdf Reviewed-on: https://skia-review.googlesource.com/23403 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/SkSLCPPCodeGenerator.cpp')
-rw-r--r--src/sksl/SkSLCPPCodeGenerator.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/sksl/SkSLCPPCodeGenerator.cpp b/src/sksl/SkSLCPPCodeGenerator.cpp
index 238615db49..3da7e8e5f0 100644
--- a/src/sksl/SkSLCPPCodeGenerator.cpp
+++ b/src/sksl/SkSLCPPCodeGenerator.cpp
@@ -225,6 +225,20 @@ void CPPCodeGenerator::writeVariableReference(const VariableReference& ref) {
}
}
+void CPPCodeGenerator::writeIfStatement(const IfStatement& s) {
+ if (s.fIsStatic) {
+ this->write("@");
+ }
+ INHERITED::writeIfStatement(s);
+}
+
+void CPPCodeGenerator::writeSwitchStatement(const SwitchStatement& s) {
+ if (s.fIsStatic) {
+ this->write("@");
+ }
+ INHERITED::writeSwitchStatement(s);
+}
+
void CPPCodeGenerator::writeFunctionCall(const FunctionCall& c) {
if (c.fFunction.fBuiltin && c.fFunction.fName == "COLORSPACE") {
String tmpVar = "_tmpVar" + to_string(++fVarCount);