summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2014-11-25 13:36:07 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2014-11-26 15:13:13 -0800
commit576533b18c7ecc93656f840994d90a3bb86ae239 (patch)
tree59867819363f56d4ccdf68198bceb763ec46baa5 /src
parent3aa15306f6b9df452a42a419b2096e41ba11d414 (diff)
downloadqtlocation-mapboxgl-576533b18c7ecc93656f840994d90a3bb86ae239.tar.gz
Eliminate Map::getTexturepool()
Diffstat (limited to 'src')
-rw-r--r--src/map/map.cpp2
-rw-r--r--src/map/raster_tile_data.cpp4
-rw-r--r--src/map/source.cpp21
-rw-r--r--src/map/tile_parser.cpp6
-rw-r--r--src/map/vector_tile_data.cpp5
-rw-r--r--src/renderer/raster_bucket.cpp2
-rw-r--r--src/util/raster.cpp6
7 files changed, 29 insertions, 17 deletions
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);