aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLGLSLCodeGenerator.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/SkSLGLSLCodeGenerator.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/SkSLGLSLCodeGenerator.h')
-rw-r--r--src/sksl/SkSLGLSLCodeGenerator.h26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/sksl/SkSLGLSLCodeGenerator.h b/src/sksl/SkSLGLSLCodeGenerator.h
index 032b70eea1..c0a638797b 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.h
+++ b/src/sksl/SkSLGLSLCodeGenerator.h
@@ -13,6 +13,7 @@
#include <unordered_map>
#include "SkSLCodeGenerator.h"
+#include "SkSLStringStream.h"
#include "ir/SkSLBinaryExpression.h"
#include "ir/SkSLBoolLiteral.h"
#include "ir/SkSLConstructor.h"
@@ -32,6 +33,7 @@
#include "ir/SkSLPostfixExpression.h"
#include "ir/SkSLProgramElement.h"
#include "ir/SkSLReturnStatement.h"
+#include "ir/SkSLSetting.h"
#include "ir/SkSLStatement.h"
#include "ir/SkSLSwitchStatement.h"
#include "ir/SkSLSwizzle.h"
@@ -74,11 +76,12 @@ public:
GLSLCodeGenerator(const Context* context, const Program* program, ErrorReporter* errors,
OutputStream* out)
: INHERITED(program, errors, out)
+ , fLineEnding("\n")
, fContext(*context) {}
- virtual bool generateCode() override;
+ bool generateCode() override;
-private:
+protected:
void write(const char* s);
void writeLine();
@@ -89,6 +92,8 @@ private:
void writeLine(const String& s);
+ virtual void writeHeader();
+
void writeType(const Type& type);
void writeExtension(const Extension& ext);
@@ -99,7 +104,7 @@ private:
void writeFunctionDeclaration(const FunctionDeclaration& f);
- void writeFunction(const FunctionDefinition& f);
+ virtual void writeFunction(const FunctionDefinition& f);
void writeLayout(const Layout& layout);
@@ -107,11 +112,13 @@ private:
void writeGlobalVars(const VarDeclaration& vs);
+ virtual void writeVarInitializer(const Variable& var, const Expression& value);
+
void writeVarDeclarations(const VarDeclarations& decl, bool global);
void writeFragCoord();
- void writeVariableReference(const VariableReference& ref);
+ virtual void writeVariableReference(const VariableReference& ref);
void writeExpression(const Expression& expr, Precedence parentPrecedence);
@@ -127,11 +134,13 @@ private:
void writeSwizzle(const Swizzle& swizzle);
- void writeBinaryExpression(const BinaryExpression& b, Precedence parentPrecedence);
+ static Precedence GetBinaryPrecedence(Token::Kind op);
+
+ virtual void writeBinaryExpression(const BinaryExpression& b, Precedence parentPrecedence);
void writeTernaryExpression(const TernaryExpression& t, Precedence parentPrecedence);
- void writeIndexExpression(const IndexExpression& expr);
+ virtual void writeIndexExpression(const IndexExpression& expr);
void writePrefixExpression(const PrefixExpression& p, Precedence parentPrecedence);
@@ -143,6 +152,8 @@ private:
void writeFloatLiteral(const FloatLiteral& f);
+ virtual void writeSetting(const Setting& s);
+
void writeStatement(const Statement& s);
void writeStatements(const std::vector<std::unique_ptr<Statement>>& statements);
@@ -161,6 +172,9 @@ private:
void writeReturnStatement(const ReturnStatement& r);
+ virtual void writeProgramElement(const ProgramElement& e);
+
+ const char* fLineEnding;
const Context& fContext;
StringStream fHeader;
String fFunctionHeader;