move atlas/painter to map context
This commit is contained in:
committed by
John Firebaugh
parent
c88a60b1e5
commit
ad0178fd45
@@ -24,16 +24,12 @@ namespace uv { class async; }
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class Painter;
|
||||
class GlyphStore;
|
||||
class Sprite;
|
||||
class Style;
|
||||
class TexturePool;
|
||||
class FileSource;
|
||||
class View;
|
||||
class GlyphAtlas;
|
||||
class SpriteAtlas;
|
||||
class LineAtlas;
|
||||
class Environment;
|
||||
class EnvironmentScope;
|
||||
class MapData;
|
||||
@@ -246,14 +242,10 @@ private:
|
||||
|
||||
FileSource& fileSource;
|
||||
|
||||
util::ptr<Style> style;
|
||||
std::unique_ptr<GlyphAtlas> glyphAtlas;
|
||||
util::ptr<GlyphStore> glyphStore;
|
||||
std::unique_ptr<SpriteAtlas> spriteAtlas;
|
||||
util::ptr<Style> style;
|
||||
util::ptr<Sprite> sprite;
|
||||
std::unique_ptr<LineAtlas> lineAtlas;
|
||||
util::ptr<TexturePool> texturePool;
|
||||
std::unique_ptr<Painter> painter;
|
||||
|
||||
std::atomic<UpdateType> updated;
|
||||
|
||||
|
||||
@@ -62,6 +62,20 @@ namespace mbgl {
|
||||
|
||||
class MapContext {
|
||||
public:
|
||||
MapContext() :
|
||||
glyphAtlas(util::make_unique<GlyphAtlas>(1024, 1024)),
|
||||
spriteAtlas(util::make_unique<SpriteAtlas>(512, 512)),
|
||||
lineAtlas(util::make_unique<LineAtlas>(512, 512)),
|
||||
painter(util::make_unique<Painter>(*spriteAtlas, *glyphAtlas, *lineAtlas))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
std::unique_ptr<GlyphAtlas> glyphAtlas;
|
||||
std::unique_ptr<SpriteAtlas> spriteAtlas;
|
||||
std::unique_ptr<LineAtlas> lineAtlas;
|
||||
std::unique_ptr<Painter> painter;
|
||||
};
|
||||
|
||||
|
||||
@@ -72,12 +86,8 @@ Map::Map(View& view_, FileSource& fileSource_)
|
||||
data(util::make_unique<MapData>(view_)),
|
||||
context(util::make_unique<MapContext>()),
|
||||
fileSource(fileSource_),
|
||||
glyphAtlas(util::make_unique<GlyphAtlas>(1024, 1024)),
|
||||
glyphStore(std::make_shared<GlyphStore>(*env)),
|
||||
spriteAtlas(util::make_unique<SpriteAtlas>(512, 512)),
|
||||
lineAtlas(util::make_unique<LineAtlas>(512, 512)),
|
||||
texturePool(std::make_shared<TexturePool>()),
|
||||
painter(util::make_unique<Painter>(*spriteAtlas, *glyphAtlas, *lineAtlas)),
|
||||
updated(static_cast<UpdateType>(Update::Nothing))
|
||||
{
|
||||
view.initialize(this);
|
||||
@@ -100,10 +110,10 @@ Map::~Map() {
|
||||
glyphStore.reset();
|
||||
style.reset();
|
||||
workers.reset();
|
||||
painter.reset();
|
||||
lineAtlas.reset();
|
||||
spriteAtlas.reset();
|
||||
glyphAtlas.reset();
|
||||
context->painter.reset();
|
||||
context->lineAtlas.reset();
|
||||
context->spriteAtlas.reset();
|
||||
context->glyphAtlas.reset();
|
||||
|
||||
uv_run(env->loop, UV_RUN_DEFAULT);
|
||||
|
||||
@@ -409,8 +419,8 @@ void Map::checkForPause() {
|
||||
}
|
||||
|
||||
void Map::terminate() {
|
||||
assert(painter);
|
||||
painter->terminate();
|
||||
assert(context->painter);
|
||||
context->painter->terminate();
|
||||
view.deactivate();
|
||||
}
|
||||
|
||||
@@ -418,8 +428,8 @@ void Map::terminate() {
|
||||
|
||||
void Map::setup() {
|
||||
assert(Environment::currentlyOn(ThreadType::Map));
|
||||
assert(painter);
|
||||
painter->setup();
|
||||
assert(context->painter);
|
||||
context->painter->setup();
|
||||
}
|
||||
|
||||
std::string Map::getStyleURL() const {
|
||||
@@ -761,8 +771,8 @@ void Map::updateTiles() {
|
||||
assert(Environment::currentlyOn(ThreadType::Map));
|
||||
if (!style) return;
|
||||
for (const auto& source : style->sources) {
|
||||
source->update(*data, getWorker(), style, *glyphAtlas, *glyphStore, *spriteAtlas,
|
||||
getSprite(), *texturePool, [this]() {
|
||||
source->update(*data, getWorker(), style, *context->glyphAtlas, *glyphStore,
|
||||
*context->spriteAtlas, getSprite(), *texturePool, [this]() {
|
||||
assert(Environment::currentlyOn(ThreadType::Map));
|
||||
triggerUpdate();
|
||||
});
|
||||
@@ -843,8 +853,8 @@ void Map::prepare() {
|
||||
}
|
||||
|
||||
if (u & static_cast<UpdateType>(Update::Debug)) {
|
||||
assert(painter);
|
||||
painter->setDebug(data->getDebug());
|
||||
assert(context->painter);
|
||||
context->painter->setDebug(data->getDebug());
|
||||
}
|
||||
|
||||
if (u & static_cast<UpdateType>(Update::RenderStill)) {
|
||||
@@ -876,8 +886,8 @@ void Map::prepare() {
|
||||
}
|
||||
|
||||
// Allow the sprite atlas to potentially pull new sprite images if needed.
|
||||
spriteAtlas->resize(data->getTransformState().getPixelRatio());
|
||||
spriteAtlas->setSprite(getSprite());
|
||||
context->spriteAtlas->resize(data->getTransformState().getPixelRatio());
|
||||
context->spriteAtlas->setSprite(getSprite());
|
||||
|
||||
updateTiles();
|
||||
}
|
||||
@@ -896,9 +906,9 @@ void Map::render() {
|
||||
env->performCleanup();
|
||||
|
||||
assert(style);
|
||||
assert(painter);
|
||||
assert(context->painter);
|
||||
|
||||
painter->render(*style, data->getTransformState(), data->getAnimationTime());
|
||||
context->painter->render(*style, data->getTransformState(), data->getAnimationTime());
|
||||
|
||||
// Schedule another rerender when we definitely need a next frame.
|
||||
if (data->transform.needsTransition() || style->hasTransitions()) {
|
||||
|
||||
Reference in New Issue
Block a user