summaryrefslogtreecommitdiff
path: root/platform/qt/app/mapwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/qt/app/mapwindow.cpp')
-rw-r--r--platform/qt/app/mapwindow.cpp36
1 files changed, 29 insertions, 7 deletions
diff --git a/platform/qt/app/mapwindow.cpp b/platform/qt/app/mapwindow.cpp
index ca73b0a8da..e8e3a13489 100644
--- a/platform/qt/app/mapwindow.cpp
+++ b/platform/qt/app/mapwindow.cpp
@@ -9,10 +9,15 @@
#include <QMouseEvent>
#include <QString>
+#if QT_VERSION >= 0x050000
+#include <QWindow>
+#endif
+
int kAnimationDuration = 10000;
+
MapWindow::MapWindow(const QMapboxGLSettings &settings)
- : m_map(nullptr, settings)
+ : m_map(nullptr, settings, size(), pixelRatio())
, m_bearingAnimation(&m_map, "bearing")
, m_zoomAnimation(&m_map, "zoom")
{
@@ -46,6 +51,17 @@ void MapWindow::selfTest()
m_zoomAnimation.start();
}
+qreal MapWindow::pixelRatio() {
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
+ return devicePixelRatioF();
+#elif (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
+ return devicePixelRatio();
+#else
+ return 1;
+#endif
+}
+
+
void MapWindow::animationFinished()
{
qDebug() << "Animation ticks/s: " << m_animationTicks / static_cast<float>(kAnimationDuration) * 1000.;
@@ -288,14 +304,20 @@ void MapWindow::initializeGL()
QMapbox::initializeGLExtensions();
}
-void MapWindow::resizeGL(int w, int h)
-{
- QSize size(w, h);
- m_map.resize(size);
-}
-
void MapWindow::paintGL()
{
m_frameDraws++;
+
+ m_map.resize(size(), size() * pixelRatio());
+
+#if QT_VERSION < 0x050400 && defined(__APPLE__)
+ // XXX GL framebuffer is valid only after first attempt of painting on
+ // older versions of Qt on macOS.
+ // See https://bugreports.qt.io/browse/QTBUG-36802 for details.
+ static bool first = true;
+ if (!first) m_map.render();
+ first = false;
+#else
m_map.render();
+#endif
}