Index: src/gpu/gl/GrGLUniformManager.h |
diff --git a/src/gpu/gl/GrGLUniformManager.h b/src/gpu/gl/GrGLUniformManager.h |
index ee693a6a5bba7d8554416a07f5b43b9e9c3504a7..863d66facdcec40c9d6fa054c6403dc8f93696ab 100644 |
--- a/src/gpu/gl/GrGLUniformManager.h |
+++ b/src/gpu/gl/GrGLUniformManager.h |
@@ -22,8 +22,29 @@ class SkMatrix; |
class GrGLUniformManager { |
public: |
// Opaque handle to a uniform |
- typedef int UniformHandle; |
- static const UniformHandle kInvalidUniformHandle = 0; |
+ class UniformHandle { |
+ public: |
+ static UniformHandle CreateFromUniformIndex(int i); |
+ |
+ bool isValid() const { return 0 != fValue; } |
+ |
+ bool operator==(const UniformHandle& other) const { return other.fValue == fValue; } |
+ |
+ UniformHandle() |
+ : fValue(0) { |
+ } |
+ |
+ private: |
+ UniformHandle(int value) |
+ : fValue(~value) { |
+ GrAssert(isValid()); |
+ } |
+ |
+ int toUniformIndex() const { GrAssert(isValid()); return ~fValue; } |
+ |
+ int fValue; |
+ friend class GrGLUniformManager; // For accessing toUniformIndex(). |
+ }; |
GrGLUniformManager(const GrGLContext& context) : fContext(context) {} |
@@ -65,6 +86,11 @@ public: |
*/ |
void getUniformLocations(GrGLuint programID, const BuilderUniformArray& uniforms); |
+ /** |
+ * Called by the GrGLShaderBuilder to access the array by the handle (index). |
+ */ |
+ const BuilderUniform& getBuilderUniform(const BuilderUniformArray&, GrGLUniformManager::UniformHandle) const; |
+ |
private: |
enum { |
kUnusedUniform = -1, |