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>
diff --git a/src/sksl/SkSLGLSLCodeGenerator.h b/src/sksl/SkSLGLSLCodeGenerator.h
index 032b70e..aaf0369 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 @@
     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 @@
 
     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 @@
 
     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 @@
 
     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 @@
 
     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 @@
 
     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 @@
 
     void writeReturnStatement(const ReturnStatement& r);
 
+    virtual void writeProgramElement(const ProgramElement& e);
+
+    const char* fLineEnding;
     const Context& fContext;
     StringStream fHeader;
     String fFunctionHeader;