Flutter Engine
The Flutter Engine
GrGLProgramDataManager.h
Go to the documentation of this file.
1/*
2 * Copyright 2012 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 GrGLProgramDataManager_DEFINED
9#define GrGLProgramDataManager_DEFINED
10
16
18
19class GrGLGpu;
20class SkMatrix;
21class GrGLProgram;
22
23/** Manages the resources used by a shader program.
24 * The resources are objects the program uses to communicate with the
25 * application code.
26 */
28public:
31 };
32
33 struct VaryingInfo {
36 };
37
38 // This uses a SkTBlockList rather than SkTArray/std::vector so that the GrShaderVars
39 // don't move in memory after they are inserted. Users of GrGLShaderBuilder get refs to the vars
40 // and ptrs to their name strings. Otherwise, we'd have to hand out copies.
43
45
46 void setSamplerUniforms(const UniformInfoArray& samplers, int startUnit) const;
47
48 /** Functions for uploading uniform values. The varities ending in v can be used to upload to an
49 * array of uniforms. arrayCount must be <= the array count of the uniform.
50 */
51 void set1i(UniformHandle, int32_t) const override;
52 void set1iv(UniformHandle, int arrayCount, const int32_t v[]) const override;
53 void set1f(UniformHandle, float v0) const override;
54 void set1fv(UniformHandle, int arrayCount, const float v[]) const override;
55 void set2i(UniformHandle, int32_t, int32_t) const override;
56 void set2iv(UniformHandle, int arrayCount, const int32_t v[]) const override;
57 void set2f(UniformHandle, float, float) const override;
58 void set2fv(UniformHandle, int arrayCount, const float v[]) const override;
59 void set3i(UniformHandle, int32_t, int32_t, int32_t) const override;
60 void set3iv(UniformHandle, int arrayCount, const int32_t v[]) const override;
61 void set3f(UniformHandle, float, float, float) const override;
62 void set3fv(UniformHandle, int arrayCount, const float v[]) const override;
63 void set4i(UniformHandle, int32_t, int32_t, int32_t, int32_t) const override;
64 void set4iv(UniformHandle, int arrayCount, const int32_t v[]) const override;
65 void set4f(UniformHandle, float, float, float, float) const override;
66 void set4fv(UniformHandle, int arrayCount, const float v[]) const override;
67 // matrices are column-major, the first three upload a single matrix, the latter three upload
68 // arrayCount matrices into a uniform array.
69 void setMatrix2f(UniformHandle, const float matrix[]) const override;
70 void setMatrix3f(UniformHandle, const float matrix[]) const override;
71 void setMatrix4f(UniformHandle, const float matrix[]) const override;
72 void setMatrix2fv(UniformHandle, int arrayCount, const float matrices[]) const override;
73 void setMatrix3fv(UniformHandle, int arrayCount, const float matrices[]) const override;
74 void setMatrix4fv(UniformHandle, int arrayCount, const float matrices[]) const override;
75
76private:
77 enum {
78 kUnusedUniform = -1,
79 };
80
81 struct Uniform {
82 GrGLint fLocation;
83#ifdef SK_DEBUG
84 SkSLType fType;
85 int fArrayCount;
86#endif
87 };
88
89 template<int N> inline void setMatrices(UniformHandle, int arrayCount,
90 const float matrices[]) const;
91
93 GrGLGpu* fGpu;
94
95 using INHERITED = GrGLSLProgramDataManager;
96};
97
98#endif
int GrGLint
Definition: GrGLTypes.h:108
SkSLType
void set1iv(UniformHandle, int arrayCount, const int32_t v[]) const override
void setMatrix4fv(UniformHandle, int arrayCount, const float matrices[]) const override
void set2i(UniformHandle, int32_t, int32_t) const override
SkTBlockList< GLUniformInfo > UniformInfoArray
void set3iv(UniformHandle, int arrayCount, const int32_t v[]) const override
void set4fv(UniformHandle, int arrayCount, const float v[]) const override
void set4iv(UniformHandle, int arrayCount, const int32_t v[]) const override
void setMatrix3fv(UniformHandle, int arrayCount, const float matrices[]) const override
void setMatrix3f(UniformHandle, const float matrix[]) const override
GrGLProgramDataManager(GrGLGpu *, const UniformInfoArray &)
void setSamplerUniforms(const UniformInfoArray &samplers, int startUnit) const
void set3f(UniformHandle, float, float, float) const override
void setMatrix2fv(UniformHandle, int arrayCount, const float matrices[]) const override
void setMatrix2f(UniformHandle, const float matrix[]) const override
void setMatrix4f(UniformHandle, const float matrix[]) const override
void set4i(UniformHandle, int32_t, int32_t, int32_t, int32_t) const override
SkTBlockList< VaryingInfo > VaryingInfoArray
void set3fv(UniformHandle, int arrayCount, const float v[]) const override
void set4f(UniformHandle, float, float, float, float) const override
void set1i(UniformHandle, int32_t) const override
void set1f(UniformHandle, float v0) const override
void set2f(UniformHandle, float, float) const override
void set1fv(UniformHandle, int arrayCount, const float v[]) const override
void set2iv(UniformHandle, int arrayCount, const int32_t v[]) const override
void set2fv(UniformHandle, int arrayCount, const float v[]) const override
void set3i(UniformHandle, int32_t, int32_t, int32_t) const override
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258