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