| 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 GrGLUniformManager_DEFINED | 8 #ifndef GrGLUniformManager_DEFINED |
| 9 #define GrGLUniformManager_DEFINED | 9 #define GrGLUniformManager_DEFINED |
| 10 | 10 |
| 11 #include "gl/GrGLShaderVar.h" | 11 #include "gl/GrGLShaderVar.h" |
| 12 #include "gl/GrGLSL.h" | 12 #include "gl/GrGLSL.h" |
| 13 #include "GrAllocator.h" | 13 #include "GrAllocator.h" |
| 14 | 14 |
| 15 #include "SkTArray.h" | 15 #include "SkTArray.h" |
| 16 | 16 |
| 17 class GrGLContext; | 17 class GrGpuGL; |
| 18 class SkMatrix; | 18 class SkMatrix; |
| 19 | 19 |
| 20 /** Manages a program's uniforms. | 20 /** Manages a program's uniforms. |
| 21 */ | 21 */ |
| 22 class GrGLUniformManager { | 22 class GrGLUniformManager { |
| 23 public: | 23 public: |
| 24 // Opaque handle to a uniform | 24 // Opaque handle to a uniform |
| 25 class UniformHandle { | 25 class UniformHandle { |
| 26 public: | 26 public: |
| 27 static UniformHandle CreateFromUniformIndex(int i); | 27 static UniformHandle CreateFromUniformIndex(int i); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 39 : fValue(~value) { | 39 : fValue(~value) { |
| 40 SkASSERT(isValid()); | 40 SkASSERT(isValid()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 int toUniformIndex() const { SkASSERT(isValid()); return ~fValue; } | 43 int toUniformIndex() const { SkASSERT(isValid()); return ~fValue; } |
| 44 | 44 |
| 45 int fValue; | 45 int fValue; |
| 46 friend class GrGLUniformManager; // For accessing toUniformIndex(). | 46 friend class GrGLUniformManager; // For accessing toUniformIndex(). |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 GrGLUniformManager(const GrGLContext& context) : fContext(context) {} | 49 GrGLUniformManager(GrGpuGL* gpu) : fGpu(gpu) {} |
| 50 | 50 |
| 51 UniformHandle appendUniform(GrSLType type, int arrayCount = GrGLShaderVar::k
NonArray); | 51 UniformHandle appendUniform(GrSLType type, int arrayCount = GrGLShaderVar::k
NonArray); |
| 52 | 52 |
| 53 /** Functions for uploading uniform values. The varities ending in v can be
used to upload to an | 53 /** Functions for uploading uniform values. The varities ending in v can be
used to upload to an |
| 54 * array of uniforms. offset + arrayCount must be <= the array count of the
uniform. | 54 * array of uniforms. offset + arrayCount must be <= the array count of the
uniform. |
| 55 */ | 55 */ |
| 56 void setSampler(UniformHandle, GrGLint texUnit) const; | 56 void setSampler(UniformHandle, GrGLint texUnit) const; |
| 57 void set1f(UniformHandle, GrGLfloat v0) const; | 57 void set1f(UniformHandle, GrGLfloat v0) const; |
| 58 void set1fv(UniformHandle, int offset, int arrayCount, const GrGLfloat v[])
const; | 58 void set1fv(UniformHandle, int offset, int arrayCount, const GrGLfloat v[])
const; |
| 59 void set2f(UniformHandle, GrGLfloat, GrGLfloat) const; | 59 void set2f(UniformHandle, GrGLfloat, GrGLfloat) const; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 struct Uniform { | 99 struct Uniform { |
| 100 GrGLint fVSLocation; | 100 GrGLint fVSLocation; |
| 101 GrGLint fFSLocation; | 101 GrGLint fFSLocation; |
| 102 GrSLType fType; | 102 GrSLType fType; |
| 103 int fArrayCount; | 103 int fArrayCount; |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 SkTArray<Uniform, true> fUniforms; | 106 SkTArray<Uniform, true> fUniforms; |
| 107 const GrGLContext& fContext; | 107 GrGpuGL* fGpu; |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 #endif | 110 #endif |
| OLD | NEW |