summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2019-03-13 16:16:33 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2019-03-13 17:56:44 +0200
commit1b39f456fdab71a918427dede28f27281bd28a14 (patch)
tree4f47d354074133b08b1f2ca146e472e9e70f8660
parent8be135231d9efe41a3b12037518d02b36104e8cf (diff)
downloadqtlocation-mapboxgl-1b39f456fdab71a918427dede28f27281bd28a14.tar.gz
[core] Lazy-load {Image,Glyph}Manager on Renderer::Impl
-rw-r--r--src/mbgl/renderer/renderer_impl.cpp24
-rw-r--r--src/mbgl/renderer/renderer_impl.hpp3
2 files changed, 18 insertions, 9 deletions
diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp
index e3346a39a5..67e648d98b 100644
--- a/src/mbgl/renderer/renderer_impl.cpp
+++ b/src/mbgl/renderer/renderer_impl.cpp
@@ -48,17 +48,14 @@ Renderer::Impl::Impl(RendererBackend& backend_,
, observer(&nullObserver())
, contextMode(contextMode_)
, pixelRatio(pixelRatio_)
- , programCacheDir(programCacheDir_)
- , glyphManager(std::make_unique<GlyphManager>(fileSource, std::make_unique<LocalGlyphRasterizer>(localFontFamily_)))
- , imageManager(std::make_unique<ImageManager>())
+ , programCacheDir(std::move(programCacheDir_))
+ , localFontFamily(std::move(localFontFamily_))
, lineAtlas(std::make_unique<LineAtlas>(Size{ 256, 512 }))
, imageImpls(makeMutable<std::vector<Immutable<style::Image::Impl>>>())
, sourceImpls(makeMutable<std::vector<Immutable<style::Source::Impl>>>())
, layerImpls(makeMutable<std::vector<Immutable<style::Layer::Impl>>>())
, renderLight(makeMutable<Light::Impl>())
- , placement(std::make_unique<Placement>(TransformState{}, MapMode::Static, TransitionOptions{}, true)) {
- glyphManager->setObserver(this);
-}
+ , placement(std::make_unique<Placement>(TransformState{}, MapMode::Static, TransitionOptions{}, true)) {}
Renderer::Impl::~Impl() {
assert(BackendScope::exists());
@@ -80,6 +77,15 @@ void Renderer::Impl::setObserver(RendererObserver* observer_) {
}
void Renderer::Impl::render(const UpdateParameters& updateParameters) {
+ if (!glyphManager) {
+ glyphManager = std::make_unique<GlyphManager>(fileSource, std::make_unique<LocalGlyphRasterizer>(localFontFamily));
+ glyphManager->setObserver(this);
+ }
+
+ if (!imageManager) {
+ imageManager = std::make_unique<ImageManager>();
+ }
+
if (updateParameters.mode != MapMode::Continuous) {
// Reset zoom history state.
zoomHistory.first = true;
@@ -748,7 +754,9 @@ void Renderer::Impl::dumDebugLogs() {
entry.second->dumpDebugLogs();
}
- imageManager->dumpDebugLogs();
+ if (imageManager) {
+ imageManager->dumpDebugLogs();
+ }
}
RenderLayer* Renderer::Impl::getRenderLayer(const std::string& id) {
@@ -808,7 +816,7 @@ bool Renderer::Impl::isLoaded() const {
}
}
- if (!imageManager->isLoaded()) {
+ if (!imageManager || !imageManager->isLoaded()) {
return false;
}
diff --git a/src/mbgl/renderer/renderer_impl.hpp b/src/mbgl/renderer/renderer_impl.hpp
index 4555ba27d5..dca5892311 100644
--- a/src/mbgl/renderer/renderer_impl.hpp
+++ b/src/mbgl/renderer/renderer_impl.hpp
@@ -38,7 +38,7 @@ class Renderer::Impl : public GlyphManagerObserver,
public RenderSourceObserver{
public:
Impl(RendererBackend&, float pixelRatio_, FileSource&, Scheduler&, GLContextMode,
- const optional<std::string> programCacheDir, const optional<std::string> localFontFamily);
+ const optional<std::string> programCacheDir, const optional<std::string> localFontFamily_);
~Impl() final;
void markContextLost() {
@@ -98,6 +98,7 @@ private:
const GLContextMode contextMode;
const float pixelRatio;
const optional<std::string> programCacheDir;
+ const optional<std::string> localFontFamily;
enum class RenderState {
Never,