Texturepool ⇢ TexturePool (fixes #655)
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
#include <mbgl/geometry/glyph_atlas.hpp>
|
||||
#include <mbgl/style/style_layer_group.hpp>
|
||||
#include <mbgl/style/style_bucket.hpp>
|
||||
#include <mbgl/util/texturepool.hpp>
|
||||
#include <mbgl/util/texture_pool.hpp>
|
||||
#include <mbgl/geometry/sprite_atlas.hpp>
|
||||
#include <mbgl/storage/file_source.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
@@ -94,7 +94,7 @@ Map::Map(View& view_)
|
||||
transform(view_),
|
||||
glyphAtlas(1024, 1024),
|
||||
spriteAtlas(512, 512),
|
||||
texturepool(std::make_shared<Texturepool>()),
|
||||
texturePool(std::make_shared<TexturePool>()),
|
||||
painter(spriteAtlas, glyphAtlas)
|
||||
{
|
||||
view.initialize(this);
|
||||
@@ -114,7 +114,7 @@ Map::~Map() {
|
||||
sprite.reset();
|
||||
glyphStore.reset();
|
||||
style.reset();
|
||||
texturepool.reset();
|
||||
texturePool.reset();
|
||||
fileSource.reset();
|
||||
workers.reset();
|
||||
|
||||
@@ -588,7 +588,7 @@ void Map::updateTiles() {
|
||||
source->source->update(*this, getWorker(),
|
||||
style, glyphAtlas, *glyphStore,
|
||||
spriteAtlas, getSprite(),
|
||||
*texturepool, *fileSource, [this](){ update(); });
|
||||
*texturePool, *fileSource, [this](){ update(); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
using namespace mbgl;
|
||||
|
||||
|
||||
RasterTileData::RasterTileData(Tile::ID const& id_, Texturepool& texturepool, const SourceInfo& source_)
|
||||
RasterTileData::RasterTileData(Tile::ID const& id_, TexturePool& texturePool, const SourceInfo& source_)
|
||||
: TileData(id_, source_),
|
||||
bucket(texturepool, properties) {
|
||||
bucket(texturePool, properties) {
|
||||
}
|
||||
|
||||
RasterTileData::~RasterTileData() {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <mbgl/util/constants.hpp>
|
||||
#include <mbgl/util/raster.hpp>
|
||||
#include <mbgl/util/string.hpp>
|
||||
#include <mbgl/util/texturepool.hpp>
|
||||
#include <mbgl/util/texture_pool.hpp>
|
||||
#include <mbgl/storage/file_source.hpp>
|
||||
#include <mbgl/util/vec.hpp>
|
||||
#include <mbgl/util/math.hpp>
|
||||
@@ -155,7 +155,7 @@ TileData::State Source::addTile(Map& map, uv::worker& worker,
|
||||
util::ptr<Style> style,
|
||||
GlyphAtlas& glyphAtlas, GlyphStore& glyphStore,
|
||||
SpriteAtlas& spriteAtlas, util::ptr<Sprite> sprite,
|
||||
FileSource& fileSource, Texturepool& texturepool,
|
||||
FileSource& fileSource, TexturePool& texturePool,
|
||||
const Tile::ID& id,
|
||||
std::function<void ()> callback) {
|
||||
const TileData::State state = hasTile(id);
|
||||
@@ -188,9 +188,9 @@ TileData::State Source::addTile(Map& map, uv::worker& worker,
|
||||
new_tile.data = std::make_shared<VectorTileData>(normalized_id, map.getMaxZoom(), style,
|
||||
glyphAtlas, glyphStore,
|
||||
spriteAtlas, sprite,
|
||||
texturepool, info);
|
||||
texturePool, info);
|
||||
} else if (info.type == SourceType::Raster) {
|
||||
new_tile.data = std::make_shared<RasterTileData>(normalized_id, texturepool, info);
|
||||
new_tile.data = std::make_shared<RasterTileData>(normalized_id, texturePool, info);
|
||||
} else {
|
||||
throw std::runtime_error("source type not implemented");
|
||||
}
|
||||
@@ -286,7 +286,7 @@ void Source::update(Map& map, uv::worker& worker,
|
||||
util::ptr<Style> style,
|
||||
GlyphAtlas& glyphAtlas, GlyphStore& glyphStore,
|
||||
SpriteAtlas& spriteAtlas, util::ptr<Sprite> sprite,
|
||||
Texturepool& texturepool, FileSource& fileSource,
|
||||
TexturePool& texturePool, FileSource& fileSource,
|
||||
std::function<void ()> callback) {
|
||||
if (!loaded || map.getTime() <= updated)
|
||||
return;
|
||||
@@ -310,7 +310,7 @@ void Source::update(Map& map, uv::worker& worker,
|
||||
const TileData::State state = addTile(map, worker, style,
|
||||
glyphAtlas, glyphStore,
|
||||
spriteAtlas, sprite,
|
||||
fileSource, texturepool,
|
||||
fileSource, texturePool,
|
||||
id, callback);
|
||||
|
||||
if (state != TileData::State::parsed) {
|
||||
|
||||
@@ -35,7 +35,7 @@ TileParser::TileParser(const std::string &data, VectorTileData &tile_,
|
||||
GlyphStore & glyphStore_,
|
||||
SpriteAtlas & spriteAtlas_,
|
||||
const util::ptr<Sprite> &sprite_,
|
||||
Texturepool& texturePool_)
|
||||
TexturePool& texturePool_)
|
||||
: vector_data(pbf((const uint8_t *)data.data(), data.size())),
|
||||
tile(tile_),
|
||||
style(style_),
|
||||
@@ -119,7 +119,7 @@ std::unique_ptr<Bucket> TileParser::createBucket(util::ptr<StyleBucket> bucket_d
|
||||
fprintf(stderr, "[WARNING] unknown bucket render type for layer '%s' (source layer '%s')\n", bucket_desc->name.c_str(), bucket_desc->source_layer.c_str());
|
||||
}
|
||||
} else if (bucket_desc->render.is<StyleBucketRaster>() && bucket_desc->render.get<StyleBucketRaster>().prerendered == true) {
|
||||
return createRasterBucket(texturePool, bucket_desc->render.get<StyleBucketRaster>());
|
||||
return createRasterBucket(bucket_desc->render.get<StyleBucketRaster>());
|
||||
} else {
|
||||
// The layer specified in the bucket does not exist. Do nothing.
|
||||
if (debug::tileParseWarnings) {
|
||||
@@ -155,8 +155,8 @@ std::unique_ptr<Bucket> TileParser::createFillBucket(const VectorTileLayer& laye
|
||||
return obsolete() ? nullptr : std::move(bucket);
|
||||
}
|
||||
|
||||
std::unique_ptr<Bucket> TileParser::createRasterBucket(Texturepool& texturepool, const StyleBucketRaster &raster) {
|
||||
std::unique_ptr<RasterBucket> bucket = std::make_unique<RasterBucket>(texturepool, raster);
|
||||
std::unique_ptr<Bucket> TileParser::createRasterBucket(const StyleBucketRaster &raster) {
|
||||
std::unique_ptr<RasterBucket> bucket = std::make_unique<RasterBucket>(texturePool, raster);
|
||||
return obsolete() ? nullptr : std::move(bucket);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,14 +12,14 @@ VectorTileData::VectorTileData(Tile::ID const& id_,
|
||||
float mapMaxZoom, util::ptr<Style> style_,
|
||||
GlyphAtlas& glyphAtlas_, GlyphStore& glyphStore_,
|
||||
SpriteAtlas& spriteAtlas_, util::ptr<Sprite> sprite_,
|
||||
Texturepool& texturepool_,
|
||||
TexturePool& texturePool_,
|
||||
const SourceInfo& source_)
|
||||
: TileData(id_, source_),
|
||||
glyphAtlas(glyphAtlas_),
|
||||
glyphStore(glyphStore_),
|
||||
spriteAtlas(spriteAtlas_),
|
||||
sprite(sprite_),
|
||||
texturepool(texturepool_),
|
||||
texturePool(texturePool_),
|
||||
style(style_),
|
||||
depth(id.z >= source.max_zoom ? mapMaxZoom - id.z : 1) {
|
||||
}
|
||||
@@ -41,7 +41,7 @@ void VectorTileData::parse() {
|
||||
TileParser parser(data, *this, style,
|
||||
glyphAtlas, glyphStore,
|
||||
spriteAtlas, sprite,
|
||||
texturepool);
|
||||
texturePool);
|
||||
parser.parse();
|
||||
} catch (const std::exception& ex) {
|
||||
#if defined(DEBUG)
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
RasterBucket::RasterBucket(Texturepool& texturepool, const StyleBucketRaster& properties_)
|
||||
RasterBucket::RasterBucket(TexturePool& texturePool, const StyleBucketRaster& properties_)
|
||||
: properties(properties_),
|
||||
texture(properties_),
|
||||
raster(texturepool) {
|
||||
raster(texturePool) {
|
||||
}
|
||||
|
||||
void RasterBucket::render(Painter &painter, util::ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix) {
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
Raster::Raster(Texturepool& texturepool_)
|
||||
: 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);
|
||||
#ifndef GL_ES_VERSION_2_0
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <mbgl/util/texturepool.hpp>
|
||||
#include <mbgl/util/texture_pool.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -6,7 +6,7 @@ const int TextureMax = 64;
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
GLuint Texturepool::getTextureID() {
|
||||
GLuint TexturePool::getTextureID() {
|
||||
if (texture_ids.empty()) {
|
||||
GLuint new_texture_ids[TextureMax];
|
||||
glGenTextures(TextureMax, new_texture_ids);
|
||||
@@ -26,7 +26,7 @@ GLuint Texturepool::getTextureID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
void Texturepool::removeTextureID(GLuint texture_id) {
|
||||
void TexturePool::removeTextureID(GLuint texture_id) {
|
||||
bool needs_clear = false;
|
||||
|
||||
texture_ids.insert(texture_id);
|
||||
@@ -41,7 +41,7 @@ void Texturepool::removeTextureID(GLuint texture_id) {
|
||||
}
|
||||
}
|
||||
|
||||
void Texturepool::clearTextureIDs() {
|
||||
void TexturePool::clearTextureIDs() {
|
||||
std::vector<GLuint> ids_to_remove;
|
||||
ids_to_remove.reserve(texture_ids.size());
|
||||
|
||||
Reference in New Issue
Block a user