summaryrefslogtreecommitdiff
path: root/platform/default
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-06-13 10:50:16 +0300
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2017-07-18 10:45:12 +0200
commit3832f8d0d8194b81ea34a045e19b0d5bc7a89e25 (patch)
treebbb4b277e1e74bde457271b9b9a5b6a9ec3ad5fb /platform/default
parent39a732d7ae3cb1b927d94c4b1154b42d9565356a (diff)
downloadqtlocation-mapboxgl-3832f8d0d8194b81ea34a045e19b0d5bc7a89e25.tar.gz
[core] renderer interface
Diffstat (limited to 'platform/default')
-rw-r--r--platform/default/mbgl/gl/headless_backend.cpp6
-rw-r--r--platform/default/mbgl/gl/headless_backend.hpp2
-rw-r--r--platform/default/mbgl/renderer/async_renderer_frontend.cpp38
-rw-r--r--platform/default/mbgl/renderer/async_renderer_frontend.hpp35
4 files changed, 74 insertions, 7 deletions
diff --git a/platform/default/mbgl/gl/headless_backend.cpp b/platform/default/mbgl/gl/headless_backend.cpp
index df3a517823..82cf7b38fd 100644
--- a/platform/default/mbgl/gl/headless_backend.cpp
+++ b/platform/default/mbgl/gl/headless_backend.cpp
@@ -16,7 +16,7 @@ HeadlessBackend::HeadlessBackend(std::shared_ptr<HeadlessDisplay> display_)
}
HeadlessBackend::~HeadlessBackend() {
- BackendScope scope(*this);
+ BackendScope guard { *this, getScopeType() };
context.reset();
}
@@ -44,8 +44,4 @@ void HeadlessBackend::updateAssumedState() {
// no-op
}
-void HeadlessBackend::invalidate() {
- assert(false);
-}
-
} // namespace mbgl
diff --git a/platform/default/mbgl/gl/headless_backend.hpp b/platform/default/mbgl/gl/headless_backend.hpp
index 26033acf82..7b9f7f5ad3 100644
--- a/platform/default/mbgl/gl/headless_backend.hpp
+++ b/platform/default/mbgl/gl/headless_backend.hpp
@@ -17,8 +17,6 @@ public:
void updateAssumedState() override;
- void invalidate() override;
-
struct Impl {
virtual ~Impl() = default;
virtual void activateContext() = 0;
diff --git a/platform/default/mbgl/renderer/async_renderer_frontend.cpp b/platform/default/mbgl/renderer/async_renderer_frontend.cpp
new file mode 100644
index 0000000000..37b4e60cf6
--- /dev/null
+++ b/platform/default/mbgl/renderer/async_renderer_frontend.cpp
@@ -0,0 +1,38 @@
+#include "async_renderer_frontend.hpp"
+#include <mbgl/renderer/renderer.hpp>
+
+namespace mbgl {
+
+AsyncRendererFrontend::AsyncRendererFrontend(std::unique_ptr<Renderer> renderer_, View& view_)
+ : renderer(std::move(renderer_))
+ , view(view_)
+ , asyncInvalidate([this] {
+ if (renderer && updateParameters) {
+ renderer->render(view, *updateParameters);
+ }
+ }) {
+}
+
+AsyncRendererFrontend::~AsyncRendererFrontend() = default;
+
+void AsyncRendererFrontend::reset() {
+ assert(renderer);
+ renderer.reset();
+}
+
+void AsyncRendererFrontend::update(std::shared_ptr<UpdateParameters> updateParameters_) {
+ updateParameters = updateParameters_;
+ asyncInvalidate.send();
+}
+
+void AsyncRendererFrontend::setObserver(RendererObserver& observer_) {
+ assert(renderer);
+ renderer->setObserver(&observer_);
+}
+
+Renderer* AsyncRendererFrontend::getRenderer() {
+ assert(renderer);
+ return renderer.get();
+}
+
+} // namespace mbgl
diff --git a/platform/default/mbgl/renderer/async_renderer_frontend.hpp b/platform/default/mbgl/renderer/async_renderer_frontend.hpp
new file mode 100644
index 0000000000..00cf3a480c
--- /dev/null
+++ b/platform/default/mbgl/renderer/async_renderer_frontend.hpp
@@ -0,0 +1,35 @@
+#pragma once
+
+#include <mbgl/map/view.hpp>
+#include <mbgl/renderer/renderer_frontend.hpp>
+#include <mbgl/util/async_task.hpp>
+
+#include <memory>
+#include <vector>
+
+namespace mbgl {
+
+class Renderer;
+
+// Default implementation for RendererFrontend
+class AsyncRendererFrontend : public mbgl::RendererFrontend {
+public:
+ AsyncRendererFrontend(std::unique_ptr<Renderer>, View&);
+ ~AsyncRendererFrontend() override;
+
+ void reset() override;
+
+ void update(std::shared_ptr<UpdateParameters> updateParameters_) override;
+
+ void setObserver(RendererObserver& observer_) override;
+
+ Renderer* getRenderer();
+
+private:
+ std::unique_ptr<Renderer> renderer;
+ View& view;
+ std::shared_ptr<UpdateParameters> updateParameters;
+ util::AsyncTask asyncInvalidate;
+};
+
+} // namespace mbgl