summaryrefslogtreecommitdiff
path: root/platform/qt/src
diff options
context:
space:
mode:
Diffstat (limited to 'platform/qt/src')
-rw-r--r--platform/qt/src/qmapboxgl.cpp37
-rw-r--r--platform/qt/src/qmapboxgl_map_renderer.cpp5
-rw-r--r--platform/qt/src/qmapboxgl_map_renderer.hpp4
-rw-r--r--platform/qt/src/qmapboxgl_renderer_backend.cpp13
-rw-r--r--platform/qt/src/qmapboxgl_renderer_backend.hpp5
5 files changed, 36 insertions, 28 deletions
diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp
index 89904ddf88..df5673e35b 100644
--- a/platform/qt/src/qmapboxgl.cpp
+++ b/platform/qt/src/qmapboxgl.cpp
@@ -1047,37 +1047,20 @@ void QMapboxGL::rotateBy(const QPointF &first, const QPointF &second)
}
/*!
- Resize the map to \a size and scale to fit at \a framebufferSize. For
- high DPI screens, the size will be smaller than the \a framebufferSize.
-
- This fallowing example will double the pixel density of the map for
- a given \c size:
-
- \code
- map->resize(size / 2, size);
- \endcode
+ Resize the map to \a size_ and scale to fit at the framebuffer. For
+ high DPI screens, the size will be smaller than the framebuffer.
*/
-void QMapboxGL::resize(const QSize& size_, const QSize& framebufferSize)
+void QMapboxGL::resize(const QSize& size_)
{
auto size = sanitizedSize(size_);
if (d_ptr->mapObj->getSize() == size)
return;
- d_ptr->mapRenderer->updateFramebufferSize(sanitizedSize(framebufferSize));
d_ptr->mapObj->setSize(size);
}
/*!
- If Mapbox GL needs to rebind the default \a fbo, it will use the
- ID supplied here.
-*/
-void QMapboxGL::setFramebufferObject(quint32)
-{
- // FIXME: No-op, implicit.
-}
-
-/*!
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.
@@ -1513,6 +1496,20 @@ void QMapboxGL::render()
}
/*!
+ If Mapbox GL needs to rebind the default \a fbo, it will use the
+ ID supplied here. \a size is the size of the framebuffer, which
+ on high DPI screens is usually bigger than the map size.
+*/
+void QMapboxGL::setFramebufferObject(quint32 fbo, const QSize& size)
+{
+ if (!d_ptr->mapRenderer) {
+ createRenderer();
+ }
+
+ d_ptr->mapRenderer->updateFramebuffer(fbo, sanitizedSize(size));
+}
+
+/*!
Informs the map that the network connection has been established, causing
all network requests that previously timed out to be retried immediately.
*/
diff --git a/platform/qt/src/qmapboxgl_map_renderer.cpp b/platform/qt/src/qmapboxgl_map_renderer.cpp
index 81293d7da1..f9120379cb 100644
--- a/platform/qt/src/qmapboxgl_map_renderer.cpp
+++ b/platform/qt/src/qmapboxgl_map_renderer.cpp
@@ -25,10 +25,9 @@ void QMapboxGLMapRenderer::updateParameters(std::shared_ptr<mbgl::UpdateParamete
m_updateParameters = std::move(newParameters);
}
-void QMapboxGLMapRenderer::updateFramebufferSize(const mbgl::Size &size)
+void QMapboxGLMapRenderer::updateFramebuffer(quint32 fbo, const mbgl::Size &size)
{
- std::lock_guard<std::mutex> lock(m_updateMutex);
- m_backend.setFramebufferSize(size);
+ m_backend.updateFramebuffer(fbo, size);
}
void QMapboxGLMapRenderer::render()
diff --git a/platform/qt/src/qmapboxgl_map_renderer.hpp b/platform/qt/src/qmapboxgl_map_renderer.hpp
index c15840a85d..f7523604c7 100644
--- a/platform/qt/src/qmapboxgl_map_renderer.hpp
+++ b/platform/qt/src/qmapboxgl_map_renderer.hpp
@@ -9,6 +9,8 @@
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/util/shared_thread_pool.hpp>
+#include <QtGlobal>
+
#include <memory>
#include <mutex>
#include <queue>
@@ -31,11 +33,11 @@ public:
void schedule(std::weak_ptr<mbgl::Mailbox> scheduled) final;
void render();
+ void updateFramebuffer(quint32 fbo, const mbgl::Size &size);
void setObserver(std::shared_ptr<mbgl::RendererObserver>);
// Thread-safe, called by the Frontend
void updateParameters(std::shared_ptr<mbgl::UpdateParameters>);
- void updateFramebufferSize(const mbgl::Size &size);
private:
Q_DISABLE_COPY(QMapboxGLMapRenderer)
diff --git a/platform/qt/src/qmapboxgl_renderer_backend.cpp b/platform/qt/src/qmapboxgl_renderer_backend.cpp
index 6cc7de53fe..917741f5ce 100644
--- a/platform/qt/src/qmapboxgl_renderer_backend.cpp
+++ b/platform/qt/src/qmapboxgl_renderer_backend.cpp
@@ -11,7 +11,15 @@
void QMapboxGLRendererBackend::updateAssumedState()
{
assumeFramebufferBinding(ImplicitFramebufferBinding);
- assumeViewport(0, 0, { 800, 600 });
+ assumeViewport(0, 0, m_size);
+}
+
+void QMapboxGLRendererBackend::bind()
+{
+ assert(mbgl::BackendScope::exists());
+
+ setFramebufferBinding(m_fbo);
+ setViewport(0, 0, m_size);
}
mbgl::Size QMapboxGLRendererBackend::getFramebufferSize() const
@@ -19,8 +27,9 @@ mbgl::Size QMapboxGLRendererBackend::getFramebufferSize() const
return m_size;
}
-void QMapboxGLRendererBackend::setFramebufferSize(const mbgl::Size &size)
+void QMapboxGLRendererBackend::updateFramebuffer(quint32 fbo, const mbgl::Size &size)
{
+ m_fbo = fbo;
m_size = size;
}
diff --git a/platform/qt/src/qmapboxgl_renderer_backend.hpp b/platform/qt/src/qmapboxgl_renderer_backend.hpp
index fb38556b55..de66b035fc 100644
--- a/platform/qt/src/qmapboxgl_renderer_backend.hpp
+++ b/platform/qt/src/qmapboxgl_renderer_backend.hpp
@@ -14,10 +14,10 @@ public:
// mbgl::RendererBackend implementation
void updateAssumedState() final;
- void bind() final {}
+ void bind() final;
mbgl::Size getFramebufferSize() const final;
- void setFramebufferSize(const mbgl::Size &);
+ void updateFramebuffer(quint32 fbo, const mbgl::Size &);
protected:
mbgl::gl::ProcAddress getExtensionFunctionPointer(const char*) final;
@@ -27,6 +27,7 @@ protected:
void deactivate() final {}
private:
+ quint32 m_fbo = 0;
mbgl::Size m_size = { 0, 0 };
Q_DISABLE_COPY(QMapboxGLRendererBackend)