move activeSources to internal Map context

This commit is contained in:
Konstantin Käfer
2015-03-23 14:49:03 +01:00
committed by John Firebaugh
parent 89167cbf8c
commit 7c8c45edab
3 changed files with 16 additions and 9 deletions

View File

@@ -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<EnvironmentScope> scope;
View &view;
const std::unique_ptr<MapData> data;
const std::unique_ptr<MapContext> context;
private:
std::unique_ptr<Worker> workers;

View File

@@ -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<Environment>(fileSource_)),
scope(util::make_unique<EnvironmentScope>(*env, ThreadType::Main, "Main")),
view(view_),
data(util::make_unique<MapData>(view_)),
context(util::make_unique<MapContext>()),
fileSource(fileSource_),
glyphAtlas(util::make_unique<GlyphAtlas>(1024, 1024)),
glyphStore(std::make_shared<GlyphStore>(*env)),
@@ -688,7 +694,7 @@ LatLngBounds Map::getBoundsForAnnotations(const std::vector<uint32_t>& annotatio
}
void Map::updateAnnotationTiles(const std::vector<TileID>& 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();
});
};
}
}

View File

@@ -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);
}