diff options
Diffstat (limited to 'include/mbgl/map')
-rw-r--r-- | include/mbgl/map/map.hpp | 12 | ||||
-rw-r--r-- | include/mbgl/map/raster_tile_data.hpp | 33 | ||||
-rw-r--r-- | include/mbgl/map/source.hpp | 86 | ||||
-rw-r--r-- | include/mbgl/map/sprite.hpp | 79 | ||||
-rw-r--r-- | include/mbgl/map/tile_data.hpp | 88 | ||||
-rw-r--r-- | include/mbgl/map/tile_parser.hpp | 77 | ||||
-rw-r--r-- | include/mbgl/map/transform_state.hpp | 1 | ||||
-rw-r--r-- | include/mbgl/map/vector_tile.hpp | 118 | ||||
-rw-r--r-- | include/mbgl/map/vector_tile_data.hpp | 74 |
9 files changed, 6 insertions, 562 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 4e6eef89cf..3a50a70136 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -2,9 +2,6 @@ #define MBGL_MAP_MAP #include <mbgl/map/transform.hpp> -#include <mbgl/renderer/painter.hpp> -#include <mbgl/geometry/glyph_atlas.hpp> -#include <mbgl/geometry/sprite_atlas.hpp> #include <mbgl/util/noncopyable.hpp> #include <mbgl/util/time.hpp> #include <mbgl/util/uv.hpp> @@ -19,6 +16,7 @@ namespace mbgl { +class Painter; class GlyphStore; class LayerDescription; class Sprite; @@ -29,6 +27,8 @@ class StyleSource; class TexturePool; class FileSource; class View; +class GlyphAtlas; +class SpriteAtlas; class Map : private util::noncopyable { typedef void (*stop_callback)(void *); @@ -182,13 +182,13 @@ private: FileSource& fileSource; util::ptr<Style> style; - GlyphAtlas glyphAtlas; + const std::unique_ptr<GlyphAtlas> glyphAtlas; util::ptr<GlyphStore> glyphStore; - SpriteAtlas spriteAtlas; + const std::unique_ptr<SpriteAtlas> spriteAtlas; util::ptr<Sprite> sprite; util::ptr<TexturePool> texturePool; - Painter painter; + const std::unique_ptr<Painter> painter; std::string styleURL; std::string styleJSON = ""; diff --git a/include/mbgl/map/raster_tile_data.hpp b/include/mbgl/map/raster_tile_data.hpp deleted file mode 100644 index 42070d9c61..0000000000 --- a/include/mbgl/map/raster_tile_data.hpp +++ /dev/null @@ -1,33 +0,0 @@ -#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> - -namespace mbgl { - -class Painter; -class SourceInfo; -class StyleLayer; -class TexturePool; - -class RasterTileData : public TileData { - friend class TileParser; - -public: - RasterTileData(Tile::ID const& id, TexturePool&, const SourceInfo&); - ~RasterTileData(); - - virtual void parse(); - virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix); - virtual bool hasData(StyleLayer const& layer_desc) const; - -protected: - StyleBucketRaster properties; - RasterBucket bucket; -}; - -} - -#endif diff --git a/include/mbgl/map/source.hpp b/include/mbgl/map/source.hpp deleted file mode 100644 index 8976f67b05..0000000000 --- a/include/mbgl/map/source.hpp +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef MBGL_MAP_SOURCE -#define MBGL_MAP_SOURCE - -#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/util/mat4.hpp> -#include <mbgl/util/ptr.hpp> - -#include <cstdint> -#include <forward_list> -#include <iosfwd> -#include <map> - -namespace mbgl { - -class Map; -class GlyphAtlas; -class GlyphStore; -class SpriteAtlas; -class Sprite; -class FileSource; -class TexturePool; -class Style; -class Painter; -class StyleLayer; -class TransformState; -struct box; - -class Source : public std::enable_shared_from_this<Source>, private util::noncopyable { -public: - Source(SourceInfo&); - - void load(Map&, FileSource&); - void update(Map&, uv::worker&, - util::ptr<Style>, - GlyphAtlas&, GlyphStore&, - SpriteAtlas&, util::ptr<Sprite>, - TexturePool&, FileSource&, - std::function<void ()> callback); - - void updateMatrices(const mat4 &projMatrix, const TransformState &transform); - void drawClippingMasks(Painter &painter); - size_t getTileCount() const; - void render(Painter &painter, util::ptr<StyleLayer> layer_desc); - void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix); - void finishRender(Painter &painter); - - std::forward_list<Tile::ID> getIDs() const; - std::forward_list<Tile *> getLoadedTiles() const; - void updateClipIDs(const std::map<Tile::ID, ClipID> &mapping); - -private: - bool findLoadedChildren(const Tile::ID& id, int32_t maxCoveringZoom, std::forward_list<Tile::ID>& retain); - bool findLoadedParent(const Tile::ID& id, int32_t minCoveringZoom, std::forward_list<Tile::ID>& retain); - int32_t coveringZoomLevel(const TransformState&) const; - std::forward_list<Tile::ID> coveringTiles(const TransformState&) const; - - TileData::State addTile(Map&, uv::worker&, - util::ptr<Style>, - GlyphAtlas&, GlyphStore&, - SpriteAtlas&, util::ptr<Sprite>, - FileSource&, TexturePool&, - const Tile::ID&, - std::function<void ()> callback); - - TileData::State hasTile(const Tile::ID& id); - - double getZoom(const TransformState &state) const; - - SourceInfo& info; - bool loaded = false; - - // Stores the time when this source was most recently updated. - timestamp updated = 0; - - std::map<Tile::ID, std::unique_ptr<Tile>> tiles; - std::map<Tile::ID, std::weak_ptr<TileData>> tile_data; -}; - -} - -#endif diff --git a/include/mbgl/map/sprite.hpp b/include/mbgl/map/sprite.hpp deleted file mode 100644 index d4b54ba1b5..0000000000 --- a/include/mbgl/map/sprite.hpp +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef MBGL_STYLE_SPRITE -#define MBGL_STYLE_SPRITE - -#include <mbgl/util/image.hpp> -#include <mbgl/util/noncopyable.hpp> -#include <mbgl/util/ptr.hpp> - -#include <cstdint> -#include <atomic> -#include <iosfwd> -#include <string> -#include <unordered_map> -#include <future> - -namespace mbgl { - -class FileSource; - -class SpritePosition { -public: - explicit SpritePosition() {} - explicit SpritePosition(uint16_t x, uint16_t y, uint16_t width, uint16_t height, float pixelRatio, bool sdf); - - operator bool() const { - return !(width == 0 && height == 0 && x == 0 && y == 0); - } - - uint16_t x = 0, y = 0; - uint16_t width = 0, height = 0; - float pixelRatio = 1.0f; - bool sdf = false; -}; - -class Sprite : public std::enable_shared_from_this<Sprite>, private util::noncopyable { -private: - struct Key {}; - void load(FileSource& fileSource); - -public: - Sprite(const Key &, const std::string& base_url, float pixelRatio); - static util::ptr<Sprite> Create(const std::string& base_url, float pixelRatio, 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 parseJSON(); - void parseImage(); - void complete(); - -private: - std::string body; - std::string image; - 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; - -}; - -} - -#endif diff --git a/include/mbgl/map/tile_data.hpp b/include/mbgl/map/tile_data.hpp deleted file mode 100644 index 1ae215b204..0000000000 --- a/include/mbgl/map/tile_data.hpp +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef MBGL_MAP_TILE_DATA -#define MBGL_MAP_TILE_DATA - -#include <mbgl/map/tile.hpp> -#include <mbgl/renderer/debug_bucket.hpp> -#include <mbgl/geometry/debug_font_buffer.hpp> - -#include <mbgl/util/noncopyable.hpp> -#include <mbgl/util/ptr.hpp> - -#include <atomic> -#include <exception> -#include <iosfwd> -#include <string> -#include <functional> - -namespace uv { -class worker; -} - -namespace mbgl { - -class Map; -class FileSource; -class Painter; -class SourceInfo; -class StyleLayer; -class Request; - -class TileData : public std::enable_shared_from_this<TileData>, - private util::noncopyable { -public: - struct exception : std::exception {}; - struct geometry_too_long_exception : exception {}; - -public: - typedef util::ptr<TileData> Ptr; - - enum class State { - invalid, - initial, - loading, - loaded, - parsed, - obsolete - }; - -public: - TileData(Tile::ID const& id, const SourceInfo&); - ~TileData(); - - void request(uv::worker&, FileSource&, float pixelRatio, std::function<void ()> callback); - void reparse(uv::worker&, std::function<void ()> callback); - void cancel(); - const std::string toString() const; - - inline bool ready() const { - return state == State::parsed; - } - - // Override this in the child class. - virtual void parse() = 0; - virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix) = 0; - virtual bool hasData(StyleLayer const& layer_desc) const = 0; - - -public: - const Tile::ID id; - const std::string name; - std::atomic<State> state; - -public: - const SourceInfo& source; - -protected: - std::unique_ptr<Request> req; - std::string data; - - // Contains the tile ID string for painting debug information. - DebugFontBuffer debugFontBuffer; - -public: - DebugBucket debugBucket; -}; - -} - -#endif diff --git a/include/mbgl/map/tile_parser.hpp b/include/mbgl/map/tile_parser.hpp deleted file mode 100644 index beae3af831..0000000000 --- a/include/mbgl/map/tile_parser.hpp +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef MBGL_MAP_TILE_PARSER -#define MBGL_MAP_TILE_PARSER - -#include <mbgl/map/vector_tile.hpp> -#include <mbgl/style/filter_expression.hpp> -#include <mbgl/text/glyph.hpp> -#include <mbgl/util/ptr.hpp> -#include <mbgl/util/noncopyable.hpp> -#include <cstdint> -#include <iosfwd> -#include <string> - -namespace mbgl { - -class Bucket; -class TexturePool; -class FontStack; -class GlyphAtlas; -class GlyphStore; -class SpriteAtlas; -class Sprite; -class Style; -class StyleBucket; -class StyleBucketFill; -class StyleBucketRaster; -class StyleBucketLine; -class StyleBucketSymbol; -class StyleLayerGroup; -class VectorTileData; -class Collision; -class TexturePool; - -class TileParser : private util::noncopyable -{ -public: - TileParser(const std::string &data, VectorTileData &tile, - const util::ptr<const Style> &style, - GlyphAtlas & glyphAtlas, - GlyphStore & glyphStore, - SpriteAtlas & spriteAtlas, - const util::ptr<Sprite> &sprite, - TexturePool& texturePool); - ~TileParser(); - -public: - void parse(); - -private: - bool obsolete() const; - void parseStyleLayers(util::ptr<StyleLayerGroup> group); - 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(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); - - template <class Bucket> void addBucketGeometries(Bucket& bucket, const VectorTileLayer& layer, const FilterExpression &filter); - -private: - const VectorTile vector_data; - VectorTileData& tile; - - // Cross-thread shared data. - util::ptr<const Style> style; - GlyphAtlas & glyphAtlas; - GlyphStore & glyphStore; - SpriteAtlas & spriteAtlas; - util::ptr<Sprite> sprite; - TexturePool& texturePool; - - std::unique_ptr<Collision> collision; -}; - -} - -#endif diff --git a/include/mbgl/map/transform_state.hpp b/include/mbgl/map/transform_state.hpp index bb330c1019..6dc34bd873 100644 --- a/include/mbgl/map/transform_state.hpp +++ b/include/mbgl/map/transform_state.hpp @@ -4,7 +4,6 @@ #include <mbgl/map/tile.hpp> #include <mbgl/util/mat4.hpp> -#include <mbgl/util/vec.hpp> #include <cstdint> #include <array> diff --git a/include/mbgl/map/vector_tile.hpp b/include/mbgl/map/vector_tile.hpp deleted file mode 100644 index 2d02ba3a0b..0000000000 --- a/include/mbgl/map/vector_tile.hpp +++ /dev/null @@ -1,118 +0,0 @@ -#ifndef MBGL_MAP_VECTOR_TILE -#define MBGL_MAP_VECTOR_TILE - -#include <mbgl/style/filter_expression.hpp> -#include <mbgl/style/value.hpp> -#include <mbgl/text/glyph.hpp> -#include <mbgl/util/pbf.hpp> -#include <mbgl/util/optional.hpp> - -#include <cstdint> -#include <iosfwd> -#include <map> -#include <string> -#include <unordered_map> -#include <vector> - -namespace mbgl { - -class VectorTileLayer; - -enum class FeatureType { - Unknown = 0, - Point = 1, - LineString = 2, - Polygon = 3 -}; - -std::ostream& operator<<(std::ostream&, const FeatureType& type); - -class VectorTileFeature { -public: - VectorTileFeature(pbf feature, const VectorTileLayer& layer); - - uint64_t id = 0; - FeatureType type = FeatureType::Unknown; - std::map<std::string, Value> properties; - pbf geometry; -}; - -std::ostream& operator<<(std::ostream&, const VectorTileFeature& feature); - - -class VectorTileTagExtractor { -public: - VectorTileTagExtractor(const VectorTileLayer &layer); - - void setTags(const pbf &pbf); - mapbox::util::optional<Value> getValue(const std::string &key) const; - void setType(FeatureType type); - FeatureType getType() const; - -private: - const VectorTileLayer &layer_; - pbf tags_; - FeatureType type_ = FeatureType::Unknown; -}; - -/* - * Allows iterating over the features of a VectorTileLayer using a - * BucketDescription as filter. Only features matching the descriptions will - * be returned (as pbf). - */ -class FilteredVectorTileLayer { -public: - class iterator { - public: - iterator(const FilteredVectorTileLayer& filter, const pbf& data); - void operator++(); - bool operator!=(const iterator& other) const; - const pbf& operator*() const; - - private: - const FilteredVectorTileLayer& parent; - bool valid = false; - pbf feature; - pbf data; - }; - -public: - FilteredVectorTileLayer(const VectorTileLayer& layer, const FilterExpression &filterExpression); - - iterator begin() const; - iterator end() const; - -private: - const VectorTileLayer& layer; - const FilterExpression& filterExpression; -}; - -std::ostream& operator<<(std::ostream&, const PositionedGlyph& placement); - -class VectorTileLayer { -public: - VectorTileLayer(pbf data); - - const pbf data; - std::string name; - uint32_t extent = 4096; - std::vector<std::string> keys; - std::unordered_map<std::string, uint32_t> key_index; - std::vector<Value> values; - std::map<std::string, std::map<Value, Shaping>> shaping; -}; - -class VectorTile { -public: - VectorTile(); - VectorTile(pbf data); - VectorTile& operator=(VectorTile&& other); - - std::map<std::string, const VectorTileLayer> layers; -}; - - - -} - -#endif diff --git a/include/mbgl/map/vector_tile_data.hpp b/include/mbgl/map/vector_tile_data.hpp deleted file mode 100644 index b9bf55a1b3..0000000000 --- a/include/mbgl/map/vector_tile_data.hpp +++ /dev/null @@ -1,74 +0,0 @@ -#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/geometry/elements_buffer.hpp> -#include <mbgl/geometry/fill_buffer.hpp> -#include <mbgl/geometry/icon_buffer.hpp> -#include <mbgl/geometry/line_buffer.hpp> -#include <mbgl/geometry/text_buffer.hpp> - -#include <iosfwd> -#include <memory> -#include <unordered_map> - -namespace mbgl { - -class Bucket; -class Painter; -class SourceInfo; -class StyleLayer; -class TileParser; -class GlyphAtlas; -class GlyphStore; -class SpriteAtlas; -class Sprite; -class TexturePool; -class Style; - -class VectorTileData : public TileData { - friend class TileParser; - -public: - VectorTileData(Tile::ID const&, - float mapMaxZoom, util::ptr<Style>, - GlyphAtlas&, GlyphStore&, - SpriteAtlas&, util::ptr<Sprite>, - TexturePool&, - const SourceInfo&); - ~VectorTileData(); - - virtual void parse(); - virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix); - virtual bool hasData(StyleLayer const& layer_desc) const; - -protected: - // Holds the actual geometries in this tile. - FillVertexBuffer fillVertexBuffer; - LineVertexBuffer lineVertexBuffer; - IconVertexBuffer iconVertexBuffer; - TextVertexBuffer textVertexBuffer; - - TriangleElementsBuffer triangleElementsBuffer; - LineElementsBuffer lineElementsBuffer; - PointElementsBuffer pointElementsBuffer; - - // Holds the buckets of this tile. - // They contain the location offsets in the buffers stored above - std::unordered_map<std::string, std::unique_ptr<Bucket>> buckets; - - GlyphAtlas& glyphAtlas; - GlyphStore& glyphStore; - SpriteAtlas& spriteAtlas; - util::ptr<Sprite> sprite; - TexturePool& texturePool; - util::ptr<Style> style; - -public: - const float depth; -}; - -} - -#endif |