OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 | 8 |
9 #ifndef GrGLProgram_DEFINED | 9 #ifndef GrGLProgram_DEFINED |
10 #define GrGLProgram_DEFINED | 10 #define GrGLProgram_DEFINED |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 * Gets the GL program ID for this program. | 53 * Gets the GL program ID for this program. |
54 */ | 54 */ |
55 GrGLuint programID() const { return fProgramID; } | 55 GrGLuint programID() const { return fProgramID; } |
56 | 56 |
57 /* | 57 /* |
58 * The base class always has a vertex shader, only the NVPR variants may omi
t a vertex shader | 58 * The base class always has a vertex shader, only the NVPR variants may omi
t a vertex shader |
59 */ | 59 */ |
60 virtual bool hasVertexShader() const { return true; } | 60 virtual bool hasVertexShader() const { return true; } |
61 | 61 |
62 /** | 62 /** |
| 63 * Some GL state that is relevant to programs is not stored per-program. In
particular color |
| 64 * and coverage attributes can be global state. This struct is read and upda
ted by |
| 65 * GrGLProgram::setColor and GrGLProgram::setCoverage to allow us to avoid s
etting this state |
| 66 * redundantly. |
| 67 */ |
| 68 struct SharedGLState { |
| 69 GrColor fConstAttribColor; |
| 70 int fConstAttribColorIndex; |
| 71 GrColor fConstAttribCoverage; |
| 72 int fConstAttribCoverageIndex; |
| 73 |
| 74 SharedGLState() { this->invalidate(); } |
| 75 void invalidate() { |
| 76 fConstAttribColor = GrColor_ILLEGAL; |
| 77 fConstAttribColorIndex = -1; |
| 78 fConstAttribCoverage = GrColor_ILLEGAL; |
| 79 fConstAttribCoverageIndex = -1; |
| 80 } |
| 81 }; |
| 82 |
| 83 /** |
63 * The GrDrawState's view matrix along with the aspects of the render target
determine the | 84 * The GrDrawState's view matrix along with the aspects of the render target
determine the |
64 * matrix sent to GL. The size of the render target affects the GL matrix be
cause we must | 85 * matrix sent to GL. The size of the render target affects the GL matrix be
cause we must |
65 * convert from Skia device coords to GL's normalized coords. Also the origi
n of the render | 86 * convert from Skia device coords to GL's normalized coords. Also the origi
n of the render |
66 * target may require us to perform a mirror-flip. | 87 * target may require us to perform a mirror-flip. |
67 */ | 88 */ |
68 struct MatrixState { | 89 struct MatrixState { |
69 SkMatrix fViewMatrix; | 90 SkMatrix fViewMatrix; |
70 SkISize fRenderTargetSize; | 91 SkISize fRenderTargetSize; |
71 GrSurfaceOrigin fRenderTargetOrigin; | 92 GrSurfaceOrigin fRenderTargetOrigin; |
72 | 93 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 }; | 145 }; |
125 | 146 |
126 /** | 147 /** |
127 * This function uploads uniforms and calls each GrGLProcessor's setData. It
is called before a | 148 * This function uploads uniforms and calls each GrGLProcessor's setData. It
is called before a |
128 * draw occurs using the program after the program has already been bound. I
t also uses the | 149 * draw occurs using the program after the program has already been bound. I
t also uses the |
129 * GrGpuGL object to bind the textures required by the GrGLProcessors. The c
olor and coverage | 150 * GrGpuGL object to bind the textures required by the GrGLProcessors. The c
olor and coverage |
130 * stages come from GrGLProgramDesc::Build(). | 151 * stages come from GrGLProgramDesc::Build(). |
131 */ | 152 */ |
132 void setData(const GrOptDrawState&, | 153 void setData(const GrOptDrawState&, |
133 GrGpu::DrawType, | 154 GrGpu::DrawType, |
134 const GrDeviceCoordTexture* dstCopy /* can be NULL*/); | 155 const GrDeviceCoordTexture* dstCopy, // can be NULL |
| 156 SharedGLState*); |
135 | 157 |
136 protected: | 158 protected: |
137 typedef GrGLProgramDataManager::UniformHandle UniformHandle; | 159 typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
138 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; | 160 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; |
139 | 161 |
140 GrGLProgram(GrGpuGL*, | 162 GrGLProgram(GrGpuGL*, |
141 const GrGLProgramDesc&, | 163 const GrGLProgramDesc&, |
142 const BuiltinUniformHandles&, | 164 const BuiltinUniformHandles&, |
143 GrGLuint programID, | 165 GrGLuint programID, |
144 const UniformInfoArray&, | 166 const UniformInfoArray&, |
145 GrGLInstalledGeoProc* geometryProcessor, | 167 GrGLInstalledGeoProc* geometryProcessor, |
146 GrGLInstalledFragProcs* fragmentProcessors); | 168 GrGLInstalledFragProcs* fragmentProcessors); |
147 | 169 |
148 // Sets the texture units for samplers. | 170 // Sets the texture units for samplers. |
149 void initSamplerUniforms(); | 171 void initSamplerUniforms(); |
150 void initSamplers(GrGLInstalledProc*, int* texUnitIdx); | 172 void initSamplers(GrGLInstalledProc*, int* texUnitIdx); |
151 | 173 |
152 // Helper for setData(). Makes GL calls to specify the initial color when th
ere is not | 174 // Helper for setData(). Makes GL calls to specify the initial color when th
ere is not |
153 // per-vertex colors. | 175 // per-vertex colors. |
154 void setColor(const GrOptDrawState&, GrColor color); | 176 void setColor(const GrOptDrawState&, GrColor color, SharedGLState*); |
155 | 177 |
156 // Helper for setData(). Makes GL calls to specify the initial coverage when
there is not | 178 // Helper for setData(). Makes GL calls to specify the initial coverage when
there is not |
157 // per-vertex coverages. | 179 // per-vertex coverages. |
158 void setCoverage(const GrOptDrawState&, GrColor coverage); | 180 void setCoverage(const GrOptDrawState&, GrColor coverage, SharedGLState*); |
159 | 181 |
160 // A templated helper to loop over effects, set the transforms(via subclass)
and bind textures | 182 // A templated helper to loop over effects, set the transforms(via subclass)
and bind textures |
161 void setFragmentData(const GrOptDrawState&); | 183 void setFragmentData(const GrOptDrawState&); |
162 virtual void setTransformData(const GrFragmentStage& effectStage, GrGLInstal
ledFragProc* pe); | 184 virtual void setTransformData(const GrFragmentStage& effectStage, GrGLInstal
ledFragProc* pe); |
163 void bindTextures(const GrGLInstalledProc*, const GrProcessor&); | 185 void bindTextures(const GrGLInstalledProc*, const GrProcessor&); |
164 | 186 |
165 /* | 187 /* |
166 * Legacy NVPR needs a hook here to flush path tex gen settings. | 188 * Legacy NVPR needs a hook here to flush path tex gen settings. |
167 * TODO when legacy nvpr is removed, remove this call. | 189 * TODO when legacy nvpr is removed, remove this call. |
168 */ | 190 */ |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 virtual void setTransformData(const GrFragmentStage&, GrGLInstalledFragProc*
) SK_OVERRIDE; | 281 virtual void setTransformData(const GrFragmentStage&, GrGLInstalledFragProc*
) SK_OVERRIDE; |
260 | 282 |
261 int fTexCoordSetCnt; | 283 int fTexCoordSetCnt; |
262 | 284 |
263 friend class GrGLLegacyNvprProgramBuilder; | 285 friend class GrGLLegacyNvprProgramBuilder; |
264 | 286 |
265 typedef GrGLNvprProgramBase INHERITED; | 287 typedef GrGLNvprProgramBase INHERITED; |
266 }; | 288 }; |
267 | 289 |
268 #endif | 290 #endif |
OLD | NEW |