diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-03-13 13:05:32 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-03-13 13:05:32 -0700 |
commit | 0c985c024b4db6c8063648d493830c67ebff50bc (patch) | |
tree | 046c6344e675c125727de8ec3a4a390cae5b8052 /src/mbgl/style | |
parent | 6325f1e25a47f1d8afa35aee0db1327c21466b67 (diff) | |
download | qtlocation-mapboxgl-0c985c024b4db6c8063648d493830c67ebff50bc.tar.gz |
Revert "Move atlas ownership to Style"
This reverts commit bffee0715458530c6c86f440f757a4de667278a2.
Diffstat (limited to 'src/mbgl/style')
-rw-r--r-- | src/mbgl/style/style.cpp | 81 | ||||
-rw-r--r-- | src/mbgl/style/style.hpp | 31 |
2 files changed, 13 insertions, 99 deletions
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index c606039a2c..45217950f6 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -1,6 +1,5 @@ #include <mbgl/style/style.hpp> #include <mbgl/map/sprite.hpp> -#include <mbgl/map/source.hpp> #include <mbgl/style/style_layer_group.hpp> #include <mbgl/style/style_parser.hpp> #include <mbgl/style/style_bucket.hpp> @@ -9,13 +8,6 @@ #include <mbgl/util/std.hpp> #include <mbgl/util/uv_detail.hpp> #include <mbgl/platform/log.hpp> -#include <mbgl/text/glyph_store.hpp> -#include <mbgl/geometry/glyph_atlas.hpp> -#include <mbgl/geometry/sprite_atlas.hpp> -#include <mbgl/geometry/line_atlas.hpp> -#include <mbgl/util/mapbox.hpp> -#include <mbgl/map/map.hpp> - #include <csscolorparser/csscolorparser.hpp> #include <rapidjson/document.h> @@ -24,76 +16,14 @@ namespace mbgl { -Style::Style(Environment& env) - : glyphAtlas(util::make_unique<GlyphAtlas>(1024, 1024)), - spriteAtlas(util::make_unique<SpriteAtlas>(512, 512)), - lineAtlas(util::make_unique<LineAtlas>(512, 512)), - mtx(util::make_unique<uv::rwlock>()), - glyphStore(util::make_unique<GlyphStore>(env)) -{ +Style::Style() + : mtx(util::make_unique<uv::rwlock>()) { } // Note: This constructor is seemingly empty, but we need to declare it anyway // because this file includes uv_detail.hpp, which has the declarations necessary // for deleting the std::unique_ptr<uv::rwlock>. -Style::~Style() { -} - -void Style::updateSources(Map& map, - Environment& env, - uv::worker& worker, - TexturePool& texturePool, - std::function<void()> callback) { - // First, disable all existing sources. - for (const auto& source : activeSources) { - source->enabled = false; - } - - // Then, reenable all of those that we actually use when drawing this layer. - if (!layers) { - return; - } - for (const util::ptr<StyleLayer> &layer : layers->layers) { - if (!layer) continue; - if (layer->bucket && layer->bucket->style_source) { - (*activeSources.emplace(layer->bucket->style_source).first)->enabled = true; - } - } - - // Then, construct or destroy the actual source object, depending on enabled state. - for (const auto& source : activeSources) { - if (source->enabled) { - if (!source->source) { - source->source = std::make_shared<Source>(source->info); - source->source->load(map, env); - } - } else { - source->source.reset(); - } - } - - // Finally, remove all sources that are disabled. - util::erase_if(activeSources, [](util::ptr<StyleSource> source){ - return !source->enabled; - }); - - // Allow the sprite atlas to potentially pull new sprite images if needed. - const float pixelRatio = map.getState().getPixelRatio(); - if (!sprite || sprite->pixelRatio != pixelRatio) { - sprite = Sprite::Create(sprite_url, pixelRatio, env); - spriteAtlas->resize(pixelRatio); - spriteAtlas->setSprite(sprite); - } - - glyphStore->setURL(util::mapbox::normalizeGlyphsURL(glyph_url, map.getAccessToken())); - - for (const auto &source : activeSources) { - source->source->update(map, env, worker, shared_from_this(), - *glyphAtlas, *glyphStore, - *spriteAtlas, sprite, - texturePool, callback); - } -} +Style::~Style() {} void Style::updateProperties(float z, std::chrono::steady_clock::time_point now) { uv::writelock lock(mtx); @@ -111,6 +41,10 @@ void Style::updateProperties(float z, std::chrono::steady_clock::time_point now) } } +const std::string &Style::getSpriteURL() const { + return sprite_url; +} + void Style::setDefaultTransitionDuration(std::chrono::steady_clock::duration duration) { defaultTransition.duration = duration; } @@ -130,6 +64,7 @@ bool Style::hasTransitions() const { return false; } + void Style::loadJSON(const uint8_t *const data) { uv::writelock lock(mtx); diff --git a/src/mbgl/style/style.hpp b/src/mbgl/style/style.hpp index 04979b3377..4de827a38c 100644 --- a/src/mbgl/style/style.hpp +++ b/src/mbgl/style/style.hpp @@ -15,39 +15,23 @@ #include <vector> #include <set> #include <chrono> -#include <memory> namespace mbgl { -class Map; -class Environment; -class GlyphAtlas; -class GlyphStore; -class SpriteAtlas; class Sprite; -class LineAtlas; class StyleLayer; class StyleLayerGroup; -class TexturePool; -class Style : public util::noncopyable, - public std::enable_shared_from_this<Style> { +class Style : public util::noncopyable { public: struct exception : std::runtime_error { exception(const char *msg) : std::runtime_error(msg) {} }; - Style(Environment&); + Style(); ~Style(); void loadJSON(const uint8_t *const data); size_t layerCount() const; - - void updateSources(Map&, - Environment&, - uv::worker&, - TexturePool&, - std::function<void()> callback); - void updateProperties(float z, std::chrono::steady_clock::time_point now); void setDefaultTransitionDuration(std::chrono::steady_clock::duration duration = std::chrono::steady_clock::duration::zero()); @@ -55,24 +39,19 @@ public: bool hasTransitions() const; - const std::unique_ptr<GlyphAtlas> glyphAtlas; - const std::unique_ptr<SpriteAtlas> spriteAtlas; - const std::unique_ptr<LineAtlas> lineAtlas; + const std::string &getSpriteURL() const; util::ptr<StyleLayerGroup> layers; - std::set<util::ptr<StyleSource>> activeSources; + std::vector<std::string> appliedClasses; + std::string glyph_url; std::string base; private: std::string sprite_url; - std::string glyph_url; PropertyTransition defaultTransition; bool initial_render_complete = false; std::unique_ptr<uv::rwlock> mtx; ZoomHistory zoomHistory; - - const std::unique_ptr<GlyphStore> glyphStore; - util::ptr<Sprite> sprite; }; } |