Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Unified Diff: src/gpu/gl/GrGLUniformManager.h

Issue 22340010: Refactor GrGLUniformManager::UniformHandle to initialize itself by default (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: description Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLUniformHandle.h ('k') | src/gpu/gl/GrGLUniformManager.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « src/gpu/gl/GrGLUniformHandle.h ('k') | src/gpu/gl/GrGLUniformManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698