summaryrefslogtreecommitdiff
path: root/platform/qt
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-11-24 17:34:43 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-11-28 18:18:42 +0200
commitb81255e5da6d8835c9732a8a3d5e962c1a4b1656 (patch)
treee990d96175eecbe19c5f819dfc40ed9f66ad3225 /platform/qt
parent74a7a5a0d458f4b7310b68e4e5fe900d3e907fd1 (diff)
downloadqtlocation-mapboxgl-b81255e5da6d8835c9732a8a3d5e962c1a4b1656.tar.gz
[qt, macos] Consume GL_INVALID_OPERATION from Qt
Diffstat (limited to 'platform/qt')
-rw-r--r--platform/qt/app/mapwindow.cpp9
-rw-r--r--platform/qt/src/qmapboxgl.cpp40
-rw-r--r--platform/qt/src/qmapboxgl_p.hpp4
3 files changed, 19 insertions, 34 deletions
diff --git a/platform/qt/app/mapwindow.cpp b/platform/qt/app/mapwindow.cpp
index e8e3a13489..8b76821479 100644
--- a/platform/qt/app/mapwindow.cpp
+++ b/platform/qt/app/mapwindow.cpp
@@ -310,14 +310,5 @@ void MapWindow::paintGL()
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
}
diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp
index 67743d180a..e1a8a463ef 100644
--- a/platform/qt/src/qmapboxgl.cpp
+++ b/platform/qt/src/qmapboxgl.cpp
@@ -5,6 +5,7 @@
#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>
@@ -798,13 +799,30 @@ void QMapboxGL::setFilter(const QString& layer_, const QVariant& filter_)
#if QT_VERSION >= 0x050000
void QMapboxGL::render(QOpenGLFramebufferObject *fbo)
{
+#if defined(__APPLE__)
+ // FIXME Consume one GL_INVALID_OPERATION from Qt.
+ // See https://bugreports.qt.io/browse/QTBUG-36802 for details.
+ GLenum error = glGetError();
+ if (!(error == GL_NO_ERROR || error == GL_INVALID_OPERATION)) {
+ throw std::runtime_error(std::string("glGetError() returned ") + std::to_string(error));
+ }
+#endif
+
d_ptr->dirty = false;
- d_ptr->updateFramebufferBinding(fbo);
+ d_ptr->fbo = fbo;
d_ptr->mapObj->render(*d_ptr);
}
#else
void QMapboxGL::render()
{
+#if defined(__APPLE__)
+ // FIXME Qt 4.x provides an incomplete FBO at start.
+ // See https://bugreports.qt.io/browse/QTBUG-36802 for details.
+ if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
+ return;
+ }
+#endif
+
d_ptr->dirty = false;
d_ptr->mapObj->render(*d_ptr);
}
@@ -844,21 +862,6 @@ QMapboxGLPrivate::~QMapboxGLPrivate()
}
#if QT_VERSION >= 0x050000
-void QMapboxGLPrivate::updateFramebufferBinding(QOpenGLFramebufferObject *fbo_)
-{
- fbo = fbo_;
- if (fbo) {
- getContext().bindFramebuffer.setDirty();
- getContext().viewport = {
- 0, 0, { static_cast<uint32_t>(fbo->width()), static_cast<uint32_t>(fbo->height()) } };
- } else {
- getContext().bindFramebuffer.setCurrentValue(0);
- assert(mbgl::gl::value::BindFramebuffer::Get() == getContext().bindFramebuffer.getCurrentValue());
- getContext().viewport = {
- 0, 0, { static_cast<uint32_t>(fbSize.width()), static_cast<uint32_t>(fbSize.height()) } };
- }
-}
-
void QMapboxGLPrivate::bind() {
if (fbo) {
fbo->bind();
@@ -866,11 +869,6 @@ void QMapboxGLPrivate::bind() {
getContext().viewport = {
0, 0, { static_cast<uint32_t>(fbo->width()), static_cast<uint32_t>(fbo->height()) }
};
- } else {
- getContext().bindFramebuffer = 0;
- getContext().viewport = {
- 0, 0, { static_cast<uint32_t>(fbSize.width()), static_cast<uint32_t>(fbSize.height()) }
- };
}
}
#else
diff --git a/platform/qt/src/qmapboxgl_p.hpp b/platform/qt/src/qmapboxgl_p.hpp
index edff728dd4..74ee207d09 100644
--- a/platform/qt/src/qmapboxgl_p.hpp
+++ b/platform/qt/src/qmapboxgl_p.hpp
@@ -31,10 +31,6 @@ public:
void invalidate() final;
void notifyMapChange(mbgl::MapChange) final;
-#if QT_VERSION >= 0x050000
- void updateFramebufferBinding(QOpenGLFramebufferObject *);
-#endif
-
mbgl::EdgeInsets margins;
QSize size { 0, 0 };
QSize fbSize { 0, 0 };