Merge branch 'master' of github.com:mapbox/mapbox-gl-native into android-mason
Conflicts: include/mbgl/map/map.hpp src/map/map.cpp
This commit is contained in:
2
configure
vendored
2
configure
vendored
@@ -45,7 +45,7 @@ case ${MASON_PLATFORM} in
|
||||
LIBUV_VERSION=0.10.28
|
||||
ZLIB_VERSION=system
|
||||
BOOST_VERSION=system
|
||||
NUNICODE_VERSION=1.5-dev
|
||||
NUNICODE_VERSION=1.5.1
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
'variables': {
|
||||
'cflags_cc': [
|
||||
'<@(png_cflags)',
|
||||
'<@(jpeg_cflags)',
|
||||
'<@(jpeg_cflags)',
|
||||
'<@(uv_cflags)',
|
||||
'<@(curl_cflags)',
|
||||
'<@(nu_cflags)',
|
||||
|
||||
@@ -26,7 +26,7 @@ class Style;
|
||||
class StyleLayer;
|
||||
class StyleLayerGroup;
|
||||
class StyleSource;
|
||||
class Texturepool;
|
||||
class TexturePool;
|
||||
class FileSource;
|
||||
class View;
|
||||
|
||||
@@ -82,12 +82,12 @@ public:
|
||||
void setAppliedClasses(const std::vector<std::string> &classes);
|
||||
void toggleClass(const std::string &name);
|
||||
const std::vector<std::string> &getAppliedClasses() const;
|
||||
void setDefaultTransitionDuration(uint64_t duration_milliseconds = 0);
|
||||
void setDefaultTransitionDuration(uint64_t milliseconds = 0);
|
||||
uint64_t getDefaultTransitionDuration();
|
||||
void setStyleURL(const std::string &url);
|
||||
void setStyleJSON(std::string newStyleJSON, const std::string &base = "");
|
||||
std::string getStyleJSON() const;
|
||||
void setAccessToken(std::string access_token);
|
||||
void setAccessToken(std::string accessToken);
|
||||
std::string getAccessToken() const;
|
||||
|
||||
// Transition
|
||||
@@ -160,9 +160,9 @@ private:
|
||||
std::unique_ptr<uv::loop> loop;
|
||||
std::unique_ptr<uv::worker> workers;
|
||||
std::unique_ptr<uv::thread> thread;
|
||||
std::unique_ptr<uv::async> async_terminate;
|
||||
std::unique_ptr<uv::async> async_render;
|
||||
std::unique_ptr<uv::async> async_cleanup;
|
||||
std::unique_ptr<uv::async> asyncTerminate;
|
||||
std::unique_ptr<uv::async> asyncRender;
|
||||
std::unique_ptr<uv::async> asyncCleanup;
|
||||
|
||||
bool terminating = false;
|
||||
bool pausing = false;
|
||||
@@ -174,24 +174,24 @@ private:
|
||||
|
||||
// If cleared, the next time the render thread attempts to render the map, it will *actually*
|
||||
// render the map.
|
||||
std::atomic_flag is_clean = ATOMIC_FLAG_INIT;
|
||||
std::atomic_flag isClean = ATOMIC_FLAG_INIT;
|
||||
|
||||
// If this flag is cleared, the current back buffer is ready for being swapped with the front
|
||||
// buffer (i.e. it has rendered data).
|
||||
std::atomic_flag is_swapped = ATOMIC_FLAG_INIT;
|
||||
std::atomic_flag isSwapped = ATOMIC_FLAG_INIT;
|
||||
|
||||
// This is cleared once the current front buffer has been presented and the back buffer is
|
||||
// ready for rendering.
|
||||
std::atomic_flag is_rendered = ATOMIC_FLAG_INIT;
|
||||
std::atomic_flag isRendered = ATOMIC_FLAG_INIT;
|
||||
|
||||
// Stores whether the map thread has been stopped already.
|
||||
std::atomic_bool is_stopped;
|
||||
std::atomic_bool isStopped;
|
||||
|
||||
View &view;
|
||||
|
||||
#ifndef NDEBUG
|
||||
const unsigned long main_thread;
|
||||
unsigned long map_thread = -1;
|
||||
const unsigned long mainThread;
|
||||
unsigned long mapThread = -1;
|
||||
#endif
|
||||
|
||||
Transform transform;
|
||||
@@ -204,7 +204,7 @@ private:
|
||||
util::ptr<GlyphStore> glyphStore;
|
||||
SpriteAtlas spriteAtlas;
|
||||
util::ptr<Sprite> sprite;
|
||||
util::ptr<Texturepool> texturepool;
|
||||
util::ptr<TexturePool> texturePool;
|
||||
|
||||
Painter painter;
|
||||
|
||||
|
||||
@@ -10,13 +10,13 @@ namespace mbgl {
|
||||
class Painter;
|
||||
class SourceInfo;
|
||||
class StyleLayer;
|
||||
class Texturepool;
|
||||
class TexturePool;
|
||||
|
||||
class RasterTileData : public TileData {
|
||||
friend class TileParser;
|
||||
|
||||
public:
|
||||
RasterTileData(Tile::ID const& id, Texturepool&, const SourceInfo&);
|
||||
RasterTileData(Tile::ID const& id, TexturePool&, const SourceInfo&);
|
||||
~RasterTileData();
|
||||
|
||||
virtual void parse();
|
||||
|
||||
@@ -23,7 +23,7 @@ class GlyphStore;
|
||||
class SpriteAtlas;
|
||||
class Sprite;
|
||||
class FileSource;
|
||||
class Texturepool;
|
||||
class TexturePool;
|
||||
class Style;
|
||||
class Painter;
|
||||
class StyleLayer;
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
util::ptr<Style>,
|
||||
GlyphAtlas&, GlyphStore&,
|
||||
SpriteAtlas&, util::ptr<Sprite>,
|
||||
Texturepool&, FileSource&,
|
||||
TexturePool&, FileSource&,
|
||||
std::function<void ()> callback);
|
||||
|
||||
void updateMatrices(const mat4 &projMatrix, const TransformState &transform);
|
||||
@@ -63,7 +63,7 @@ private:
|
||||
util::ptr<Style>,
|
||||
GlyphAtlas&, GlyphStore&,
|
||||
SpriteAtlas&, util::ptr<Sprite>,
|
||||
FileSource&, Texturepool&,
|
||||
FileSource&, TexturePool&,
|
||||
const Tile::ID&,
|
||||
std::function<void ()> callback);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
namespace mbgl {
|
||||
|
||||
class Bucket;
|
||||
class Texturepool;
|
||||
class TexturePool;
|
||||
class FontStack;
|
||||
class GlyphAtlas;
|
||||
class GlyphStore;
|
||||
@@ -28,7 +28,7 @@ class StyleBucketSymbol;
|
||||
class StyleLayerGroup;
|
||||
class VectorTileData;
|
||||
class Collision;
|
||||
class Texturepool;
|
||||
class TexturePool;
|
||||
|
||||
class TileParser : private util::noncopyable
|
||||
{
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
GlyphStore & glyphStore,
|
||||
SpriteAtlas & spriteAtlas,
|
||||
const util::ptr<Sprite> &sprite,
|
||||
Texturepool& texturepool);
|
||||
TexturePool& texturePool);
|
||||
~TileParser();
|
||||
|
||||
public:
|
||||
@@ -51,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(Texturepool& texturepool, const StyleBucketRaster &raster);
|
||||
std::unique_ptr<Bucket> createRasterBucket(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);
|
||||
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
GlyphStore & glyphStore;
|
||||
SpriteAtlas & spriteAtlas;
|
||||
util::ptr<Sprite> sprite;
|
||||
Texturepool& texturePool;
|
||||
TexturePool& texturePool;
|
||||
|
||||
std::unique_ptr<Collision> collision;
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ class GlyphAtlas;
|
||||
class GlyphStore;
|
||||
class SpriteAtlas;
|
||||
class Sprite;
|
||||
class Texturepool;
|
||||
class TexturePool;
|
||||
class Style;
|
||||
|
||||
class VectorTileData : public TileData {
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
float mapMaxZoom, util::ptr<Style>,
|
||||
GlyphAtlas&, GlyphStore&,
|
||||
SpriteAtlas&, util::ptr<Sprite>,
|
||||
Texturepool&,
|
||||
TexturePool&,
|
||||
const SourceInfo&);
|
||||
~VectorTileData();
|
||||
|
||||
@@ -62,7 +62,7 @@ protected:
|
||||
GlyphStore& glyphStore;
|
||||
SpriteAtlas& spriteAtlas;
|
||||
util::ptr<Sprite> sprite;
|
||||
Texturepool& texturepool;
|
||||
TexturePool& texturePool;
|
||||
util::ptr<Style> style;
|
||||
|
||||
public:
|
||||
|
||||
@@ -16,7 +16,7 @@ class VertexArrayObject;
|
||||
|
||||
class RasterBucket : public Bucket {
|
||||
public:
|
||||
RasterBucket(Texturepool&, const StyleBucketRaster&);
|
||||
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;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define MBGL_UTIL_RASTER
|
||||
|
||||
#include <mbgl/util/transition.hpp>
|
||||
#include <mbgl/util/texturepool.hpp>
|
||||
#include <mbgl/util/texture_pool.hpp>
|
||||
#include <mbgl/util/image.hpp>
|
||||
#include <mbgl/util/ptr.hpp>
|
||||
#include <mbgl/renderer/prerendered_texture.hpp>
|
||||
@@ -17,7 +17,7 @@ namespace mbgl {
|
||||
class Raster : public std::enable_shared_from_this<Raster> {
|
||||
|
||||
public:
|
||||
Raster(Texturepool&);
|
||||
Raster(TexturePool&);
|
||||
~Raster();
|
||||
|
||||
// load image data
|
||||
@@ -57,7 +57,7 @@ private:
|
||||
bool loaded = false;
|
||||
|
||||
// shared texture pool
|
||||
Texturepool& texturepool;
|
||||
TexturePool& texturePool;
|
||||
|
||||
// min/mag filter
|
||||
uint32_t filter = 0;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class Texturepool : private util::noncopyable {
|
||||
class TexturePool : private util::noncopyable {
|
||||
|
||||
public:
|
||||
GLuint getTextureID();
|
||||
@@ -20,10 +20,26 @@ void close(T* handle) {
|
||||
|
||||
class thread : public mbgl::util::noncopyable {
|
||||
public:
|
||||
inline operator uv_thread_t *() { return &t; }
|
||||
inline thread(std::function<void ()> fn_)
|
||||
: fn(fn_) {
|
||||
if (uv_thread_create(&t, thread_cb, this) != 0) {
|
||||
throw std::runtime_error("failed to initialize thread");
|
||||
}
|
||||
}
|
||||
|
||||
void join() {
|
||||
if (uv_thread_join(&t) != 0) {
|
||||
throw std::runtime_error("failed to join thred");
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static void thread_cb(void* data) {
|
||||
reinterpret_cast<thread*>(data)->fn();
|
||||
}
|
||||
|
||||
uv_thread_t t;
|
||||
std::function<void ()> fn;
|
||||
};
|
||||
|
||||
class loop : public mbgl::util::noncopyable {
|
||||
|
||||
117
src/map/map.cpp
117
src/map/map.cpp
@@ -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>
|
||||
@@ -91,22 +91,21 @@ using namespace mbgl;
|
||||
|
||||
Map::Map(View& view_)
|
||||
: loop(std::make_unique<uv::loop>()),
|
||||
thread(std::make_unique<uv::thread>()),
|
||||
view(view_),
|
||||
#ifndef NDEBUG
|
||||
main_thread(uv_thread_self()),
|
||||
mainThread(uv_thread_self()),
|
||||
#endif
|
||||
transform(view_),
|
||||
glyphAtlas(1024, 1024),
|
||||
spriteAtlas(512, 512),
|
||||
texturepool(std::make_shared<Texturepool>()),
|
||||
texturePool(std::make_shared<TexturePool>()),
|
||||
painter(spriteAtlas, glyphAtlas)
|
||||
{
|
||||
view.initialize(this);
|
||||
// Make sure that we're doing an initial drawing in all cases.
|
||||
is_clean.clear();
|
||||
is_rendered.clear();
|
||||
is_swapped.test_and_set();
|
||||
isClean.clear();
|
||||
isRendered.clear();
|
||||
isSwapped.test_and_set();
|
||||
}
|
||||
|
||||
Map::~Map() {
|
||||
@@ -119,7 +118,7 @@ Map::~Map() {
|
||||
sprite.reset();
|
||||
glyphStore.reset();
|
||||
style.reset();
|
||||
texturepool.reset();
|
||||
texturePool.reset();
|
||||
fileSource.reset();
|
||||
workers.reset();
|
||||
|
||||
@@ -134,7 +133,7 @@ uv::worker &Map::getWorker() {
|
||||
}
|
||||
|
||||
void Map::start(bool start_paused) {
|
||||
assert(uv_thread_self() == main_thread);
|
||||
assert(uv_thread_self() == mainThread);
|
||||
assert(!async);
|
||||
|
||||
// When starting map rendering in another thread, we perform async/continuously
|
||||
@@ -142,11 +141,11 @@ void Map::start(bool start_paused) {
|
||||
async = true;
|
||||
|
||||
// Reset the flag.
|
||||
is_stopped = false;
|
||||
isStopped = false;
|
||||
|
||||
// Setup async notifications
|
||||
async_terminate = std::make_unique<uv::async>(**loop, [this]() {
|
||||
assert(uv_thread_self() == map_thread);
|
||||
asyncTerminate = std::make_unique<uv::async>(**loop, [this]() {
|
||||
assert(uv_thread_self() == mapThread);
|
||||
|
||||
// Remove all of these to make sure they are destructed in the correct thread.
|
||||
glyphStore.reset();
|
||||
@@ -158,31 +157,31 @@ void Map::start(bool start_paused) {
|
||||
terminating = true;
|
||||
|
||||
// Closes all open handles on the loop. This means that the loop will automatically terminate.
|
||||
async_cleanup.reset();
|
||||
async_render.reset();
|
||||
async_terminate.reset();
|
||||
asyncCleanup.reset();
|
||||
asyncRender.reset();
|
||||
asyncTerminate.reset();
|
||||
});
|
||||
|
||||
async_render = std::make_unique<uv::async>(**loop, [this]() {
|
||||
assert(uv_thread_self() == map_thread);
|
||||
asyncRender = std::make_unique<uv::async>(**loop, [this]() {
|
||||
assert(uv_thread_self() == mapThread);
|
||||
|
||||
if (state.hasSize()) {
|
||||
if (is_rendered.test_and_set() == false) {
|
||||
if (isRendered.test_and_set() == false) {
|
||||
prepare();
|
||||
if (is_clean.test_and_set() == false) {
|
||||
if (isClean.test_and_set() == false) {
|
||||
render();
|
||||
is_swapped.clear();
|
||||
isSwapped.clear();
|
||||
view.swap();
|
||||
} else {
|
||||
// We set the rendered flag in the test above, so we have to reset it
|
||||
// now that we're not actually rendering because the map is clean.
|
||||
is_rendered.clear();
|
||||
isRendered.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
async_cleanup = std::make_unique<uv::async>(**loop, [this]() {
|
||||
asyncCleanup = std::make_unique<uv::async>(**loop, [this]() {
|
||||
painter.cleanup();
|
||||
});
|
||||
|
||||
@@ -191,31 +190,33 @@ void Map::start(bool start_paused) {
|
||||
pause();
|
||||
}
|
||||
|
||||
uv_thread_create(*thread, [](void *arg) {
|
||||
Map *map = static_cast<Map *>(arg);
|
||||
thread = std::make_unique<uv::thread>([this]() {
|
||||
#ifndef NDEBUG
|
||||
map->map_thread = uv_thread_self();
|
||||
mapThread = uv_thread_self();
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
pthread_setname_np("Map");
|
||||
#endif
|
||||
map->run();
|
||||
|
||||
run();
|
||||
|
||||
#ifndef NDEBUG
|
||||
map->map_thread = -1;
|
||||
mapThread = -1;
|
||||
#endif
|
||||
|
||||
// Make sure that the stop() function knows when to stop invoking the callback function.
|
||||
map->is_stopped = true;
|
||||
map->view.notify();
|
||||
}, this);
|
||||
isStopped = true;
|
||||
view.notify();
|
||||
});
|
||||
}
|
||||
|
||||
void Map::stop(stop_callback cb, void *data) {
|
||||
assert(uv_thread_self() == main_thread);
|
||||
assert(main_thread != map_thread);
|
||||
assert(uv_thread_self() == mainThread);
|
||||
assert(mainThread != mapThread);
|
||||
assert(async);
|
||||
|
||||
async_terminate->send();
|
||||
asyncTerminate->send();
|
||||
|
||||
resume();
|
||||
|
||||
@@ -226,14 +227,14 @@ void Map::stop(stop_callback cb, void *data) {
|
||||
// the case with Cocoa's NSURLRequest. Otherwise, we will eventually deadlock because this
|
||||
// thread (== main thread) is blocked. The callback function should use an efficient waiting
|
||||
// function to avoid a busy waiting loop.
|
||||
while (!is_stopped) {
|
||||
while (!isStopped) {
|
||||
cb(data);
|
||||
}
|
||||
}
|
||||
|
||||
// If a callback function was provided, this should return immediately because the thread has
|
||||
// already finished executing.
|
||||
uv_thread_join(*thread);
|
||||
thread->join();
|
||||
|
||||
async = false;
|
||||
}
|
||||
@@ -273,10 +274,10 @@ void Map::run() {
|
||||
|
||||
#ifndef NDEBUG
|
||||
if (!async) {
|
||||
map_thread = main_thread;
|
||||
mapThread = mainThread;
|
||||
}
|
||||
#endif
|
||||
assert(uv_thread_self() == map_thread);
|
||||
assert(uv_thread_self() == mapThread);
|
||||
|
||||
if (async) {
|
||||
check_for_pause();
|
||||
@@ -303,7 +304,7 @@ void Map::run() {
|
||||
if (!async) {
|
||||
render();
|
||||
#ifndef NDEBUG
|
||||
map_thread = -1;
|
||||
mapThread = -1;
|
||||
#endif
|
||||
}
|
||||
#ifdef __ANDROID__
|
||||
@@ -338,27 +339,27 @@ void Map::rerender() {
|
||||
// We only send render events if we want to continuously update the map
|
||||
// (== async rendering).
|
||||
if (async) {
|
||||
async_render->send();
|
||||
asyncRender->send();
|
||||
}
|
||||
}
|
||||
|
||||
void Map::update() {
|
||||
is_clean.clear();
|
||||
isClean.clear();
|
||||
rerender();
|
||||
}
|
||||
|
||||
bool Map::needsSwap() {
|
||||
return is_swapped.test_and_set() == false;
|
||||
return isSwapped.test_and_set() == false;
|
||||
}
|
||||
|
||||
void Map::swapped() {
|
||||
is_rendered.clear();
|
||||
isRendered.clear();
|
||||
rerender();
|
||||
}
|
||||
|
||||
void Map::cleanup() {
|
||||
if (async_cleanup != nullptr) {
|
||||
async_cleanup->send();
|
||||
if (asyncCleanup != nullptr) {
|
||||
asyncCleanup->send();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,7 +381,7 @@ void Map::setReachability(bool reachable) {
|
||||
#pragma mark - Setup
|
||||
|
||||
void Map::setup() {
|
||||
assert(uv_thread_self() == map_thread);
|
||||
assert(uv_thread_self() == mapThread);
|
||||
view.make_active();
|
||||
painter.setup();
|
||||
}
|
||||
@@ -433,9 +434,9 @@ std::string Map::getStyleJSON() const {
|
||||
return styleJSON;
|
||||
}
|
||||
|
||||
void Map::setAccessToken(std::string access_token) {
|
||||
void Map::setAccessToken(std::string accessToken_) {
|
||||
// TODO: Make threadsafe.
|
||||
accessToken.swap(access_token);
|
||||
accessToken.swap(accessToken_);
|
||||
}
|
||||
|
||||
std::string Map::getAccessToken() const {
|
||||
@@ -644,10 +645,10 @@ const std::vector<std::string> &Map::getAppliedClasses() const {
|
||||
return style->getAppliedClasses();
|
||||
}
|
||||
|
||||
void Map::setDefaultTransitionDuration(uint64_t duration_milliseconds) {
|
||||
defaultTransitionDuration = duration_milliseconds;
|
||||
void Map::setDefaultTransitionDuration(uint64_t milliseconds) {
|
||||
defaultTransitionDuration = milliseconds;
|
||||
if (style) {
|
||||
style->setDefaultTransitionDuration(duration_milliseconds);
|
||||
style->setDefaultTransitionDuration(milliseconds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -656,7 +657,7 @@ uint64_t Map::getDefaultTransitionDuration() {
|
||||
}
|
||||
|
||||
void Map::updateSources() {
|
||||
assert(uv_thread_self() == map_thread);
|
||||
assert(uv_thread_self() == mapThread);
|
||||
|
||||
// First, disable all existing sources.
|
||||
for (const auto& source : activeSources) {
|
||||
@@ -667,14 +668,14 @@ void Map::updateSources() {
|
||||
updateSources(style->layers);
|
||||
|
||||
// Then, construct or destroy the actual source object, depending on enabled state.
|
||||
for (const auto& style_source : activeSources) {
|
||||
if (style_source->enabled) {
|
||||
if (!style_source->source) {
|
||||
style_source->source = std::make_shared<Source>(style_source->info);
|
||||
style_source->source->load(*this, *fileSource);
|
||||
for (const auto& source : activeSources) {
|
||||
if (source->enabled) {
|
||||
if (!source->source) {
|
||||
source->source = std::make_shared<Source>(source->info);
|
||||
source->source->load(*this, *fileSource);
|
||||
}
|
||||
} else {
|
||||
style_source->source.reset();
|
||||
source->source.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,7 +706,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) {
|
||||
|
||||
@@ -97,7 +97,7 @@ void Style::loadJSON(const uint8_t *const data) {
|
||||
}
|
||||
|
||||
StyleParser parser;
|
||||
parser.parse(const_cast<const rapidjson::Document &>(doc));
|
||||
parser.parse(doc);
|
||||
|
||||
layers = parser.getLayers();
|
||||
sprite_url = parser.getSprite();
|
||||
|
||||
@@ -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