diff options
-rw-r--r-- | include/mbgl/map/map.hpp | 1 | ||||
-rw-r--r-- | include/mbgl/map/raster_tile_data.hpp | 3 | ||||
-rw-r--r-- | include/mbgl/map/source.hpp | 18 | ||||
-rw-r--r-- | include/mbgl/map/tile_parser.hpp | 8 | ||||
-rw-r--r-- | include/mbgl/map/vector_tile_data.hpp | 3 | ||||
-rw-r--r-- | include/mbgl/renderer/raster_bucket.hpp | 4 | ||||
-rw-r--r-- | include/mbgl/util/raster.hpp | 4 | ||||
-rw-r--r-- | src/map/map.cpp | 2 | ||||
-rw-r--r-- | src/map/raster_tile_data.cpp | 4 | ||||
-rw-r--r-- | src/map/source.cpp | 21 | ||||
-rw-r--r-- | src/map/tile_parser.cpp | 6 | ||||
-rw-r--r-- | src/map/vector_tile_data.cpp | 5 | ||||
-rw-r--r-- | src/renderer/raster_bucket.cpp | 2 | ||||
-rw-r--r-- | src/util/raster.cpp | 6 |
14 files changed, 57 insertions, 30 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index e56a0f81c1..f36ec6d734 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -128,7 +128,6 @@ public: inline const TransformState &getState() const { return state; } inline util::ptr<Style> getStyle() const { return style; } util::ptr<Sprite> getSprite(); - inline util::ptr<Texturepool> getTexturepool() { return texturepool; } inline timestamp getAnimationTime() const { return animationTime; } inline timestamp getTime() const { return animationTime; } void updateTiles(); diff --git a/include/mbgl/map/raster_tile_data.hpp b/include/mbgl/map/raster_tile_data.hpp index 97317537b9..c73897289f 100644 --- a/include/mbgl/map/raster_tile_data.hpp +++ b/include/mbgl/map/raster_tile_data.hpp @@ -11,12 +11,13 @@ class Map; class Painter; class SourceInfo; class StyleLayer; +class Texturepool; class RasterTileData : public TileData { friend class TileParser; public: - RasterTileData(Tile::ID const& id, Map &map, const util::ptr<SourceInfo> &source); + RasterTileData(Tile::ID const& id, Map &map, Texturepool&, const util::ptr<SourceInfo> &source); ~RasterTileData(); virtual void parse(); diff --git a/include/mbgl/map/source.hpp b/include/mbgl/map/source.hpp index 1ceb04d326..a358cfaee5 100644 --- a/include/mbgl/map/source.hpp +++ b/include/mbgl/map/source.hpp @@ -22,6 +22,7 @@ class GlyphAtlas; class GlyphStore; class SpriteAtlas; class FileSource; +class Texturepool; class Painter; class StyleLayer; class TransformState; @@ -32,7 +33,10 @@ public: Source(const util::ptr<SourceInfo>& info); void load(Map&, FileSource&); - bool update(Map&, uv::worker&, GlyphAtlas&, GlyphStore&, SpriteAtlas&, FileSource&); + bool update(Map&, uv::worker&, + GlyphAtlas&, GlyphStore&, + SpriteAtlas&, + Texturepool&, FileSource&); void updateMatrices(const mat4 &projMatrix, const TransformState &transform); void drawClippingMasks(Painter &painter); @@ -51,9 +55,17 @@ private: int32_t coveringZoomLevel(const TransformState&) const; std::forward_list<Tile::ID> coveringTiles(const TransformState&) const; - bool updateTiles(Map&, uv::worker&, GlyphAtlas&, GlyphStore&, SpriteAtlas&, FileSource&); + bool updateTiles(Map&, uv::worker&, + GlyphAtlas&, GlyphStore&, + SpriteAtlas&, + Texturepool&, FileSource&); + + TileData::State addTile(Map&, uv::worker&, + GlyphAtlas&, GlyphStore&, + SpriteAtlas&, + FileSource&, Texturepool&, + const Tile::ID&); - TileData::State addTile(Map&, uv::worker&, GlyphAtlas&, GlyphStore&, SpriteAtlas&, FileSource&, const Tile::ID&); TileData::State hasTile(const Tile::ID& id); double getZoom(const TransformState &state) const; diff --git a/include/mbgl/map/tile_parser.hpp b/include/mbgl/map/tile_parser.hpp index 5e8aa4fc36..460225db9f 100644 --- a/include/mbgl/map/tile_parser.hpp +++ b/include/mbgl/map/tile_parser.hpp @@ -28,6 +28,7 @@ class StyleBucketSymbol; class StyleLayerGroup; class VectorTileData; class Collision; +class Texturepool; class TileParser : private util::noncopyable { @@ -37,7 +38,8 @@ public: GlyphAtlas & glyphAtlas, GlyphStore & glyphStore, SpriteAtlas & spriteAtlas, - const util::ptr<Sprite> &sprite); + const util::ptr<Sprite> &sprite, + Texturepool& texturepool); ~TileParser(); public: @@ -49,7 +51,7 @@ private: std::unique_ptr<Bucket> createBucket(util::ptr<StyleBucket> bucket_desc); std::unique_ptr<Bucket> createFillBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketFill &fill); - std::unique_ptr<Bucket> createRasterBucket(const util::ptr<Texturepool> &texturepool, const StyleBucketRaster &raster); + std::unique_ptr<Bucket> createRasterBucket(Texturepool& texturepool, const StyleBucketRaster &raster); std::unique_ptr<Bucket> createLineBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketLine &line); std::unique_ptr<Bucket> createSymbolBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketSymbol &symbol); @@ -65,7 +67,7 @@ private: GlyphStore & glyphStore; SpriteAtlas & spriteAtlas; util::ptr<Sprite> sprite; - util::ptr<Texturepool> texturePool; + Texturepool& texturePool; std::unique_ptr<Collision> collision; }; diff --git a/include/mbgl/map/vector_tile_data.hpp b/include/mbgl/map/vector_tile_data.hpp index 59846fcaae..56ecfb51eb 100644 --- a/include/mbgl/map/vector_tile_data.hpp +++ b/include/mbgl/map/vector_tile_data.hpp @@ -24,6 +24,7 @@ class TileParser; class GlyphAtlas; class GlyphStore; class SpriteAtlas; +class Texturepool; class VectorTileData : public TileData { friend class TileParser; @@ -32,6 +33,7 @@ public: VectorTileData(Tile::ID const&, Map&, GlyphAtlas&, GlyphStore&, SpriteAtlas&, + Texturepool&, const util::ptr<SourceInfo>&); ~VectorTileData(); @@ -57,6 +59,7 @@ protected: GlyphAtlas& glyphAtlas; GlyphStore& glyphStore; SpriteAtlas& spriteAtlas; + Texturepool& texturepool; public: const float depth; diff --git a/include/mbgl/renderer/raster_bucket.hpp b/include/mbgl/renderer/raster_bucket.hpp index 794da3b143..8c5d9839a5 100644 --- a/include/mbgl/renderer/raster_bucket.hpp +++ b/include/mbgl/renderer/raster_bucket.hpp @@ -16,7 +16,7 @@ class VertexArrayObject; class RasterBucket : public Bucket { public: - RasterBucket(const util::ptr<Texturepool> &texturepool, const StyleBucketRaster& properties); + RasterBucket(Texturepool&, const StyleBucketRaster&); virtual void render(Painter& painter, util::ptr<StyleLayer> layer_desc, const Tile::ID& id, const mat4 &matrix); virtual bool hasData() const; @@ -31,8 +31,6 @@ public: void drawRaster(RasterShader& shader, StaticVertexBuffer &vertices, VertexArrayObject &array, GLuint texture); Raster raster; - -private: }; } diff --git a/include/mbgl/util/raster.hpp b/include/mbgl/util/raster.hpp index 7051c30091..d74c78f714 100644 --- a/include/mbgl/util/raster.hpp +++ b/include/mbgl/util/raster.hpp @@ -17,7 +17,7 @@ namespace mbgl { class Raster : public std::enable_shared_from_this<Raster> { public: - Raster(const util::ptr<Texturepool> &texturepool); + Raster(Texturepool&); ~Raster(); // load image data @@ -57,7 +57,7 @@ private: bool loaded = false; // shared texture pool - util::ptr<Texturepool> texturepool; + Texturepool& texturepool; // min/mag filter uint32_t filter = 0; diff --git a/src/map/map.cpp b/src/map/map.cpp index 750061e082..c0a45b69d9 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -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, getWorker(), glyphAtlas, *glyphStore, spriteAtlas, *fileSource); + source->source->update(*this, getWorker(), glyphAtlas, *glyphStore, spriteAtlas, *texturepool, *fileSource); } } diff --git a/src/map/raster_tile_data.cpp b/src/map/raster_tile_data.cpp index 1552e359bd..04e89d9e37 100644 --- a/src/map/raster_tile_data.cpp +++ b/src/map/raster_tile_data.cpp @@ -5,9 +5,9 @@ using namespace mbgl; -RasterTileData::RasterTileData(Tile::ID const& id_, Map &map_, const util::ptr<SourceInfo> &source_) +RasterTileData::RasterTileData(Tile::ID const& id_, Map &map_, Texturepool& texturepool, const util::ptr<SourceInfo> &source_) : TileData(id_, map_, source_), - bucket(map.getTexturepool(), properties) { + bucket(texturepool, properties) { } RasterTileData::~RasterTileData() { diff --git a/src/map/source.cpp b/src/map/source.cpp index 72e63f9e17..d68ea1a167 100644 --- a/src/map/source.cpp +++ b/src/map/source.cpp @@ -63,9 +63,10 @@ void Source::load(Map& map, FileSource& fileSource) { bool Source::update(Map& map, uv::worker& worker, GlyphAtlas& glyphAtlas, GlyphStore& glyphStore, - SpriteAtlas& spriteAtlas, FileSource& fileSource) { + SpriteAtlas& spriteAtlas, + Texturepool& texturepool, FileSource& fileSource) { if (loaded && map.getTime() > updated) { - return updateTiles(map, worker, glyphAtlas, glyphStore, spriteAtlas, fileSource); + return updateTiles(map, worker, glyphAtlas, glyphStore, spriteAtlas, texturepool, fileSource); } else { return false; } @@ -164,7 +165,8 @@ TileData::State Source::hasTile(const Tile::ID& id) { TileData::State Source::addTile(Map& map, uv::worker& worker, GlyphAtlas& glyphAtlas, GlyphStore& glyphStore, SpriteAtlas& spriteAtlas, - FileSource& fileSource, const Tile::ID& id) { + FileSource& fileSource, Texturepool& texturepool, + const Tile::ID& id) { const TileData::State state = hasTile(id); if (state != TileData::State::invalid) { @@ -192,9 +194,9 @@ 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, info); + new_tile.data = std::make_shared<VectorTileData>(normalized_id, map, glyphAtlas, glyphStore, spriteAtlas, texturepool, info); } else if (info->type == SourceType::Raster) { - new_tile.data = std::make_shared<RasterTileData>(normalized_id, map, info); + new_tile.data = std::make_shared<RasterTileData>(normalized_id, map, texturepool, info); } else { throw std::runtime_error("source type not implemented"); } @@ -288,7 +290,8 @@ 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, FileSource& fileSource) { + SpriteAtlas& spriteAtlas, + Texturepool& texturepool, FileSource& fileSource) { bool changed = false; int32_t zoom = std::floor(getZoom(map.getState())); @@ -305,7 +308,11 @@ bool Source::updateTiles(Map& map, uv::worker& worker, // 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, worker, glyphAtlas, glyphStore, spriteAtlas, fileSource, id); + const TileData::State state = addTile(map, worker, + glyphAtlas, glyphStore, + spriteAtlas, + fileSource, texturepool, + id); if (state != TileData::State::parsed) { // The tile we require is not yet loaded. Try to find a parent or diff --git a/src/map/tile_parser.cpp b/src/map/tile_parser.cpp index 768b7da9fd..dcbac71c7c 100644 --- a/src/map/tile_parser.cpp +++ b/src/map/tile_parser.cpp @@ -34,7 +34,8 @@ TileParser::TileParser(const std::string &data, VectorTileData &tile_, GlyphAtlas & glyphAtlas_, GlyphStore & glyphStore_, SpriteAtlas & spriteAtlas_, - const util::ptr<Sprite> &sprite_) + const util::ptr<Sprite> &sprite_, + Texturepool& texturePool_) : vector_data(pbf((const uint8_t *)data.data(), data.size())), tile(tile_), style(style_), @@ -42,6 +43,7 @@ TileParser::TileParser(const std::string &data, VectorTileData &tile_, glyphStore(glyphStore_), spriteAtlas(spriteAtlas_), sprite(sprite_), + texturePool(texturePool_), collision(std::make_unique<Collision>(tile.id.z, 4096, tile.source->tile_size, tile.depth)) { assert(&tile != nullptr); assert(style); @@ -153,7 +155,7 @@ std::unique_ptr<Bucket> TileParser::createFillBucket(const VectorTileLayer& laye return obsolete() ? nullptr : std::move(bucket); } -std::unique_ptr<Bucket> TileParser::createRasterBucket(const util::ptr<Texturepool> &texturepool, const StyleBucketRaster &raster) { +std::unique_ptr<Bucket> TileParser::createRasterBucket(Texturepool& texturepool, const StyleBucketRaster &raster) { std::unique_ptr<RasterBucket> bucket = std::make_unique<RasterBucket>(texturepool, raster); return obsolete() ? nullptr : std::move(bucket); } diff --git a/src/map/vector_tile_data.cpp b/src/map/vector_tile_data.cpp index d2f73269c0..fde181e2cb 100644 --- a/src/map/vector_tile_data.cpp +++ b/src/map/vector_tile_data.cpp @@ -11,11 +11,13 @@ using namespace mbgl; VectorTileData::VectorTileData(Tile::ID const& id_, Map &map_, GlyphAtlas& glyphAtlas_, GlyphStore& glyphStore_, SpriteAtlas& spriteAtlas_, + Texturepool& texturepool_, const util::ptr<SourceInfo> &source_) : TileData(id_, map_, source_), glyphAtlas(glyphAtlas_), glyphStore(glyphStore_), spriteAtlas(spriteAtlas_), + texturepool(texturepool_), depth(id.z >= source->max_zoom ? map.getMaxZoom() - id.z : 1) { } @@ -35,7 +37,8 @@ void VectorTileData::parse() { // is going to be discarded afterwards. TileParser parser(data, *this, map.getStyle(), glyphAtlas, glyphStore, - spriteAtlas, map.getSprite()); + spriteAtlas, map.getSprite(), + texturepool); parser.parse(); } catch (const std::exception& ex) { #if defined(DEBUG) diff --git a/src/renderer/raster_bucket.cpp b/src/renderer/raster_bucket.cpp index 7adb3f845e..12b2b9e514 100644 --- a/src/renderer/raster_bucket.cpp +++ b/src/renderer/raster_bucket.cpp @@ -3,7 +3,7 @@ using namespace mbgl; -RasterBucket::RasterBucket(const util::ptr<Texturepool> &texturepool, const StyleBucketRaster& properties_) +RasterBucket::RasterBucket(Texturepool& texturepool, const StyleBucketRaster& properties_) : properties(properties_), texture(properties_), raster(texturepool) { diff --git a/src/util/raster.cpp b/src/util/raster.cpp index 76cd411223..4f6acc36cf 100644 --- a/src/util/raster.cpp +++ b/src/util/raster.cpp @@ -11,13 +11,13 @@ using namespace mbgl; -Raster::Raster(const util::ptr<Texturepool> &texturepool_) +Raster::Raster(Texturepool& texturepool_) : texturepool(texturepool_) {} Raster::~Raster() { if (textured) { - texturepool->removeTextureID(texture); + texturepool.removeTextureID(texture); } } @@ -46,7 +46,7 @@ void Raster::bind(bool linear) { } if (img && !textured) { - texture = texturepool->getTextureID(); + texture = texturepool.getTextureID(); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |