diff options
Diffstat (limited to 'src/mbgl/gl/state.hpp')
-rw-r--r-- | src/mbgl/gl/state.hpp | 36 |
1 files changed, 6 insertions, 30 deletions
diff --git a/src/mbgl/gl/state.hpp b/src/mbgl/gl/state.hpp index dbb005e77d..efe869e5b9 100644 --- a/src/mbgl/gl/state.hpp +++ b/src/mbgl/gl/state.hpp @@ -3,20 +3,6 @@ namespace mbgl { namespace gl { -// Helper struct that allows obtaining the default value of a Value class -template <typename T, typename = void> -struct DefaultValue { - static typename T::Type Get() { - return T::Get(); - } -}; -template <typename T> -struct DefaultValue<T, decltype((void)T::Default, void())> { - static typename T::Type Get() { - return T::Default; - } -}; - // Wraps a piece of OpenGL state and remember its value to avoid redundant state calls. // Wrapped types need to implement to the Value class interface: // @@ -26,17 +12,12 @@ struct DefaultValue<T, decltype((void)T::Default, void())> { // static void Set(const Type& value); // static Type Get(); // }; -// -// The Get() function is optional, but if it is omitted, you must provide a Default. -// Default is also optional, but if it is omitted, you must provide a Get() function. -// If both are present, DefaultValue<T>::Get() will use the Default member. template <typename T> class State { public: void operator=(const typename T::Type& value) { if (*this != value) { - dirty = false; - currentValue = value; + setCurrentValue(value); T::Set(currentValue); } } @@ -49,9 +30,9 @@ public: return dirty || currentValue != value; } - // Explicitly resets the piece of OpenGL state to its default value. - void reset() { - *this = defaultValue; + void setCurrentValue(const typename T::Type& value) { + dirty = false; + currentValue = value; } // Mark the state as dirty. This means that the next time we are assigning a value to this @@ -68,14 +49,9 @@ public: return dirty; } - void setDefaultValue(const typename T::Type& value) { - defaultValue = value; - } - private: - typename T::Type defaultValue = DefaultValue<T>::Get(); - typename T::Type currentValue = defaultValue; - bool dirty = false; + typename T::Type currentValue = T::Default; + bool dirty = true; }; // Helper struct that stores the current state and restores it upon destruction. You should not use |