Flutter Engine
The Flutter Engine
GrGLUniformHandler.h
Go to the documentation of this file.
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
13
14#include <vector>
15
16class GrGLCaps;
17
19public:
20 static const int kUniformsPerBlock = 8;
21
22 const GrShaderVar& getUniformVariable(UniformHandle u) const override {
23 return fUniforms.item(u.toIndex()).fVariable;
24 }
25
26 const char* getUniformCStr(UniformHandle u) const override {
27 return this->getUniformVariable(u).c_str();
28 }
29
30 int numUniforms() const override {
31 return fUniforms.count();
32 }
33
34 UniformInfo& uniform(int idx) override {
35 return fUniforms.item(idx);
36 }
37 const UniformInfo& uniform(int idx) const override {
38 return fUniforms.item(idx);
39 }
40
41private:
43 : INHERITED(program)
44 , fUniforms(kUniformsPerBlock)
45 , fSamplers(kUniformsPerBlock) {}
46
47 UniformHandle internalAddUniformArray(const GrProcessor* owner,
48 uint32_t visibility,
50 const char* name,
51 bool mangleName,
52 int arrayCount,
53 const char** outName) override;
54
55 SamplerHandle addSampler(const GrBackendFormat&, GrSamplerState, const skgpu::Swizzle&,
56 const char* name, const GrShaderCaps*) override;
57
58 const char* samplerVariable(SamplerHandle handle) const override {
59 return fSamplers.item(handle.toIndex()).fVariable.c_str();
60 }
61
62 skgpu::Swizzle samplerSwizzle(SamplerHandle handle) const override {
63 return fSamplerSwizzles[handle.toIndex()];
64 }
65
66 void appendUniformDecls(GrShaderFlags visibility, SkString*) const override;
67
68 // Manually set uniform locations for all our uniforms.
69 void bindUniformLocations(GrGLuint programID, const GrGLCaps& caps);
70
71 // Updates the loction of the Uniforms if we cannot bind uniform locations manually
72 void getUniformLocations(GrGLuint programID, const GrGLCaps& caps, bool force);
73
74 const GrGLGpu* glGpu() const;
75
76 typedef GrGLProgramDataManager::GLUniformInfo GLUniformInfo;
77 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray;
78
79 UniformInfoArray fUniforms;
80 UniformInfoArray fSamplers;
82
83 friend class GrGLProgramBuilder;
84
86};
87
88#endif
unsigned int GrGLuint
Definition: GrGLTypes.h:113
GrShaderFlags
Definition: GrTypesPriv.h:284
SkSLType
GLenum type
GrGLSLUniformHandler(GrGLSLProgramBuilder *program)
GrGLSLProgramDataManager::UniformHandle UniformHandle
const char * getUniformCStr(UniformHandle u) const override
static const int kUniformsPerBlock
UniformInfo & uniform(int idx) override
const UniformInfo & uniform(int idx) const override
int numUniforms() const override
const GrShaderVar & getUniformVariable(UniformHandle u) const override
const char * c_str() const
Definition: GrShaderVar.h:94
T & item(int i)
Definition: SkTBlockList.h:217
int count() const
Definition: SkTBlockList.h:167
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32