2 * Copyright 2012 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef GrGLProgramDataManager_DEFINED
9 #define GrGLProgramDataManager_DEFINED
11 #include "glsl/GrGLSLProgramDataManager.h"
13 #include "GrAllocator.h"
14 #include "gl/GrGLTypes.h"
15 #include "glsl/GrGLSLShaderVar.h"
22 class GrGLProgramBuilder;
24 /** Manages the resources used by a shader program.
25 * The resources are objects the program uses to communicate with the
28 class GrGLProgramDataManager : public GrGLSLProgramDataManager {
31 GrGLSLShaderVar fVariable;
37 GrGLSLShaderVar fVariable;
41 // This uses an allocator rather than array so that the GrGLSLShaderVars don't move in memory
42 // after they are inserted. Users of GrGLShaderBuilder get refs to the vars and ptrs to their
43 // name strings. Otherwise, we'd have to hand out copies.
44 typedef GrTAllocator<UniformInfo> UniformInfoArray;
45 typedef GrTAllocator<VaryingInfo> VaryingInfoArray;
47 GrGLProgramDataManager(GrGLGpu*, GrGLuint programID, const UniformInfoArray&,
48 const VaryingInfoArray&);
50 /** Functions for uploading uniform values. The varities ending in v can be used to upload to an
51 * array of uniforms. arrayCount must be <= the array count of the uniform.
53 void setSampler(UniformHandle, int texUnit) const;
55 void set1f(UniformHandle, float v0) const override;
56 void set1fv(UniformHandle, int arrayCount, const float v[]) const override;
57 void set2f(UniformHandle, float, float) const override;
58 void set2fv(UniformHandle, int arrayCount, const float v[]) const override;
59 void set3f(UniformHandle, float, float, float) const override;
60 void set3fv(UniformHandle, int arrayCount, const float v[]) const override;
61 void set4f(UniformHandle, float, float, float, float) const override;
62 void set4fv(UniformHandle, int arrayCount, const float v[]) const override;
63 // matrices are column-major, the first three upload a single matrix, the latter three upload
64 // arrayCount matrices into a uniform array.
65 void setMatrix3f(UniformHandle, const float matrix[]) const override;
66 void setMatrix4f(UniformHandle, const float matrix[]) const override;
67 void setMatrix3fv(UniformHandle, int arrayCount, const float matrices[]) const override;
68 void setMatrix4fv(UniformHandle, int arrayCount, const float matrices[]) const override;
70 // convenience method for uploading a SkMatrix to a 3x3 matrix uniform
71 void setSkMatrix(UniformHandle, const SkMatrix&) const override;
74 void setPathFragmentInputTransform(VaryingHandle u, int components,
75 const SkMatrix& matrix) const override;
92 kUnusedPathProcVarying = -1,
94 struct PathProcVarying {
102 SkDEBUGCODE(void printUnused(const Uniform&) const;)
104 SkTArray<Uniform, true> fUniforms;
105 SkTArray<PathProcVarying, true> fPathProcVaryings;
109 typedef GrGLSLProgramDataManager INHERITED;