| 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 GrGLUniformHandler_DEFINED | 8 #ifndef GrGLUniformHandler_DEFINED |
| 9 #define GrGLUniformHandler_DEFINED | 9 #define GrGLUniformHandler_DEFINED |
| 10 | 10 |
| 11 #include "glsl/GrGLSLUniformHandler.h" | 11 #include "glsl/GrGLSLUniformHandler.h" |
| 12 | 12 |
| 13 #include "gl/GrGLProgramDataManager.h" | 13 #include "gl/GrGLProgramDataManager.h" |
| 14 #include "gl/GrGLSampler.h" |
| 14 | 15 |
| 15 class GrGLCaps; | 16 class GrGLCaps; |
| 16 | 17 |
| 17 class GrGLUniformHandler : public GrGLSLUniformHandler { | 18 class GrGLUniformHandler : public GrGLSLUniformHandler { |
| 18 public: | 19 public: |
| 19 static const int kUniformsPerBlock = 8; | 20 static const int kUniformsPerBlock = 8; |
| 20 | 21 |
| 21 const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const override { | 22 const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const override { |
| 22 return fUniforms[u.toIndex()].fVariable; | 23 return fUniforms[u.toIndex()].fVariable; |
| 23 } | 24 } |
| 24 | 25 |
| 25 const char* getUniformCStr(UniformHandle u) const override { | 26 const char* getUniformCStr(UniformHandle u) const override { |
| 26 return this->getUniformVariable(u).c_str(); | 27 return this->getUniformVariable(u).c_str(); |
| 27 } | 28 } |
| 28 private: | 29 private: |
| 29 explicit GrGLUniformHandler(GrGLSLProgramBuilder* program) | 30 explicit GrGLUniformHandler(GrGLSLProgramBuilder* program) |
| 30 : INHERITED(program) | 31 : INHERITED(program) |
| 31 , fUniforms(kUniformsPerBlock) {} | 32 , fUniforms(kUniformsPerBlock) {} |
| 32 | 33 |
| 33 UniformHandle internalAddUniformArray(uint32_t visibility, | 34 UniformHandle internalAddUniformArray(uint32_t visibility, |
| 34 GrSLType type, | 35 GrSLType type, |
| 35 GrSLPrecision precision, | 36 GrSLPrecision precision, |
| 36 const char* name, | 37 const char* name, |
| 37 bool mangleName, | 38 bool mangleName, |
| 38 int arrayCount, | 39 int arrayCount, |
| 39 const char** outName) override; | 40 const char** outName) override; |
| 40 | 41 |
| 42 SamplerHandle internalAddSampler(uint32_t visibility, |
| 43 GrPixelConfig config, |
| 44 GrSLType type, |
| 45 GrSLPrecision precision, |
| 46 const char* name) override; |
| 47 |
| 48 int numSamplers() const override { return fSamplers.count(); } |
| 49 const GrGLSLSampler& getSampler(SamplerHandle handle) const override { |
| 50 return fSamplers[handle.toIndex()]; |
| 51 } |
| 52 |
| 53 |
| 41 void appendUniformDecls(GrShaderFlags visibility, SkString*) const override; | 54 void appendUniformDecls(GrShaderFlags visibility, SkString*) const override; |
| 42 | 55 |
| 43 // Manually set uniform locations for all our uniforms. | 56 // Manually set uniform locations for all our uniforms. |
| 44 void bindUniformLocations(GrGLuint programID, const GrGLCaps& caps); | 57 void bindUniformLocations(GrGLuint programID, const GrGLCaps& caps); |
| 45 | 58 |
| 46 // Updates the loction of the Uniforms if we cannot bind uniform locations m
anually | 59 // Updates the loction of the Uniforms if we cannot bind uniform locations m
anually |
| 47 void getUniformLocations(GrGLuint programID, const GrGLCaps& caps); | 60 void getUniformLocations(GrGLuint programID, const GrGLCaps& caps); |
| 48 | 61 |
| 49 const GrGLGpu* glGpu() const; | 62 const GrGLGpu* glGpu() const; |
| 50 | 63 |
| 51 typedef GrGLProgramDataManager::UniformInfo UniformInfo; | 64 typedef GrGLProgramDataManager::UniformInfo UniformInfo; |
| 52 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; | 65 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; |
| 53 | 66 |
| 54 UniformInfoArray fUniforms; | 67 UniformInfoArray fUniforms; |
| 55 | 68 |
| 69 SkTArray<GrGLSampler> fSamplers; |
| 70 |
| 56 friend class GrGLProgramBuilder; | 71 friend class GrGLProgramBuilder; |
| 57 | 72 |
| 58 typedef GrGLSLUniformHandler INHERITED; | 73 typedef GrGLSLUniformHandler INHERITED; |
| 59 }; | 74 }; |
| 60 | 75 |
| 61 #endif | 76 #endif |
| OLD | NEW |