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

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: 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..a9cf3ad702ea1b55e2931a695a2af19378652d65 100644
--- a/src/gpu/gl/GrGLUniformManager.h
+++ b/src/gpu/gl/GrGLUniformManager.h
@@ -22,8 +22,27 @@ 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);
+
+ 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.
+ bool isValid() const { return 0 != fHandle; }
+
+ bool operator==(const UniformHandle& other) const { return other.fHandle == fHandle; }
+
+ UniformHandle()
+ : fHandle(0) {
+ }
+
+ private:
+ UniformHandle(int handle)
+ : fHandle(~handle) {
+ GrAssert(isValid());
+ }
+
+ int fHandle;
+ };
GrGLUniformManager(const GrGLContext& context) : fContext(context) {}
« 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