diff options
author | Ansis Brammanis <brammanis@gmail.com> | 2015-05-28 20:01:15 -0400 |
---|---|---|
committer | Ansis Brammanis <brammanis@gmail.com> | 2015-05-28 20:01:15 -0400 |
commit | ff6a5ce5bc674e17a24c3f18b305d5dd2f0e21b0 (patch) | |
tree | 405ec719109186590311262045ff1651b06e9506 /include | |
parent | fd19eb79056b8e62f037c0ae4532f4f7cc970580 (diff) | |
parent | 6c166b564ebb3acefb56bb4d39be4813851db4a7 (diff) | |
download | qtlocation-mapboxgl-ff6a5ce5bc674e17a24c3f18b305d5dd2f0e21b0.tar.gz |
Merge remote-tracking branch 'origin/master' into new-labelling
Conflicts:
src/mbgl/map/source.cpp
src/mbgl/map/source.hpp
src/mbgl/map/tile_data.cpp
src/mbgl/map/tile_parser.cpp
src/mbgl/map/vector_tile_data.cpp
src/mbgl/renderer/painter.cpp
src/mbgl/renderer/symbol_bucket.cpp
src/mbgl/text/glyph.hpp
src/mbgl/text/glyph_store.cpp
src/mbgl/text/placement.cpp
test/suite
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/ios/MGLAccountManager.h | 2 | ||||
-rw-r--r-- | include/mbgl/ios/MGLMapView+IBAdditions.h | 3 | ||||
-rw-r--r-- | include/mbgl/ios/MGLMapView.h | 34 | ||||
-rw-r--r-- | include/mbgl/map/map.hpp | 6 | ||||
-rw-r--r-- | include/mbgl/platform/darwin/reachability.h | 41 | ||||
-rw-r--r-- | include/mbgl/platform/default/image_reader.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/platform/event.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/platform/log.hpp | 1 | ||||
-rw-r--r-- | include/mbgl/storage/default_file_source.hpp | 4 | ||||
-rw-r--r-- | include/mbgl/storage/file_source.hpp | 1 | ||||
-rw-r--r-- | include/mbgl/storage/resource.hpp | 10 | ||||
-rw-r--r-- | include/mbgl/util/exception.hpp | 20 | ||||
-rw-r--r-- | include/mbgl/util/exclusive.hpp | 30 | ||||
-rw-r--r-- | include/mbgl/util/std.hpp | 23 |
14 files changed, 93 insertions, 86 deletions
diff --git a/include/mbgl/ios/MGLAccountManager.h b/include/mbgl/ios/MGLAccountManager.h index 7ec4135f18..6b127543ee 100644 --- a/include/mbgl/ios/MGLAccountManager.h +++ b/include/mbgl/ios/MGLAccountManager.h @@ -21,7 +21,7 @@ /** Certain Mapbox plans require the collection of user metrics. If you aren't using a preference switch in an existing or new `Settings.bundle` in your application, set this value to `YES` to indicate that you are providing a metrics opt-out for users within your app's interface directly. * @param showsOptOut Whether your application's interface provides a user opt-out preference. The default value is `NO`, meaning a `Settings.bundle` is expected for providing a user opt-out preference. */ -+ (void)setMapboxMetricsEnabledSettingShownInApp:(BOOL)showsOptOut; ++ (void)setMapboxMetricsEnabledSettingShownInApp:(BOOL)showsOptOut __attribute__((unavailable("Set MGLMapboxMetricsEnabledSettingShownInApp in Info.plist."))); /** Whether in-app user metrics opt-out is configured. If set to the default value of `NO`, a user opt-out preference is expected in a `Settings.bundle` that shows in the application's section within the system Settings app. */ + (BOOL)mapboxMetricsEnabledSettingShownInApp; diff --git a/include/mbgl/ios/MGLMapView+IBAdditions.h b/include/mbgl/ios/MGLMapView+IBAdditions.h index df9a19a6b7..23762cca94 100644 --- a/include/mbgl/ios/MGLMapView+IBAdditions.h +++ b/include/mbgl/ios/MGLMapView+IBAdditions.h @@ -8,8 +8,7 @@ // inspectables declared in MGLMapView.h are always sorted before those in // MGLMapView+IBAdditions.h, due to ASCII sort order. -@property (nonatomic) IBInspectable NSString *accessToken; -@property (nonatomic) IBInspectable NSString *mapID; +@property (nonatomic) IBInspectable NSString *styleID; // Convenience properties related to the initial viewport. These properties // are not meant to be used outside of Interface Builder. latitude and longitude diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h index 9d7b5c9019..0ccb8225bb 100644 --- a/include/mbgl/ios/MGLMapView.h +++ b/include/mbgl/ios/MGLMapView.h @@ -20,30 +20,25 @@ IB_DESIGNABLE /** @name Initializing a Map View */ -/** Initialize a map view with the default style, given frame, and access token set in MapboxGL singleton. -* @param frame The frame with which to initialize the map view. -* @return An initialized map view, or `nil` if the map view was unable to be initialized. */ +/** Initializes and returns a newly allocated map view with the specified frame and the default style. +* @param frame The frame for the view, measured in points. +* @return An initialized map view. */ - (instancetype)initWithFrame:(CGRect)frame; +- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken __attribute__((unavailable("Use -initWithFrame:. Set MGLMapboxAccessToken in the Info.plist or call +[MGLAccountManager setAccessToken:]."))); -/** Initialize a map view with the default style and a given frame and access token. -* @param frame The frame with which to initialize the map view. -* @param accessToken A Mapbox API access token. -* @return An initialized map view, or `nil` if the map view was unable to be initialized. */ -- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken; - -/** Initialize a map view with a given frame, access token, and style URL. - * @param frame The frame with which to initialize the map view. - * @param accessToken A Mapbox API access token. - * @param styleURL The map style URL to use. Can be either an HTTP/HTTPS URL or a Mapbox map ID style URL (`mapbox://<user.style>`). - * @return An initialized map view, or `nil` if the map view was unable to be initialized. */ -- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken styleURL:(NSURL *)styleURL; +/** Initializes and returns a newly allocated map view with the specified frame and style URL. +* @param frame The frame for the view, measured in points. +* @param styleURL The map style URL to use. Can be either an HTTP/HTTPS URL or a Mapbox map ID style URL (`mapbox://<user.style>`). +* @return An initialized map view. */ +- (instancetype)initWithFrame:(CGRect)frame styleURL:(NSURL *)styleURL; +- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken styleURL:(NSURL *)styleURL __attribute__((unavailable("Use -initWithFrame:styleURL:. Set MGLMapboxAccessToken in the Info.plist or call +[MGLAccountManager setAccessToken:]."))); #pragma mark - Authorizing Access /** @name Authorizing Access */ /** Mapbox API access token for the map view. */ -@property (nonatomic) NSString *accessToken; +@property (nonatomic) NSString *accessToken __attribute__((unavailable("Use +[MGLAccountManager accessToken] and +[MGLAccountManager setAccessToken:]."))); #pragma mark - Managing Constraints @@ -162,12 +157,13 @@ IB_DESIGNABLE /** @name Styling the Map */ -/** Mapbox map ID of the style currently displayed in the receiver, or `nil` if the style does not have a map ID. +/** Mapbox ID of the style currently displayed in the receiver, or `nil` if the style does not have an ID. * -* The style may lack a map ID if it is located at an HTTP, HTTPS, or local file URL. Use `styleURL` to get the URL in these cases. +* The style may lack an ID if it is located at an HTTP, HTTPS, or local file URL. Use `styleURL` to get the URL in these cases. * * To display the default style, set this property to `nil`. */ -@property (nonatomic) NSString *mapID; +@property (nonatomic) NSString *styleID; +@property (nonatomic) NSString *mapID __attribute__((unavailable("Use styleID."))); /** Returns the URLs to the styles bundled with the library. */ - (NSArray *)bundledStyleURLs; diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index ccc963d086..5535dbcc91 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -42,7 +42,7 @@ public: // Register a callback that will get called (on the render thread) when all resources have // been loaded and a complete render occurs. - using StillImageCallback = std::function<void(std::unique_ptr<const StillImage>)>; + using StillImageCallback = std::function<void(std::exception_ptr, std::unique_ptr<const StillImage>)>; void renderStill(StillImageCallback callback); // Triggers a synchronous or asynchronous render. @@ -99,10 +99,6 @@ public: uint16_t getWidth() const; uint16_t getHeight() const; - // API - void setAccessToken(const std::string &token); - std::string getAccessToken() const; - // Projection void getWorldBoundsMeters(ProjectedMeters &sw, ProjectedMeters &ne) const; void getWorldBoundsLatLng(LatLng &sw, LatLng &ne) const; diff --git a/include/mbgl/platform/darwin/reachability.h b/include/mbgl/platform/darwin/reachability.h index 1cf7d2ecea..0101b91d48 100644 --- a/include/mbgl/platform/darwin/reachability.h +++ b/include/mbgl/platform/darwin/reachability.h @@ -28,24 +28,6 @@ #import <Foundation/Foundation.h> #import <SystemConfiguration/SystemConfiguration.h> -#import <sys/socket.h> -#import <netinet/in.h> -#import <netinet6/in6.h> -#import <arpa/inet.h> -#import <ifaddrs.h> -#import <netdb.h> - -/** - * Does ARC support GCD objects? - * It does if the minimum deployment target is iOS 6+ or Mac OS X 8+ - * - * @see http://opensource.apple.com/source/libdispatch/libdispatch-228.18/os/object.h - **/ -#if OS_OBJECT_USE_OBJC -#define NEEDS_DISPATCH_RETAIN_RELEASE 0 -#else -#define NEEDS_DISPATCH_RETAIN_RELEASE 1 -#endif /** * Create NS_ENUM macro if it does not exist on the targeted version of iOS or OS X. @@ -65,28 +47,29 @@ typedef NS_ENUM(NSInteger, NetworkStatus) { ReachableViaWWAN = 1 }; -@class Reachability; +@class MGLReachability; + +typedef void (^NetworkReachable)(MGLReachability * reachability); +typedef void (^NetworkUnreachable)(MGLReachability * reachability); -typedef void (^NetworkReachable)(Reachability * reachability); -typedef void (^NetworkUnreachable)(Reachability * reachability); -@interface Reachability : NSObject +@interface MGLReachability : NSObject @property (nonatomic, copy) NetworkReachable reachableBlock; @property (nonatomic, copy) NetworkUnreachable unreachableBlock; - @property (nonatomic, assign) BOOL reachableOnWWAN; -+(Reachability*)reachabilityWithHostname:(NSString*)hostname; + ++(instancetype)reachabilityWithHostname:(NSString*)hostname; // This is identical to the function above, but is here to maintain //compatibility with Apples original code. (see .m) -+(Reachability*)reachabilityWithHostName:(NSString*)hostname; -+(Reachability*)reachabilityForInternetConnection; -+(Reachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress; -+(Reachability*)reachabilityForLocalWiFi; ++(instancetype)reachabilityWithHostName:(NSString*)hostname; ++(instancetype)reachabilityForInternetConnection; ++(instancetype)reachabilityWithAddress:(void *)hostAddress; ++(instancetype)reachabilityForLocalWiFi; --(Reachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref; +-(instancetype)initWithReachabilityRef:(SCNetworkReachabilityRef)ref; -(BOOL)startNotifier; -(void)stopNotifier; diff --git a/include/mbgl/platform/default/image_reader.hpp b/include/mbgl/platform/default/image_reader.hpp index 985e4874cd..52a67a2830 100644 --- a/include/mbgl/platform/default/image_reader.hpp +++ b/include/mbgl/platform/default/image_reader.hpp @@ -1,11 +1,11 @@ #ifndef MBGL_UTIL_IMAGE_READER_HPP #define MBGL_UTIL_IMAGE_READER_HPP -#include <mbgl/util/std.hpp> #include <mbgl/util/noncopyable.hpp> // stl #include <stdexcept> #include <string> +#include <memory> namespace mbgl { namespace util { diff --git a/include/mbgl/platform/event.hpp b/include/mbgl/platform/event.hpp index 5fd64119cc..8cdd1d50a9 100644 --- a/include/mbgl/platform/event.hpp +++ b/include/mbgl/platform/event.hpp @@ -29,6 +29,7 @@ enum class Event : uint8_t { ParseStyle, ParseTile, Render, + ResourceLoader, Database, HttpRequest, Sprite, @@ -46,6 +47,7 @@ MBGL_DEFINE_ENUM_CLASS(EventClass, Event, { { Event::ParseStyle, "ParseStyle" }, { Event::ParseTile, "ParseTile" }, { Event::Render, "Render" }, + { Event::ResourceLoader, "ResourceLoader" }, { Event::Database, "Database" }, { Event::HttpRequest, "HttpRequest" }, { Event::Sprite, "Sprite" }, diff --git a/include/mbgl/platform/log.hpp b/include/mbgl/platform/log.hpp index d6f3cd1ab4..86a8cdbef1 100644 --- a/include/mbgl/platform/log.hpp +++ b/include/mbgl/platform/log.hpp @@ -3,7 +3,6 @@ #include <mbgl/platform/event.hpp> -#include <mbgl/util/std.hpp> #include <mbgl/util/noncopyable.hpp> #include <memory> diff --git a/include/mbgl/storage/default_file_source.hpp b/include/mbgl/storage/default_file_source.hpp index 405b04a49c..8cfae03a96 100644 --- a/include/mbgl/storage/default_file_source.hpp +++ b/include/mbgl/storage/default_file_source.hpp @@ -15,6 +15,9 @@ public: DefaultFileSource(FileCache *cache, const std::string &root = ""); ~DefaultFileSource() override; + void setAccessToken(const std::string& t) { accessToken = t; } + std::string getAccessToken() const { return accessToken; } + // FileSource API Request* request(const Resource&, uv_loop_t*, Callback) override; void cancel(Request*) override; @@ -23,6 +26,7 @@ public: class Impl; private: const std::unique_ptr<util::Thread<Impl>> thread; + std::string accessToken; }; } diff --git a/include/mbgl/storage/file_source.hpp b/include/mbgl/storage/file_source.hpp index 7c6e578a9a..3b19e00788 100644 --- a/include/mbgl/storage/file_source.hpp +++ b/include/mbgl/storage/file_source.hpp @@ -5,7 +5,6 @@ #include "resource.hpp" #include <mbgl/util/noncopyable.hpp> -#include <mbgl/util/std.hpp> #include <mbgl/util/util.hpp> #include <functional> diff --git a/include/mbgl/storage/resource.hpp b/include/mbgl/storage/resource.hpp index cfd52caa75..2fcb3b1b78 100644 --- a/include/mbgl/storage/resource.hpp +++ b/include/mbgl/storage/resource.hpp @@ -9,10 +9,12 @@ namespace mbgl { struct Resource { enum Kind : uint8_t { Unknown = 0, - Tile = 1, - Glyphs = 2, - Image = 3, - JSON = 4, + Style, + Source, + Tile, + Glyphs, + JSON, + Image }; const Kind kind; diff --git a/include/mbgl/util/exception.hpp b/include/mbgl/util/exception.hpp index 0b4403270c..da61aa482a 100644 --- a/include/mbgl/util/exception.hpp +++ b/include/mbgl/util/exception.hpp @@ -11,6 +11,11 @@ struct Exception : std::runtime_error { inline Exception(const std::string &msg) : std::runtime_error(msg) {} }; +struct GlyphRangeLoadingException : Exception { + inline GlyphRangeLoadingException(const char *msg) : Exception(msg) {} + inline GlyphRangeLoadingException(const std::string &msg) : Exception(msg) {} +}; + struct MisuseException : Exception { inline MisuseException(const char *msg) : Exception(msg) {} inline MisuseException(const std::string &msg) : Exception(msg) {} @@ -21,6 +26,21 @@ struct ShaderException : Exception { inline ShaderException(const std::string &msg) : Exception(msg) {} }; +struct SourceLoadingException : Exception { + inline SourceLoadingException(const char *msg) : Exception(msg) {} + inline SourceLoadingException(const std::string &msg) : Exception(msg) {} +}; + +struct SpriteLoadingException : Exception { + inline SpriteLoadingException(const char *msg) : Exception(msg) {} + inline SpriteLoadingException(const std::string &msg) : Exception(msg) {} +}; + +struct TileLoadingException : Exception { + inline TileLoadingException(const char *msg) : Exception(msg) {} + inline TileLoadingException(const std::string &msg) : Exception(msg) {} +}; + } } diff --git a/include/mbgl/util/exclusive.hpp b/include/mbgl/util/exclusive.hpp new file mode 100644 index 0000000000..bb3395996b --- /dev/null +++ b/include/mbgl/util/exclusive.hpp @@ -0,0 +1,30 @@ +#ifndef MBGL_UTIL_EXCLUSIVE +#define MBGL_UTIL_EXCLUSIVE + +#include <memory> +#include <mutex> + + +namespace mbgl { +namespace util { + +template <class T> +class exclusive { +public: + inline exclusive(T* val, std::unique_ptr<std::lock_guard<std::mutex>> mtx) : ptr(val), lock(std::move(mtx)) {} + + inline T* operator->() { return ptr; } + inline const T* operator->() const { return ptr; } + inline T* operator*() { return ptr; } + inline const T* operator*() const { return ptr; } + +private: + T *ptr; + std::unique_ptr<std::lock_guard<std::mutex>> lock; +}; + + +} // end namespace util +} // end namespace mbgl + +#endif diff --git a/include/mbgl/util/std.hpp b/include/mbgl/util/std.hpp index e64820de47..0e2d3346bf 100644 --- a/include/mbgl/util/std.hpp +++ b/include/mbgl/util/std.hpp @@ -8,29 +8,6 @@ namespace mbgl { namespace util { -// C++14 backfill based on http://llvm.org/svn/llvm-project/libcxx/trunk/include/memory - -namespace detail { -template<class T> struct unique_type { typedef ::std::unique_ptr<T> single; }; -template<class T> struct unique_type<T[]> { typedef ::std::unique_ptr<T[]> unknown_bound; }; -template<class T, size_t size> struct unique_type<T[size]> { typedef void known_bound; }; -} - -template<class T, class... Args> -typename detail::unique_type<T>::single make_unique(Args&&... args) { - return ::std::unique_ptr<T>(new T(::std::forward<Args>(args)...)); -} - -template<class T> -typename detail::unique_type<T>::unknown_bound make_unique(size_t size) { - return ::std::unique_ptr<T>(new typename ::std::remove_extent<T>::type[size]()); -} - -template<class T, class... Args> -typename detail::unique_type<T>::known_bound make_unique(Args&&...) = delete; - - - template <typename Container, typename ForwardIterator, typename Predicate> void erase_if(Container &container, ForwardIterator it, const ForwardIterator end, Predicate pred) { while (it != end) { |