diff options
Diffstat (limited to 'src/sksl/SkSLGLSLCodeGenerator.h')
-rw-r--r-- | src/sksl/SkSLGLSLCodeGenerator.h | 26 |
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; |