GrSLPrecision fsPrecision = kDefault_GrSLPrecision);
private:
+ void onFinalize() override {}
+
typedef GrGLProgramDataManager::VaryingInfo VaryingInfo;
typedef GrGLProgramDataManager::VaryingInfoArray VaryingInfoArray;
fOutputs.push_back().set(kVec4f_GrSLType,
GrGLSLShaderVar::kOut_TypeModifier,
DeclaredColorOutputName());
+ fProgramBuilder->finalizeFragmentOutputColor(fOutputs.back());
}
}
if (caps.mustDeclareFragmentShaderOutput()) {
fOutputs.push_back().set(kVec4f_GrSLType, GrGLSLShaderVar::kOut_TypeModifier,
DeclaredSecondaryColorOutputName());
+ fProgramBuilder->finalizeFragmentSecondaryColor(fOutputs.back());
}
}
virtual const GrGLSLUniformHandler* uniformHandler() const = 0;
virtual GrGLSLVaryingHandler* varyingHandler() = 0;
+ // Used for backend customization of the output color and secondary color variables from the
+ // fragment processor. Only used if the outputs are explicitly declared in the shaders
+ virtual void finalizeFragmentOutputColor(GrGLSLShaderVar& outputColor) {}
+ virtual void finalizeFragmentSecondaryColor(GrGLSLShaderVar& outputColor) {}
+
// number of each input/output type in a single allocation block, used by many builders
static const int kVarsPerBlock;
fVertexInputs.push_back(var);
}
+void GrGLSLVaryingHandler::finalize() {
+ this->onFinalize();
+}
+
void GrGLSLVaryingHandler::appendDecls(const VarArray& vars, SkString* out) const {
for (int i = 0; i < vars.count(); ++i) {
vars[i].appendDecl(fProgramBuilder->glslCaps(), out);
, fFragOutputs(kVaryingsPerBlock)
, fProgramBuilder(program) {}
+ virtual ~GrGLSLVaryingHandler() {}
+
typedef GrTAllocator<GrGLSLShaderVar> VarArray;
typedef GrGLSLProgramDataManager::VaryingHandle VaryingHandle;
void emitAttributes(const GrGeometryProcessor& gp);
+ // This should be called once all attributes and varyings have been added to the
+ // GrGLSLVaryingHanlder and before getting/adding any of the declarations to the shaders.
+ void finalize();
+
void getVertexDecls(SkString* inputDecls, SkString* outputDecls) const;
void getGeomDecls(SkString* inputDecls, SkString* outputDecls) const;
void getFragDecls(SkString* inputDecls, SkString* outputDecls) const;
void addAttribute(const GrShaderVar& var);
+ virtual void onFinalize() = 0;
+
// helper function for get*Decls
void appendDecls(const VarArray& vars, SkString* out) const;