diff options
Diffstat (limited to 'platform/default')
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 |