Browse Source

GL: drop another std::pair occurence from the internals.

Hm, and here I used the "capability" of std::pair that allowed it to
store references. I don't even want to know what all was involved to
support that, Containers::Reference is much easier to reason about.
pull/499/head
Vladimír Vondruš 3 years ago
parent
commit
2620eca9ae
  1. 7
      src/Magnum/GL/Context.cpp
  2. 3
      src/Magnum/GL/Implementation/State.cpp
  3. 3
      src/Magnum/GL/Implementation/State.h

7
src/Magnum/GL/Context.cpp

@ -28,6 +28,7 @@
#include <algorithm> /* std::lower_bound() */ #include <algorithm> /* std::lower_bound() */
#include <Corrade/Containers/EnumSet.hpp> #include <Corrade/Containers/EnumSet.hpp>
#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/Reference.h>
#include <Corrade/Containers/StringIterable.h> #include <Corrade/Containers/StringIterable.h>
#include <Corrade/Utility/Arguments.h> #include <Corrade/Utility/Arguments.h>
#include <Corrade/Utility/Debug.h> #include <Corrade/Utility/Debug.h>
@ -985,9 +986,9 @@ bool Context::tryCreate(const Configuration& configuration) {
Debug{output} << " " << extension.string(); Debug{output} << " " << extension.string();
} }
std::pair<Containers::ArrayTuple, Implementation::State&> state = Implementation::State::allocate(*this, output); Containers::Pair<Containers::ArrayTuple, Containers::Reference<Implementation::State>> state = Implementation::State::allocate(*this, output);
_stateData = std::move(state.first); _stateData = std::move(state.first());
_state = &state.second; _state = &*state.second();
/* Print a list of used workarounds */ /* Print a list of used workarounds */
if(!_driverWorkarounds.isEmpty()) { if(!_driverWorkarounds.isEmpty()) {

3
src/Magnum/GL/Implementation/State.cpp

@ -27,6 +27,7 @@
#include <Corrade/Containers/ArrayTuple.h> #include <Corrade/Containers/ArrayTuple.h>
#include <Corrade/Containers/Pair.h> #include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/Reference.h>
#include <Corrade/Utility/Assert.h> #include <Corrade/Utility/Assert.h>
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"
@ -49,7 +50,7 @@
namespace Magnum { namespace GL { namespace Implementation { namespace Magnum { namespace GL { namespace Implementation {
std::pair<Containers::ArrayTuple, State&> State::allocate(Context& context, std::ostream* const out) { Containers::Pair<Containers::ArrayTuple, Containers::Reference<State>> State::allocate(Context& context, std::ostream* const out) {
/* TextureState needs to track state per texture / image binding, fetch /* TextureState needs to track state per texture / image binding, fetch
how many of them is there and allocate here as well so we don't need to how many of them is there and allocate here as well so we don't need to
do another nested allocation */ do another nested allocation */

3
src/Magnum/GL/Implementation/State.h

@ -26,7 +26,6 @@
*/ */
#include <iosfwd> #include <iosfwd>
#include <utility>
#include <Corrade/Containers/Containers.h> #include <Corrade/Containers/Containers.h>
#include "Magnum/Magnum.h" #include "Magnum/Magnum.h"
@ -53,7 +52,7 @@ struct TransformFeedbackState;
struct State { struct State {
/* Initializes context-based functionality together with all nested classes /* Initializes context-based functionality together with all nested classes
in a single allocation */ in a single allocation */
static std::pair<Containers::ArrayTuple, State&> allocate(Context& context, std::ostream* out); static Containers::Pair<Containers::ArrayTuple, Containers::Reference<State>> allocate(Context& context, std::ostream* out);
enum: GLuint { DisengagedBinding = ~0u }; enum: GLuint { DisengagedBinding = ~0u };

Loading…
Cancel
Save