aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLCPPCodeGenerator.h
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-06-27 09:56:09 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-27 14:20:05 +0000
commitccf59917d3fe7aaf59de714acfbd0596503f324f (patch)
treecc97719c47276c9dcbf0ec09effd580c4e7450dd /src/sksl/SkSLCPPCodeGenerator.h
parentc3aef18419c1bb16951370e11758c7ef131fa10b (diff)
sksl fragment processor support
Bug: skia: Change-Id: Ia3b0305c2b0c78074303831f628fb01852b90d34 Reviewed-on: https://skia-review.googlesource.com/17843 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Ben Wagner <benjaminwagner@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
Diffstat (limited to 'src/sksl/SkSLCPPCodeGenerator.h')
-rw-r--r--src/sksl/SkSLCPPCodeGenerator.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/sksl/SkSLCPPCodeGenerator.h b/src/sksl/SkSLCPPCodeGenerator.h
new file mode 100644
index 0000000000..74ee8f6289
--- /dev/null
+++ b/src/sksl/SkSLCPPCodeGenerator.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SKSL_CPPCODEGENERATOR
+#define SKSL_CPPCODEGENERATOR
+
+#include "SkSLGLSLCodeGenerator.h"
+#include "SkSLSectionAndParameterHelper.h"
+
+#include <set>
+
+namespace SkSL {
+
+class CPPCodeGenerator : public GLSLCodeGenerator {
+public:
+ CPPCodeGenerator(const Context* context, const Program* program, ErrorReporter* errors,
+ String name, OutputStream* out);
+
+ bool generateCode() override;
+
+private:
+ void writef(const char* s, va_list va) SKSL_PRINTF_LIKE(2, 0);
+
+ void writef(const char* s, ...) SKSL_PRINTF_LIKE(2, 3);
+
+ void writeSection(const char* name, const char* prefix = "");
+
+ void writeHeader() override;
+
+ void writeBinaryExpression(const BinaryExpression& b, Precedence parentPrecedence) override;
+
+ void writeIndexExpression(const IndexExpression& i) override;
+
+ void writeVariableReference(const VariableReference& ref) override;
+
+ void writeFunction(const FunctionDefinition& f) override;
+
+ void writeSetting(const Setting& s) override;
+
+ void writeProgramElement(const ProgramElement& p) override;
+
+ void addUniform(const Variable& var);
+
+ // writes a printf escape that will be filled in at runtime by the given C++ expression string
+ void writeRuntimeValue(const Type& type, const String& cppCode);
+
+ void writeVarInitializer(const Variable& var, const Expression& value) override;
+
+ void writePrivateVars();
+
+ void writePrivateVarValues();
+
+ bool writeEmitCode(std::vector<const Variable*>& uniforms);
+
+ void writeSetData(std::vector<const Variable*>& uniforms);
+
+ void writeGetKey();
+
+ void writeTest();
+
+ String fName;
+ String fFullName;
+ SectionAndParameterHelper fSectionAndParameterHelper;
+ String fExtraEmitCodeCode;
+ std::vector<String> fFormatArgs;
+ std::set<int> fWrittenTransformedCoords;
+ bool fNeedColorSpaceHelper = false;
+
+ typedef GLSLCodeGenerator INHERITED;
+};
+
+}
+
+#endif