OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrGLProgramDataManager_DEFINED | 8 #ifndef GrGLProgramDataManager_DEFINED |
9 #define GrGLProgramDataManager_DEFINED | 9 #define GrGLProgramDataManager_DEFINED |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 * application code. | 26 * application code. |
27 */ | 27 */ |
28 class GrGLProgramDataManager : public GrGLSLProgramDataManager { | 28 class GrGLProgramDataManager : public GrGLSLProgramDataManager { |
29 public: | 29 public: |
30 struct UniformInfo { | 30 struct UniformInfo { |
31 GrGLSLShaderVar fVariable; | 31 GrGLSLShaderVar fVariable; |
32 uint32_t fVisibility; | 32 uint32_t fVisibility; |
33 GrGLint fLocation; | 33 GrGLint fLocation; |
34 }; | 34 }; |
35 | 35 |
36 struct SeparableVaryingInfo { | 36 struct VaryingInfo { |
37 GrGLSLShaderVar fVariable; | 37 GrGLSLShaderVar fVariable; |
38 GrGLint fLocation; | 38 GrGLint fLocation; |
39 }; | 39 }; |
40 | 40 |
41 // This uses an allocator rather than array so that the GrGLSLShaderVars don
't move in memory | 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 | 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. | 43 // name strings. Otherwise, we'd have to hand out copies. |
44 typedef GrTAllocator<UniformInfo> UniformInfoArray; | 44 typedef GrTAllocator<UniformInfo> UniformInfoArray; |
45 typedef GrTAllocator<SeparableVaryingInfo> SeparableVaryingInfoArray; | 45 typedef GrTAllocator<VaryingInfo> VaryingInfoArray; |
46 | 46 |
47 GrGLProgramDataManager(GrGLGpu*, GrGLuint programID, const UniformInfoArray&
, | 47 GrGLProgramDataManager(GrGLGpu*, GrGLuint programID, const UniformInfoArray&
, |
48 const SeparableVaryingInfoArray&); | 48 const VaryingInfoArray&); |
49 | 49 |
50 /** Functions for uploading uniform values. The varities ending in v can be
used to upload to an | 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. | 51 * array of uniforms. arrayCount must be <= the array count of the uniform. |
52 */ | 52 */ |
53 void setSampler(UniformHandle, int texUnit) const; | 53 void setSampler(UniformHandle, int texUnit) const; |
54 | 54 |
55 void set1f(UniformHandle, float v0) const override; | 55 void set1f(UniformHandle, float v0) const override; |
56 void set1fv(UniformHandle, int arrayCount, const float v[]) const override; | 56 void set1fv(UniformHandle, int arrayCount, const float v[]) const override; |
57 void set2f(UniformHandle, float, float) const override; | 57 void set2f(UniformHandle, float, float) const override; |
58 void set2fv(UniformHandle, int arrayCount, const float v[]) const override; | 58 void set2fv(UniformHandle, int arrayCount, const float v[]) const override; |
59 void set3f(UniformHandle, float, float, float) const override; | 59 void set3f(UniformHandle, float, float, float) const override; |
60 void set3fv(UniformHandle, int arrayCount, const float v[]) const override; | 60 void set3fv(UniformHandle, int arrayCount, const float v[]) const override; |
61 void set4f(UniformHandle, float, float, float, float) const override; | 61 void set4f(UniformHandle, float, float, float, float) const override; |
62 void set4fv(UniformHandle, int arrayCount, const float v[]) 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 la
tter three upload | 63 // matrices are column-major, the first three upload a single matrix, the la
tter three upload |
64 // arrayCount matrices into a uniform array. | 64 // arrayCount matrices into a uniform array. |
65 void setMatrix3f(UniformHandle, const float matrix[]) const override; | 65 void setMatrix3f(UniformHandle, const float matrix[]) const override; |
66 void setMatrix4f(UniformHandle, const float matrix[]) const override; | 66 void setMatrix4f(UniformHandle, const float matrix[]) const override; |
67 void setMatrix3fv(UniformHandle, int arrayCount, const float matrices[]) con
st override; | 67 void setMatrix3fv(UniformHandle, int arrayCount, const float matrices[]) con
st override; |
68 void setMatrix4fv(UniformHandle, int arrayCount, const float matrices[]) con
st override; | 68 void setMatrix4fv(UniformHandle, int arrayCount, const float matrices[]) con
st override; |
69 | 69 |
70 // convenience method for uploading a SkMatrix to a 3x3 matrix uniform | 70 // convenience method for uploading a SkMatrix to a 3x3 matrix uniform |
71 void setSkMatrix(UniformHandle, const SkMatrix&) const override; | 71 void setSkMatrix(UniformHandle, const SkMatrix&) const override; |
72 | 72 |
73 // for nvpr only | 73 // for nvpr only |
74 void setPathFragmentInputTransform(SeparableVaryingHandle u, int components, | 74 void setPathFragmentInputTransform(VaryingHandle u, int components, |
75 const SkMatrix& matrix) const override; | 75 const SkMatrix& matrix) const override; |
76 | 76 |
77 private: | 77 private: |
78 enum { | 78 enum { |
79 kUnusedUniform = -1, | 79 kUnusedUniform = -1, |
80 }; | 80 }; |
81 | 81 |
82 struct Uniform { | 82 struct Uniform { |
83 GrGLint fVSLocation; | 83 GrGLint fVSLocation; |
84 GrGLint fFSLocation; | 84 GrGLint fFSLocation; |
85 SkDEBUGCODE( | 85 SkDEBUGCODE( |
86 GrSLType fType; | 86 GrSLType fType; |
87 int fArrayCount; | 87 int fArrayCount; |
88 ); | 88 ); |
89 }; | 89 }; |
90 | 90 |
91 enum { | 91 enum { |
92 kUnusedSeparableVarying = -1, | 92 kUnusedPathProcVarying = -1, |
93 }; | 93 }; |
94 struct SeparableVarying { | 94 struct PathProcVarying { |
95 GrGLint fLocation; | 95 GrGLint fLocation; |
96 SkDEBUGCODE( | 96 SkDEBUGCODE( |
97 GrSLType fType; | 97 GrSLType fType; |
98 int fArrayCount; | 98 int fArrayCount; |
99 ); | 99 ); |
100 }; | 100 }; |
101 | 101 |
102 SkDEBUGCODE(void printUnused(const Uniform&) const;) | 102 SkDEBUGCODE(void printUnused(const Uniform&) const;) |
103 | 103 |
104 SkTArray<Uniform, true> fUniforms; | 104 SkTArray<Uniform, true> fUniforms; |
105 SkTArray<SeparableVarying, true> fSeparableVaryings; | 105 SkTArray<PathProcVarying, true> fPathProcVaryings; |
106 GrGLGpu* fGpu; | 106 GrGLGpu* fGpu; |
107 GrGLuint fProgramID; | 107 GrGLuint fProgramID; |
108 | 108 |
109 typedef GrGLSLProgramDataManager INHERITED; | 109 typedef GrGLSLProgramDataManager INHERITED; |
110 }; | 110 }; |
111 | 111 |
112 #endif | 112 #endif |
OLD | NEW |