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

Side by Side Diff: src/gpu/gl/builders/GrGLFullProgramBuilder.h

Issue 582963002: Solo gp (Closed) Base URL: https://skia.googlesource.com/skia.git@no_peb
Patch Set: fix 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
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 GrGLFullProgramBuilder_DEFINED 8 #ifndef GrGLFullProgramBuilder_DEFINED
9 #define GrGLFullProgramBuilder_DEFINED 9 #define GrGLFullProgramBuilder_DEFINED
10 10
11 #include "GrGLProgramBuilder.h" 11 #include "GrGLProgramBuilder.h"
12 #include "../GrGLGeometryProcessor.h"
12 13
13 class GrGLVertexProgramEffects; 14 class GrGLVertexProgramEffects;
14 15
15 class GrGLFullProgramBuilder : public GrGLProgramBuilder { 16 class GrGLFullProgramBuilder : public GrGLProgramBuilder {
16 public: 17 public:
17 GrGLFullProgramBuilder(GrGpuGL*, const GrGLProgramDesc&); 18 GrGLFullProgramBuilder(GrGpuGL*, const GrGLProgramDesc&);
18 19
19 /** Add a varying variable to the current program to pass values between vert ex and fragment 20 /** Add a varying variable to the current program to pass values between vert ex and fragment
20 shaders. If the last two parameters are non-NULL, they are filled in wit h the name 21 shaders. If the last two parameters are non-NULL, they are filled in wit h the name
21 generated. */ 22 generated. */
22 void addVarying(GrSLType type, 23 void addVarying(GrSLType type,
23 const char* name, 24 const char* name,
24 const char** vsOutName = NULL, 25 const char** vsOutName = NULL,
25 const char** fsInName = NULL, 26 const char** fsInName = NULL,
26 GrGLShaderVar::Precision fsPrecision=GrGLShaderVar::kDefault _Precision); 27 GrGLShaderVar::Precision fsPrecision=GrGLShaderVar::kDefault _Precision);
27 28
28 /** Add a separable varying input variable to the current program. 29 /** Add a separable varying input variable to the current program.
29 * A separable varying (fragment shader input) is a varying that can be used also when vertex 30 * A separable varying (fragment shader input) is a varying that can be used also when vertex
30 * shaders are not used. With a vertex shader, the operation is same as with other 31 * shaders are not used. With a vertex shader, the operation is same as with other
31 * varyings. Without a vertex shader, such as with NV_path_rendering, GL API s are used to 32 * varyings. Without a vertex shader, such as with NV_path_rendering, GL API s are used to
32 * populate the variable. The APIs can refer to the variable through the ret urned handle. 33 * populate the variable. The APIs can refer to the variable through the ret urned handle.
33 */ 34 */
34 VaryingHandle addSeparableVarying(GrSLType type, 35 VaryingHandle addSeparableVarying(GrSLType type,
35 const char* name, 36 const char* name,
36 const char** vsOutName, 37 const char** vsOutName,
37 const char** fsInName); 38 const char** fsInName);
38 39
39 GrGLVertexShaderBuilder* getVertexShaderBuilder() { return &fVS; } 40 GrGLVertexShaderBuilder* getVertexShaderBuilder() { return &fVS; }
40 41
42 /*
43 * This non-virtual call will hide the parent call to prevent GPs from acces sing fragment shader
44 * functionality they shouldn't be using
45 */
46 GrGLBaseFragmentShaderBuilder* getFragmentShaderBuilder() { return &fFS; }
47
41 private: 48 private:
42 virtual void createAndEmitEffects(const GrEffectStage* geometryProcessor, 49 virtual void createAndEmitEffects(const GrGeometryStage* geometryProcessor,
43 const GrEffectStage* colorStages[], 50 const GrFragmentStage* colorStages[],
44 const GrEffectStage* coverageStages[], 51 const GrFragmentStage* coverageStages[],
45 GrGLSLExpr4* inputColor, 52 GrGLSLExpr4* inputColor,
46 GrGLSLExpr4* inputCoverage) SK_OVERRIDE; 53 GrGLSLExpr4* inputCoverage) SK_OVERRIDE;
47 54
48 GrGLProgramEffects* onCreateAndEmitEffects(const GrEffectStage* effectStages [], 55 GrGLProgramEffects* onCreateAndEmitEffects(const GrFragmentStage* effectStag es[],
49 int effectCnt, 56 int effectCnt,
50 const GrGLProgramDesc::EffectKeyP rovider&, 57 const GrGLProgramDesc::EffectKeyP rovider&,
51 GrGLSLExpr4* inOutFSColor); 58 GrGLSLExpr4* inOutFSColor);
52 59
53 virtual void emitEffect(const GrEffectStage& stage, 60 class GrGLGeometryProcessorEmitter : public GrGLProgramBuilder::GrGLProcesso rEmitterInterface {
54 const GrEffectKey& key, 61 public:
62 GrGLGeometryProcessorEmitter(GrGLFullProgramBuilder* builder)
63 : fBuilder(builder)
64 , fGeometryProcessor(NULL)
65 , fGLGeometryProcessor(NULL) {}
66 virtual ~GrGLGeometryProcessorEmitter() {}
67 void set(const GrGeometryProcessor* gp) {
68 SkASSERT(NULL == fGeometryProcessor);
69 fGeometryProcessor = gp;
70 }
71 virtual GrGLProcessor* createGLInstance() {
72 SkASSERT(fGeometryProcessor);
73 SkASSERT(NULL == fGLGeometryProcessor);
74 fGLGeometryProcessor =
75 fGeometryProcessor->getFactory().createGLInstance(*fGeom etryProcessor);
76 return fGLGeometryProcessor;
77 }
78 virtual void emit(const GrProcessorKey& key,
79 const char* outColor,
80 const char* inColor,
81 const GrGLProcessor::TransformedCoordsArray& coord s,
82 const GrGLProcessor::TextureSamplerArray& samplers ) {
83 SkASSERT(fGeometryProcessor);
84 SkASSERT(fGLGeometryProcessor);
85 fGLGeometryProcessor->emitCode(fBuilder, *fGeometryProcessor, ke y, outColor,
86 inColor, coords, samplers);
87 // this will not leak because it has already been used by create GLInstance
88 fGLGeometryProcessor = NULL;
89 fGeometryProcessor = NULL;
90 }
91 private:
92 GrGLFullProgramBuilder* fBuilder;
93 const GrGeometryProcessor* fGeometryProcessor;
94 GrGLGeometryProcessor* fGLGeometryProcessor;
95 };
96
97 virtual void emitEffect(const GrProcessorStage& stage,
98 const GrProcessorKey& key,
55 const char* outColor, 99 const char* outColor,
56 const char* inColor, 100 const char* inColor,
57 int stageIndex) SK_OVERRIDE; 101 int stageIndex) SK_OVERRIDE;
58 102
59 /** 103 /**
60 * Helper for emitEffect(). Emits code to implement an effect's coord transf orms in the VS. 104 * Helper for emitEffect(). Emits code to implement an effect's coord transf orms in the VS.
61 * Varyings are added as an outputs of the VS and inputs to the FS. The vary ings may be either a 105 * Varyings are added as an outputs of the VS and inputs to the FS. The vary ings may be either a
62 * vec2f or vec3f depending upon whether perspective interpolation is requir ed or not. The names 106 * vec2f or vec3f depending upon whether perspective interpolation is requir ed or not. The names
63 * of the varyings in the VS and FS as well their types are appended to the 107 * of the varyings in the VS and FS as well their types are appended to the
64 * TransformedCoordsArray* object, which is in turn passed to the effect's e mitCode() function. 108 * TransformedCoordsArray* object, which is in turn passed to the effect's e mitCode() function.
65 */ 109 */
66 void emitTransforms(const GrEffectStage& effectStage, 110 void emitTransforms(const GrProcessorStage& effectStage,
67 GrGLEffect::TransformedCoordsArray* outCoords); 111 GrGLProcessor::TransformedCoordsArray* outCoords);
68 112
69 virtual bool compileAndAttachShaders(GrGLuint programId, 113 virtual bool compileAndAttachShaders(GrGLuint programId,
70 SkTDArray<GrGLuint>* shaderIds) const S K_OVERRIDE; 114 SkTDArray<GrGLuint>* shaderIds) const S K_OVERRIDE;
71 115
72 virtual void bindProgramLocations(GrGLuint programId) SK_OVERRIDE; 116 virtual void bindProgramLocations(GrGLuint programId) SK_OVERRIDE;
73 117
74 virtual GrGLProgramEffects* getProgramEffects() SK_OVERRIDE { return fProgra mEffects.get(); } 118 virtual GrGLProgramEffects* getProgramEffects() SK_OVERRIDE { return fProgra mEffects.get(); }
75 119
76 typedef GrGLProgramDesc::EffectKeyProvider EffectKeyProvider; 120 typedef GrGLProgramDesc::EffectKeyProvider EffectKeyProvider;
77 121
122 GrGLGeometryProcessorEmitter fGLGeometryProcessorEmitter;
78 GrGLGeometryShaderBuilder fGS; 123 GrGLGeometryShaderBuilder fGS;
79 GrGLVertexShaderBuilder fVS; 124 GrGLVertexShaderBuilder fVS;
80 SkAutoTDelete<GrGLVertexProgramEffects> fProgramEffects; 125 SkAutoTDelete<GrGLVertexProgramEffects> fProgramEffects;
81 126
82 typedef GrGLProgramBuilder INHERITED; 127 typedef GrGLProgramBuilder INHERITED;
83 }; 128 };
84 129
85 #endif 130 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698