Chromium Code Reviews| 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 GrGLContext; |
| 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 typedef int UniformHandle; | 25 class UniformHandle { |
| 26 static const UniformHandle kInvalidUniformHandle = 0; | 26 public: |
| 27 static UniformHandle CreateFromUniformIndex(int i); | |
| 28 | |
| 29 int toUniformIndex() const { GrAssert(isValid()); return ~fHandle; } | |
|
bsalomon
2013/08/09 13:19:40
Can we make this private to GrGLUniformManager?
I
Kimmo Kinnunen
2013/08/13 09:00:33
Done.
| |
| 30 bool isValid() const { return 0 != fHandle; } | |
| 31 | |
| 32 bool operator==(const UniformHandle& other) const { return other.fHandle == fHandle; } | |
| 33 | |
| 34 UniformHandle() | |
| 35 : fHandle(0) { | |
| 36 } | |
| 37 | |
| 38 private: | |
| 39 UniformHandle(int handle) | |
| 40 : fHandle(~handle) { | |
| 41 GrAssert(isValid()); | |
| 42 } | |
| 43 | |
| 44 int fHandle; | |
| 45 }; | |
| 27 | 46 |
| 28 GrGLUniformManager(const GrGLContext& context) : fContext(context) {} | 47 GrGLUniformManager(const GrGLContext& context) : fContext(context) {} |
| 29 | 48 |
| 30 UniformHandle appendUniform(GrSLType type, int arrayCount = GrGLShaderVar::k NonArray); | 49 UniformHandle appendUniform(GrSLType type, int arrayCount = GrGLShaderVar::k NonArray); |
| 31 | 50 |
| 32 /** Functions for uploading uniform values. The varities ending in v can be used to upload to an | 51 /** Functions for uploading uniform values. The varities ending in v can be used to upload to an |
| 33 * array of uniforms. offset + arrayCount must be <= the array count of the uniform. | 52 * array of uniforms. offset + arrayCount must be <= the array count of the uniform. |
| 34 */ | 53 */ |
| 35 void setSampler(UniformHandle, GrGLint texUnit) const; | 54 void setSampler(UniformHandle, GrGLint texUnit) const; |
| 36 void set1f(UniformHandle, GrGLfloat v0) const; | 55 void set1f(UniformHandle, GrGLfloat v0) const; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 GrGLint fFSLocation; | 94 GrGLint fFSLocation; |
| 76 GrSLType fType; | 95 GrSLType fType; |
| 77 int fArrayCount; | 96 int fArrayCount; |
| 78 }; | 97 }; |
| 79 | 98 |
| 80 SkTArray<Uniform, true> fUniforms; | 99 SkTArray<Uniform, true> fUniforms; |
| 81 const GrGLContext& fContext; | 100 const GrGLContext& fContext; |
| 82 }; | 101 }; |
| 83 | 102 |
| 84 #endif | 103 #endif |
| OLD | NEW |