Use a shared scheduler on threads without a default scheduler

Render threads won't have a scheduler, so we create one that is
shared by all the maps rendering at this thread. The bad side
effect of this is that we need to wake up the render thread
to process events.

Mapbox GL should get rid of processing events on the render
thread. This solution is a workaround.
This commit is contained in:
Thiago Marcos P. Santos
2018-06-06 14:15:15 +03:00
parent 144c167274
commit a5ef72a051
5 changed files with 115 additions and 39 deletions

View File

@@ -14,7 +14,6 @@
#include <memory>
#include <mutex>
#include <queue>
namespace mbgl {
class Renderer;
@@ -23,7 +22,7 @@ class UpdateParameters;
class QMapboxGLRendererBackend;
class QMapboxGLMapRenderer : public QObject, public mbgl::Scheduler
class QMapboxGLMapRenderer : public QObject
{
Q_OBJECT
@@ -32,9 +31,6 @@ public:
mbgl::ThreadPool &, QMapboxGLSettings::GLContextMode);
virtual ~QMapboxGLMapRenderer();
// mbgl::Scheduler implementation.
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>);
@@ -56,8 +52,5 @@ private:
QMapboxGLRendererBackend m_backend;
std::unique_ptr<mbgl::Renderer> m_renderer;
std::mutex m_taskQueueMutex;
std::queue<std::weak_ptr<mbgl::Mailbox>> m_taskQueue;
bool m_threadWithScheduler;
bool m_forceScheduler;
};