Make Map::getSprite() private

This commit is contained in:
John Firebaugh
2014-11-25 16:22:05 -08:00
parent 576533b18c
commit d3ba1071cb
6 changed files with 21 additions and 14 deletions

View File

@@ -127,12 +127,12 @@ public:
public:
inline const TransformState &getState() const { return state; }
inline util::ptr<Style> getStyle() const { return style; }
util::ptr<Sprite> getSprite();
inline timestamp getAnimationTime() const { return animationTime; }
inline timestamp getTime() const { return animationTime; }
void updateTiles();
private:
util::ptr<Sprite> getSprite();
uv::worker& getWorker();
// uv async callbacks

View File

@@ -21,6 +21,7 @@ class Map;
class GlyphAtlas;
class GlyphStore;
class SpriteAtlas;
class Sprite;
class FileSource;
class Texturepool;
class Painter;
@@ -35,7 +36,7 @@ public:
void load(Map&, FileSource&);
bool update(Map&, uv::worker&,
GlyphAtlas&, GlyphStore&,
SpriteAtlas&,
SpriteAtlas&, util::ptr<Sprite>,
Texturepool&, FileSource&);
void updateMatrices(const mat4 &projMatrix, const TransformState &transform);
@@ -57,12 +58,12 @@ private:
bool updateTiles(Map&, uv::worker&,
GlyphAtlas&, GlyphStore&,
SpriteAtlas&,
SpriteAtlas&, util::ptr<Sprite>,
Texturepool&, FileSource&);
TileData::State addTile(Map&, uv::worker&,
GlyphAtlas&, GlyphStore&,
SpriteAtlas&,
SpriteAtlas&, util::ptr<Sprite>,
FileSource&, Texturepool&,
const Tile::ID&);

View File

@@ -24,6 +24,7 @@ class TileParser;
class GlyphAtlas;
class GlyphStore;
class SpriteAtlas;
class Sprite;
class Texturepool;
class VectorTileData : public TileData {
@@ -32,7 +33,7 @@ class VectorTileData : public TileData {
public:
VectorTileData(Tile::ID const&, Map&,
GlyphAtlas&, GlyphStore&,
SpriteAtlas&,
SpriteAtlas&, util::ptr<Sprite>,
Texturepool&,
const util::ptr<SourceInfo>&);
~VectorTileData();
@@ -59,6 +60,7 @@ protected:
GlyphAtlas& glyphAtlas;
GlyphStore& glyphStore;
SpriteAtlas& spriteAtlas;
util::ptr<Sprite> sprite;
Texturepool& texturepool;
public:

View File

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

View File

@@ -63,10 +63,10 @@ void Source::load(Map& map, FileSource& fileSource) {
bool Source::update(Map& map, uv::worker& worker,
GlyphAtlas& glyphAtlas, GlyphStore& glyphStore,
SpriteAtlas& spriteAtlas,
SpriteAtlas& spriteAtlas, util::ptr<Sprite> sprite,
Texturepool& texturepool, FileSource& fileSource) {
if (loaded && map.getTime() > updated) {
return updateTiles(map, worker, glyphAtlas, glyphStore, spriteAtlas, texturepool, fileSource);
return updateTiles(map, worker, glyphAtlas, glyphStore, spriteAtlas, sprite, texturepool, fileSource);
} else {
return false;
}
@@ -164,7 +164,7 @@ TileData::State Source::hasTile(const Tile::ID& id) {
TileData::State Source::addTile(Map& map, uv::worker& worker,
GlyphAtlas& glyphAtlas, GlyphStore& glyphStore,
SpriteAtlas& spriteAtlas,
SpriteAtlas& spriteAtlas, util::ptr<Sprite> sprite,
FileSource& fileSource, Texturepool& texturepool,
const Tile::ID& id) {
const TileData::State state = hasTile(id);
@@ -194,7 +194,7 @@ TileData::State Source::addTile(Map& map, uv::worker& worker,
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, glyphStore, spriteAtlas, texturepool, info);
new_tile.data = std::make_shared<VectorTileData>(normalized_id, map, glyphAtlas, glyphStore, spriteAtlas, sprite, texturepool, info);
} else if (info->type == SourceType::Raster) {
new_tile.data = std::make_shared<RasterTileData>(normalized_id, map, texturepool, info);
} else {
@@ -290,7 +290,7 @@ bool Source::findLoadedParent(const Tile::ID& id, int32_t minCoveringZoom, std::
bool Source::updateTiles(Map& map, uv::worker& worker,
GlyphAtlas& glyphAtlas, GlyphStore& glyphStore,
SpriteAtlas& spriteAtlas,
SpriteAtlas& spriteAtlas, util::ptr<Sprite> sprite,
Texturepool& texturepool, FileSource& fileSource) {
bool changed = false;
@@ -310,7 +310,7 @@ bool Source::updateTiles(Map& map, uv::worker& worker,
for (const Tile::ID& id : required) {
const TileData::State state = addTile(map, worker,
glyphAtlas, glyphStore,
spriteAtlas,
spriteAtlas, sprite,
fileSource, texturepool,
id);

View File

@@ -10,13 +10,14 @@ using namespace mbgl;
VectorTileData::VectorTileData(Tile::ID const& id_, Map &map_,
GlyphAtlas& glyphAtlas_, GlyphStore& glyphStore_,
SpriteAtlas& spriteAtlas_,
SpriteAtlas& spriteAtlas_, util::ptr<Sprite> sprite_,
Texturepool& texturepool_,
const util::ptr<SourceInfo> &source_)
: TileData(id_, map_, source_),
glyphAtlas(glyphAtlas_),
glyphStore(glyphStore_),
spriteAtlas(spriteAtlas_),
sprite(sprite_),
texturepool(texturepool_),
depth(id.z >= source->max_zoom ? map.getMaxZoom() - id.z : 1) {
}
@@ -37,7 +38,7 @@ void VectorTileData::parse() {
// is going to be discarded afterwards.
TileParser parser(data, *this, map.getStyle(),
glyphAtlas, glyphStore,
spriteAtlas, map.getSprite(),
spriteAtlas, sprite,
texturepool);
parser.parse();
} catch (const std::exception& ex) {