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

Side by Side Diff: src/gpu/gl/GrGLProgramEffects.h

Issue 25846002: Use vertexless shaders when NVpr is available (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Oops, make all the tests pass Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGLProgramDesc.h ('k') | src/gpu/gl/GrGLProgramEffects.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 GrGLProgramEffects_DEFINED 8 #ifndef GrGLProgramEffects_DEFINED
9 #define GrGLProgramEffects_DEFINED 9 #define GrGLProgramEffects_DEFINED
10 10
11 #include "GrBackendEffectFactory.h" 11 #include "GrBackendEffectFactory.h"
12 #include "GrTexture.h" 12 #include "GrTexture.h"
13 #include "GrTextureAccess.h" 13 #include "GrTextureAccess.h"
14 #include "GrGLUniformManager.h" 14 #include "GrGLUniformManager.h"
15 15
16 class GrEffectStage; 16 class GrEffectStage;
17 class GrGLProgramEffectsBuilder; 17 class GrGLProgramEffectsBuilder;
18 class GrGLVertexProgramEffectsBuilder; 18 class GrGLVertexProgramEffectsBuilder;
19 class GrGLShaderBuilder; 19 class GrGLShaderBuilder;
20 class GrGLFullShaderBuilder; 20 class GrGLFullShaderBuilder;
21 class GrGLFragmentOnlyShaderBuilder;
21 22
22 /** 23 /**
23 * This class encapsulates an array of GrGLEffects and their supporting data (co ord transforms 24 * This class encapsulates an array of GrGLEffects and their supporting data (co ord transforms
24 * and textures). It is built with GrGLProgramEffectsBuilder, then used to manag e the necessary GL 25 * and textures). It is built with GrGLProgramEffectsBuilder, then used to manag e the necessary GL
25 * state and shader uniforms. 26 * state and shader uniforms.
26 */ 27 */
27 class GrGLProgramEffects { 28 class GrGLProgramEffects {
28 public: 29 public:
29 typedef GrBackendEffectFactory::EffectKey EffectKey; 30 typedef GrBackendEffectFactory::EffectKey EffectKey;
30 typedef GrGLUniformManager::UniformHandle UniformHandle; 31 typedef GrGLUniformManager::UniformHandle UniformHandle;
(...skipping 18 matching lines...) Expand all
49 */ 50 */
50 virtual void setData(GrGpuGL*, 51 virtual void setData(GrGpuGL*,
51 const GrGLUniformManager&, 52 const GrGLUniformManager&,
52 const GrEffectStage* effectStages[]) = 0; 53 const GrEffectStage* effectStages[]) = 0;
53 54
54 /** 55 /**
55 * Passed to GrGLEffects so they can add transformed coordinates to their sh ader code. 56 * Passed to GrGLEffects so they can add transformed coordinates to their sh ader code.
56 */ 57 */
57 class TransformedCoords { 58 class TransformedCoords {
58 public: 59 public:
59 TransformedCoords(const char* name, GrSLType type) 60 TransformedCoords(const SkString& name, GrSLType type)
60 : fName(name), fType(type) { 61 : fName(name), fType(type) {
61 } 62 }
62 63
63 const char* c_str() const { return fName.c_str(); } 64 const char* c_str() const { return fName.c_str(); }
64 GrSLType type() const { return fType; } 65 GrSLType type() const { return fType; }
65 const SkString& getName() const { return fName; } 66 const SkString& getName() const { return fName; }
66 67
67 private: 68 private:
68 SkString fName; 69 SkString fName;
69 GrSLType fType; 70 GrSLType fType;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 GrSLType fType; 149 GrSLType fType;
149 SkMatrix fCurrentValue; 150 SkMatrix fCurrentValue;
150 }; 151 };
151 152
152 SkTArray<SkSTArray<2, Transform, true> > fTransforms; 153 SkTArray<SkSTArray<2, Transform, true> > fTransforms;
153 bool fHasExplicitLocalCoords; 154 bool fHasExplicitLocalCoords;
154 155
155 typedef GrGLProgramEffects INHERITED; 156 typedef GrGLProgramEffects INHERITED;
156 }; 157 };
157 158
159 /**
160 * This is a GrGLProgramEffects implementation that does coord transforms with t he the built-in GL
161 * TexGen functionality.
162 */
163 class GrGLTexGenProgramEffects : public GrGLProgramEffects {
164 public:
165 virtual void setData(GrGpuGL*,
166 const GrGLUniformManager&,
167 const GrEffectStage* effectStages[]) SK_OVERRIDE;
168
169 private:
170 friend class GrGLTexGenProgramEffectsBuilder;
171
172 GrGLTexGenProgramEffects(int reserveCount)
173 : INHERITED(reserveCount)
174 #ifdef SK_DEBUG
175 , fFirstTexCoordIdx(0)
Kimmo Kinnunen 2013/10/04 11:02:33 This variable is never set in release mode. Causes
176 , fNumTexCoordSets(0)
177 #endif
178 , fTransformKeys(reserveCount) {
179 }
180
181 /**
182 * Helper for setData(). Sets the TexGen state for each transform in an effe ct. The transforms
183 * use adjacent texture units, starting with *texCoordIdx. Increments *texCo ordIdx by the number
184 * of transforms before returning.
185 */
186 void setTexGenState(GrGpuGL*, const GrDrawEffect&, int* texCoordIdx, int eff ectIdx);
187
188 int fFirstTexCoordIdx;
189 SkDEBUGCODE(int fNumTexCoordSets;)
190 SkTArray<EffectKey, true> fTransformKeys;
191
192 typedef GrGLProgramEffects INHERITED;
193 };
194
195
158 //////////////////////////////////////////////////////////////////////////////// 196 ////////////////////////////////////////////////////////////////////////////////
159 197
160 /** 198 /**
161 * This is an abstract base class for constructing different types of GrGLProgra mEffects objects. 199 * This is an abstract base class for constructing different types of GrGLProgra mEffects objects.
162 */ 200 */
163 class GrGLProgramEffectsBuilder { 201 class GrGLProgramEffectsBuilder {
164 public: 202 public:
165 /** 203 /**
166 * Emits the effect's shader code, and stores the necessary uniforms interna lly. 204 * Emits the effect's shader code, and stores the necessary uniforms interna lly.
167 */ 205 */
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 void emitTransforms(const GrEffectRef&, 255 void emitTransforms(const GrEffectRef&,
218 GrGLProgramEffects::EffectKey, 256 GrGLProgramEffects::EffectKey,
219 GrGLProgramEffects::TransformedCoordsArray*); 257 GrGLProgramEffects::TransformedCoordsArray*);
220 258
221 GrGLFullShaderBuilder* fBuilder; 259 GrGLFullShaderBuilder* fBuilder;
222 SkAutoTDelete<GrGLVertexProgramEffects> fProgramEffects; 260 SkAutoTDelete<GrGLVertexProgramEffects> fProgramEffects;
223 261
224 typedef GrGLProgramEffectsBuilder INHERITED; 262 typedef GrGLProgramEffectsBuilder INHERITED;
225 }; 263 };
226 264
265 /**
266 * This class is used by GrGLFragmentOnlyBuilder to construct a GrGLTexGenProgra mEffects.
267 */
268 class GrGLTexGenProgramEffectsBuilder : public GrGLProgramEffectsBuilder {
269 public:
270 GrGLTexGenProgramEffectsBuilder(GrGLFragmentOnlyShaderBuilder*, int reserveC ount);
271
272 virtual void emitEffect(const GrEffectStage&,
273 GrGLProgramEffects::EffectKey,
274 const char* outColor,
275 const char* inColor,
276 int stageIndex) SK_OVERRIDE;
277
278 /**
279 * Finalizes the building process and returns the effect array. After this c all, the builder
280 * becomes invalid.
281 */
282 GrGLProgramEffects* finish() { return fProgramEffects.detach(); }
283
284 private:
285 /**
286 * Helper for emitEffect(). Allocates texture units from the builder for eac h transform in an
287 * effect. The transforms all use adjacent texture units. They either use tw o or three of the
288 * coordinates at a given texture unit, depending on if they need perspectiv e interpolation.
289 * The expressions to access the transformed coords (i.e. 'vec2(gl_TexCoord[ 0])') as well as the
290 * types are appended to the TransformedCoordsArray* object, which is in tur n passed to the
291 * effect's emitCode() function.
292 */
293 void setupTexGen(const GrEffectRef&,
294 GrGLProgramEffects::EffectKey,
295 GrGLProgramEffects::TransformedCoordsArray*);
296
297 GrGLFragmentOnlyShaderBuilder* fBuilder;
298 SkAutoTDelete<GrGLTexGenProgramEffects> fProgramEffects;
299
300 typedef GrGLProgramEffectsBuilder INHERITED;
301 };
302
227 #endif 303 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgramDesc.h ('k') | src/gpu/gl/GrGLProgramEffects.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698