Eliminate Map::getSpriteAtlas()

This commit is contained in:
John Firebaugh
2014-11-21 15:47:35 -08:00
parent a5fe8ec3dc
commit 8e33076bf1
6 changed files with 22 additions and 14 deletions

View File

@@ -128,7 +128,6 @@ public:
inline const TransformState &getState() const { return state; }
inline util::ptr<Style> getStyle() const { return style; }
inline util::ptr<GlyphStore> getGlyphStore() { return glyphStore; }
inline SpriteAtlas & getSpriteAtlas() { return spriteAtlas; }
util::ptr<Sprite> getSprite();
inline util::ptr<Texturepool> getTexturepool() { return texturepool; }
uv::worker &getWorker();

View File

@@ -19,6 +19,7 @@ namespace mbgl {
class Map;
class GlyphAtlas;
class SpriteAtlas;
class FileSource;
class Painter;
class StyleLayer;
@@ -30,7 +31,7 @@ public:
Source(const util::ptr<SourceInfo>& info);
void load(Map&, FileSource&);
bool update(Map&, GlyphAtlas&, FileSource&);
bool update(Map&, GlyphAtlas&, SpriteAtlas&, FileSource&);
void updateMatrices(const mat4 &projMatrix, const TransformState &transform);
void drawClippingMasks(Painter &painter);
@@ -49,9 +50,9 @@ private:
int32_t coveringZoomLevel(const TransformState&) const;
std::forward_list<Tile::ID> coveringTiles(const TransformState&) const;
bool updateTiles(Map&, GlyphAtlas&, FileSource&);
bool updateTiles(Map&, GlyphAtlas&, SpriteAtlas&, FileSource&);
TileData::State addTile(Map&, GlyphAtlas&, FileSource&, const Tile::ID&);
TileData::State addTile(Map&, GlyphAtlas&, SpriteAtlas&, FileSource&, const Tile::ID&);
TileData::State hasTile(const Tile::ID& id);
double getZoom(const TransformState &state) const;

View File

@@ -22,12 +22,15 @@ class SourceInfo;
class StyleLayer;
class TileParser;
class GlyphAtlas;
class SpriteAtlas;
class VectorTileData : public TileData {
friend class TileParser;
public:
VectorTileData(Tile::ID const&, Map&, GlyphAtlas&, const util::ptr<SourceInfo>&);
VectorTileData(Tile::ID const&, Map&,
GlyphAtlas&, SpriteAtlas&,
const util::ptr<SourceInfo>&);
~VectorTileData();
virtual void parse();
@@ -48,7 +51,9 @@ protected:
// Holds the buckets of this tile.
// They contain the location offsets in the buffers stored above
std::unordered_map<std::string, std::unique_ptr<Bucket>> buckets;
GlyphAtlas& glyphAtlas;
SpriteAtlas& spriteAtlas;
public:
const float depth;

View File

@@ -642,7 +642,7 @@ void Map::updateSources(const util::ptr<StyleLayerGroup> &group) {
void Map::updateTiles() {
for (const util::ptr<StyleSource> &source : getActiveSources()) {
source->source->update(*this, glyphAtlas, *fileSource);
source->source->update(*this, glyphAtlas, spriteAtlas, *fileSource);
}
}

View File

@@ -61,9 +61,9 @@ void Source::load(Map& map, FileSource& fileSource) {
});
}
bool Source::update(Map& map, GlyphAtlas& glyphAtlas, FileSource& fileSource) {
bool Source::update(Map& map, GlyphAtlas& glyphAtlas, SpriteAtlas& spriteAtlas, FileSource& fileSource) {
if (loaded && map.getTime() > updated) {
return updateTiles(map, glyphAtlas, fileSource);
return updateTiles(map, glyphAtlas, spriteAtlas, fileSource);
} else {
return false;
}
@@ -159,7 +159,7 @@ TileData::State Source::hasTile(const Tile::ID& id) {
return TileData::State::invalid;
}
TileData::State Source::addTile(Map& map, GlyphAtlas& glyphAtlas, FileSource& fileSource, const Tile::ID& id) {
TileData::State Source::addTile(Map& map, GlyphAtlas& glyphAtlas, SpriteAtlas& spriteAtlas, FileSource& fileSource, const Tile::ID& id) {
const TileData::State state = hasTile(id);
if (state != TileData::State::invalid) {
@@ -187,7 +187,7 @@ TileData::State Source::addTile(Map& map, GlyphAtlas& glyphAtlas, FileSource& fi
if (!new_tile.data) {
// If we don't find working tile data, we're just going to load it.
if (info->type == SourceType::Vector) {
new_tile.data = std::make_shared<VectorTileData>(normalized_id, map, glyphAtlas, info);
new_tile.data = std::make_shared<VectorTileData>(normalized_id, map, glyphAtlas, spriteAtlas, info);
} else if (info->type == SourceType::Raster) {
new_tile.data = std::make_shared<RasterTileData>(normalized_id, map, info);
} else {
@@ -281,7 +281,7 @@ bool Source::findLoadedParent(const Tile::ID& id, int32_t minCoveringZoom, std::
return false;
}
bool Source::updateTiles(Map& map, GlyphAtlas& glyphAtlas, FileSource& fileSource) {
bool Source::updateTiles(Map& map, GlyphAtlas& glyphAtlas, SpriteAtlas& spriteAtlas, FileSource& fileSource) {
bool changed = false;
int32_t zoom = std::floor(getZoom(map.getState()));
@@ -298,7 +298,7 @@ bool Source::updateTiles(Map& map, GlyphAtlas& glyphAtlas, FileSource& fileSourc
// Add existing child/parent tiles if the actual tile is not yet loaded
for (const Tile::ID& id : required) {
const TileData::State state = addTile(map, glyphAtlas, fileSource, id);
const TileData::State state = addTile(map, glyphAtlas, spriteAtlas, fileSource, id);
if (state != TileData::State::parsed) {
// The tile we require is not yet loaded. Try to find a parent or

View File

@@ -8,9 +8,12 @@
using namespace mbgl;
VectorTileData::VectorTileData(Tile::ID const& id_, Map &map_, GlyphAtlas& glyphAtlas_, const util::ptr<SourceInfo> &source_)
VectorTileData::VectorTileData(Tile::ID const& id_, Map &map_,
GlyphAtlas& glyphAtlas_, SpriteAtlas& spriteAtlas_,
const util::ptr<SourceInfo> &source_)
: TileData(id_, map_, source_),
glyphAtlas(glyphAtlas_),
spriteAtlas(spriteAtlas_),
depth(id.z >= source->max_zoom ? map.getMaxZoom() - id.z : 1) {
}
@@ -29,7 +32,7 @@ void VectorTileData::parse() {
// the TileParser object writes results into this objects. All other state
// is going to be discarded afterwards.
TileParser parser(data, *this, map.getStyle(), glyphAtlas,
map.getGlyphStore(), map.getSpriteAtlas(), map.getSprite());
map.getGlyphStore(), spriteAtlas, map.getSprite());
parser.parse();
} catch (const std::exception& ex) {
#if defined(DEBUG)