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

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

Issue 571163002: removing GrDrawEffect (Closed) Base URL: https://skia.googlesource.com/skia.git@gp3
Patch Set: rebase after revert Created 6 years, 3 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
« no previous file with comments | « src/gpu/effects/GrYUVtoRGBEffect.cpp ('k') | src/gpu/gl/GrGLGeometryProcessor.h » ('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 "GrGLProgramEffects.h"
13 #include "GrGLShaderVar.h" 13 #include "GrGLShaderVar.h"
14 #include "GrGLSL.h" 14 #include "GrGLSL.h"
15 15
16 class GrGLShaderBuilder; 16 class GrGLShaderBuilder;
17 17
18 /** @file 18 /** @file
19 This file contains specializations for OpenGL of the shader stages declared in 19 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 20 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 21 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: 22 always emit the same GLSL code, they must have a function:
23 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffect KeyBuilder*) 23 static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyB uilder*)
24 that is used to implement a program cache. When two GrEffects produce the sa me key this means 24 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. 25 that their GrGLEffects would emit the same GLSL code.
26 26
27 The GrGLEffect subclass must also have a constructor of the form: 27 The GrGLEffect subclass must also have a constructor of the form:
28 EffectSubclass::EffectSubclass(const GrBackendEffectFactory&, const GrDr awEffect&) 28 EffectSubclass::EffectSubclass(const GrBackendEffectFactory&, const GrEf fect&)
29 The effect held by the GrDrawEffect is guaranteed to be of the type that gen erated the
30 GrGLEffect subclass instance.
31 29
32 These objects are created by the factory object returned by the GrEffect::ge tFactory(). 30 These objects are created by the factory object returned by the GrEffect::ge tFactory().
33 */ 31 */
34 32
35 class GrDrawEffect;
36 class GrGLTexture; 33 class GrGLTexture;
37 class GrGLGeometryProcessor; 34 class GrGLGeometryProcessor;
38 35
39 class GrGLEffect { 36 class GrGLEffect {
40 37
41 public: 38 public:
42 typedef GrGLProgramEffects::TransformedCoordsArray TransformedCoordsArray; 39 typedef GrGLProgramEffects::TransformedCoordsArray TransformedCoordsArray;
43 typedef GrGLProgramEffects::TextureSampler TextureSampler; 40 typedef GrGLProgramEffects::TextureSampler TextureSampler;
44 typedef GrGLProgramEffects::TextureSamplerArray TextureSamplerArray; 41 typedef GrGLProgramEffects::TextureSamplerArray TextureSamplerArray;
45 42
46 GrGLEffect(const GrBackendEffectFactory& factory) 43 GrGLEffect(const GrBackendEffectFactory& factory)
47 : fFactory(factory) 44 : fFactory(factory)
48 , fIsVertexEffect(false) { 45 , fIsVertexEffect(false) {
49 } 46 }
50 47
51 virtual ~GrGLEffect() {} 48 virtual ~GrGLEffect() {}
52 49
53 /** Called when the program stage should insert its code into the shaders. T he code in each 50 /** Called when the program stage should insert its code into the shaders. T he code in each
54 shader will be in its own block ({}) and so locally scoped names will no t collide across 51 shader will be in its own block ({}) and so locally scoped names will no t collide across
55 stages. 52 stages.
56 53
57 @param builder Interface used to emit code in the shaders. 54 @param builder Interface used to emit code in the shaders.
58 @param drawEffect A wrapper on the effect that generated this program stage. 55 @param effect The effect that generated this program stage.
59 @param key The key that was computed by GenKey() from the gener ating GrEffect. 56 @param key The key that was computed by GenKey() from the gener ating GrEffect.
60 @param outputColor A predefined vec4 in the FS in which the stage shoul d place its output 57 @param outputColor A predefined vec4 in the FS in which the stage shoul d place its output
61 color (or coverage). 58 color (or coverage).
62 @param inputColor A vec4 that holds the input color to the stage in th e FS. This may be 59 @param inputColor A vec4 that holds the input color to the stage in th e FS. This may be
63 NULL in which case the implied input is solid white (all ones). 60 NULL in which case the implied input is solid white (all ones).
64 TODO: Better system for communicating optimization i nfo (e.g. input 61 TODO: Better system for communicating optimization i nfo (e.g. input
65 color is solid white, trans black, known to be opaqu e, etc.) that allows 62 color is solid white, trans black, known to be opaqu e, etc.) that allows
66 the effect to communicate back similar known info ab out its output. 63 the effect to communicate back similar known info ab out its output.
67 @param samplers One entry for each GrTextureAccess of the GrEffect t hat generated the 64 @param samplers One entry for each GrTextureAccess of the GrEffect t hat generated the
68 GrGLEffect. These can be passed to the builder to em it texture 65 GrGLEffect. These can be passed to the builder to em it texture
69 reads in the generated code. 66 reads in the generated code.
70 */ 67 */
71 virtual void emitCode(GrGLProgramBuilder* builder, 68 virtual void emitCode(GrGLProgramBuilder* builder,
72 const GrDrawEffect& drawEffect, 69 const GrEffect& effect,
73 const GrEffectKey& key, 70 const GrEffectKey& key,
74 const char* outputColor, 71 const char* outputColor,
75 const char* inputColor, 72 const char* inputColor,
76 const TransformedCoordsArray& coords, 73 const TransformedCoordsArray& coords,
77 const TextureSamplerArray& samplers) = 0; 74 const TextureSamplerArray& samplers) = 0;
78 75
79 /** A GrGLEffect instance can be reused with any GrEffect that produces the same stage 76 /** A GrGLEffect instance can be reused with any GrEffect that produces the same stage
80 key; this function reads data from a GrEffect and uploads any uniform va riables required 77 key; this function reads data from a GrEffect and uploads any uniform va riables required
81 by the shaders created in emitCode(). The GrEffect installed in the GrDr awEffect is 78 by the shaders created in emitCode(). The GrEffect is
82 guaranteed to be of the same type that created this GrGLEffect and to ha ve an identical 79 guaranteed to be of the same type that created this GrGLEffect and to ha ve an identical
83 effect key as the one that created this GrGLEffect. Effects that use loc al coords have 80 effect key as the one that created this GrGLEffect. Effects that use loc al coords have
84 to consider whether the GrEffectStage's coord change matrix should be us ed. When explicit 81 to consider whether the GrEffectStage's coord change matrix should be us ed. When explicit
85 local coordinates are used it can be ignored. */ 82 local coordinates are used it can be ignored. */
86 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) {} 83 virtual void setData(const GrGLProgramDataManager&, const GrEffect&) {}
87 84
88 const char* name() const { return fFactory.name(); } 85 const char* name() const { return fFactory.name(); }
89 86
90 static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder* ) {} 87 static void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
91 88
92 /** Used by the system when generating shader code, to see if this effect ca n be downcasted to 89 /** Used by the system when generating shader code, to see if this effect ca n be downcasted to
93 the internal GrGLGeometryProcessor type */ 90 the internal GrGLGeometryProcessor type */
94 bool isVertexEffect() const { return fIsVertexEffect; } 91 bool isVertexEffect() const { return fIsVertexEffect; }
95 92
96 protected: 93 protected:
97 const GrBackendEffectFactory& fFactory; 94 const GrBackendEffectFactory& fFactory;
98 95
99 private: 96 private:
100 friend class GrGLGeometryProcessor; // to set fIsVertexEffect 97 friend class GrGLGeometryProcessor; // to set fIsVertexEffect
101 98
102 bool fIsVertexEffect; 99 bool fIsVertexEffect;
103 }; 100 };
104 101
105 #endif 102 #endif
OLDNEW
« no previous file with comments | « src/gpu/effects/GrYUVtoRGBEffect.cpp ('k') | src/gpu/gl/GrGLGeometryProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698