diff options
author | egdaniel <egdaniel@google.com> | 2015-12-03 09:20:44 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-03 09:20:44 -0800 |
commit | 7ea439b2203855db97330b25945b87dd4b170b8b (patch) | |
tree | c64bdcbd415fc639ec8c4fb791846cac80ff6f44 /src/gpu/gl/GrGLUniformHandler.h | |
parent | 73063dc517f424ad5660db0fbc5fe6fcc13f77f7 (diff) |
Create GLSLUniformHandler class for gpu backend
BUG=skia:
Review URL: https://codereview.chromium.org/1490283004
Diffstat (limited to 'src/gpu/gl/GrGLUniformHandler.h')
-rw-r--r-- | src/gpu/gl/GrGLUniformHandler.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/gpu/gl/GrGLUniformHandler.h b/src/gpu/gl/GrGLUniformHandler.h new file mode 100644 index 0000000000..a782bcb1c3 --- /dev/null +++ b/src/gpu/gl/GrGLUniformHandler.h @@ -0,0 +1,61 @@ +/* + * Copyright 2015 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrGLUniformHandler_DEFINED +#define GrGLUniformHandler_DEFINED + +#include "glsl/GrGLSLUniformHandler.h" + +#include "gl/GrGLProgramDataManager.h" + +class GrGLCaps; + +static const int kUniformsPerBlock = 8; + +class GrGLUniformHandler : public GrGLSLUniformHandler { +public: + const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const override { + return fUniforms[u.toIndex()].fVariable; + } + + const char* getUniformCStr(UniformHandle u) const override { + return this->getUniformVariable(u).c_str(); + } +private: + explicit GrGLUniformHandler(GrGLSLProgramBuilder* program) + : INHERITED(program) + , fUniforms(kUniformsPerBlock) {} + + UniformHandle internalAddUniformArray(uint32_t visibility, + GrSLType type, + GrSLPrecision precision, + const char* name, + bool mangleName, + int arrayCount, + const char** outName) override; + + void appendUniformDecls(ShaderVisibility, SkString*) const override; + + // Manually set uniform locations for all our uniforms. + void bindUniformLocations(GrGLuint programID, const GrGLCaps& caps); + + // Updates the loction of the Uniforms if we cannot bind uniform locations manually + void getUniformLocations(GrGLuint programID, const GrGLCaps& caps); + + const GrGLGpu* glGpu() const; + + typedef GrGLProgramDataManager::UniformInfo UniformInfo; + typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; + + UniformInfoArray fUniforms; + + friend class GrGLProgramBuilder; + + typedef GrGLSLUniformHandler INHERITED; +}; + +#endif |