summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/platform/darwin/log_nslog.hpp21
-rw-r--r--include/mbgl/platform/darwin/reachability.h112
-rw-r--r--include/mbgl/platform/darwin/settings_nsuserdefaults.hpp24
-rw-r--r--include/mbgl/platform/default/glfw_view.hpp48
-rw-r--r--include/mbgl/platform/default/headless_view.hpp65
-rw-r--r--include/mbgl/platform/default/log_stderr.hpp21
-rw-r--r--include/mbgl/platform/default/settings_json.hpp24
7 files changed, 315 insertions, 0 deletions
diff --git a/include/mbgl/platform/darwin/log_nslog.hpp b/include/mbgl/platform/darwin/log_nslog.hpp
new file mode 100644
index 0000000000..d40f963036
--- /dev/null
+++ b/include/mbgl/platform/darwin/log_nslog.hpp
@@ -0,0 +1,21 @@
+#ifndef MBGL_COMMON_NSLOG_LOG
+#define MBGL_COMMON_NSLOG_LOG
+
+#include <mbgl/platform/log.hpp>
+
+namespace mbgl {
+
+class NSLogBackend : public LogBackend {
+public:
+ inline ~NSLogBackend() = default;
+
+ void record(EventSeverity severity, Event event, const std::string &msg);
+ void record(EventSeverity severity, Event event, const char* format, ...);
+ void record(EventSeverity severity, Event event, int64_t code);
+ void record(EventSeverity severity, Event event, int64_t code, const std::string &msg);
+};
+
+
+}
+
+#endif
diff --git a/include/mbgl/platform/darwin/reachability.h b/include/mbgl/platform/darwin/reachability.h
new file mode 100644
index 0000000000..1cf7d2ecea
--- /dev/null
+++ b/include/mbgl/platform/darwin/reachability.h
@@ -0,0 +1,112 @@
+/*
+ Copyright (c) 2011, Tony Million.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#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.
+ *
+ * @see http://nshipster.com/ns_enum-ns_options/
+ **/
+#ifndef NS_ENUM
+#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+#endif
+
+extern NSString *const kReachabilityChangedNotification;
+
+typedef NS_ENUM(NSInteger, NetworkStatus) {
+ // Apple NetworkStatus Compatible Names.
+ NotReachable = 0,
+ ReachableViaWiFi = 2,
+ ReachableViaWWAN = 1
+};
+
+@class Reachability;
+
+typedef void (^NetworkReachable)(Reachability * reachability);
+typedef void (^NetworkUnreachable)(Reachability * reachability);
+
+@interface Reachability : NSObject
+
+@property (nonatomic, copy) NetworkReachable reachableBlock;
+@property (nonatomic, copy) NetworkUnreachable unreachableBlock;
+
+
+@property (nonatomic, assign) BOOL reachableOnWWAN;
+
++(Reachability*)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;
+
+-(Reachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref;
+
+-(BOOL)startNotifier;
+-(void)stopNotifier;
+
+-(BOOL)isReachable;
+-(BOOL)isReachableViaWWAN;
+-(BOOL)isReachableViaWiFi;
+
+// WWAN may be available, but not active until a connection has been established.
+// WiFi may require a connection for VPN on Demand.
+-(BOOL)isConnectionRequired; // Identical DDG variant.
+-(BOOL)connectionRequired; // Apple's routine.
+// Dynamic, on demand connection?
+-(BOOL)isConnectionOnDemand;
+// Is user intervention required?
+-(BOOL)isInterventionRequired;
+
+-(NetworkStatus)currentReachabilityStatus;
+-(SCNetworkReachabilityFlags)reachabilityFlags;
+-(NSString*)currentReachabilityString;
+-(NSString*)currentReachabilityFlags;
+
+@end
diff --git a/include/mbgl/platform/darwin/settings_nsuserdefaults.hpp b/include/mbgl/platform/darwin/settings_nsuserdefaults.hpp
new file mode 100644
index 0000000000..3533e3da35
--- /dev/null
+++ b/include/mbgl/platform/darwin/settings_nsuserdefaults.hpp
@@ -0,0 +1,24 @@
+#ifndef MBGL_COMMON_SETTINGS_NSUSERDEFAULTS
+#define MBGL_COMMON_SETTINGS_NSUSERDEFAULTS
+
+namespace mbgl {
+
+class Settings_NSUserDefaults {
+public:
+ Settings_NSUserDefaults();
+ void load();
+ void save();
+ void clear();
+
+public:
+ double longitude = 0;
+ double latitude = 0;
+ double zoom = 0;
+ double bearing = 0;
+
+ bool debug = false;
+};
+
+}
+
+#endif
diff --git a/include/mbgl/platform/default/glfw_view.hpp b/include/mbgl/platform/default/glfw_view.hpp
new file mode 100644
index 0000000000..6e91c1125e
--- /dev/null
+++ b/include/mbgl/platform/default/glfw_view.hpp
@@ -0,0 +1,48 @@
+#ifndef MBGL_COMMON_GLFW_VIEW
+#define MBGL_COMMON_GLFW_VIEW
+
+#include <mbgl/mbgl.hpp>
+#include <mbgl/util/time.hpp>
+
+#ifdef NVIDIA
+#define GLFW_INCLUDE_ES2
+#endif
+#include <GLFW/glfw3.h>
+
+class GLFWView : public mbgl::View {
+public:
+ GLFWView(bool fullscreen = false);
+ ~GLFWView();
+
+ void initialize(mbgl::Map *map);
+ void swap();
+ void make_active();
+ void make_inactive();
+ void notify();
+ void notify_map_change(mbgl::MapChange change, mbgl::timestamp delay = 0);
+
+ static void key(GLFWwindow *window, int key, int scancode, int action, int mods);
+ static void scroll(GLFWwindow *window, double xoffset, double yoffset);
+ static void resize(GLFWwindow *window, int, int);
+ static void mouseclick(GLFWwindow *window, int button, int action, int modifiers);
+ static void mousemove(GLFWwindow *window, double x, double y);
+
+ static void eventloop(void *arg);
+
+ int run();
+ void fps();
+
+public:
+ bool fullscreen = false;
+
+ double last_x = 0, last_y = 0;
+ bool tracking = false;
+
+ bool rotating = false;
+
+ double last_click = -1;
+
+ GLFWwindow *window = nullptr;
+};
+
+#endif
diff --git a/include/mbgl/platform/default/headless_view.hpp b/include/mbgl/platform/default/headless_view.hpp
new file mode 100644
index 0000000000..c0baddb884
--- /dev/null
+++ b/include/mbgl/platform/default/headless_view.hpp
@@ -0,0 +1,65 @@
+#ifndef MBGL_COMMON_HEADLESS_VIEW
+#define MBGL_COMMON_HEADLESS_VIEW
+
+#ifdef __APPLE__
+#define MBGL_USE_CGL 1
+#else
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glx.h>
+#define MBGL_USE_GLX 1
+#endif
+
+#include <mbgl/map/view.hpp>
+#include <mbgl/platform/gl.hpp>
+
+#include <memory>
+
+namespace mbgl {
+
+class HeadlessDisplay;
+
+class HeadlessView : public View {
+public:
+ HeadlessView();
+ HeadlessView(std::shared_ptr<HeadlessDisplay> display);
+ ~HeadlessView();
+
+ void createContext();
+
+ void resize(uint16_t width, uint16_t height, float pixelRatio);
+ const std::unique_ptr<uint32_t[]> readPixels();
+
+ void notify();
+ void notify_map_change(MapChange change, timestamp delay = 0);
+ void make_active();
+ void make_inactive();
+ void swap();
+
+private:
+ void clear_buffers();
+
+private:
+ std::shared_ptr<HeadlessDisplay> display_;
+ uint16_t width_;
+ uint16_t height_;
+ float pixelRatio_;
+
+#if MBGL_USE_CGL
+ CGLContextObj gl_context;
+#endif
+
+#if MBGL_USE_GLX
+ Display *x_display = nullptr;
+ GLXFBConfig *fb_configs = nullptr;
+ GLXContext gl_context = 0;
+ GLXPbuffer glx_pbuffer = 0;
+#endif
+
+ GLuint fbo = 0;
+ GLuint fbo_depth_stencil = 0;
+ GLuint fbo_color = 0;
+};
+
+}
+
+#endif
diff --git a/include/mbgl/platform/default/log_stderr.hpp b/include/mbgl/platform/default/log_stderr.hpp
new file mode 100644
index 0000000000..45f76f0d1a
--- /dev/null
+++ b/include/mbgl/platform/default/log_stderr.hpp
@@ -0,0 +1,21 @@
+#ifndef MBGL_COMMON_STDERR_LOG
+#define MBGL_COMMON_STDERR_LOG
+
+#include <mbgl/platform/log.hpp>
+
+namespace mbgl {
+
+class StderrLogBackend : public LogBackend {
+public:
+ inline ~StderrLogBackend() = default;
+
+ void record(EventSeverity severity, Event event, const std::string &msg);
+ void record(EventSeverity severity, Event event, const char* format, ...);
+ void record(EventSeverity severity, Event event, int64_t code);
+ void record(EventSeverity severity, Event event, int64_t code, const std::string &msg);
+};
+
+
+}
+
+#endif
diff --git a/include/mbgl/platform/default/settings_json.hpp b/include/mbgl/platform/default/settings_json.hpp
new file mode 100644
index 0000000000..25c2179ba0
--- /dev/null
+++ b/include/mbgl/platform/default/settings_json.hpp
@@ -0,0 +1,24 @@
+#ifndef MBGL_JSON_SETTINGS
+#define MBGL_JSON_SETTINGS
+
+namespace mbgl {
+
+class Settings_JSON {
+public:
+ Settings_JSON();
+ void load();
+ void save();
+ void clear();
+
+public:
+ double longitude = 0;
+ double latitude = 0;
+ double zoom = 0;
+ double bearing = 0;
+
+ bool debug = false;
+};
+
+}
+
+#endif