aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLGLSLCodeGenerator.h
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-06-29 10:03:38 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-29 14:57:47 +0000
commit762466e9fe0478bcf11fba532998e81e33b3069e (patch)
tree8934a152b11007d7d530db05f7ba731bb05aa5c0 /src/sksl/SkSLGLSLCodeGenerator.h
parente78c8ed9cba31ebb970d3002270ddb03f4d6baae (diff)
Re-re-land sksl fragment processor support
This reverts commit 5ce397205528f82084fc650c2ce27d246c01da33. Bug: skia: Change-Id: I88260c90004610a1cf8ad1a87c2b4b222525bbb6 Reviewed-on: https://skia-review.googlesource.com/21108 Reviewed-by: Ben Wagner <benjaminwagner@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/SkSLGLSLCodeGenerator.h')
-rw-r--r--src/sksl/SkSLGLSLCodeGenerator.h28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/sksl/SkSLGLSLCodeGenerator.h b/src/sksl/SkSLGLSLCodeGenerator.h
index 032b70eea1..aaf036900d 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,10 @@ private:
void writeLine(const String& s);
+ virtual void writeHeader();
+
+ virtual void writePrecisionModifier();
+
void writeType(const Type& type);
void writeExtension(const Extension& ext);
@@ -99,7 +106,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 +114,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 +136,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 +154,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 +174,9 @@ private:
void writeReturnStatement(const ReturnStatement& r);
+ virtual void writeProgramElement(const ProgramElement& e);
+
+ const char* fLineEnding;
const Context& fContext;
StringStream fHeader;
String fFunctionHeader;