Home | History | Annotate | Download | only in gl
      1 /*
      2  * Copyright 2015 Google Inc.
      3  *
      4  * Use of this source code is governed by a BSD-style license that can be
      5  * found in the LICENSE file.
      6  */
      7 
      8 #ifndef GrGLUniformHandler_DEFINED
      9 #define GrGLUniformHandler_DEFINED
     10 
     11 #include "glsl/GrGLSLUniformHandler.h"
     12 
     13 #include "gl/GrGLProgramDataManager.h"
     14 
     15 class GrGLCaps;
     16 
     17 static const int kUniformsPerBlock = 8;
     18 
     19 class GrGLUniformHandler : public GrGLSLUniformHandler {
     20 public:
     21     const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const override {
     22         return fUniforms[u.toIndex()].fVariable;
     23     }
     24 
     25     const char* getUniformCStr(UniformHandle u) const override {
     26         return this->getUniformVariable(u).c_str();
     27     }
     28 private:
     29     explicit GrGLUniformHandler(GrGLSLProgramBuilder* program)
     30         : INHERITED(program)
     31         , fUniforms(kUniformsPerBlock) {}
     32 
     33     UniformHandle internalAddUniformArray(uint32_t visibility,
     34                                           GrSLType type,
     35                                           GrSLPrecision precision,
     36                                           const char* name,
     37                                           bool mangleName,
     38                                           int arrayCount,
     39                                           const char** outName) override;
     40 
     41     void appendUniformDecls(GrShaderFlags visibility, SkString*) const override;
     42 
     43     // Manually set uniform locations for all our uniforms.
     44     void bindUniformLocations(GrGLuint programID, const GrGLCaps& caps);
     45 
     46     // Updates the loction of the Uniforms if we cannot bind uniform locations manually
     47     void getUniformLocations(GrGLuint programID, const GrGLCaps& caps);
     48 
     49     const GrGLGpu* glGpu() const;
     50 
     51     typedef GrGLProgramDataManager::UniformInfo UniformInfo;
     52     typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray;
     53 
     54     UniformInfoArray fUniforms;
     55 
     56     friend class GrGLProgramBuilder;
     57 
     58     typedef GrGLSLUniformHandler INHERITED;
     59 };
     60 
     61 #endif
     62