diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-02-27 18:33:16 +0100 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-03-23 14:50:11 -0700 |
commit | 8e5214144ec4f3a4fb40b7a7e4d8f09fd10dbb78 (patch) | |
tree | cf79b67b4af670438cbc79a524be82e88da83904 /platform | |
parent | d7227e13a7a87cf50a4c8c1f0615fc565f5a2679 (diff) | |
download | qtlocation-mapboxgl-8e5214144ec4f3a4fb40b7a7e4d8f09fd10dbb78.tar.gz |
[core] Ensure that a BackendScope exists when doing GL calls
Diffstat (limited to 'platform')
-rw-r--r-- | platform/glfw/glfw_view.cpp | 2 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 4 | ||||
-rw-r--r-- | platform/macos/src/MGLMapView.mm | 6 | ||||
-rw-r--r-- | platform/node/src/node_map.cpp | 2 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl.cpp | 4 |
5 files changed, 17 insertions, 1 deletions
diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index 39dca8080b..d73b147deb 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -10,6 +10,7 @@ #include <mbgl/util/platform.hpp> #include <mbgl/util/string.hpp> #include <mbgl/util/chrono.hpp> +#include <mbgl/map/backend_scope.hpp> #include <mbgl/map/camera.hpp> #include <mbgl/gl/state.hpp> @@ -462,6 +463,7 @@ void GLFWView::run() { const double started = glfwGetTime(); glfwMakeContextCurrent(window); + mbgl::BackendScope scope { *this, mbgl::BackendScope::ScopeType::Implicit }; updateViewBinding(); map->render(*this); diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 1ccd5ce355..6bd3092445 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -21,6 +21,7 @@ #include <mbgl/style/transition_options.hpp> #include <mbgl/style/layers/custom_layer.hpp> #include <mbgl/map/backend.hpp> +#include <mbgl/map/backend_scope.hpp> #include <mbgl/math/wrap.hpp> #include <mbgl/util/exception.hpp> #include <mbgl/util/geo.hpp> @@ -881,6 +882,9 @@ public: { if ( ! self.dormant) { + // The OpenGL implementation automatically enables the OpenGL context for us. + mbgl::BackendScope scope { *_mbglView, mbgl::BackendScope::ScopeType::Implicit }; + _mbglView->updateViewBinding(); _mbglMap->render(*_mbglView); diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 028d41ceda..ef1c0f3bc1 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -29,6 +29,7 @@ #import <mbgl/gl/extension.hpp> #import <mbgl/gl/context.hpp> #import <mbgl/map/backend.hpp> +#import <mbgl/map/backend_scope.hpp> #import <mbgl/sprite/sprite_image.hpp> #import <mbgl/storage/default_file_source.hpp> #import <mbgl/storage/network_status.hpp> @@ -780,6 +781,8 @@ public: return reinterpret_cast<mbgl::gl::glProc>(symbol); }); + // The OpenGL implementation automatically enables the OpenGL context for us. + mbgl::BackendScope scope { *_mbglView, mbgl::BackendScope::ScopeType::Implicit }; _mbglView->updateViewBinding(); _mbglMap->render(*_mbglView); @@ -2872,7 +2875,8 @@ public: fbo = mbgl::gl::value::BindFramebuffer::Get(); getContext().bindFramebuffer.setCurrentValue(fbo); getContext().viewport.setCurrentValue(getViewport()); - assert(mbgl::gl::value::Viewport::Get() == getContext().viewport.getCurrentValue()); + auto actualViewport = mbgl::gl::value::Viewport::Get(); + assert(actualViewport == getContext().viewport.getCurrentValue()); } void bind() override { diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index 881c1b2fb7..52d659b117 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -10,6 +10,7 @@ #include <mbgl/style/conversion/layer.hpp> #include <mbgl/style/conversion/filter.hpp> #include <mbgl/sprite/sprite_image.cpp> +#include <mbgl/map/backend_scope.hpp> #include <mbgl/map/query.hpp> #include <unistd.h> @@ -369,6 +370,7 @@ void NodeMap::startRender(NodeMap::RenderOptions options) { static_cast<uint32_t>(options.height * pixelRatio) }; if (!view || view->getSize() != fbSize) { view.reset(); + mbgl::BackendScope scope { backend }; view = std::make_unique<mbgl::OffscreenView>(backend.getContext(), fbSize); } diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index 3d5da10c36..384bdc8ebf 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -8,6 +8,7 @@ #include <mbgl/map/camera.hpp> #include <mbgl/map/map.hpp> #include <mbgl/gl/context.hpp> +#include <mbgl/map/backend_scope.hpp> #include <mbgl/style/conversion.hpp> #include <mbgl/style/conversion/layer.hpp> #include <mbgl/style/conversion/source.hpp> @@ -1495,6 +1496,9 @@ void QMapboxGL::render() } #endif + // The OpenGL implementation automatically enables the OpenGL context for us. + mbgl::BackendScope scope { *d_ptr, mbgl::BackendScope::ScopeType::Implicit }; + d_ptr->dirty = false; d_ptr->updateViewBinding(); d_ptr->mapObj->render(*d_ptr); |