Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Unified Diff: src/gpu/gl/builders/GrGLFragmentShaderBuilder.h

Issue 635533005: Revert of Cleanup of shader building system (Closed) Base URL: https://skia.googlesource.com/skia.git@solo_gp
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
index fdf685cc09bcc32c28e2eec296979b170861eaad..38d569e734189f552713d4ba07160ba2672ab897 100644
--- a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
+++ b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.h
@@ -7,16 +7,18 @@
#ifndef GrGLFragmentShaderBuilder_DEFINED
#define GrGLFragmentShaderBuilder_DEFINED
-
#include "GrGLShaderBuilder.h"
+class GrGLProgramBuilder;
+
/*
- * This base class encapsulates the functionality which the GP uses to build fragment shaders
+ * This base class encapsulates the functionality which all GrProcessors are allowed to use in their
+ * fragment shader
*/
-class GrGLGPFragmentBuilder : public GrGLShaderBuilder {
+class GrGLProcessorFragmentShaderBuilder : public GrGLShaderBuilder {
public:
- GrGLGPFragmentBuilder(GrGLProgramBuilder* program) : INHERITED(program) {}
- virtual ~GrGLGPFragmentBuilder() {}
+ GrGLProcessorFragmentShaderBuilder(GrGLProgramBuilder* program) : INHERITED(program) {}
+ virtual ~GrGLProcessorFragmentShaderBuilder() {}
/**
* Use of these features may require a GLSL extension to be enabled. Shaders may not compile
* if code is added that uses one of these features without calling enableFeature()
@@ -51,23 +53,20 @@
/*
* Fragment processor's, in addition to all of the above, may need to use dst color so they use
- * this builder to create their shader. Because this is the only shader builder the FP sees, we
- * just call it FPShaderBuilder
+ * this builder to create their shader
*/
-class GrGLFPFragmentBuilder : public GrGLGPFragmentBuilder {
+class GrGLFragmentProcessorShaderBuilder : public GrGLProcessorFragmentShaderBuilder {
public:
- GrGLFPFragmentBuilder(GrGLProgramBuilder* program) : INHERITED(program) {}
-
+ GrGLFragmentProcessorShaderBuilder(GrGLProgramBuilder* program) : INHERITED(program) {}
/** Returns the variable name that holds the color of the destination pixel. This may be NULL if
no effect advertised that it will read the destination. */
virtual const char* dstColor() = 0;
private:
- typedef GrGLGPFragmentBuilder INHERITED;
+ typedef GrGLProcessorFragmentShaderBuilder INHERITED;
};
-// TODO rename to Fragment Builder
-class GrGLFragmentShaderBuilder : public GrGLFPFragmentBuilder {
+class GrGLFragmentShaderBuilder : public GrGLFragmentProcessorShaderBuilder {
public:
typedef uint8_t DstReadKey;
typedef uint8_t FragPosKey;
@@ -84,42 +83,39 @@
GrGLFragmentShaderBuilder(GrGLProgramBuilder* program, const GrGLProgramDesc& desc);
- // true public interface, defined explicitly in the abstract interfaces above
+ virtual const char* dstColor() SK_OVERRIDE;
+
virtual bool enableFeature(GLSLFeature) SK_OVERRIDE;
+
virtual SkString ensureFSCoords2D(const GrGLProcessor::TransformedCoordsArray& coords,
int index) SK_OVERRIDE;
+
virtual const char* fragmentPosition() SK_OVERRIDE;
- virtual const char* dstColor() SK_OVERRIDE;
- // Private public interface, used by GrGLProgramBuilder to build a fragment shader
- void emitCodeToReadDstTexture();
- void enableCustomOutput();
- void enableSecondaryOutput();
- const char* getPrimaryColorOutputName() const;
- const char* getSecondaryColorOutputName() const;
- void enableSecondaryOutput(const GrGLSLExpr4& inputColor, const GrGLSLExpr4& inputCoverage);
- void combineColorAndCoverage(const GrGLSLExpr4& inputColor, const GrGLSLExpr4& inputCoverage);
- bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shaderIds) const;
- void bindFragmentShaderLocations(GrGLuint programID);
-
+private:
/*
- * An internal call for GrGLProgramBuilder to use to add varyings to the vertex shader
+ * An internal call for GrGLFullProgramBuilder to use to add varyings to the vertex shader
*/
void addVarying(GrSLType type,
const char* name,
const char** fsInName,
GrGLShaderVar::Precision fsPrecision = GrGLShaderVar::kDefault_Precision);
- // As GLProcessors emit code, there are some conditions we need to verify. We use the below
- // state to track this. The reset call is called per processor emitted.
- bool hasReadDstColor() const { return fHasReadDstColor; }
- bool hasReadFragmentPosition() const { return fHasReadFragmentPosition; }
- void reset() {
- fHasReadDstColor = false;
- fHasReadFragmentPosition = false;
- }
+ /*
+ * Private functions used by GrGLProgramBuilder for compilation
+ */
+ void bindProgramLocations(GrGLuint programId);
+ bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shaderIds) const;
+ void emitCodeBeforeEffects();
+ void emitCodeAfterEffects(const GrGLSLExpr4& inputColor, const GrGLSLExpr4& inputCoverage);
-private:
+ /** Enables using the secondary color output and returns the name of the var in which it is
+ to be stored */
+ const char* enableSecondaryOutput();
+
+ /** Gets the name of the primary color output. */
+ const char* getColorOutputName() const;
+
/**
* Features that should only be enabled by GrGLFragmentShaderBuilder itself.
*/
@@ -136,29 +132,21 @@
kTopLeftOrigin_DstReadKeyBit = 0x4, // Set if dst-copy origin is top-left.
};
- // Interpretation of FragPosKey when generating code
enum {
kNoFragPosRead_FragPosKey = 0, // The fragment positition will not be needed.
kTopLeftFragPosRead_FragPosKey = 0x1,// Read frag pos relative to top-left.
kBottomLeftFragPosRead_FragPosKey = 0x2,// Read frag pos relative to bottom-left.
};
- static const char* kDstCopyColorName;
-
bool fHasCustomColorOutput;
bool fHasSecondaryOutput;
bool fSetupFragPosition;
bool fTopLeftFragPosRead;
- // some state to verify shaders and effects are consistent, this is reset between effects by
- // the program creator
- bool fHasReadDstColor;
- bool fHasReadFragmentPosition;
+ friend class GrGLProgramBuilder;
+ friend class GrGLFullProgramBuilder;
- friend class GrGLNvprProgramBuilder;
- friend class GrGLProgramBuilder;
-
- typedef GrGLFPFragmentBuilder INHERITED;
+ typedef GrGLFragmentProcessorShaderBuilder INHERITED;
};
#endif
« no previous file with comments | « src/gpu/gl/builders/GrGLFragmentOnlyProgramBuilder.cpp ('k') | src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698