From 7c8c45edabf3407fd5084d896fea685c53fa1a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Mon, 23 Mar 2015 14:49:03 +0100 Subject: [PATCH] move activeSources to internal Map context --- include/mbgl/map/map.hpp | 5 ++--- src/mbgl/map/map.cpp | 14 +++++++++++--- src/mbgl/map/source.cpp | 6 +++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index f1e3924fd..944781e58 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -26,10 +26,8 @@ namespace mbgl { class Painter; class GlyphStore; -class LayerDescription; class Sprite; class Style; -class StyleLayer; class TexturePool; class FileSource; class View; @@ -38,11 +36,11 @@ class SpriteAtlas; class LineAtlas; class Environment; class EnvironmentScope; -class AnnotationManager; class MapData; class Worker; class StillImage; class TileID; +class MapContext; class Map : private util::noncopyable { friend class View; @@ -220,6 +218,7 @@ private: std::unique_ptr scope; View &view; const std::unique_ptr data; + const std::unique_ptr context; private: std::unique_ptr workers; diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index e238297be..bdfb082ed 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -58,13 +58,19 @@ const static bool uvVersionCheck = []() { return true; }(); -using namespace mbgl; +namespace mbgl { + +class MapContext { +public: +}; + Map::Map(View& view_, FileSource& fileSource_) : env(util::make_unique(fileSource_)), scope(util::make_unique(*env, ThreadType::Main, "Main")), view(view_), data(util::make_unique(view_)), + context(util::make_unique()), fileSource(fileSource_), glyphAtlas(util::make_unique(1024, 1024)), glyphStore(std::make_shared(*env)), @@ -688,7 +694,7 @@ LatLngBounds Map::getBoundsForAnnotations(const std::vector& annotatio } void Map::updateAnnotationTiles(const std::vector& ids) { - assert(Environment::currentlyOn(ThreadType::Map)); + assert(Environment::currentlyOn(ThreadType::Main)); if (!style) return; for (const auto &source : style->sources) { if (source->info.type == SourceType::Annotations) { @@ -921,4 +927,6 @@ void Map::onLowMemory() { } env->performCleanup(); }); -}; +} + +} diff --git a/src/mbgl/map/source.cpp b/src/mbgl/map/source.cpp index 9ad127876..4e8c66ffb 100644 --- a/src/mbgl/map/source.cpp +++ b/src/mbgl/map/source.cpp @@ -398,9 +398,9 @@ void Source::update(MapData& data, } if (info.type != SourceType::Raster && cache.getSize() == 0) { - size_t conservativeCacheSize = ((float)map.getState().getWidth() / util::tileSize) * - ((float)map.getState().getHeight() / util::tileSize) * - (map.getMaxZoom() - map.getMinZoom() + 1) * + size_t conservativeCacheSize = ((float)data.getTransformState().getWidth() / util::tileSize) * + ((float)data.getTransformState().getHeight() / util::tileSize) * + (data.transform.getMaxZoom() - data.transform.getMinZoom() + 1) * 0.5; cache.setSize(conservativeCacheSize); }