diff options
Diffstat (limited to 'include/mbgl/map')
-rw-r--r-- | include/mbgl/map/map.hpp | 61 | ||||
-rw-r--r-- | include/mbgl/map/raster_tile_data.hpp | 10 | ||||
-rw-r--r-- | include/mbgl/map/source.hpp | 29 | ||||
-rw-r--r-- | include/mbgl/map/sprite.hpp | 51 | ||||
-rw-r--r-- | include/mbgl/map/tile.hpp | 8 | ||||
-rw-r--r-- | include/mbgl/map/tile_data.hpp | 23 | ||||
-rw-r--r-- | include/mbgl/map/tile_parser.hpp | 39 | ||||
-rw-r--r-- | include/mbgl/map/transform.hpp | 17 | ||||
-rw-r--r-- | include/mbgl/map/transform_state.hpp | 8 | ||||
-rw-r--r-- | include/mbgl/map/vector_tile.hpp | 18 | ||||
-rw-r--r-- | include/mbgl/map/vector_tile_data.hpp | 22 |
11 files changed, 168 insertions, 118 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 774e5e1292..be01b456cc 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -1,26 +1,34 @@ - #ifndef MBGL_MAP_MAP #define MBGL_MAP_MAP -#include <uv.h> - -#include <mbgl/map/view.hpp> #include <mbgl/map/transform.hpp> -#include <mbgl/style/style.hpp> -#include <mbgl/geometry/glyph_atlas.hpp> -#include <mbgl/text/glyph_store.hpp> #include <mbgl/renderer/painter.hpp> + #include <mbgl/util/noncopyable.hpp> -#include <mbgl/util/texturepool.hpp> +#include <mbgl/util/time.hpp> +#include <mbgl/util/uv.hpp> #include <cstdint> -#include <string> -#include <map> +#include <atomic> +#include <iosfwd> +#include <memory> +#include <set> +#include <vector> namespace mbgl { -class Source; +class GlyphAtlas; +class GlyphStore; +class LayerDescription; class SpriteAtlas; +class Sprite; +class Style; +class StyleLayer; +class StyleLayerGroup; +class StyleSource; +class Texturepool; +class FileSource; +class View; class Map : private util::noncopyable { public: @@ -57,7 +65,8 @@ public: void toggleClass(const std::string &name); const std::vector<std::string> &getAppliedClasses() const; void setDefaultTransitionDuration(uint64_t duration_milliseconds = 0); - void setStyleJSON(std::string newStyleJSON); + 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); std::string getAccessToken() const; @@ -89,9 +98,9 @@ public: // Rotation void rotateBy(double sx, double sy, double ex, double ey, double duration = 0); - void setAngle(double angle, double duration = 0); - void setAngle(double angle, double cx, double cy); - double getAngle() const; + void setBearing(double degrees, double duration = 0); + void setBearing(double degrees, double cx, double cy); + double getBearing() const; void resetNorth(); void startRotating(); void stopRotating(); @@ -104,10 +113,12 @@ public: public: inline const TransformState &getState() const { return state; } - inline std::shared_ptr<const Style> getStyle() const { return style; } + inline std::shared_ptr<FileSource> getFileSource() const { return fileSource; } + inline std::shared_ptr<Style> getStyle() const { return style; } inline std::shared_ptr<GlyphAtlas> getGlyphAtlas() { return glyphAtlas; } inline std::shared_ptr<GlyphStore> getGlyphStore() { return glyphStore; } inline std::shared_ptr<SpriteAtlas> getSpriteAtlas() { return spriteAtlas; } + std::shared_ptr<Sprite> getSprite(); inline std::shared_ptr<Texturepool> getTexturepool() { return texturepool; } inline std::shared_ptr<uv::loop> getLoop() { return loop; } inline timestamp getAnimationTime() const { return animationTime; } @@ -143,6 +154,14 @@ private: void renderLayer(std::shared_ptr<StyleLayer> layer_desc, RenderPass pass); private: + bool async = false; + std::shared_ptr<uv::loop> loop; + uv_thread_t thread; + uv_async_t *async_terminate = nullptr; + uv_async_t *async_render = nullptr; + uv_async_t *async_cleanup = nullptr; + +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; @@ -162,10 +181,13 @@ private: Transform transform; TransformState state; + std::shared_ptr<FileSource> fileSource; + std::shared_ptr<Style> style; std::shared_ptr<GlyphAtlas> glyphAtlas; std::shared_ptr<GlyphStore> glyphStore; std::shared_ptr<SpriteAtlas> spriteAtlas; + std::shared_ptr<Sprite> sprite; std::shared_ptr<Texturepool> texturepool; Painter painter; @@ -180,13 +202,6 @@ private: std::set<std::shared_ptr<StyleSource>> activeSources; -private: - bool async = false; - std::shared_ptr<uv::loop> loop; - uv_thread_t thread; - uv_async_t *async_terminate = nullptr; - uv_async_t *async_render = nullptr; - uv_async_t *async_cleanup = nullptr; }; } diff --git a/include/mbgl/map/raster_tile_data.hpp b/include/mbgl/map/raster_tile_data.hpp index 976faa91bc..bf8691454f 100644 --- a/include/mbgl/map/raster_tile_data.hpp +++ b/include/mbgl/map/raster_tile_data.hpp @@ -1,18 +1,24 @@ #ifndef MBGL_MAP_RASTER_TILE_DATA #define MBGL_MAP_RASTER_TILE_DATA +#include <mbgl/map/tile.hpp> #include <mbgl/map/tile_data.hpp> - #include <mbgl/renderer/raster_bucket.hpp> +#include <memory> namespace mbgl { +class Map; +class Painter; +class SourceInfo; +class StyleLayer; + class RasterTileData : public TileData { friend class TileParser; public: - RasterTileData(Tile::ID id, Map &map, const std::string url); + RasterTileData(Tile::ID id, Map &map, const SourceInfo &source); ~RasterTileData(); virtual void parse(); diff --git a/include/mbgl/map/source.hpp b/include/mbgl/map/source.hpp index be5fad3af8..c3f2d4fe8b 100644 --- a/include/mbgl/map/source.hpp +++ b/include/mbgl/map/source.hpp @@ -3,30 +3,29 @@ #include <mbgl/map/tile.hpp> #include <mbgl/map/tile_data.hpp> +#include <mbgl/style/style_source.hpp> + #include <mbgl/util/noncopyable.hpp> #include <mbgl/util/time.hpp> -#include <mbgl/style/style_source.hpp> -#include <mbgl/style/types.hpp> +#include <mbgl/util/mat4.hpp> -#include <list> +#include <cstdint> #include <forward_list> -#include <memory> -#include <vector> -#include <string> +#include <iosfwd> #include <map> -#include <set> +#include <memory> namespace mbgl { +class Map; +class Painter; +class StyleLayer; class TransformState; -class Texturepool; +struct box; class Source : public std::enable_shared_from_this<Source>, private util::noncopyable { public: - Source(StyleSource style_source, const std::string &access_token = ""); - Source(SourceType type = SourceType::Vector, const std::string &url = "", - uint32_t tile_size = 512, uint32_t min_zoom = 0, uint32_t max_zoom = 22, - const std::string &access_token = ""); + Source(SourceInfo info, const std::string &access_token = ""); bool update(Map &map); void updateMatrices(const mat4 &projMatrix, const TransformState &transform); @@ -41,11 +40,7 @@ public: static std::string normalizeSourceURL(const std::string &url, const std::string &access_token); public: - const SourceType type; - const std::string url; - const uint32_t tile_size; - const int32_t min_zoom; - const int32_t max_zoom; + const SourceInfo info; private: bool findLoadedChildren(const Tile::ID& id, int32_t maxCoveringZoom, std::forward_list<Tile::ID>& retain); diff --git a/include/mbgl/map/sprite.hpp b/include/mbgl/map/sprite.hpp index 22126eb6a1..967f1d6614 100644 --- a/include/mbgl/map/sprite.hpp +++ b/include/mbgl/map/sprite.hpp @@ -1,18 +1,20 @@ #ifndef MBGL_STYLE_SPRITE #define MBGL_STYLE_SPRITE -#include <mbgl/util/raster.hpp> -#include <mbgl/util/vec.hpp> +#include <mbgl/util/image.hpp> +#include <mbgl/util/noncopyable.hpp> -#include <string> -#include <mutex> -#include <memory> +#include <cstdint> #include <atomic> +#include <iosfwd> +#include <memory> +#include <string> #include <unordered_map> +#include <future> namespace mbgl { -class Map; +class FileSource; class SpritePosition { public: @@ -28,36 +30,47 @@ public: uint8_t pixelRatio = 1; }; -class Sprite : public std::enable_shared_from_this<Sprite> { -public: - Sprite(Map &map, float pixelRatio = 1); +class Sprite : public std::enable_shared_from_this<Sprite>, private util::noncopyable { +private: + struct Key {}; + void load(const std::shared_ptr<FileSource> &fileSource); - void load(const std::string& base_url); +public: + Sprite(const Key &, const std::string& base_url, float pixelRatio); + static std::shared_ptr<Sprite> Create(const std::string& base_url, float pixelRatio, const std::shared_ptr<FileSource> &fileSource); const SpritePosition &getSpritePosition(const std::string& name) const; + void waitUntilLoaded() const; bool isLoaded() const; + operator bool() const; + +private: + const bool valid; + public: const float pixelRatio; + const std::string spriteURL; + const std::string jsonURL; std::unique_ptr<util::Image> raster; private: - void asyncParseJSON(); - void asyncParseImage(); - - static void parseJSON(std::shared_ptr<Sprite> &sprite); - static void parseImage(std::shared_ptr<Sprite> &sprite); - static void complete(std::shared_ptr<Sprite> &sprite); + void parseJSON(); + void parseImage(); + void complete(); private: - Map ↦ - std::string url; std::string body; std::string image; - std::atomic<bool> loaded; + std::atomic<bool> loadedImage; + std::atomic<bool> loadedJSON; std::unordered_map<std::string, SpritePosition> pos; const SpritePosition empty; + + std::promise<void> promise; + std::future<void> future; + }; } diff --git a/include/mbgl/map/tile.hpp b/include/mbgl/map/tile.hpp index 7e868afad9..9cf5ff5341 100644 --- a/include/mbgl/map/tile.hpp +++ b/include/mbgl/map/tile.hpp @@ -1,15 +1,17 @@ #ifndef MBGL_MAP_TILE #define MBGL_MAP_TILE -#include <mbgl/util/vec.hpp> #include <mbgl/util/mat4.hpp> #include <mbgl/util/noncopyable.hpp> #include <cstdint> -#include <forward_list> -#include <string> #include <bitset> +#include <cmath> +#include <cstdint> +#include <forward_list> +#include <iosfwd> #include <memory> +#include <string> namespace mbgl { diff --git a/include/mbgl/map/tile_data.hpp b/include/mbgl/map/tile_data.hpp index a4b73c339f..c349ea2bae 100644 --- a/include/mbgl/map/tile_data.hpp +++ b/include/mbgl/map/tile_data.hpp @@ -2,22 +2,26 @@ #define MBGL_MAP_TILE_DATA #include <mbgl/map/tile.hpp> -#include <mbgl/util/noncopyable.hpp> -#include <mbgl/platform/platform.hpp> -#include <mbgl/geometry/vao.hpp> #include <mbgl/renderer/debug_bucket.hpp> +#include <mbgl/geometry/debug_font_buffer.hpp> + +#include <mbgl/util/noncopyable.hpp> -#include <cstdint> -#include <string> -#include <memory> #include <atomic> +#include <exception> +#include <iosfwd> +#include <memory> +#include <string> namespace mbgl { class Map; class Painter; +class SourceInfo; class StyleLayer; +namespace platform { class Request; } + class TileData : public std::enable_shared_from_this<TileData>, private util::noncopyable { public: @@ -37,7 +41,7 @@ public: }; public: - TileData(Tile::ID id, Map &map, const std::string url); + TileData(Tile::ID id, Map &map, const SourceInfo &source); ~TileData(); void request(); @@ -60,8 +64,13 @@ public: protected: Map ↦ +public: + const SourceInfo &source; + // Request-related information. const std::string url; + +protected: std::weak_ptr<platform::Request> req; std::string data; diff --git a/include/mbgl/map/tile_parser.hpp b/include/mbgl/map/tile_parser.hpp index 14e00946b8..9aa0f4dc66 100644 --- a/include/mbgl/map/tile_parser.hpp +++ b/include/mbgl/map/tile_parser.hpp @@ -2,27 +2,30 @@ #define MBGL_MAP_TILE_PARSER #include <mbgl/map/vector_tile.hpp> -#include <mbgl/text/placement.hpp> -#include <mbgl/text/glyph_store.hpp> -#include <mbgl/text/glyph.hpp> -#include <mbgl/util/utf.hpp> #include <mbgl/style/filter_expression.hpp> +#include <mbgl/text/glyph.hpp> +#include <mbgl/text/collision.hpp> + +#include <cstdint> +#include <iosfwd> +#include <memory> +#include <string> namespace mbgl { -class Style; +class Bucket; +class FontStack; class GlyphAtlas; class GlyphStore; class SpriteAtlas; -class VectorTileData; -class StyleLayer; -class StyleLayerGroup; +class Sprite; +class Style; class StyleBucket; class StyleBucketFill; class StyleBucketLine; -class StyleBucketIcon; - -class Bucket; +class StyleBucketSymbol; +class StyleLayerGroup; +class VectorTileData; class TileParser { public: @@ -30,25 +33,22 @@ public: const std::shared_ptr<const Style> &style, const std::shared_ptr<GlyphAtlas> &glyphAtlas, const std::shared_ptr<GlyphStore> &glyphStore, - const std::shared_ptr<SpriteAtlas> &spriteAtlas); + const std::shared_ptr<SpriteAtlas> &spriteAtlas, + const std::shared_ptr<Sprite> &sprite); public: void parse(); private: bool obsolete() const; - void parseGlyphs(); void parseStyleLayers(std::shared_ptr<StyleLayerGroup> group); - void addGlyph(uint64_t tileid, const std::string stackname, const std::u32string &string, const FontStack &fontStack, GlyphAtlas &glyphAtlas, GlyphPositions &face); std::unique_ptr<Bucket> createBucket(std::shared_ptr<StyleBucket> bucket_desc); std::unique_ptr<Bucket> createFillBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketFill &fill); std::unique_ptr<Bucket> createLineBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketLine &line); - std::unique_ptr<Bucket> createIconBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketIcon &icon); - std::unique_ptr<Bucket> createTextBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketText &text); + std::unique_ptr<Bucket> createSymbolBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketSymbol &symbol); - template <class Bucket> void addBucketFeatures(Bucket& bucket, const VectorTileLayer& layer, const FilterExpression &filter); - template <class Bucket, typename ...Args> void addBucketFeatures(Bucket& bucket, const VectorTileLayer& layer, const FilterExpression &filter, Args&& ...args); + template <class Bucket> void addBucketGeometries(Bucket& bucket, const VectorTileLayer& layer, const FilterExpression &filter); private: const VectorTile vector_data; @@ -59,8 +59,9 @@ private: std::shared_ptr<GlyphAtlas> glyphAtlas; std::shared_ptr<GlyphStore> glyphStore; std::shared_ptr<SpriteAtlas> spriteAtlas; + std::shared_ptr<Sprite> sprite; - Placement placement; + Collision collision; }; } diff --git a/include/mbgl/map/transform.hpp b/include/mbgl/map/transform.hpp index 61bef76563..df7839ea96 100644 --- a/include/mbgl/map/transform.hpp +++ b/include/mbgl/map/transform.hpp @@ -1,20 +1,23 @@ #ifndef MBGL_MAP_TRANSFORM #define MBGL_MAP_TRANSFORM -#include <mbgl/util/transition.hpp> +#include <mbgl/util/time.hpp> +#include <mbgl/map/transform_state.hpp> + #include <mbgl/util/noncopyable.hpp> #include <mbgl/util/uv.hpp> -#include "view.hpp" -#include "transform_state.hpp" - +#include <cstdint> +#include <cmath> #include <forward_list> +#include <memory> namespace mbgl { -struct box; +class View; +namespace util { class transition; } - class Transform : private util::noncopyable { +class Transform : private util::noncopyable { public: Transform(View &view); @@ -93,7 +96,7 @@ private: const double max_scale = std::pow(2, 18); // cache values for spherical mercator math - double zc, Bc, Cc; + double Bc, Cc; std::forward_list<std::shared_ptr<util::transition>> transitions; std::shared_ptr<util::transition> scale_timeout; diff --git a/include/mbgl/map/transform_state.hpp b/include/mbgl/map/transform_state.hpp index 85dd2eb87d..5b3b7d3755 100644 --- a/include/mbgl/map/transform_state.hpp +++ b/include/mbgl/map/transform_state.hpp @@ -1,15 +1,17 @@ #ifndef MBGL_MAP_TRANSFORM_STATE #define MBGL_MAP_TRANSFORM_STATE -#include <mbgl/util/mat4.hpp> #include <mbgl/map/tile.hpp> +#include <mbgl/util/mat4.hpp> +#include <mbgl/util/vec.hpp> + #include <cstdint> +#include <array> +#include <limits> namespace mbgl { -class Transform; - class TransformState { friend class Transform; diff --git a/include/mbgl/map/vector_tile.hpp b/include/mbgl/map/vector_tile.hpp index 77e379865f..1bbe645307 100644 --- a/include/mbgl/map/vector_tile.hpp +++ b/include/mbgl/map/vector_tile.hpp @@ -1,24 +1,22 @@ #ifndef MBGL_MAP_VECTOR_TILE #define MBGL_MAP_VECTOR_TILE -#include <mbgl/util/pbf.hpp> -#include <mbgl/util/vec.hpp> +#include <mbgl/style/filter_expression.hpp> #include <mbgl/style/value.hpp> #include <mbgl/text/glyph.hpp> -#include <mbgl/style/filter_expression.hpp> -#include <vector> +#include <mbgl/util/pbf.hpp> + +#include <cstdint> +#include <iosfwd> #include <map> +#include <string> #include <unordered_map> -#include <set> -#include <limits> +#include <vector> namespace mbgl { -class BucketDescription; class VectorTileLayer; -struct pbf; - enum class FeatureType { Unknown = 0, Point = 1, @@ -88,7 +86,7 @@ private: const FilterExpression& filterExpression; }; -std::ostream& operator<<(std::ostream&, const GlyphPlacement& placement); +std::ostream& operator<<(std::ostream&, const PositionedGlyph& placement); class VectorTileLayer { public: diff --git a/include/mbgl/map/vector_tile_data.hpp b/include/mbgl/map/vector_tile_data.hpp index dd55e8dae1..edad228999 100644 --- a/include/mbgl/map/vector_tile_data.hpp +++ b/include/mbgl/map/vector_tile_data.hpp @@ -1,29 +1,32 @@ #ifndef MBGL_MAP_VECTOR_TILE_DATA #define MBGL_MAP_VECTOR_TILE_DATA +#include <mbgl/map/tile.hpp> #include <mbgl/map/tile_data.hpp> - - -#include <mbgl/renderer/bucket.hpp> - -#include <mbgl/geometry/vertex_buffer.hpp> #include <mbgl/geometry/elements_buffer.hpp> #include <mbgl/geometry/fill_buffer.hpp> -#include <mbgl/geometry/line_buffer.hpp> #include <mbgl/geometry/icon_buffer.hpp> +#include <mbgl/geometry/line_buffer.hpp> #include <mbgl/geometry/text_buffer.hpp> -#include <mbgl/map/tile_parser.hpp> +#include <iosfwd> +#include <memory> #include <unordered_map> namespace mbgl { +class Bucket; +class Map; +class Painter; +class SourceInfo; +class StyleLayer; +class TileParser; class VectorTileData : public TileData { friend class TileParser; public: - VectorTileData(Tile::ID id, Map &map, const std::string url); + VectorTileData(Tile::ID id, Map &map, const SourceInfo &source); ~VectorTileData(); virtual void beforeParse(); @@ -48,6 +51,9 @@ protected: std::unordered_map<std::string, std::unique_ptr<Bucket>> buckets; std::unique_ptr<TileParser> parser; + +public: + const float depth; }; } |