summaryrefslogtreecommitdiff
path: root/include/mbgl
diff options
context:
space:
mode:
authorTim Watson <tewatson89@gmail.com>2019-04-03 14:51:13 -0700
committerGitHub <noreply@github.com>2019-04-03 14:51:13 -0700
commit0ff25060dae4858a1b60e2277dbd8921de7a6785 (patch)
treed29d578b9b9d6cfb0999b7a30819d379b85172b7 /include/mbgl
parentba2b7a74c420856401d344ff15b27771175c9819 (diff)
parent0f416fbbde9b146eb28a4bf88586738d12505007 (diff)
downloadqtlocation-mapboxgl-upstream/friedbunny-external-pr-14135.tar.gz
Merge pull request #1 from mapbox/masterupstream/friedbunny-external-pr-14135
Merge Master
Diffstat (limited to 'include/mbgl')
-rw-r--r--include/mbgl/map/map.hpp28
-rw-r--r--include/mbgl/map/map_observer.hpp2
-rw-r--r--include/mbgl/map/map_options.hpp71
-rw-r--r--include/mbgl/renderer/renderer.hpp2
-rw-r--r--include/mbgl/renderer/renderer_observer.hpp4
-rw-r--r--include/mbgl/storage/default_file_source.hpp2
-rw-r--r--include/mbgl/storage/file_source.hpp12
-rw-r--r--include/mbgl/storage/offline.hpp2
-rw-r--r--include/mbgl/storage/resource_options.hpp122
-rw-r--r--include/mbgl/style/conversion/constant.hpp5
-rw-r--r--include/mbgl/style/layers/symbol_layer.hpp8
-rw-r--r--include/mbgl/style/types.hpp3
-rw-r--r--include/mbgl/util/constants.hpp3
13 files changed, 210 insertions, 54 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index b4f60a19ba..2fdd72dcb8 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -12,6 +12,7 @@
#include <mbgl/map/camera.hpp>
#include <mbgl/util/geometry.hpp>
#include <mbgl/map/projection_mode.hpp>
+#include <mbgl/storage/resource_options.hpp>
#include <cstdint>
#include <string>
@@ -21,7 +22,6 @@
namespace mbgl {
-class FileSource;
class Scheduler;
class RendererFrontend;
@@ -34,11 +34,9 @@ class Map : private util::noncopyable {
public:
explicit Map(RendererFrontend&,
MapObserver&,
- Size size,
- float pixelRatio,
- FileSource&,
Scheduler&,
- const MapOptions&);
+ const MapOptions&,
+ const ResourceOptions&);
~Map();
// Register a callback that will get called (on the render thread) when all resources have
@@ -87,26 +85,17 @@ public:
/// @}
- // North Orientation
+ // Map Options
void setNorthOrientation(NorthOrientation);
- NorthOrientation getNorthOrientation() const;
-
- // Constrain mode
void setConstrainMode(ConstrainMode);
- ConstrainMode getConstrainMode() const;
-
- // Viewport mode
void setViewportMode(ViewportMode);
- ViewportMode getViewportMode() const;
+ void setSize(Size);
+ MapOptions getMapOptions() const;
//Projection Mode
void setProjectionMode(const ProjectionMode&);
ProjectionMode getProjectionMode() const;
- // Size
- void setSize(Size);
- Size getSize() const;
-
// Projection
ScreenCoordinate pixelForLatLng(const LatLng&) const;
LatLng latLngForPixel(const ScreenCoordinate&) const;
@@ -137,9 +126,12 @@ public:
bool isFullyLoaded() const;
void dumpDebugLogs() const;
-private:
+protected:
class Impl;
const std::unique_ptr<Impl> impl;
+
+ // For testing only.
+ Map(std::unique_ptr<Impl>);
};
} // namespace mbgl
diff --git a/include/mbgl/map/map_observer.hpp b/include/mbgl/map/map_observer.hpp
index 8ad9e93d0b..75e389df9f 100644
--- a/include/mbgl/map/map_observer.hpp
+++ b/include/mbgl/map/map_observer.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <mbgl/style/source.hpp>
+#include <mbgl/style/image.hpp>
#include <cstdint>
#include <string>
@@ -46,6 +47,7 @@ public:
virtual void onDidFinishLoadingStyle() {}
virtual void onSourceChanged(style::Source&) {}
virtual void onDidBecomeIdle() {}
+ virtual void onStyleImageMissing(const std::string&) {}
};
} // namespace mbgl
diff --git a/include/mbgl/map/map_options.hpp b/include/mbgl/map/map_options.hpp
index 13772332a8..fcb8c8f32f 100644
--- a/include/mbgl/map/map_options.hpp
+++ b/include/mbgl/map/map_options.hpp
@@ -1,16 +1,17 @@
#pragma once
#include <mbgl/map/mode.hpp>
+#include <mbgl/util/geo.hpp>
+#include <mbgl/util/size.hpp>
#include <memory>
-#include <string>
namespace mbgl {
/**
* @brief Holds values for Map options.
*/
-class MapOptions {
+class MapOptions final {
public:
/**
* @brief Constructs a MapOptions object with default values.
@@ -18,13 +19,15 @@ public:
MapOptions();
~MapOptions();
+ MapOptions(MapOptions&&) noexcept;
+
/**
* @brief Sets the map rendering mode. By default, it is set to Continuous
* so the map will render as data arrives from the network and react
* immediately to state changes.
*
* @param mode Map rendering mode.
- * @return reference to MapOptions for chaining options together.
+ * @return MapOptions for chaining options together.
*/
MapOptions& withMapMode(MapMode mode);
@@ -41,7 +44,7 @@ public:
* HeightOnly.
*
* @param mode Map constrain mode.
- * @return reference to MapOptions for chaining options together.
+ * @return MapOptions for chaining options together.
*/
MapOptions& withConstrainMode(ConstrainMode mode);
@@ -57,7 +60,7 @@ public:
* orientation of the map as some devices may use inverted orientation.
*
* @param mode Viewport mode.
- * @return reference to MapOptions for chaining options together.
+ * @return MapOptions for chaining options together.
*/
MapOptions& withViewportMode(ViewportMode mode);
@@ -69,71 +72,71 @@ public:
ViewportMode viewportMode() const;
/**
- * @brief Sets the cache path.
+ * @brief Specify whether to enable cross-source symbol collision detection
+ * or not. By default, it is set to true.
*
- * @param path Cache path.
- * @return reference to MapOptions for chaining options together.
+ * @param enableCollisions true to enable, false to disable
+ * @return MapOptions for chaining options together.
*/
- MapOptions& withCachePath(std::string path);
+ MapOptions& withCrossSourceCollisions(bool enableCollisions);
/**
- * @brief Gets the previously set (or default) cache path.
+ * @brief Gets the previously set (or default) crossSourceCollisions value.
*
- * @return cache path
+ * @return true if ecross-source symbol collision detection enabled,
+ * false otherwise.
*/
- const std::string& cachePath() const;
+ bool crossSourceCollisions() const;
/**
- * @brief Sets the asset path, which is the root directory from where
- * the asset:// scheme gets resolved in a style.
+ * @brief Sets the orientation of the Map. By default, it is set to
+ * Upwards.
*
- * @param path Asset path.
+ * @param orientation Orientation of the Map.
* @return reference to MapOptions for chaining options together.
*/
- MapOptions& withAssetRoot(std::string path);
+ MapOptions& withNorthOrientation(NorthOrientation orientation);
/**
- * @brief Gets the previously set (or default) asset path.
+ * @brief Gets the previously set (or default) orientation.
*
- * @return asset path
+ * @return Map orientation.
*/
- const std::string& assetRoot() const;
+ NorthOrientation northOrientation() const;
/**
- * @brief Sets the maximum cache size.
+ * @brief Sets the size to resize the map object and renderer backend.
*
- * @param size Cache maximum size in bytes.
+ * @param size_ A size given in logical pixels.
* @return reference to MapOptions for chaining options together.
*/
- MapOptions& withMaximumCacheSize(uint64_t size);
+ MapOptions& withSize(Size size_);
/**
- * @brief Gets the previously set (or default) maximum allowed cache size.
+ * @brief Gets the previously set size.
*
- * @return maximum allowed cache database size in bytes.
+ * @return Size.
*/
- uint64_t maximumCacheSize() const;
+ Size size() const;
/**
- * @brief Specify whether to enable cross-source symbol collision detection
- * or not. By default, it is set to true.
+ * @brief Sets the custom pixel ratio. By default, it is set to 1.
*
- * @param enableCollisions true to enable, false to disable
+ * @param ratio Pixel ratio value.
* @return reference to MapOptions for chaining options together.
*/
- MapOptions& withCrossSourceCollisions(bool enableCollisions);
+ MapOptions& withPixelRatio(float ratio);
/**
- * @brief Gets the previously set (or default) crossSourceCollisions value.
+ * @brief Gets the previously set (or default) pixel ratio value.
*
- * @return true if ecross-source symbol collision detection enabled,
- * false otherwise.
+ * @return pixel ratio value.
*/
- bool crossSourceCollisions() const;
+ float pixelRatio() const;
private:
class Impl;
- std::shared_ptr<Impl> impl_;
+ std::unique_ptr<Impl> impl_;
};
} // namespace mbgl
diff --git a/include/mbgl/renderer/renderer.hpp b/include/mbgl/renderer/renderer.hpp
index 1d92f9c0cb..0bed4cdaa8 100644
--- a/include/mbgl/renderer/renderer.hpp
+++ b/include/mbgl/renderer/renderer.hpp
@@ -34,6 +34,8 @@ public:
void render(const UpdateParameters&);
+ void flush();
+
// Feature queries
std::vector<Feature> queryRenderedFeatures(const ScreenLineString&, const RenderedQueryOptions& options = {}) const;
std::vector<Feature> queryRenderedFeatures(const ScreenCoordinate& point, const RenderedQueryOptions& options = {}) const;
diff --git a/include/mbgl/renderer/renderer_observer.hpp b/include/mbgl/renderer/renderer_observer.hpp
index 0a76d01ca7..1a9d3ff9bc 100644
--- a/include/mbgl/renderer/renderer_observer.hpp
+++ b/include/mbgl/renderer/renderer_observer.hpp
@@ -31,6 +31,10 @@ public:
// Final frame
virtual void onDidFinishRenderingMap() {}
+
+ // Style is missing an image
+ using StyleImageMissingCallback = std::function<void()>;
+ virtual void onStyleImageMissing(const std::string&, StyleImageMissingCallback done) { done(); }
};
} // namespace mbgl
diff --git a/include/mbgl/storage/default_file_source.hpp b/include/mbgl/storage/default_file_source.hpp
index 5f6999e99f..8f88964acf 100644
--- a/include/mbgl/storage/default_file_source.hpp
+++ b/include/mbgl/storage/default_file_source.hpp
@@ -28,7 +28,7 @@ public:
* of megabytes).
*/
DefaultFileSource(const std::string& cachePath,
- const std::string& assetRoot,
+ const std::string& assetPath,
uint64_t maximumCacheSize = util::DEFAULT_MAX_CACHE_SIZE);
DefaultFileSource(const std::string& cachePath,
std::unique_ptr<FileSource>&& assetFileSource,
diff --git a/include/mbgl/storage/file_source.hpp b/include/mbgl/storage/file_source.hpp
index 0709a1c245..868dbf7347 100644
--- a/include/mbgl/storage/file_source.hpp
+++ b/include/mbgl/storage/file_source.hpp
@@ -1,16 +1,21 @@
#pragma once
+#include <mbgl/actor/actor_ref.hpp>
#include <mbgl/storage/response.hpp>
#include <mbgl/storage/resource.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/async_request.hpp>
+#include <mbgl/util/optional.hpp>
#include <functional>
#include <memory>
namespace mbgl {
+class ResourceOptions;
+class ResourceTransform;
+
class FileSource : private util::noncopyable {
public:
virtual ~FileSource() = default;
@@ -31,6 +36,13 @@ public:
virtual bool supportsCacheOnlyRequests() const {
return false;
}
+
+ // Factory for creating a platform-specific file source.
+ static std::shared_ptr<FileSource> createPlatformFileSource(const ResourceOptions&);
+
+ // Singleton for obtaining the shared platform-specific file source. A single instance of a file source is provided
+ // for each unique combination of a Mapbox API base URL, access token, cache path and platform context.
+ static std::shared_ptr<FileSource> getSharedFileSource(const ResourceOptions&);
};
} // namespace mbgl
diff --git a/include/mbgl/storage/offline.hpp b/include/mbgl/storage/offline.hpp
index b3d258a7e3..f884c8b465 100644
--- a/include/mbgl/storage/offline.hpp
+++ b/include/mbgl/storage/offline.hpp
@@ -153,7 +153,7 @@ public:
bool requiredResourceCountIsPrecise = false;
bool complete() const {
- return completedResourceCount == requiredResourceCount;
+ return completedResourceCount >= requiredResourceCount;
}
};
diff --git a/include/mbgl/storage/resource_options.hpp b/include/mbgl/storage/resource_options.hpp
new file mode 100644
index 0000000000..6d603b8cca
--- /dev/null
+++ b/include/mbgl/storage/resource_options.hpp
@@ -0,0 +1,122 @@
+#pragma once
+
+#include <memory>
+#include <string>
+
+namespace mbgl {
+
+/**
+ * @brief Holds values for resource options.
+ */
+class ResourceOptions final {
+public:
+ /**
+ * @brief Constructs a ResourceOptions object with default values.
+ */
+ ResourceOptions();
+ ~ResourceOptions();
+
+ ResourceOptions(ResourceOptions&&) noexcept;
+
+ ResourceOptions clone() const;
+
+ /**
+ * @brief Sets the Mapbox access token - see https://docs.mapbox.com/help/how-mapbox-works/access-tokens/ for details.
+ *
+ * @param token Mapbox access token.
+ * @return ResourceOptions for chaining options together.
+ */
+ ResourceOptions& withAccessToken(std::string token);
+
+ /**
+ * @brief Gets the previously set (or default) Mapbox access token.
+ *
+ * @return const std::string& Mapbox access token.
+ */
+ const std::string& accessToken() const;
+
+ /**
+ * @brief Sets the API base URL. Default is https://api.mapbox.com for Mapbox.
+ *
+ * @param baseURL API base URL.
+ * @return ResourceOptions for chaining options together.
+ */
+ ResourceOptions& withBaseURL(std::string baseURL);
+
+ /**
+ * @brief Gets the previously set (or default) API base URL.
+ *
+ * @return const std::string& API base URL.
+ */
+ const std::string& baseURL() const;
+
+ /**
+ * @brief Sets the cache path.
+ *
+ * @param path Cache path.
+ * @return ResourceOptions for chaining options together.
+ */
+ ResourceOptions& withCachePath(std::string path);
+
+ /**
+ * @brief Gets the previously set (or default) cache path.
+ *
+ * @return cache path
+ */
+ const std::string& cachePath() const;
+
+ /**
+ * @brief Sets the asset path, which is the root directory from where
+ * the asset:// scheme gets resolved in a style.
+ *
+ * @param path Asset path.
+ * @return ResourceOptions for chaining options together.
+ */
+ ResourceOptions& withAssetPath(std::string path);
+
+ /**
+ * @brief Gets the previously set (or default) asset path.
+ *
+ * @return asset path
+ */
+ const std::string& assetPath() const;
+
+ /**
+ * @brief Sets the maximum cache size.
+ *
+ * @param size Cache maximum size in bytes.
+ * @return reference to ResourceOptions for chaining options together.
+ */
+ ResourceOptions& withMaximumCacheSize(uint64_t size);
+
+ /**
+ * @brief Gets the previously set (or default) maximum allowed cache size.
+ *
+ * @return maximum allowed cache database size in bytes.
+ */
+ uint64_t maximumCacheSize() const;
+
+ /**
+ * @brief Sets the platform context. A platform context is usually an object
+ * that assists the creation of a file source.
+ *
+ * @param context Platform context.
+ * @return reference to ResourceOptions for chaining options together.
+ */
+ ResourceOptions& withPlatformContext(void* context);
+
+ /**
+ * @brief Gets the previously set (or default) platform context.
+ *
+ * @return Platform context.
+ */
+ void* platformContext() const;
+
+private:
+ ResourceOptions(const ResourceOptions&);
+
+ class Impl;
+ std::unique_ptr<Impl> impl_;
+};
+
+} // namespace mbgl
diff --git a/include/mbgl/style/conversion/constant.hpp b/include/mbgl/style/conversion/constant.hpp
index 40657528c4..3a5833be64 100644
--- a/include/mbgl/style/conversion/constant.hpp
+++ b/include/mbgl/style/conversion/constant.hpp
@@ -34,6 +34,11 @@ struct Converter<T, typename std::enable_if_t<std::is_enum<T>::value>> {
optional<T> operator()(const Convertible& value, Error& error) const;
};
+template <class T>
+struct Converter<std::vector<T>, typename std::enable_if_t<std::is_enum<T>::value>> {
+ optional<std::vector<T>> operator()(const Convertible& value, Error& error) const;
+};
+
template <>
struct Converter<Color> {
optional<Color> operator()(const Convertible& value, Error& error) const;
diff --git a/include/mbgl/style/layers/symbol_layer.hpp b/include/mbgl/style/layers/symbol_layer.hpp
index 764f1585f6..35fe72e6bf 100644
--- a/include/mbgl/style/layers/symbol_layer.hpp
+++ b/include/mbgl/style/layers/symbol_layer.hpp
@@ -134,6 +134,14 @@ public:
PropertyValue<TextJustifyType> getTextJustify() const;
void setTextJustify(PropertyValue<TextJustifyType>);
+ static PropertyValue<float> getDefaultTextRadialOffset();
+ PropertyValue<float> getTextRadialOffset() const;
+ void setTextRadialOffset(PropertyValue<float>);
+
+ static PropertyValue<std::vector<TextVariableAnchorType>> getDefaultTextVariableAnchor();
+ PropertyValue<std::vector<TextVariableAnchorType>> getTextVariableAnchor() const;
+ void setTextVariableAnchor(PropertyValue<std::vector<TextVariableAnchorType>>);
+
static PropertyValue<SymbolAnchorType> getDefaultTextAnchor();
PropertyValue<SymbolAnchorType> getTextAnchor() const;
void setTextAnchor(PropertyValue<SymbolAnchorType>);
diff --git a/include/mbgl/style/types.hpp b/include/mbgl/style/types.hpp
index ed875733c7..628e0d2395 100644
--- a/include/mbgl/style/types.hpp
+++ b/include/mbgl/style/types.hpp
@@ -81,6 +81,7 @@ enum class AlignmentType : uint8_t {
};
enum class TextJustifyType : uint8_t {
+ Auto,
Center,
Left,
Right
@@ -98,6 +99,8 @@ enum class SymbolAnchorType : uint8_t {
BottomRight
};
+using TextVariableAnchorType = SymbolAnchorType;
+
enum class TextTransformType : uint8_t {
None,
Uppercase,
diff --git a/include/mbgl/util/constants.hpp b/include/mbgl/util/constants.hpp
index b39b3a83e9..f7799a953f 100644
--- a/include/mbgl/util/constants.hpp
+++ b/include/mbgl/util/constants.hpp
@@ -41,6 +41,9 @@ constexpr float MIN_ZOOM_F = MIN_ZOOM;
constexpr float MAX_ZOOM_F = MAX_ZOOM;
constexpr uint8_t DEFAULT_MAX_ZOOM = 22;
+// ONE_EM constant used to go between "em" units used in style spec and "points" used internally for layout.
+constexpr float ONE_EM = 24.0f;
+
constexpr uint8_t DEFAULT_PREFETCH_ZOOM_DELTA = 4;
constexpr uint64_t DEFAULT_MAX_CACHE_SIZE = 50 * 1024 * 1024;