diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-03-22 10:36:48 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2017-03-22 14:15:50 +0100 |
commit | d20327844cac88b6bf42b201eac35e816a189a8a (patch) | |
tree | b4bda78efe5dc150cdaba301326b0a9cc20abc04 /platform/qt/src | |
parent | e488ca702e8f822ba6297a2f3c933ee22ca6ce42 (diff) | |
download | qtlocation-mapboxgl-d20327844cac88b6bf42b201eac35e816a189a8a.tar.gz |
[qt] Add setFramebufferObject() for correct FBO binding restoration
Diffstat (limited to 'platform/qt/src')
-rw-r--r-- | platform/qt/src/qmapboxgl.cpp | 30 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl_p.hpp | 12 |
2 files changed, 31 insertions, 11 deletions
diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index ab727a62e7..b1c0a11ee1 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -5,10 +5,9 @@ #include "qt_geojson.hpp" #include <mbgl/annotation/annotation.hpp> -#include <mbgl/gl/gl.hpp> -#include <mbgl/gl/context.hpp> #include <mbgl/map/camera.hpp> #include <mbgl/map/map.hpp> +#include <mbgl/gl/context.hpp> #include <mbgl/style/conversion.hpp> #include <mbgl/style/conversion/layer.hpp> #include <mbgl/style/conversion/source.hpp> @@ -31,6 +30,7 @@ #include <QOpenGLContext> #else #include <QCoreApplication> +#include <QGLContext> #endif #include <QDebug> @@ -1084,6 +1084,14 @@ void QMapboxGL::resize(const QSize& size, const QSize& framebufferSize) } /*! + If Mapbox GL needs to rebind the default framebuffer, it will use the + ID supplied here. +*/ +void QMapboxGL::setFramebufferObject(quint32 fbo) { + d_ptr->fbObject = fbo; +} + +/*! Adds an \a icon to the annotation icon pool. This can be later used by the annotation functions to shown any drawing on the map by referencing its \a name. @@ -1484,6 +1492,7 @@ void QMapboxGL::render() #endif d_ptr->dirty = false; + d_ptr->updateViewBinding(); d_ptr->mapObj->render(*d_ptr); } @@ -1554,11 +1563,20 @@ QMapboxGLPrivate::~QMapboxGLPrivate() { } +mbgl::Size QMapboxGLPrivate::framebufferSize() const { + return { static_cast<uint32_t>(fbSize.width()), static_cast<uint32_t>(fbSize.height()) }; +} + +void QMapboxGLPrivate::updateViewBinding() { + getContext().bindFramebuffer.setCurrentValue(fbObject); + assert(mbgl::gl::value::BindFramebuffer::Get() == getContext().bindFramebuffer.getCurrentValue()); + getContext().viewport.setCurrentValue({ 0, 0, framebufferSize() }); + assert(mbgl::gl::value::Viewport::Get() == getContext().viewport.getCurrentValue()); +} + void QMapboxGLPrivate::bind() { - getContext().bindFramebuffer = 0; - getContext().viewport = { - 0, 0, { static_cast<uint32_t>(fbSize.width()), static_cast<uint32_t>(fbSize.height()) } - }; + getContext().bindFramebuffer = fbObject; + getContext().viewport = { 0, 0, framebufferSize() }; } void QMapboxGLPrivate::invalidate() diff --git a/platform/qt/src/qmapboxgl_p.hpp b/platform/qt/src/qmapboxgl_p.hpp index 2d8bfaaf53..4112542431 100644 --- a/platform/qt/src/qmapboxgl_p.hpp +++ b/platform/qt/src/qmapboxgl_p.hpp @@ -20,17 +20,18 @@ public: explicit QMapboxGLPrivate(QMapboxGL *, const QMapboxGLSettings &, const QSize &size, qreal pixelRatio); virtual ~QMapboxGLPrivate(); + mbgl::Size framebufferSize() const; + void updateViewBinding(); + // mbgl::View implementation. - float getPixelRatio() const; void bind() final; - std::array<uint16_t, 2> getSize() const; - std::array<uint16_t, 2> getFramebufferSize() const; + // mbgl::Backend implementation. + void invalidate() final; void activate() final {} void deactivate() final {} - void invalidate() final; - // mbgl::Backend (mbgl::MapObserver) implementation. + // mbgl::MapObserver implementation. void onCameraWillChange(mbgl::MapObserver::CameraChangeMode) final; void onCameraIsChanging() final; void onCameraDidChange(mbgl::MapObserver::CameraChangeMode) final; @@ -47,6 +48,7 @@ public: mbgl::EdgeInsets margins; QSize size { 0, 0 }; QSize fbSize { 0, 0 }; + quint32 fbObject = 0; QMapboxGL *q_ptr { nullptr }; |