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

Side by Side Diff: src/gpu/gl/builders/GrGLFragmentShaderBuilder.h

Issue 671023002: Added varying struct (Closed) Base URL: https://skia.googlesource.com/skia.git@gp_emit_struct
Patch Set: cleanup 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrGLFragmentShaderBuilder_DEFINED 8 #ifndef GrGLFragmentShaderBuilder_DEFINED
9 #define GrGLFragmentShaderBuilder_DEFINED 9 #define GrGLFragmentShaderBuilder_DEFINED
10 10
11 #include "GrGLShaderBuilder.h" 11 #include "GrGLShaderBuilder.h"
12 12
13 class GrGLVarying;
14
13 /* 15 /*
14 * This base class encapsulates the functionality which the GP uses to build fra gment shaders 16 * This base class encapsulates the functionality which the GP uses to build fra gment shaders
15 */ 17 */
16 class GrGLGPFragmentBuilder : public GrGLShaderBuilder { 18 class GrGLGPFragmentBuilder : public GrGLShaderBuilder {
17 public: 19 public:
18 GrGLGPFragmentBuilder(GrGLProgramBuilder* program) : INHERITED(program) {} 20 GrGLGPFragmentBuilder(GrGLProgramBuilder* program) : INHERITED(program) {}
19 virtual ~GrGLGPFragmentBuilder() {} 21 virtual ~GrGLGPFragmentBuilder() {}
20 /** 22 /**
21 * Use of these features may require a GLSL extension to be enabled. Shaders may not compile 23 * Use of these features may require a GLSL extension to be enabled. Shaders may not compile
22 * if code is added that uses one of these features without calling enableFe ature() 24 * if code is added that uses one of these features without calling enableFe ature()
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 86
85 GrGLFragmentShaderBuilder(GrGLProgramBuilder* program, const GrGLProgramDesc & desc); 87 GrGLFragmentShaderBuilder(GrGLProgramBuilder* program, const GrGLProgramDesc & desc);
86 88
87 // true public interface, defined explicitly in the abstract interfaces abov e 89 // true public interface, defined explicitly in the abstract interfaces abov e
88 virtual bool enableFeature(GLSLFeature) SK_OVERRIDE; 90 virtual bool enableFeature(GLSLFeature) SK_OVERRIDE;
89 virtual SkString ensureFSCoords2D(const GrGLProcessor::TransformedCoordsArra y& coords, 91 virtual SkString ensureFSCoords2D(const GrGLProcessor::TransformedCoordsArra y& coords,
90 int index) SK_OVERRIDE; 92 int index) SK_OVERRIDE;
91 virtual const char* fragmentPosition() SK_OVERRIDE; 93 virtual const char* fragmentPosition() SK_OVERRIDE;
92 virtual const char* dstColor() SK_OVERRIDE; 94 virtual const char* dstColor() SK_OVERRIDE;
93 95
96 private:
94 // Private public interface, used by GrGLProgramBuilder to build a fragment shader 97 // Private public interface, used by GrGLProgramBuilder to build a fragment shader
95 void emitCodeToReadDstTexture(); 98 void emitCodeToReadDstTexture();
96 void enableCustomOutput(); 99 void enableCustomOutput();
97 void enableSecondaryOutput(); 100 void enableSecondaryOutput();
98 const char* getPrimaryColorOutputName() const; 101 const char* getPrimaryColorOutputName() const;
99 const char* getSecondaryColorOutputName() const; 102 const char* getSecondaryColorOutputName() const;
100 void enableSecondaryOutput(const GrGLSLExpr4& inputColor, const GrGLSLExpr4& inputCoverage); 103 void enableSecondaryOutput(const GrGLSLExpr4& inputColor, const GrGLSLExpr4& inputCoverage);
101 void combineColorAndCoverage(const GrGLSLExpr4& inputColor, const GrGLSLExpr 4& inputCoverage); 104 void combineColorAndCoverage(const GrGLSLExpr4& inputColor, const GrGLSLExpr 4& inputCoverage);
102 bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shader Ids) const; 105 bool compileAndAttachShaders(GrGLuint programId, SkTDArray<GrGLuint>* shader Ids) const;
103 void bindFragmentShaderLocations(GrGLuint programID); 106 void bindFragmentShaderLocations(GrGLuint programID);
104 107
105 /*
106 * An internal call for GrGLProgramBuilder to use to add varyings to the ver tex shader
107 */
108 void addVarying(GrSLType type,
109 const char* name,
110 const char** fsInName,
111 GrGLShaderVar::Precision fsPrecision = GrGLShaderVar::kDefaul t_Precision);
112
113 // As GLProcessors emit code, there are some conditions we need to verify. We use the below 108 // As GLProcessors emit code, there are some conditions we need to verify. We use the below
114 // state to track this. The reset call is called per processor emitted. 109 // state to track this. The reset call is called per processor emitted.
115 bool hasReadDstColor() const { return fHasReadDstColor; } 110 bool hasReadDstColor() const { return fHasReadDstColor; }
116 bool hasReadFragmentPosition() const { return fHasReadFragmentPosition; } 111 bool hasReadFragmentPosition() const { return fHasReadFragmentPosition; }
117 void reset() { 112 void reset() {
118 fHasReadDstColor = false; 113 fHasReadDstColor = false;
119 fHasReadFragmentPosition = false; 114 fHasReadFragmentPosition = false;
120 } 115 }
121 116
122 private: 117 /*
118 * An internal call for GrGLProgramBuilder to use to add varyings to the ver tex shader
119 */
120 void addVarying(GrGLVarying*, GrGLShaderVar::Precision);
121
123 /** 122 /**
124 * Features that should only be enabled by GrGLFragmentShaderBuilder itself. 123 * Features that should only be enabled by GrGLFragmentShaderBuilder itself.
125 */ 124 */
126 enum GLSLPrivateFeature { 125 enum GLSLPrivateFeature {
127 kFragCoordConventions_GLSLPrivateFeature = kLastGLSLFeature + 1, 126 kFragCoordConventions_GLSLPrivateFeature = kLastGLSLFeature + 1,
128 kLastGLSLPrivateFeature = kFragCoordConventions_GLSLPrivateFeature 127 kLastGLSLPrivateFeature = kFragCoordConventions_GLSLPrivateFeature
129 }; 128 };
130 129
131 // Interpretation of DstReadKey when generating code 130 // Interpretation of DstReadKey when generating code
132 enum { 131 enum {
(...skipping 23 matching lines...) Expand all
156 bool fHasReadDstColor; 155 bool fHasReadDstColor;
157 bool fHasReadFragmentPosition; 156 bool fHasReadFragmentPosition;
158 157
159 friend class GrGLNvprProgramBuilder; 158 friend class GrGLNvprProgramBuilder;
160 friend class GrGLProgramBuilder; 159 friend class GrGLProgramBuilder;
161 160
162 typedef GrGLFPFragmentBuilder INHERITED; 161 typedef GrGLFPFragmentBuilder INHERITED;
163 }; 162 };
164 163
165 #endif 164 #endif
OLDNEW
« no previous file with comments | « src/gpu/effects/GrDistanceFieldTextureEffect.cpp ('k') | src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698