diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-04-15 12:46:19 -0400 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-04-15 12:46:19 -0400 |
commit | 78c10c0701a85dd4f74d8fb249847f8178b1b6e1 (patch) | |
tree | 3af6101bfe3e19550234241ce4e3ef068decf515 /include/llmr/map | |
parent | 8e442411b0339072666f2b434963a0bd88215f3d (diff) | |
parent | 228ce3327855bd8b41d5f971902de8a8f3269115 (diff) | |
download | qtlocation-mapboxgl-78c10c0701a85dd4f74d8fb249847f8178b1b6e1.tar.gz |
Merge remote-tracking branch 'remotes/origin/pr/127'
Conflicts:
include/llmr/map/map.hpp
src/map/map.cpp
src/platform/platform.cpp
Diffstat (limited to 'include/llmr/map')
-rw-r--r-- | include/llmr/map/coverage.hpp | 14 | ||||
-rw-r--r-- | include/llmr/map/map.hpp | 23 | ||||
-rw-r--r-- | include/llmr/map/source.hpp | 67 | ||||
-rw-r--r-- | include/llmr/map/tile_data.hpp | 8 | ||||
-rw-r--r-- | include/llmr/map/tile_parser.hpp | 6 | ||||
-rw-r--r-- | include/llmr/map/transform.hpp | 3 |
6 files changed, 85 insertions, 36 deletions
diff --git a/include/llmr/map/coverage.hpp b/include/llmr/map/coverage.hpp deleted file mode 100644 index ed6317a560..0000000000 --- a/include/llmr/map/coverage.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef LLMR_MAP_COVERAGE -#define LLMR_MAP_COVERAGE - -#include <llmr/map/tile.hpp> - -#include <forward_list> - -namespace llmr { - -std::forward_list<Tile::ID> covering_tiles(int32_t zoom, const box& points, const bool use_raster = false, const bool use_retina = false); - -} - -#endif diff --git a/include/llmr/map/map.hpp b/include/llmr/map/map.hpp index 640786e105..fef3673860 100644 --- a/include/llmr/map/map.hpp +++ b/include/llmr/map/map.hpp @@ -5,7 +5,6 @@ #include <llmr/map/tile_data.hpp> #include <llmr/map/transform.hpp> #include <llmr/style/style.hpp> -#include <llmr/style/style.hpp> #include <llmr/geometry/glyph_atlas.hpp> #include <llmr/renderer/painter.hpp> #include <llmr/util/noncopyable.hpp> @@ -13,10 +12,12 @@ #include <cstdint> #include <string> +#include <map> namespace llmr { class Settings; +class Source; class Map : private util::noncopyable { public: @@ -28,7 +29,6 @@ public: void loadStyle(const uint8_t *const data, uint32_t bytes); void loadSettings(); void resize(uint16_t width, uint16_t height, float ratio, uint16_t fb_width, uint16_t fb_height); - void toggleRaster(); /* callback */ void update(); @@ -64,14 +64,15 @@ public: void stopRotating(); void toggleDebug(); + void toggleRaster(); + + box cornersToBox(uint32_t z) const; + float getPixelRatio() const; + Style& getStyle(); + GlyphAtlas& getGlyphAtlas(); 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); bool updateTiles(); - TileData::State addTile(const Tile::ID& id); - TileData::State hasTile(const Tile::ID& id); - private: Settings& settings; @@ -81,16 +82,12 @@ private: GlyphAtlas glyphAtlas; Painter painter; - bool use_raster = false; + std::map<std::string, Source> sources; int32_t min_zoom; int32_t max_zoom; - float pixel_ratio; - - - std::forward_list<Tile> tiles; - std::forward_list<std::weak_ptr<TileData>> tile_data; + // float pixel_ratio; }; } diff --git a/include/llmr/map/source.hpp b/include/llmr/map/source.hpp new file mode 100644 index 0000000000..3ddebb0ee4 --- /dev/null +++ b/include/llmr/map/source.hpp @@ -0,0 +1,67 @@ +#ifndef LLMR_MAP_SOURCE +#define LLMR_MAP_SOURCE + +#include <llmr/map/tile.hpp> +#include <llmr/map/tile_data.hpp> + +#include <forward_list> +#include <memory> +#include <list> +#include <string> + +namespace llmr { + +class Map; +class Transform; +class Painter; +class Texturepool; + +class Source : public std::enable_shared_from_this<Source> { +public: + enum class Type { + vector, + raster + }; + +public: + Source(Map& map, Transform& transform, Painter& painter, Texturepool& texturepool, const char *url = "", Type type = Type::vector, std::list<uint32_t> zooms = {0}, uint32_t tile_size = 512, uint32_t min_zoom = 0, uint32_t max_zoom = 14, bool enabled = true); + + bool update(); + void prepare_render(bool is_baselayer = false); + void render(double animationTime, bool is_baselayer = false); + +public: + bool enabled; + +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); + std::forward_list<Tile::ID> covering_tiles(int32_t zoom, const box& points); + + bool updateTiles(); + + TileData::State addTile(const Tile::ID& id); + TileData::State hasTile(const Tile::ID& id); + + double getZoom() const; + +private: + Map& map; + Transform& transform; + Painter& painter; + Texturepool& texturepool; + + Type type; + std::list<uint32_t> zooms; + const char *url; + uint32_t tile_size; + uint32_t min_zoom; + uint32_t max_zoom; + + std::forward_list<Tile> tiles; + std::forward_list<std::weak_ptr<TileData>> tile_data; +}; + +} + +#endif diff --git a/include/llmr/map/tile_data.hpp b/include/llmr/map/tile_data.hpp index 955c1ffbc8..c6283e3706 100644 --- a/include/llmr/map/tile_data.hpp +++ b/include/llmr/map/tile_data.hpp @@ -35,7 +35,6 @@ class Raster; class LayerDescription; class BucketDescription; - class PlainShader; class TileData : public std::enable_shared_from_this<TileData>, @@ -57,7 +56,7 @@ public: }; public: - TileData(Tile::ID id, const Style& style, GlyphAtlas& glyphAtlas, const bool use_raster = false, const bool use_retina = false); + TileData(Tile::ID id, const Style& style, GlyphAtlas& glyphAtlas, const std::string url, const bool is_raster); ~TileData(); void request(); @@ -68,8 +67,6 @@ public: public: const Tile::ID id; - const bool use_raster; - const bool use_retina; std::atomic<State> state; std::shared_ptr<Raster> raster; @@ -91,7 +88,8 @@ public: std::map<std::string, std::unique_ptr<Bucket>> buckets; private: - // Source data + const std::string url; + const bool is_raster = false; std::string data; const Style& style; GlyphAtlas& glyphAtlas; diff --git a/include/llmr/map/tile_parser.hpp b/include/llmr/map/tile_parser.hpp index b99f9aaf94..ee623f1ff9 100644 --- a/include/llmr/map/tile_parser.hpp +++ b/include/llmr/map/tile_parser.hpp @@ -8,7 +8,7 @@ namespace llmr { class TileParser { public: - TileParser(const std::string& data, TileData& tile, const Style& style, GlyphAtlas& glyphAtlas); + TileParser(const std::string& data, TileData& tile, const Style& style, GlyphAtlas& glyphAtlas, bool is_raster = false); private: bool obsolete() const; @@ -19,10 +19,12 @@ private: std::unique_ptr<Bucket> createLineBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc); std::unique_ptr<Bucket> createPointBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc); std::unique_ptr<Bucket> createTextBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc); + std::unique_ptr<Bucket> createRasterBucket(const BucketDescription& bucket_desc); template <class Bucket> void addBucketFeatures(Bucket& bucket, const VectorTileLayer& layer, const BucketDescription& bucket_desc); private: - const VectorTile data; + const VectorTile vector_data; + const std::string raster_data; TileData& tile; const Style& style; GlyphAtlas& glyphAtlas; diff --git a/include/llmr/map/transform.hpp b/include/llmr/map/transform.hpp index 7b4d59ee17..e81b9e4121 100644 --- a/include/llmr/map/transform.hpp +++ b/include/llmr/map/transform.hpp @@ -56,8 +56,7 @@ public: void startScaling(); void stopScaling(); - // Temporary - box mapCornersToBox(uint32_t z) const; + box cornersToBox(uint32_t z) const; // More getters inline uint16_t getWidth() const { return width; } |