From cd9a89257a0004ca18460befc4b141bc07ed5c22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Fri, 24 Oct 2014 15:43:05 +0200 Subject: restructure gyp files --- include/mbgl/platform/darwin/log_nslog.hpp | 21 ++++ include/mbgl/platform/darwin/reachability.h | 112 +++++++++++++++++++++ .../platform/darwin/settings_nsuserdefaults.hpp | 24 +++++ include/mbgl/platform/default/glfw_view.hpp | 47 +++++++++ include/mbgl/platform/default/headless_view.hpp | 53 ++++++++++ include/mbgl/platform/default/log_stderr.hpp | 21 ++++ include/mbgl/platform/default/settings_json.hpp | 24 +++++ 7 files changed, 302 insertions(+) create mode 100644 include/mbgl/platform/darwin/log_nslog.hpp create mode 100644 include/mbgl/platform/darwin/reachability.h create mode 100644 include/mbgl/platform/darwin/settings_nsuserdefaults.hpp create mode 100644 include/mbgl/platform/default/glfw_view.hpp create mode 100644 include/mbgl/platform/default/headless_view.hpp create mode 100644 include/mbgl/platform/default/log_stderr.hpp create mode 100644 include/mbgl/platform/default/settings_json.hpp (limited to 'include') 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 + +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 +#import + +#import +#import +#import +#import +#import +#import + +/** + * 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..481b1598bb --- /dev/null +++ b/include/mbgl/platform/default/glfw_view.hpp @@ -0,0 +1,47 @@ +#ifndef MBGL_COMMON_GLFW_VIEW +#define MBGL_COMMON_GLFW_VIEW + +#include +#include + +#ifdef NVIDIA +#define GLFW_INCLUDE_ES2 +#endif +#include + +class GLFWView : public mbgl::View { +public: + GLFWView(bool fullscreen = false); + ~GLFWView(); + + void initialize(mbgl::Map *map); + void swap(); + void make_active(); + 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..42f9c46da2 --- /dev/null +++ b/include/mbgl/platform/default/headless_view.hpp @@ -0,0 +1,53 @@ +#ifndef MBGL_COMMON_HEADLESS_CGL +#define MBGL_COMMON_HEADLESS_CGL + +#ifdef __APPLE__ +#define MBGL_USE_CGL 1 +#else +#include +#define MBGL_USE_GLX 1 +#endif + +#include +#include +#include + +namespace mbgl { + +class HeadlessView : public View { +public: + HeadlessView(); + ~HeadlessView(); + + void resize(uint16_t width, uint16_t height, float pixelRatio); + + void notify(); + void notify_map_change(MapChange change, timestamp delay = 0); + void make_active(); + void swap(); + unsigned int root_fbo(); + +private: + void clear_buffers(); + + +private: +#if MBGL_USE_CGL + CGLContextObj gl_context; + GLuint fbo = 0; + GLuint fbo_depth_stencil = 0; + GLuint fbo_color = 0; +#endif + +#if MBGL_USE_GLX + GLXContext gl_context = nullptr; + XVisualInfo *x_info = nullptr; + Display *x_display = nullptr; + Pixmap x_pixmap = 0; + GLXPixmap glx_pixmap = 0; +#endif +}; + +} + +#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 + +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 -- cgit v1.2.1