This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6e80ba
commit 121be92
Showing
5 changed files
with
111 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "qrenderer_frontend.hpp" | ||
|
||
#include <mbgl/map/backend_scope.hpp> | ||
#include <mbgl/renderer/renderer.hpp> | ||
|
||
QRendererFrontend::QRendererFrontend(mbgl::Backend& backend_, mbgl::View& view_) | ||
: backend(backend_) | ||
, view(view_) { | ||
} | ||
|
||
QRendererFrontend::~QRendererFrontend() { | ||
mbgl::BackendScope guard { backend, mbgl::BackendScope::ScopeType::Implicit }; | ||
renderer.reset(); | ||
} | ||
|
||
void QRendererFrontend::update(std::shared_ptr<mbgl::UpdateParameters> updateParameters_) { | ||
updateParameters = updateParameters_; | ||
emit updated(); | ||
} | ||
|
||
std::vector<mbgl::Feature> QRendererFrontend::queryRenderedFeatures(std::shared_ptr<mbgl::RenderedQueryParameters> params) const { | ||
if (!renderer) return {}; | ||
return renderer->queryRenderedFeatures(*params); | ||
} | ||
|
||
std::vector<mbgl::Feature> QRendererFrontend::querySourceFeatures(std::shared_ptr<mbgl::SourceQueryParameters> params) const { | ||
if (!renderer) return {}; | ||
return renderer->querySourceFeatures(*params); | ||
} | ||
|
||
void QRendererFrontend::setRenderer(std::unique_ptr<mbgl::Renderer> renderer_, mbgl::RendererObserver& observer_) { | ||
renderer = std::move(renderer_); | ||
renderer->setObserver(&observer_); | ||
} | ||
|
||
void QRendererFrontend::render() { | ||
if (!renderer || !updateParameters) return; | ||
renderer->render(backend, view, *updateParameters); | ||
} | ||
|
||
void QRendererFrontend::onLowMemory() { | ||
if (!renderer) return; | ||
renderer->onLowMemory(); | ||
} | ||
|
||
void QRendererFrontend::dumpDebugLogs() { | ||
if (!renderer) return; | ||
renderer->dumpDebugLogs(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#pragma once | ||
|
||
#include <mbgl/map/backend.hpp> | ||
#include <mbgl/renderer/renderer_frontend.hpp> | ||
|
||
#include <QObject> | ||
|
||
class QRendererFrontend : public QObject, public mbgl::RendererFrontend | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit QRendererFrontend(mbgl::Backend&, mbgl::View&); | ||
~QRendererFrontend() override; | ||
|
||
void update(std::shared_ptr<mbgl::UpdateParameters> updateParameters_) override; | ||
|
||
std::vector<mbgl::Feature> queryRenderedFeatures(std::shared_ptr<mbgl::RenderedQueryParameters> params) const override; | ||
std::vector<mbgl::Feature> querySourceFeatures(std::shared_ptr<mbgl::SourceQueryParameters> params) const override; | ||
|
||
void setRenderer(std::unique_ptr<mbgl::Renderer> renderer_, mbgl::RendererObserver& observer_) override; | ||
|
||
void onLowMemory() override; | ||
void dumpDebugLogs() override; | ||
|
||
public slots: | ||
void render(); | ||
|
||
signals: | ||
void updated(); | ||
|
||
private: | ||
mbgl::Backend& backend; | ||
mbgl::View& view; | ||
|
||
std::shared_ptr<mbgl::UpdateParameters> updateParameters; | ||
std::unique_ptr<mbgl::Renderer> renderer; | ||
}; |