| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 typedef ShaderResourceHandle UniformHandle; | 48 typedef ShaderResourceHandle UniformHandle; |
| 49 | 49 |
| 50 struct UniformInfo { | 50 struct UniformInfo { |
| 51 GrGLShaderVar fVariable; | 51 GrGLShaderVar fVariable; |
| 52 uint32_t fVisibility; | 52 uint32_t fVisibility; |
| 53 GrGLint fLocation; | 53 GrGLint fLocation; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 struct SeparableVaryingInfo { |
| 57 GrGLShaderVar fVariable; |
| 58 GrGLint fLocation; |
| 59 }; |
| 60 |
| 56 // This uses an allocator rather than array so that the GrGLShaderVars don't
move in memory | 61 // This uses an allocator rather than array so that the GrGLShaderVars don't
move in memory |
| 57 // after they are inserted. Users of GrGLShaderBuilder get refs to the vars
and ptrs to their | 62 // after they are inserted. Users of GrGLShaderBuilder get refs to the vars
and ptrs to their |
| 58 // name strings. Otherwise, we'd have to hand out copies. | 63 // name strings. Otherwise, we'd have to hand out copies. |
| 59 typedef GrTAllocator<UniformInfo> UniformInfoArray; | 64 typedef GrTAllocator<UniformInfo> UniformInfoArray; |
| 65 typedef GrTAllocator<SeparableVaryingInfo> SeparableVaryingInfoArray; |
| 60 | 66 |
| 61 GrGLProgramDataManager(GrGLGpu*, const UniformInfoArray&); | 67 GrGLProgramDataManager(GrGLGpu*, GrGLuint programID, const UniformInfoArray&
, |
| 68 const SeparableVaryingInfoArray&); |
| 62 | 69 |
| 63 /** Functions for uploading uniform values. The varities ending in v can be
used to upload to an | 70 /** Functions for uploading uniform values. The varities ending in v can be
used to upload to an |
| 64 * array of uniforms. arrayCount must be <= the array count of the uniform. | 71 * array of uniforms. arrayCount must be <= the array count of the uniform. |
| 65 */ | 72 */ |
| 66 void setSampler(UniformHandle, GrGLint texUnit) const; | 73 void setSampler(UniformHandle, GrGLint texUnit) const; |
| 67 void set1f(UniformHandle, GrGLfloat v0) const; | 74 void set1f(UniformHandle, GrGLfloat v0) const; |
| 68 void set1fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; | 75 void set1fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; |
| 69 void set2f(UniformHandle, GrGLfloat, GrGLfloat) const; | 76 void set2f(UniformHandle, GrGLfloat, GrGLfloat) const; |
| 70 void set2fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; | 77 void set2fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; |
| 71 void set3f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat) const; | 78 void set3f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat) const; |
| 72 void set3fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; | 79 void set3fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; |
| 73 void set4f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat, GrGLfloat) const; | 80 void set4f(UniformHandle, GrGLfloat, GrGLfloat, GrGLfloat, GrGLfloat) const; |
| 74 void set4fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; | 81 void set4fv(UniformHandle, int arrayCount, const GrGLfloat v[]) const; |
| 75 // matrices are column-major, the first three upload a single matrix, the la
tter three upload | 82 // matrices are column-major, the first three upload a single matrix, the la
tter three upload |
| 76 // arrayCount matrices into a uniform array. | 83 // arrayCount matrices into a uniform array. |
| 77 void setMatrix3f(UniformHandle, const GrGLfloat matrix[]) const; | 84 void setMatrix3f(UniformHandle, const GrGLfloat matrix[]) const; |
| 78 void setMatrix4f(UniformHandle, const GrGLfloat matrix[]) const; | 85 void setMatrix4f(UniformHandle, const GrGLfloat matrix[]) const; |
| 79 void setMatrix3fv(UniformHandle, int arrayCount, const GrGLfloat matrices[])
const; | 86 void setMatrix3fv(UniformHandle, int arrayCount, const GrGLfloat matrices[])
const; |
| 80 void setMatrix4fv(UniformHandle, int arrayCount, const GrGLfloat matrices[])
const; | 87 void setMatrix4fv(UniformHandle, int arrayCount, const GrGLfloat matrices[])
const; |
| 81 | 88 |
| 82 // convenience method for uploading a SkMatrix to a 3x3 matrix uniform | 89 // convenience method for uploading a SkMatrix to a 3x3 matrix uniform |
| 83 void setSkMatrix(UniformHandle, const SkMatrix&) const; | 90 void setSkMatrix(UniformHandle, const SkMatrix&) const; |
| 84 | 91 |
| 92 // for nvpr only |
| 93 typedef GrGLProgramDataManager::ShaderResourceHandle SeparableVaryingHandle; |
| 94 void setPathFragmentInputTransform(SeparableVaryingHandle u, int components, |
| 95 const SkMatrix& matrix) const; |
| 96 |
| 85 private: | 97 private: |
| 86 enum { | 98 enum { |
| 87 kUnusedUniform = -1, | 99 kUnusedUniform = -1, |
| 88 }; | 100 }; |
| 89 | 101 |
| 90 struct Uniform { | 102 struct Uniform { |
| 91 GrGLint fVSLocation; | 103 GrGLint fVSLocation; |
| 92 GrGLint fFSLocation; | 104 GrGLint fFSLocation; |
| 93 SkDEBUGCODE( | 105 SkDEBUGCODE( |
| 94 GrSLType fType; | 106 GrSLType fType; |
| 95 int fArrayCount; | 107 int fArrayCount; |
| 96 ); | 108 ); |
| 97 }; | 109 }; |
| 98 | 110 |
| 111 enum { |
| 112 kUnusedSeparableVarying = -1, |
| 113 }; |
| 114 struct SeparableVarying { |
| 115 GrGLint fLocation; |
| 116 SkDEBUGCODE( |
| 117 GrSLType fType; |
| 118 int fArrayCount; |
| 119 ); |
| 120 }; |
| 121 |
| 99 SkDEBUGCODE(void printUnused(const Uniform&) const;) | 122 SkDEBUGCODE(void printUnused(const Uniform&) const;) |
| 100 | 123 |
| 101 SkTArray<Uniform, true> fUniforms; | 124 SkTArray<Uniform, true> fUniforms; |
| 125 SkTArray<SeparableVarying, true> fSeparableVaryings; |
| 102 GrGLGpu* fGpu; | 126 GrGLGpu* fGpu; |
| 127 GrGLuint fProgramID; |
| 103 | 128 |
| 104 typedef SkNoncopyable INHERITED; | 129 typedef SkNoncopyable INHERITED; |
| 105 }; | 130 }; |
| 106 | 131 |
| 107 #endif | 132 #endif |
| OLD | NEW |