store spriteAtlas by value + make TileParser noncopyable

This commit is contained in:
artemp
2014-10-29 14:09:06 -04:00
parent 92f99cbc16
commit 2607a755af
4 changed files with 16 additions and 18 deletions

View File

@@ -4,6 +4,7 @@
#include <mbgl/map/transform.hpp>
#include <mbgl/renderer/painter.hpp>
#include <mbgl/geometry/glyph_atlas.hpp>
#include <mbgl/geometry/sprite_atlas.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/time.hpp>
#include <mbgl/util/uv.hpp>
@@ -18,7 +19,6 @@ namespace mbgl {
class GlyphStore;
class LayerDescription;
class SpriteAtlas;
class Sprite;
class Style;
class StyleLayer;
@@ -131,7 +131,7 @@ public:
inline util::ptr<Style> getStyle() const { return style; }
inline GlyphAtlas & getGlyphAtlas() { return glyphAtlas; }
inline util::ptr<GlyphStore> getGlyphStore() { return glyphStore; }
inline util::ptr<SpriteAtlas> getSpriteAtlas() { return spriteAtlas; }
inline SpriteAtlas & getSpriteAtlas() { return spriteAtlas; }
util::ptr<Sprite> getSprite();
inline util::ptr<Texturepool> getTexturepool() { return texturepool; }
inline util::ptr<uv::loop> getLoop() { return loop; }
@@ -203,7 +203,7 @@ private:
util::ptr<Style> style;
GlyphAtlas glyphAtlas;
util::ptr<GlyphStore> glyphStore;
util::ptr<SpriteAtlas> spriteAtlas;
SpriteAtlas spriteAtlas;
util::ptr<Sprite> sprite;
util::ptr<Texturepool> texturepool;

View File

@@ -5,7 +5,7 @@
#include <mbgl/style/filter_expression.hpp>
#include <mbgl/text/glyph.hpp>
#include <mbgl/util/ptr.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <cstdint>
#include <iosfwd>
#include <string>
@@ -29,13 +29,14 @@ class StyleLayerGroup;
class VectorTileData;
class Collision;
class TileParser {
class TileParser : private util::noncopyable
{
public:
TileParser(const std::string &data, VectorTileData &tile,
const util::ptr<const Style> &style,
GlyphAtlas & glyphAtlas,
const util::ptr<GlyphStore> &glyphStore,
const util::ptr<SpriteAtlas> &spriteAtlas,
SpriteAtlas & spriteAtlas,
const util::ptr<Sprite> &sprite);
~TileParser();
@@ -62,7 +63,7 @@ private:
util::ptr<const Style> style;
GlyphAtlas & glyphAtlas;
util::ptr<GlyphStore> glyphStore;
util::ptr<SpriteAtlas> spriteAtlas;
SpriteAtlas & spriteAtlas;
util::ptr<Sprite> sprite;
util::ptr<Texturepool> texturePool;

View File

@@ -42,12 +42,11 @@ Map::Map(View& view_)
#endif
transform(view_),
glyphAtlas(1024, 1024),
spriteAtlas(std::make_shared<SpriteAtlas>(512, 512)),
spriteAtlas(512, 512),
texturepool(std::make_shared<Texturepool>()),
painter(*spriteAtlas, glyphAtlas) {
painter(spriteAtlas, glyphAtlas)
{
view.initialize(this);
// Make sure that we're doing an initial drawing in all cases.
is_clean.clear();
is_rendered.clear();
@@ -62,7 +61,6 @@ Map::~Map() {
// Explicitly reset all pointers.
texturepool.reset();
sprite.reset();
spriteAtlas.reset();
glyphStore.reset();
style.reset();
fileSource.reset();
@@ -635,8 +633,8 @@ void Map::prepare() {
style->updateProperties(state.getNormalizedZoom(), animationTime);
// Allow the sprite atlas to potentially pull new sprite images if needed.
spriteAtlas->resize(state.getPixelRatio());
spriteAtlas->setSprite(getSprite());
spriteAtlas.resize(state.getPixelRatio());
spriteAtlas.setSprite(getSprite());
updateTiles();
}

View File

@@ -39,9 +39,9 @@ TileParser::~TileParser() = default;
TileParser::TileParser(const std::string &data, VectorTileData &tile_,
const util::ptr<const Style> &style_,
GlyphAtlas& glyphAtlas_,
GlyphAtlas & glyphAtlas_,
const util::ptr<GlyphStore> &glyphStore_,
const util::ptr<SpriteAtlas> &spriteAtlas_,
SpriteAtlas & spriteAtlas_,
const util::ptr<Sprite> &sprite_)
: vector_data(pbf((const uint8_t *)data.data(), data.size())),
tile(tile_),
@@ -54,7 +54,6 @@ TileParser::TileParser(const std::string &data, VectorTileData &tile_,
assert(&tile != nullptr);
assert(style);
assert(glyphStore);
assert(spriteAtlas);
assert(sprite);
assert(collision);
}
@@ -176,7 +175,7 @@ std::unique_ptr<Bucket> TileParser::createLineBucket(const VectorTileLayer& laye
std::unique_ptr<Bucket> TileParser::createSymbolBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketSymbol &symbol) {
std::unique_ptr<SymbolBucket> bucket = std::make_unique<SymbolBucket>(symbol, *collision);
bucket->addFeatures(layer, filter, tile.id, *spriteAtlas, *sprite, glyphAtlas, *glyphStore);
bucket->addFeatures(layer, filter, tile.id, spriteAtlas, *sprite, glyphAtlas, *glyphStore);
return obsolete() ? nullptr : std::move(bucket);
}