diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2017-06-13 10:50:16 +0300 |
---|---|---|
committer | Ivo van Dongen <ivovandongen@users.noreply.github.com> | 2017-07-18 10:45:12 +0200 |
commit | 3832f8d0d8194b81ea34a045e19b0d5bc7a89e25 (patch) | |
tree | bbb4b277e1e74bde457271b9b9a5b6a9ec3ad5fb /platform | |
parent | 39a732d7ae3cb1b927d94c4b1154b42d9565356a (diff) | |
download | qtlocation-mapboxgl-3832f8d0d8194b81ea34a045e19b0d5bc7a89e25.tar.gz |
[core] renderer interface
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/config.cmake | 2 | ||||
-rw-r--r-- | platform/default/mbgl/gl/headless_backend.cpp | 6 | ||||
-rw-r--r-- | platform/default/mbgl/gl/headless_backend.hpp | 2 | ||||
-rw-r--r-- | platform/default/mbgl/renderer/async_renderer_frontend.cpp | 38 | ||||
-rw-r--r-- | platform/default/mbgl/renderer/async_renderer_frontend.hpp | 35 | ||||
-rw-r--r-- | platform/node/src/node_map.cpp | 1 |
6 files changed, 76 insertions, 8 deletions
diff --git a/platform/android/config.cmake b/platform/android/config.cmake index 5a6950a23f..9fdbfa1b45 100644 --- a/platform/android/config.cmake +++ b/platform/android/config.cmake @@ -57,6 +57,8 @@ macro(mbgl_platform_core) PRIVATE platform/default/bidi.cpp PRIVATE platform/default/thread_local.cpp PRIVATE platform/default/utf.cpp + PRIVATE platform/default/mbgl/renderer/default_render_bridge.cpp + PRIVATE platform/default/mbgl/renderer/default_render_bridge.hpp # Image handling PRIVATE platform/default/png_writer.cpp 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 diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index 78e98e2a28..2599996f7c 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -12,7 +12,6 @@ #include <mbgl/style/style.hpp> #include <mbgl/style/image.hpp> #include <mbgl/map/backend_scope.hpp> -#include <mbgl/map/query.hpp> #include <mbgl/util/premultiply.hpp> #include <unistd.h> |