From 8f9e4ccbae96d73bde252cdbf7eaa8a269fd9999 Mon Sep 17 00:00:00 2001 From: skyjake Date: Tue, 23 Apr 2013 15:45:00 +0300 Subject: [PATCH] Refactor|libgui: Streamlined GLState's interface somewhat --- doomsday/libgui/include/de/gui/glstate.h | 9 +++++++-- doomsday/libgui/src/glstate.cpp | 17 ++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/doomsday/libgui/include/de/gui/glstate.h b/doomsday/libgui/include/de/gui/glstate.h index 0c56e8027a..3b23c759ed 100644 --- a/doomsday/libgui/include/de/gui/glstate.h +++ b/doomsday/libgui/include/de/gui/glstate.h @@ -119,6 +119,11 @@ class LIBGUI_PUBLIC GLState void apply() const; public: + /** + * Returns the current topmost state on the GL state stack. + */ + static GLState &top(); + /** * Pushes a copy of the current state onto the current thread's GL state * stack. @@ -137,14 +142,14 @@ class LIBGUI_PUBLIC GLState * * @param state State to push. Ownership taken. */ - static void pushState(GLState *state); + static void push(GLState *state); /** * Removes the topmost state off of the current thread's stack. * * @return State instance. Ownership given to caller. */ - static GLState *takeState(); + static GLState *take(); private: DENG2_PRIVATE(d) diff --git a/doomsday/libgui/src/glstate.cpp b/doomsday/libgui/src/glstate.cpp index 9f79bc3d1e..67aae951f1 100644 --- a/doomsday/libgui/src/glstate.cpp +++ b/doomsday/libgui/src/glstate.cpp @@ -315,27 +315,30 @@ void GLState::apply() const } } -GLState &GLState::push() +GLState &GLState::top() { DENG2_ASSERT(!stack.isEmpty()); + return *stack.last(); +} +GLState &GLState::push() +{ // Duplicate the topmost state. - GLState *top = new GLState(*stack.last()); - pushState(top); - return *top; + push(new GLState(top())); + return top(); } void GLState::pop() { - delete takeState(); + delete take(); } -void GLState::pushState(GLState *state) +void GLState::push(GLState *state) { stack.append(state); } -GLState *GLState::takeState() +GLState *GLState::take() { DENG2_ASSERT(stack.size() > 1); return stack.takeLast();