OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 GrGLSLUniformHandler_DEFINED | 8 #ifndef GrGLSLUniformHandler_DEFINED |
9 #define GrGLSLUniformHandler_DEFINED | 9 #define GrGLSLUniformHandler_DEFINED |
10 | 10 |
11 #include "GrGLSLProgramDataManager.h" | 11 #include "GrGLSLProgramDataManager.h" |
12 #include "GrGLSLShaderVar.h" | 12 #include "GrGLSLShaderVar.h" |
13 | 13 |
14 class GrGLSLProgramBuilder; | 14 class GrGLSLProgramBuilder; |
15 | 15 |
16 class GrGLSLUniformHandler { | 16 class GrGLSLUniformHandler { |
17 public: | 17 public: |
18 enum ShaderVisibility { | |
19 kVertex_Visibility = 1 << kVertex_GrShaderType, | |
20 kGeometry_Visibility = 1 << kGeometry_GrShaderType, | |
21 kFragment_Visibility = 1 << kFragment_GrShaderType, | |
22 }; | |
23 | |
24 virtual ~GrGLSLUniformHandler() {} | 18 virtual ~GrGLSLUniformHandler() {} |
25 | 19 |
26 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; | 20 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; |
27 | 21 |
28 /** Add a uniform variable to the current program, that has visibility in on
e or more shaders. | 22 /** Add a uniform variable to the current program, that has visibility in on
e or more shaders. |
29 visibility is a bitfield of ShaderVisibility values indicating from whic
h shaders the | 23 visibility is a bitfield of GrShaderFlag values indicating from which sh
aders the uniform |
30 uniform should be accessible. At least one bit must be set. Geometry sha
der uniforms are not | 24 should be accessible. At least one bit must be set. Geometry shader unif
orms are not |
31 supported at this time. The actual uniform name will be mangled. If outN
ame is not nullptr | 25 supported at this time. The actual uniform name will be mangled. If outN
ame is not nullptr |
32 then it will refer to the final uniform name after return. Use the addUn
iformArray variant | 26 then it will refer to the final uniform name after return. Use the addUn
iformArray variant |
33 to add an array of uniforms. */ | 27 to add an array of uniforms. */ |
34 UniformHandle addUniform(uint32_t visibility, | 28 UniformHandle addUniform(uint32_t visibility, |
35 GrSLType type, | 29 GrSLType type, |
36 GrSLPrecision precision, | 30 GrSLPrecision precision, |
37 const char* name, | 31 const char* name, |
38 const char** outName = nullptr) { | 32 const char** outName = nullptr) { |
39 return this->addUniformArray(visibility, type, precision, name, 0, outNa
me); | 33 return this->addUniformArray(visibility, type, precision, name, 0, outNa
me); |
40 } | 34 } |
(...skipping 22 matching lines...) Expand all Loading... |
63 | 57 |
64 private: | 58 private: |
65 virtual UniformHandle internalAddUniformArray(uint32_t visibility, | 59 virtual UniformHandle internalAddUniformArray(uint32_t visibility, |
66 GrSLType type, | 60 GrSLType type, |
67 GrSLPrecision precision, | 61 GrSLPrecision precision, |
68 const char* name, | 62 const char* name, |
69 bool mangleName, | 63 bool mangleName, |
70 int arrayCount, | 64 int arrayCount, |
71 const char** outName) = 0; | 65 const char** outName) = 0; |
72 | 66 |
73 virtual void appendUniformDecls(ShaderVisibility, SkString*) const = 0; | 67 virtual void appendUniformDecls(GrShaderFlags visibility, SkString*) const =
0; |
74 | 68 |
75 friend class GrGLSLProgramBuilder; | 69 friend class GrGLSLProgramBuilder; |
76 }; | 70 }; |
77 | 71 |
78 #endif | 72 #endif |
79 | 73 |
OLD | NEW |