aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLGLSLCodeGenerator.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/sksl/SkSLGLSLCodeGenerator.h')
-rw-r--r--src/sksl/SkSLGLSLCodeGenerator.h27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/sksl/SkSLGLSLCodeGenerator.h b/src/sksl/SkSLGLSLCodeGenerator.h
index bb7d8b1080..ffc5a4d473 100644
--- a/src/sksl/SkSLGLSLCodeGenerator.h
+++ b/src/sksl/SkSLGLSLCodeGenerator.h
@@ -4,7 +4,7 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+
#ifndef SKSL_GLSLCODEGENERATOR
#define SKSL_GLSLCODEGENERATOR
@@ -12,6 +12,7 @@
#include <tuple>
#include <unordered_map>
+#include "GrShaderCaps.h"
#include "SkStream.h"
#include "SkSLCodeGenerator.h"
#include "ir/SkSLBinaryExpression.h"
@@ -71,12 +72,11 @@ public:
kTopLevel_Precedence = 18
};
- GLSLCodeGenerator(const Context* context, const Program* program, ErrorReporter* errors,
- SkWStream* out)
- : INHERITED(program, errors, out)
- , fContext(*context) {}
+ GLSLCodeGenerator(const Context* context, const GrShaderCaps* caps)
+ : fContext(*context)
+ , fCaps(*caps) {}
- virtual bool generateCode() override;
+ void generateCode(const Program& program, ErrorReporter& errors, SkWStream& out) override;
private:
void write(const char* s);
@@ -104,17 +104,15 @@ private:
void writeLayout(const Layout& layout);
void writeModifiers(const Modifiers& modifiers, bool globalContext);
-
+
void writeGlobalVars(const VarDeclaration& vs);
void writeVarDeclarations(const VarDeclarations& decl, bool global);
- void writeFragCoord();
-
void writeVariableReference(const VariableReference& ref);
void writeExpression(const Expression& expr, Precedence parentPrecedence);
-
+
void writeIntrinsicCall(const FunctionCall& c);
void writeMinAbsHack(Expression& absExpr, Expression& otherExpr);
@@ -158,22 +156,21 @@ private:
void writeReturnStatement(const ReturnStatement& r);
const Context& fContext;
+ const GrShaderCaps& fCaps;
+ SkWStream* fOut = nullptr;
SkDynamicMemoryWStream fHeader;
SkString fFunctionHeader;
Program::Kind fProgramKind;
int fVarCount = 0;
int fIndentation = 0;
bool fAtLineStart = false;
- // Keeps track of which struct types we have written. Given that we are unlikely to ever write
- // more than one or two structs per shader, a simple linear search will be faster than anything
+ // Keeps track of which struct types we have written. Given that we are unlikely to ever write
+ // more than one or two structs per shader, a simple linear search will be faster than anything
// fancier.
std::vector<const Type*> fWrittenStructs;
// true if we have run into usages of dFdx / dFdy
bool fFoundDerivatives = false;
bool fFoundImageDecl = false;
- bool fSetupFragPosition = false;
-
- typedef CodeGenerator INHERITED;
};
}