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

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

Issue 25605008: Repurpose GrGLCoordTransform as GrGLEffectArray (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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/GrGLCoordTransform.cpp ('k') | src/gpu/gl/GrGLEffect.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 2012 Google Inc. 2 * Copyright 2012 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 GrGLEffect_DEFINED 8 #ifndef GrGLEffect_DEFINED
9 #define GrGLEffect_DEFINED 9 #define GrGLEffect_DEFINED
10 10
11 #include "GrBackendEffectFactory.h" 11 #include "GrBackendEffectFactory.h"
12 #include "GrGLProgramEffects.h"
12 #include "GrGLShaderBuilder.h" 13 #include "GrGLShaderBuilder.h"
13 #include "GrGLShaderVar.h" 14 #include "GrGLShaderVar.h"
14 #include "GrGLSL.h" 15 #include "GrGLSL.h"
15 16
16 class GrGLTexture; 17 class GrGLTexture;
17 18
18 /** @file 19 /** @file
19 This file contains specializations for OpenGL of the shader stages declared in 20 This file contains specializations for OpenGL of the shader stages declared in
20 include/gpu/GrEffect.h. Objects of type GrGLEffect are responsible for emitt ing the 21 include/gpu/GrEffect.h. Objects of type GrGLEffect are responsible for emitt ing the
21 GLSL code that implements a GrEffect and for uploading uniforms at draw time . If they don't 22 GLSL code that implements a GrEffect and for uploading uniforms at draw time . If they don't
22 always emit the same GLSL code, they must have a function: 23 always emit the same GLSL code, they must have a function:
23 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&) 24 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&)
24 that is used to implement a program cache. When two GrEffects produce the sa me key this means 25 that is used to implement a program cache. When two GrEffects produce the sa me key this means
25 that their GrGLEffects would emit the same GLSL code. 26 that their GrGLEffects would emit the same GLSL code.
26 27
27 The GrGLEffect subclass must also have a constructor of the form: 28 The GrGLEffect subclass must also have a constructor of the form:
28 EffectSubclass::EffectSubclass(const GrBackendEffectFactory&, const GrDr awEffect&) 29 EffectSubclass::EffectSubclass(const GrBackendEffectFactory&, const GrDr awEffect&)
29 The effect held by the GrDrawEffect is guaranteed to be of the type that gen erated the 30 The effect held by the GrDrawEffect is guaranteed to be of the type that gen erated the
30 GrGLEffect subclass instance. 31 GrGLEffect subclass instance.
31 32
32 These objects are created by the factory object returned by the GrEffect::ge tFactory(). 33 These objects are created by the factory object returned by the GrEffect::ge tFactory().
33 */ 34 */
34 35
35 class GrDrawEffect; 36 class GrDrawEffect;
36 37
37 class GrGLEffect { 38 class GrGLEffect {
38 39
39 public: 40 public:
40 typedef GrBackendEffectFactory::EffectKey EffectKey; 41 typedef GrBackendEffectFactory::EffectKey EffectKey;
42 typedef GrGLProgramEffects::TransformedCoordsArray TransformedCoordsArray;
43 typedef GrGLProgramEffects::TextureSamplerArray TextureSamplerArray;
41 44
42 enum { 45 enum {
43 kNoEffectKey = GrBackendEffectFactory::kNoEffectKey, 46 kNoEffectKey = GrBackendEffectFactory::kNoEffectKey,
44 // the number of bits in EffectKey available to GenKey 47 // the number of bits in EffectKey available to GenKey
45 kEffectKeyBits = GrBackendEffectFactory::kEffectKeyBits, 48 kEffectKeyBits = GrBackendEffectFactory::kEffectKeyBits,
46 }; 49 };
47 50
48 typedef GrGLShaderBuilder::TransformedCoordsArray TransformedCoordsArray; 51 GrGLEffect(const GrBackendEffectFactory& factory) : fFactory(factory) {}
49 typedef GrGLShaderBuilder::TextureSamplerArray TextureSamplerArray;
50 52
51 GrGLEffect(const GrBackendEffectFactory&); 53 virtual ~GrGLEffect() {}
52
53 virtual ~GrGLEffect();
54 54
55 /** Called when the program stage should insert its code into the shaders. T he code in each 55 /** Called when the program stage should insert its code into the shaders. T he code in each
56 shader will be in its own block ({}) and so locally scoped names will no t collide across 56 shader will be in its own block ({}) and so locally scoped names will no t collide across
57 stages. 57 stages.
58 58
59 @param builder Interface used to emit code in the shaders. 59 @param builder Interface used to emit code in the shaders.
60 @param drawEffect A wrapper on the effect that generated this program stage. 60 @param drawEffect A wrapper on the effect that generated this program stage.
61 @param key The key that was computed by GenKey() from the gener ating GrEffect. 61 @param key The key that was computed by GenKey() from the gener ating GrEffect.
62 Only the bits indicated by GrBackendEffectFactory::k EffectKeyBits are 62 Only the bits indicated by GrBackendEffectFactory::k EffectKeyBits are
63 guaranteed to match the value produced by GenKey(); 63 guaranteed to match the value produced by GenKey();
(...skipping 16 matching lines...) Expand all
80 const TransformedCoordsArray& coords, 80 const TransformedCoordsArray& coords,
81 const TextureSamplerArray& samplers) = 0; 81 const TextureSamplerArray& samplers) = 0;
82 82
83 /** A GrGLEffect instance can be reused with any GrEffect that produces the same stage 83 /** A GrGLEffect instance can be reused with any GrEffect that produces the same stage
84 key; this function reads data from a stage and uploads any uniform varia bles required 84 key; this function reads data from a stage and uploads any uniform varia bles required
85 by the shaders created in emitCode(). The GrEffect installed in the GrEf fectStage is 85 by the shaders created in emitCode(). The GrEffect installed in the GrEf fectStage is
86 guaranteed to be of the same type that created this GrGLEffect and to ha ve an identical 86 guaranteed to be of the same type that created this GrGLEffect and to ha ve an identical
87 EffectKey as the one that created this GrGLEffect. Effects that use loca l coords have 87 EffectKey as the one that created this GrGLEffect. Effects that use loca l coords have
88 to consider whether the GrEffectStage's coord change matrix should be us ed. When explicit 88 to consider whether the GrEffectStage's coord change matrix should be us ed. When explicit
89 local coordinates are used it can be ignored. */ 89 local coordinates are used it can be ignored. */
90 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&); 90 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) {}
91 91
92 const char* name() const { return fFactory.name(); } 92 const char* name() const { return fFactory.name(); }
93 93
94 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&) { retur n 0; } 94 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&) { retur n 0; }
95 95
96 static EffectKey GenTextureKey(const GrDrawEffect&, const GrGLCaps&);
97 static EffectKey GenTransformKey(const GrDrawEffect&);
98 static EffectKey GenAttribKey(const GrDrawEffect& stage);
99
100 protected: 96 protected:
101 const GrBackendEffectFactory& fFactory; 97 const GrBackendEffectFactory& fFactory;
102 }; 98 };
103 99
104 #endif 100 #endif
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCoordTransform.cpp ('k') | src/gpu/gl/GrGLEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698