diff --git a/.gitignore b/.gitignore index 5cf9666f5..c69b0331e 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,7 @@ /config/constants_local.cpp /build /bin/node_modules -/include/llmr/shader/shaders.hpp +/include/mbgl/shader/shaders.hpp /src/shader/shaders_gl.cpp /src/shader/shaders_gles2.cpp /bin/style.bin.js diff --git a/Makefile b/Makefile index cbc00c8ea..bfb550aff 100644 --- a/Makefile +++ b/Makefile @@ -12,9 +12,9 @@ config.gypi: ./setup-libraries.sh # Builds the regular library -llmr: config.gypi llmr.gyp node - deps/run_gyp llmr.gyp --depth=. -Goutput_dir=.. --generator-output=./build/llmr -f make - $(MAKE) -C build/llmr BUILDTYPE=$(BUILDTYPE) V=$(V) llmr-x86 +mbgl: config.gypi mapboxgl.gyp node + deps/run_gyp mapboxgl.gyp --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make + $(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mapboxgl node: @if [ ! `which node` ]; then echo 'error: depends on node.js. please make sure node is on your PATH'; exit 1; fi; @@ -40,8 +40,8 @@ xtest: config.gypi clear_xcode_cache node # Builds the linux app with make. This is also used by Travis CI -linux: config.gypi linux/llmr-app.gyp node - deps/run_gyp linux/llmr-app.gyp --depth=. -Goutput_dir=.. --generator-output=./build/linux -f make +linux: config.gypi linux/mapboxgl-app.gyp node + deps/run_gyp linux/mapboxgl-app.gyp --depth=. -Goutput_dir=.. --generator-output=./build/linux -f make $(MAKE) -C build/linux BUILDTYPE=$(BUILDTYPE) V=$(V) linuxapp # Executes the Linux binary @@ -51,8 +51,8 @@ run-linux: linux # Builds the OS X app with make. -osx: config.gypi macosx/llmr-app.gyp node - deps/run_gyp macosx/llmr-app.gyp --depth=. -Goutput_dir=.. --generator-output=./build/macosx -f make +osx: config.gypi macosx/mapboxgl-app.gyp node + deps/run_gyp macosx/mapboxgl-app.gyp --depth=. -Goutput_dir=.. --generator-output=./build/macosx -f make $(MAKE) -C build/macosx BUILDTYPE=$(BUILDTYPE) V=$(V) osxapp # Executes the OS X binary @@ -65,27 +65,27 @@ clear_xcode_cache: @CUSTOM_DD=`defaults read com.apple.dt.Xcode IDECustomDerivedDataLocation 2>/dev/null`; \ if [[ $$CUSTOM_DD ]]; then \ echo clearing files in $$CUSTOM_DD older than one day; \ - find $$CUSTOM_DD/llmr-app-* -mtime +1 | xargs rm -rf; \ + find $$CUSTOM_DD/mapboxgl-app-* -mtime +1 | xargs rm -rf; \ fi; \ if [[ -d ~/Library/Developer/Xcode/DerivedData/ ]] && [[ ! $$CUSTOM_DD ]]; then \ - echo 'clearing files in ~/Library/Developer/Xcode/DerivedData/llmr-app-* older than one day'; \ - find ~/Library/Developer/Xcode/DerivedData/llmr-app-* -mtime +1 | xargs rm -rf; \ + echo 'clearing files in ~/Library/Developer/Xcode/DerivedData/mapboxgl-app-* older than one day'; \ + find ~/Library/Developer/Xcode/DerivedData/mapboxgl-app-* -mtime +1 | xargs rm -rf; \ fi # build Mac OS X project for Xcode -xproj: config.gypi macosx/llmr-app.gyp clear_xcode_cache node - deps/run_gyp macosx/llmr-app.gyp --depth=. --generator-output=./build -f xcode - open ./build/macosx/llmr-app.xcodeproj +xproj: config.gypi macosx/mapboxgl-app.gyp clear_xcode_cache node + deps/run_gyp macosx/mapboxgl-app.gyp --depth=. --generator-output=./build -f xcode + open ./build/macosx/mapboxgl-app.xcodeproj # build iOS project for Xcode -iproj: config.gypi ios/mapbox-gl-cocoa/app/llmr-app.gyp clear_xcode_cache node - deps/run_gyp ios/mapbox-gl-cocoa/app/llmr-app.gyp --depth=. --generator-output=./build -f xcode - open ./build/ios/mapbox-gl-cocoa/app/llmr-app.xcodeproj +iproj: config.gypi ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp clear_xcode_cache node + deps/run_gyp ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp --depth=. --generator-output=./build -f xcode + open ./build/ios/mapbox-gl-cocoa/app/mapboxgl-app.xcodeproj # build Linux project for Xcode (Runs on Mac OS X too, but without platform-specific code) -lproj: config.gypi linux/llmr-app.gyp clear_xcode_cache node - deps/run_gyp linux/llmr-app.gyp --depth=. --generator-output=./build -f xcode - open ./build/linux/llmr-app.xcodeproj +lproj: config.gypi linux/mapboxgl-app.gyp clear_xcode_cache node + deps/run_gyp linux/mapboxgl-app.gyp --depth=. --generator-output=./build -f xcode + open ./build/linux/mapboxgl-app.xcodeproj ##### Maintenace operations #################################################### @@ -101,4 +101,4 @@ distclean: clean -rm -rf ./config.gypi -rm -rf ./mapnik-packaging/osx/out/ -.PHONY: llmr test linux +.PHONY: mbgl test linux diff --git a/bin/build-shaders.js b/bin/build-shaders.js index 61d182b03..38aa75373 100755 --- a/bin/build-shaders.js +++ b/bin/build-shaders.js @@ -83,10 +83,10 @@ module.exports = function(shader_type, prefix, suffix) { } var header = '// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.\n\n'; - header += '#ifndef LLMR_SHADER_SHADERS\n'; - header += '#define LLMR_SHADER_SHADERS\n'; + header += '#ifndef MBGL_SHADER_SHADERS\n'; + header += '#define MBGL_SHADER_SHADERS\n'; header += '\n'; - header += 'namespace llmr {\n'; + header += 'namespace mbgl {\n'; header += '\n'; header += 'struct shader_source {\n'; header += ' const char *vertex;\n'; @@ -106,18 +106,19 @@ module.exports = function(shader_type, prefix, suffix) { var code = '// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.\n'; - code += '#include \n'; + code += '#include \n'; code += prefix + '\n'; - code += '#include \n'; + code += '#include \n'; code += '\n'; - code += 'using namespace llmr;\n'; + code += 'namespace mbgl {\n'; code += '\n'; - code += 'const shader_source llmr::shaders[SHADER_COUNT] = {\n'; + code += 'const shader_source shaders[SHADER_COUNT] = {\n'; code += lines.join(',\n'); code += '\n};\n'; + code += '\n}\n'; code += suffix + '\n'; - var header_path = path.join(process.argv[2], 'include/llmr/shader/shaders.hpp'); + var header_path = path.join(process.argv[2], 'include/mbgl/shader/shaders.hpp'); mkdirp.sync(path.dirname(header_path)); fs.writeFileSync(header_path, header); console.warn('wrote file ' + header_path); diff --git a/bin/package.json b/bin/package.json index 77edcb9bf..50843fa4b 100644 --- a/bin/package.json +++ b/bin/package.json @@ -1,5 +1,5 @@ { - "name": "llmr-native", + "name": "mbgl-native", "version": "0.0.1", "dependencies": { "brfs": "^1.1.2", diff --git a/common/curl_request.cpp b/common/curl_request.cpp index 66750e459..b7e5e8b5c 100644 --- a/common/curl_request.cpp +++ b/common/curl_request.cpp @@ -1,8 +1,8 @@ -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -47,7 +47,7 @@ See http://nikhilm.github.com/uvbook/ for more information on libuv. */ -namespace llmr { +namespace mbgl { namespace platform { namespace request { @@ -66,8 +66,8 @@ static uv_async_t async_cancel; // Stores pointers (!) to shared_ptrs. We use shared_ptrs so that request objects don't get // auto-destructed while they're in progress. The TileData object retains a weak_ptr to this // request, so we have to use a shared_ptr here to ensure that this object stays alive. -static boost::lockfree::queue *> add_queue(8); -static boost::lockfree::queue *> cancel_queue(8); +static boost::lockfree::queue *> add_queue(8); +static boost::lockfree::queue *> cancel_queue(8); // Used as the CURL timer function to periodically check for socket updates. static uv_timer_t timeout; @@ -85,10 +85,10 @@ static CURLSH *curl_share = nullptr; static std::queue curl_handle_cache; -class CURLRequest : public llmr::platform::Request { +class CURLRequest : public mbgl::platform::Request { public: CURLRequest(const std::string &url, - std::function callback, + std::function callback, std::shared_ptr loop) : Request(url, callback, loop) {} @@ -380,4 +380,4 @@ void platform::cancel_request_http(const std::shared_ptr &req) { uv_async_send(&async_cancel); } } -} // end namespace llmr +} // end namespace mbgl diff --git a/common/foundation_request.mm b/common/foundation_request.mm index 4d6ca9c5f..4684ff55f 100644 --- a/common/foundation_request.mm +++ b/common/foundation_request.mm @@ -9,9 +9,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include uv_once_t request_initialize = UV_ONCE_INIT; @@ -37,10 +37,10 @@ void request_initialize_cb() { // We're using a child class to make sure ARC is working correctly, as well as to add activity // indicators on iOS. -class FoundationRequest : public llmr::platform::Request { +class FoundationRequest : public mbgl::platform::Request { public: FoundationRequest(const std::string &url, - std::function callback, + std::function callback, std::shared_ptr loop) : Request(url, callback, loop) { #if TARGET_OS_IPHONE @@ -65,8 +65,8 @@ public: NSURLSessionDataTask *task = nullptr; }; -std::shared_ptr -llmr::platform::request_http(const std::string &url, +std::shared_ptr +mbgl::platform::request_http(const std::string &url, std::function callback, std::shared_ptr loop) { uv_once(&request_initialize, request_initialize_cb); @@ -109,7 +109,7 @@ llmr::platform::request_http(const std::string &url, return req; } -void llmr::platform::cancel_request_http(const std::shared_ptr &req) { +void mbgl::platform::cancel_request_http(const std::shared_ptr &req) { if (req) { [((FoundationRequest *)(req.get()))->task cancel]; } diff --git a/common/glfw_view.cpp b/common/glfw_view.cpp index d4f896914..60d95c8b8 100644 --- a/common/glfw_view.cpp +++ b/common/glfw_view.cpp @@ -8,7 +8,7 @@ GLFWView::GLFWView(bool fullscreen) : fullscreen(fullscreen) { GLFWView::~GLFWView() { glfwTerminate(); } -void GLFWView::initialize(llmr::Map *map) { +void GLFWView::initialize(mbgl::Map *map) { View::initialize(map); if (!glfwInit()) { @@ -34,7 +34,7 @@ void GLFWView::initialize(llmr::Map *map) { glfwWindowHint(GLFW_STENCIL_BITS, 8); glfwWindowHint(GLFW_DEPTH_BITS, 16); - window = glfwCreateWindow(1024, 768, "llmr", monitor, NULL); + window = glfwCreateWindow(1024, 768, "Mapbox GL", monitor, NULL); if (!window) { glfwTerminate(); fprintf(stderr, "Failed to initialize window\n"); @@ -194,6 +194,10 @@ void GLFWView::swap() { glfwPostEmptyEvent(); } +void GLFWView::notify_map_change(mbgl::MapChange change, mbgl::timestamp delay) { + // no-op +} + void GLFWView::fps() { static int frames = 0; static double time_elapsed = 0; @@ -208,7 +212,7 @@ void GLFWView::fps() { } } -namespace llmr { +namespace mbgl { namespace platform { double elapsed() { return glfwGetTime(); } @@ -281,9 +285,5 @@ void show_color_debug_image(std::string name, const char *data, size_t logical_w } #endif -void notify_map_change(MapChange change) { - // no-op -} - } } diff --git a/common/glfw_view.hpp b/common/glfw_view.hpp index 62da124ca..efef3431a 100644 --- a/common/glfw_view.hpp +++ b/common/glfw_view.hpp @@ -1,7 +1,8 @@ -#ifndef LLMR_COMMON_GLFW_VIEW -#define LLMR_COMMON_GLFW_VIEW +#ifndef MBGL_COMMON_GLFW_VIEW +#define MBGL_COMMON_GLFW_VIEW -#include +#include +#include #ifdef NVIDIA #define GLFW_INCLUDE_ES2 @@ -10,14 +11,15 @@ #include -class GLFWView : public llmr::View { +class GLFWView : public mbgl::View { public: GLFWView(bool fullscreen = false); ~GLFWView(); - void initialize(llmr::Map *map); + void initialize(mbgl::Map *map); void swap(); void make_active(); + 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); diff --git a/common/headless_view.cpp b/common/headless_view.cpp index a44c6e6ed..6a7d75d75 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -1,19 +1,12 @@ #include "headless_view.hpp" -#include -#include +#include -namespace llmr { +#include -namespace platform { - -void notify_map_change(MapChange change) { - // no-op -} - -} +namespace mbgl { HeadlessView::HeadlessView() { -#if LLMR_USE_CGL +#if MBGL_USE_CGL // TODO: test if OpenGL 4.1 with GL_ARB_ES2_compatibility is supported // If it is, use kCGLOGLPVersion_3_2_Core and enable that extension. CGLPixelFormatAttribute attributes[] = { @@ -39,7 +32,7 @@ HeadlessView::HeadlessView() { } #endif -#if LLMR_USE_GLX +#if MBGL_USE_GLX x_display = XOpenDisplay(0); if (x_display == nullptr) { @@ -75,7 +68,7 @@ HeadlessView::HeadlessView() { void HeadlessView::resize(int width, int height) { clear_buffers(); -#if LLMR_USE_CGL +#if MBGL_USE_CGL make_active(); // Create depth/stencil buffer @@ -110,7 +103,7 @@ void HeadlessView::resize(int width, int height) { } #endif -#if LLMR_USE_GLX +#if MBGL_USE_GLX x_pixmap = XCreatePixmap(x_display, DefaultRootWindow(x_display), width, height, 32); glx_pixmap = glXCreateGLXPixmap(x_display, x_info, x_pixmap); @@ -120,7 +113,7 @@ void HeadlessView::resize(int width, int height) { } void HeadlessView::clear_buffers() { -#if LLMR_USE_CGL +#if MBGL_USE_CGL glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); if (fbo) { @@ -139,7 +132,7 @@ void HeadlessView::clear_buffers() { } #endif -#if LLMR_USE_GLX +#if MBGL_USE_GLX if (glx_pixmap) { glXDestroyGLXPixmap(x_display, glx_pixmap); glx_pixmap = 0; @@ -155,20 +148,24 @@ void HeadlessView::clear_buffers() { HeadlessView::~HeadlessView() { clear_buffers(); -#if LLMR_USE_CGL +#if MBGL_USE_CGL CGLDestroyContext(gl_context); #endif } +void HeadlessView::notify_map_change(mbgl::MapChange change, mbgl::timestamp delay) { + // no-op +} + void HeadlessView::make_active() { -#if LLMR_USE_CGL +#if MBGL_USE_CGL CGLError error = CGLSetCurrentContext(gl_context); if (error) { fprintf(stderr, "Switching OpenGL context failed\n"); } #endif -#if LLMR_USE_GLX +#if MBGL_USE_GLX if (!glXMakeCurrent(x_display, glx_pixmap, gl_context)) { fprintf(stderr, "Switching OpenGL context failed\n"); } @@ -178,7 +175,7 @@ void HeadlessView::make_active() { void HeadlessView::swap() {} unsigned int HeadlessView::root_fbo() { -#if LLMR_USE_CGL +#if MBGL_USE_CGL return fbo; #endif diff --git a/common/headless_view.hpp b/common/headless_view.hpp index b3e1c11b9..0b255b4a3 100644 --- a/common/headless_view.hpp +++ b/common/headless_view.hpp @@ -1,17 +1,18 @@ -#ifndef LLMR_COMMON_HEADLESS_CGL -#define LLMR_COMMON_HEADLESS_CGL +#ifndef MBGL_COMMON_HEADLESS_CGL +#define MBGL_COMMON_HEADLESS_CGL #ifdef __APPLE__ -#define LLMR_USE_CGL 1 +#define MBGL_USE_CGL 1 #else #include -#define LLMR_USE_GLX 1 +#define MBGL_USE_GLX 1 #endif -#include -#include +#include +#include +#include -namespace llmr { +namespace mbgl { class HeadlessView : public View { public: @@ -20,6 +21,7 @@ public: void resize(int width, int height); + void notify_map_change(MapChange change, timestamp delay = 0); void make_active(); void swap(); unsigned int root_fbo(); @@ -29,14 +31,14 @@ private: private: -#if LLMR_USE_CGL +#if MBGL_USE_CGL CGLContextObj gl_context; GLuint fbo = 0; GLuint fbo_depth_stencil = 0; GLuint fbo_color = 0; #endif -#if LLMR_USE_GLX +#if MBGL_USE_GLX GLXContext gl_context = nullptr; XVisualInfo *x_info = nullptr; Display *x_display = nullptr; diff --git a/common/nslog_log.hpp b/common/nslog_log.hpp index 9f2f3aee7..d40f96303 100644 --- a/common/nslog_log.hpp +++ b/common/nslog_log.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_COMMON_NSLOG_LOG -#define LLMR_COMMON_NSLOG_LOG +#ifndef MBGL_COMMON_NSLOG_LOG +#define MBGL_COMMON_NSLOG_LOG -#include +#include -namespace llmr { +namespace mbgl { class NSLogBackend : public LogBackend { public: diff --git a/common/nslog_log.mm b/common/nslog_log.mm index c6ca65d0b..12230143a 100644 --- a/common/nslog_log.mm +++ b/common/nslog_log.mm @@ -4,7 +4,7 @@ #include -namespace llmr { +namespace mbgl { void NSLogBackend::record(EventSeverity severity, Event event, const std::string &msg) { NSLog(@"[%s] %s: %@", EventSeverityClass(severity).c_str(), EventClass(event).c_str(), diff --git a/common/settings_json.cpp b/common/settings_json.cpp index 771d89e1a..bceab50da 100644 --- a/common/settings_json.cpp +++ b/common/settings_json.cpp @@ -4,12 +4,12 @@ #include #include -using namespace llmr; +using namespace mbgl; Settings_JSON::Settings_JSON() { load(); } void Settings_JSON::load() { - FILE *settingsFile = fopen("/tmp/llmr-native.json", "r"); + FILE *settingsFile = fopen("/tmp/mbgl-native.json", "r"); if (settingsFile != NULL) { rapidjson::FileStream is(settingsFile); rapidjson::Document document; @@ -26,7 +26,7 @@ void Settings_JSON::load() { void Settings_JSON::save() { - rapidjson::FileStream s(fopen("/tmp/llmr-native.json", "w")); + rapidjson::FileStream s(fopen("/tmp/mbgl-native.json", "w")); rapidjson::PrettyWriter writer(s); writer.StartArray(); writer.Double(longitude); diff --git a/common/settings_json.hpp b/common/settings_json.hpp index fa9525465..09f7841c9 100644 --- a/common/settings_json.hpp +++ b/common/settings_json.hpp @@ -1,7 +1,7 @@ -#ifndef LLMR_JSON_SETTINGS -#define LLMR_JSON_SETTINGS +#ifndef MBGL_JSON_SETTINGS +#define MBGL_JSON_SETTINGS -namespace llmr { +namespace mbgl { class Settings_JSON { public: diff --git a/common/settings_nsuserdefaults.hpp b/common/settings_nsuserdefaults.hpp index 575cc4a75..dcc6ab46b 100644 --- a/common/settings_nsuserdefaults.hpp +++ b/common/settings_nsuserdefaults.hpp @@ -1,7 +1,7 @@ -#ifndef LLMR_COMMON_SETTINGS_NSUSERDEFAULTS -#define LLMR_COMMON_SETTINGS_NSUSERDEFAULTS +#ifndef MBGL_COMMON_SETTINGS_NSUSERDEFAULTS +#define MBGL_COMMON_SETTINGS_NSUSERDEFAULTS -namespace llmr { +namespace mbgl { class Settings_NSUserDefaults { public: diff --git a/common/settings_nsuserdefaults.mm b/common/settings_nsuserdefaults.mm index 783aa500d..24571677f 100644 --- a/common/settings_nsuserdefaults.mm +++ b/common/settings_nsuserdefaults.mm @@ -2,7 +2,7 @@ #include "settings_nsuserdefaults.hpp" -using namespace llmr; +using namespace mbgl; Settings_NSUserDefaults::Settings_NSUserDefaults() { diff --git a/common/stderr_log.cpp b/common/stderr_log.cpp index da5799d75..bcb84447b 100644 --- a/common/stderr_log.cpp +++ b/common/stderr_log.cpp @@ -3,7 +3,7 @@ #include #include -namespace llmr { +namespace mbgl { void StderrLogBackend::record(EventSeverity severity, Event event, const std::string &msg) { std::cerr << "[" << severity << "] " << event << ": " << msg << std::endl; diff --git a/common/stderr_log.hpp b/common/stderr_log.hpp index e2492d3af..45f76f0d1 100644 --- a/common/stderr_log.hpp +++ b/common/stderr_log.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_COMMON_STDERR_LOG -#define LLMR_COMMON_STDERR_LOG +#ifndef MBGL_COMMON_STDERR_LOG +#define MBGL_COMMON_STDERR_LOG -#include +#include -namespace llmr { +namespace mbgl { class StderrLogBackend : public LogBackend { public: diff --git a/config/constants.cpp b/config/constants.cpp index 36f51559e..3d1422e6c 100644 --- a/config/constants.cpp +++ b/config/constants.cpp @@ -1,27 +1,27 @@ -#include +#include -const float llmr::util::tileSize = 512.0f; +const float mbgl::util::tileSize = 512.0f; #if defined(DEBUG) -const bool llmr::debug::tileParseWarnings = false; -const bool llmr::debug::styleParseWarnings = false; -const bool llmr::debug::spriteWarnings = false; -const bool llmr::debug::renderWarnings = false; -const bool llmr::debug::renderTree = false; -const bool llmr::debug::labelTextMissingWarning = true; -const bool llmr::debug::missingFontStackWarning = true; -const bool llmr::debug::missingFontFaceWarning = true; -const bool llmr::debug::glyphWarning = true; -const bool llmr::debug::shapingWarning = true; +const bool mbgl::debug::tileParseWarnings = false; +const bool mbgl::debug::styleParseWarnings = false; +const bool mbgl::debug::spriteWarnings = false; +const bool mbgl::debug::renderWarnings = false; +const bool mbgl::debug::renderTree = false; +const bool mbgl::debug::labelTextMissingWarning = true; +const bool mbgl::debug::missingFontStackWarning = true; +const bool mbgl::debug::missingFontFaceWarning = true; +const bool mbgl::debug::glyphWarning = true; +const bool mbgl::debug::shapingWarning = true; #else -const bool llmr::debug::tileParseWarnings = false; -const bool llmr::debug::styleParseWarnings = false; -const bool llmr::debug::spriteWarnings = false; -const bool llmr::debug::renderWarnings = false; -const bool llmr::debug::renderTree = false; -const bool llmr::debug::labelTextMissingWarning = false; -const bool llmr::debug::missingFontStackWarning = false; -const bool llmr::debug::missingFontFaceWarning = false; -const bool llmr::debug::glyphWarning = false; -const bool llmr::debug::shapingWarning = false; +const bool mbgl::debug::tileParseWarnings = false; +const bool mbgl::debug::styleParseWarnings = false; +const bool mbgl::debug::spriteWarnings = false; +const bool mbgl::debug::renderWarnings = false; +const bool mbgl::debug::renderTree = false; +const bool mbgl::debug::labelTextMissingWarning = false; +const bool mbgl::debug::missingFontStackWarning = false; +const bool mbgl::debug::missingFontFaceWarning = false; +const bool mbgl::debug::glyphWarning = false; +const bool mbgl::debug::shapingWarning = false; #endif diff --git a/configure b/configure index 3c9a421bf..f1a39cbbc 100755 --- a/configure +++ b/configure @@ -50,7 +50,7 @@ def pkg_config(pkg, pkgconfig_root): return (libs, cflags) -def configure_llmr(o): +def configure_mbgl(o): if options.boost_root: o['variables']['boost_root'] = options.boost_root else: @@ -115,7 +115,7 @@ output = { } if __name__ == '__main__': - configure_llmr(output) + configure_mbgl(output) configure_glfw3(output) configure_uv(output) configure_png(output) diff --git a/include/llmr/geometry/interpolate.hpp b/include/llmr/geometry/interpolate.hpp deleted file mode 100644 index 0014d56aa..000000000 --- a/include/llmr/geometry/interpolate.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef LLMR_GEOMETRY_INTERPOLATE -#define LLMR_GEOMETRY_INTERPOLATE - -#include -#include - -namespace llmr { - -Anchors interpolate(const std::vector &vertices, float spacing, - float minScale = 0.0f, int start = 0); -} - -#endif diff --git a/include/llmr/map/view.hpp b/include/llmr/map/view.hpp deleted file mode 100644 index d032f783c..000000000 --- a/include/llmr/map/view.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef LLMR_MAP_VIEW -#define LLMR_MAP_VIEW - -namespace llmr { - -class Map; - -class View { -public: - virtual void initialize(Map *map) { - this->map = map; - } - - // Called from the render (=GL) thread. Signals that the context should - // swap the front and the back buffer. - virtual void swap() = 0; - - // Called from the render thread. Makes the GL context active in the current - // thread. This is typically just called once at the beginning of the - // renderer setup since the render thread doesn't switch the contexts. - virtual void make_active() = 0; - - // Returns the base framebuffer object, if any, and 0 if using the system - // provided framebuffer. - virtual unsigned int root_fbo() { - return 0; - } - -protected: - llmr::Map *map = nullptr; -}; -} - -#endif diff --git a/include/llmr/style/filter_expression.hpp b/include/llmr/style/filter_expression.hpp deleted file mode 100644 index 5c7a400d8..000000000 --- a/include/llmr/style/filter_expression.hpp +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef LLMR_STYLE_FILTER_EXPRESSION -#define LLMR_STYLE_FILTER_EXPRESSION - -#include -#include - -#include -#include -#include -#include - -namespace llmr { - -class VectorTileTagExtractor; - -class FilterComparison { -public: - enum class Operator : uint8_t { - Equal, - NotEqual, - Greater, - GreaterEqual, - Less, - LessEqual, - In, - NotIn - }; - - class Instance { - public: - Instance(Operator op, std::forward_list &&values) - : op(op), values(values) {} - - bool compare(const Value &property_value) const; - bool compare(const std::forward_list &property_values) const; - - private: - template inline bool includes(const Value &property_value, const Comparer &comparer) const; - template inline bool compare(const Value &property_value, const Comparer &comparer) const; - template inline bool all(const std::forward_list &property_values, const Comparer &comparer) const; - - private: - Operator op = Operator::Equal; - std::forward_list values; - - friend std::ostream& operator <<(std::ostream &, const Instance &); - }; - -public: - FilterComparison(const std::string &field) : field(field) {}; - - const std::string &getField() const; - inline bool compare(const VectorTileTagExtractor &extractor) const; - - template - inline void add(Args&& ...args) { - instances.emplace_front(::std::forward(args)...); - } - -private: - std::string field; - std::forward_list instances; - - friend std::ostream& operator <<(std::ostream &, const FilterComparison &); -}; - -std::ostream& operator <<(std::ostream &s, const FilterComparison &comparison); -std::ostream& operator <<(std::ostream &s, const FilterComparison::Instance &instance); - - -FilterComparison::Operator parseFilterComparisonOperator(const std::string &op); - - -class FilterExpression { -public: - typedef util::recursive_wrapper Wrapper; - - enum class Operator : uint8_t { - And, - Or, - Xor, - Nor - }; - - enum class GeometryType : uint8_t { - Any, - Point, - LineString, - Polygon - }; - -public: - FilterExpression() = default; - FilterExpression(Operator op) : op(op) {}; - - bool empty() const; - - bool compare(const VectorTileTagExtractor &extractor) const; - void add(const FilterComparison &comparison); - void add(const FilterExpression &expression); - void setGeometryType(GeometryType g); - -private: - Operator op = Operator::And; - GeometryType type = GeometryType::Any; - std::forward_list comparisons; - std::forward_list expressions; - - friend std::ostream& operator <<(std::ostream &, const FilterExpression &); -}; - -std::ostream& operator <<(std::ostream &s, const FilterExpression &expression); - -FilterExpression::GeometryType parseGeometryType(const std::string &geometry); -} - -#endif diff --git a/include/llmr/style/property_value.hpp b/include/llmr/style/property_value.hpp deleted file mode 100644 index 3e2a675b5..000000000 --- a/include/llmr/style/property_value.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef LLMR_STYLE_PROPERTY_VALUE -#define LLMR_STYLE_PROPERTY_VALUE - -#include -#include -#include - -namespace llmr { - -typedef util::variant< - std::string, - TranslateAnchorType, - RotateAnchorType, - Function, - Function, - Function -> PropertyValue; - -} - -#endif diff --git a/include/llmr/style/value.hpp b/include/llmr/style/value.hpp deleted file mode 100644 index fac316d3d..000000000 --- a/include/llmr/style/value.hpp +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef LLMR_STYLE_VALUE -#define LLMR_STYLE_VALUE - -#include -#include - -namespace llmr { - -typedef util::variant Value; - -std::string toString(const Value &value); - -Value parseValue(pbf data); - -namespace util { - -namespace detail { - -inline int string_to_bool(std::string str) { - std::transform(str.begin(), str.end(), str.begin(), ::tolower); - if (str == "0" || str == "0.0" || str == "false" || str == "null" || !str.length()) return 0; - else if (str == "true") return 1; - else return -1; -} - -template -struct string_to_number {}; - -template <> struct string_to_number { - bool operator()(const std::string &str) const { - // Converts 0 => false, 1 => true and -1 => true. - return string_to_bool(str); - } -}; - -template <> struct string_to_number { - double operator()(std::string const &str) const { - int val = string_to_bool(str); - return val < 0 ? std::stod(str) : val; - } -}; - -template <> struct string_to_number { - int64_t operator()(std::string const &str) const { - int val = string_to_bool(str); - return val < 0 ? std::stoll(str) : val; - } -}; - -template <> struct string_to_number { - uint64_t operator()(std::string const &str) const { - int val = string_to_bool(str); - return val < 0 ? std::stoull(str) : val; - } -}; - -template -struct relaxed_operator_visitor { - typedef bool result_type; - - bool operator()(bool lhs, bool rhs) const { return Operator()(lhs, rhs); } - - template ::value>::type> - bool operator()(bool lhs, T rhs) const { return Operator()(lhs, bool(rhs)); } - - template ::value>::type> - bool operator()(T lhs, bool rhs) const { return Operator()(bool(lhs), rhs); } - - bool operator()(int64_t lhs, uint64_t rhs) const { return lhs < 0 ? false : Operator()(uint64_t(lhs), rhs); } - bool operator()(uint64_t lhs, int64_t rhs) const { return rhs < 0 ? false : Operator()(lhs, uint64_t(rhs)); } - - template ::value>::type> - bool operator()(const std::string &lhs, T rhs) const try { return Operator()(string_to_number()(lhs), rhs); } - catch(...) { return false; } - - template ::value>::type> - bool operator()(T lhs, const std::string &rhs) const try { return Operator()(lhs, string_to_number()(rhs)); } - catch(...) { return false; } - - template - bool operator()(T0 lhs, T1 rhs) const { return Operator()(lhs, rhs); } -}; - -struct relaxed_equal_operator { - template - bool operator()(T0 lhs, T1 rhs) const { return lhs == rhs; } -}; - -struct relaxed_greater_operator { - template - bool operator()(T0 lhs, T1 rhs) const { return lhs > rhs; } -}; - -struct relaxed_greater_equal_operator { - template - bool operator()(T0 lhs, T1 rhs) const { return lhs >= rhs; } -}; - -struct relaxed_less_operator { - template - bool operator()(T0 lhs, T1 rhs) const { return lhs < rhs; } -}; - -struct relaxed_less_equal_operator { - template - bool operator()(T0 lhs, T1 rhs) const { return lhs <= rhs; } -}; - - -} // end namespace detail - -inline bool relaxed_equal(Value const &lhs, Value const &rhs) { - return apply_visitor(detail::relaxed_operator_visitor(), lhs, rhs); -} - -inline bool relaxed_greater(Value const &lhs, Value const &rhs) { - return apply_visitor(detail::relaxed_operator_visitor(), lhs, rhs); -} - -inline bool relaxed_greater_equal(Value const &lhs, Value const &rhs) { - return apply_visitor(detail::relaxed_operator_visitor(), lhs, rhs); -} - -inline bool relaxed_less(Value const &lhs, Value const &rhs) { - return apply_visitor(detail::relaxed_operator_visitor(), lhs, rhs); -} - -inline bool relaxed_less_equal(Value const &lhs, Value const &rhs) { - return apply_visitor(detail::relaxed_operator_visitor(), lhs, rhs); -} - -} - - -template -T toNumber(const Value &value) { - if (value.is()) return util::detail::string_to_number()(value.get()); - else if (value.is()) return value.get(); - else if (value.is()) return value.get(); - else if (value.is()) return value.get(); - else if (value.is()) return value.get(); - else return 0; -} - -} - -#endif diff --git a/include/llmr/geometry/anchor.hpp b/include/mbgl/geometry/anchor.hpp similarity index 86% rename from include/llmr/geometry/anchor.hpp rename to include/mbgl/geometry/anchor.hpp index dd97c507f..ab006530f 100644 --- a/include/llmr/geometry/anchor.hpp +++ b/include/mbgl/geometry/anchor.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_GEOMETRY_ANCHOR -#define LLMR_GEOMETRY_ANCHOR +#ifndef MBGL_GEOMETRY_ANCHOR +#define MBGL_GEOMETRY_ANCHOR #include -namespace llmr { +namespace mbgl { struct Anchor { float x = 0.0f; diff --git a/include/llmr/geometry/binpack.hpp b/include/mbgl/geometry/binpack.hpp similarity index 95% rename from include/llmr/geometry/binpack.hpp rename to include/mbgl/geometry/binpack.hpp index 11536ee8b..9aadaa202 100644 --- a/include/llmr/geometry/binpack.hpp +++ b/include/mbgl/geometry/binpack.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_GEOMETRY_BINPACK -#define LLMR_GEOMETRY_BINPACK +#ifndef MBGL_GEOMETRY_BINPACK +#define MBGL_GEOMETRY_BINPACK -#include -#include +#include +#include #include #include -namespace llmr { +namespace mbgl { template class BinPack : private util::noncopyable { diff --git a/include/llmr/geometry/buffer.hpp b/include/mbgl/geometry/buffer.hpp similarity index 95% rename from include/llmr/geometry/buffer.hpp rename to include/mbgl/geometry/buffer.hpp index 607f902bf..20489cb33 100644 --- a/include/llmr/geometry/buffer.hpp +++ b/include/mbgl/geometry/buffer.hpp @@ -1,14 +1,14 @@ -#ifndef LLMR_GEOMETRY_BUFFER -#define LLMR_GEOMETRY_BUFFER +#ifndef MBGL_GEOMETRY_BUFFER +#define MBGL_GEOMETRY_BUFFER -#include -#include +#include +#include #include #include #include -namespace llmr { +namespace mbgl { template < size_t item_size, diff --git a/include/llmr/geometry/debug_font_buffer.hpp b/include/mbgl/geometry/debug_font_buffer.hpp similarity index 69% rename from include/llmr/geometry/debug_font_buffer.hpp rename to include/mbgl/geometry/debug_font_buffer.hpp index 15f6daf07..7cceb0f57 100644 --- a/include/llmr/geometry/debug_font_buffer.hpp +++ b/include/mbgl/geometry/debug_font_buffer.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_GEOMETRY_DEBUG_FONT_BUFFER -#define LLMR_GEOMETRY_DEBUG_FONT_BUFFER +#ifndef MBGL_GEOMETRY_DEBUG_FONT_BUFFER +#define MBGL_GEOMETRY_DEBUG_FONT_BUFFER #include "buffer.hpp" -namespace llmr { +namespace mbgl { class DebugFontBuffer : public Buffer< 4 // 2 bytes per coordinate, 2 coordinates diff --git a/include/llmr/geometry/elements_buffer.hpp b/include/mbgl/geometry/elements_buffer.hpp similarity index 85% rename from include/llmr/geometry/elements_buffer.hpp rename to include/mbgl/geometry/elements_buffer.hpp index a058312bd..ed60338e0 100644 --- a/include/llmr/geometry/elements_buffer.hpp +++ b/include/mbgl/geometry/elements_buffer.hpp @@ -1,10 +1,10 @@ -#ifndef LLMR_GEOMETRY_TRIANGLE_ELEMENTS_BUFFER -#define LLMR_GEOMETRY_TRIANGLE_ELEMENTS_BUFFER +#ifndef MBGL_GEOMETRY_TRIANGLE_ELEMENTS_BUFFER +#define MBGL_GEOMETRY_TRIANGLE_ELEMENTS_BUFFER -#include -#include +#include +#include -namespace llmr { +namespace mbgl { struct ElementGroup { VertexArrayObject array; diff --git a/include/llmr/geometry/fill_buffer.hpp b/include/mbgl/geometry/fill_buffer.hpp similarity index 75% rename from include/llmr/geometry/fill_buffer.hpp rename to include/mbgl/geometry/fill_buffer.hpp index 9aebe35ab..4a3d5a5b3 100644 --- a/include/llmr/geometry/fill_buffer.hpp +++ b/include/mbgl/geometry/fill_buffer.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_GEOMETRY_FILL_BUFFER -#define LLMR_GEOMETRY_FILL_BUFFER +#ifndef MBGL_GEOMETRY_FILL_BUFFER +#define MBGL_GEOMETRY_FILL_BUFFER #include "buffer.hpp" #include #include -namespace llmr { +namespace mbgl { class FillVertexBuffer : public Buffer< 4 // bytes per coordinates (2 * unsigned short == 4 bytes) diff --git a/include/llmr/geometry/geometry.hpp b/include/mbgl/geometry/geometry.hpp similarity index 90% rename from include/llmr/geometry/geometry.hpp rename to include/mbgl/geometry/geometry.hpp index 2f321934a..47981ce83 100644 --- a/include/llmr/geometry/geometry.hpp +++ b/include/mbgl/geometry/geometry.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_GEOMETRY_GEOMETRY -#define LLMR_GEOMETRY_GEOMETRY +#ifndef MBGL_GEOMETRY_GEOMETRY +#define MBGL_GEOMETRY_GEOMETRY -#include -#include +#include +#include #include -namespace llmr { +namespace mbgl { class Geometry : private util::noncopyable { diff --git a/include/llmr/geometry/glyph_atlas.hpp b/include/mbgl/geometry/glyph_atlas.hpp similarity index 84% rename from include/llmr/geometry/glyph_atlas.hpp rename to include/mbgl/geometry/glyph_atlas.hpp index 0aada6a73..e05cbe3b9 100644 --- a/include/llmr/geometry/glyph_atlas.hpp +++ b/include/mbgl/geometry/glyph_atlas.hpp @@ -1,8 +1,8 @@ -#ifndef LLMR_GEOMETRY_GLYPH_ATLAS -#define LLMR_GEOMETRY_GLYPH_ATLAS +#ifndef MBGL_GEOMETRY_GLYPH_ATLAS +#define MBGL_GEOMETRY_GLYPH_ATLAS -#include -#include +#include +#include #include #include @@ -10,7 +10,7 @@ #include #include -namespace llmr { +namespace mbgl { class GlyphAtlas { public: diff --git a/include/llmr/geometry/icon_buffer.hpp b/include/mbgl/geometry/icon_buffer.hpp similarity index 80% rename from include/llmr/geometry/icon_buffer.hpp rename to include/mbgl/geometry/icon_buffer.hpp index 6bb0ec30c..346b3b5f0 100644 --- a/include/llmr/geometry/icon_buffer.hpp +++ b/include/mbgl/geometry/icon_buffer.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_GEOMETRY_ICON_BUFFER -#define LLMR_GEOMETRY_ICON_BUFFER +#ifndef MBGL_GEOMETRY_ICON_BUFFER +#define MBGL_GEOMETRY_ICON_BUFFER #include "buffer.hpp" -namespace llmr { +namespace mbgl { class IconVertexBuffer : public Buffer< 4 + // int16 x/y coordinates per vertex (== 4 bytes) diff --git a/include/mbgl/geometry/interpolate.hpp b/include/mbgl/geometry/interpolate.hpp new file mode 100644 index 000000000..cebbcc702 --- /dev/null +++ b/include/mbgl/geometry/interpolate.hpp @@ -0,0 +1,13 @@ +#ifndef MBGL_GEOMETRY_INTERPOLATE +#define MBGL_GEOMETRY_INTERPOLATE + +#include +#include + +namespace mbgl { + +Anchors interpolate(const std::vector &vertices, float spacing, + float minScale = 0.0f, int start = 0); +} + +#endif diff --git a/include/llmr/geometry/line_buffer.hpp b/include/mbgl/geometry/line_buffer.hpp similarity index 92% rename from include/llmr/geometry/line_buffer.hpp rename to include/mbgl/geometry/line_buffer.hpp index 289f1bc6e..5012bb12a 100644 --- a/include/llmr/geometry/line_buffer.hpp +++ b/include/mbgl/geometry/line_buffer.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_GEOMETRY_LINE_BUFFER -#define LLMR_GEOMETRY_LINE_BUFFER +#ifndef MBGL_GEOMETRY_LINE_BUFFER +#define MBGL_GEOMETRY_LINE_BUFFER #include "buffer.hpp" -namespace llmr { +namespace mbgl { class LineVertexBuffer : public Buffer< 8 // 2 coordinates per vertex + 1 linesofar + 1 extrude coord pair == 4 (== 8 bytes) diff --git a/include/llmr/geometry/sprite_atlas.hpp b/include/mbgl/geometry/sprite_atlas.hpp similarity index 94% rename from include/llmr/geometry/sprite_atlas.hpp rename to include/mbgl/geometry/sprite_atlas.hpp index 13b85e548..4b55540cc 100644 --- a/include/llmr/geometry/sprite_atlas.hpp +++ b/include/mbgl/geometry/sprite_atlas.hpp @@ -1,7 +1,7 @@ -#ifndef LLMR_GEOMETRY_SPRITE_ATLAS -#define LLMR_GEOMETRY_SPRITE_ATLAS +#ifndef MBGL_GEOMETRY_SPRITE_ATLAS +#define MBGL_GEOMETRY_SPRITE_ATLAS -#include +#include #include #include @@ -9,7 +9,7 @@ #include #include -namespace llmr { +namespace mbgl { class Sprite; class SpritePosition; diff --git a/include/llmr/geometry/text_buffer.hpp b/include/mbgl/geometry/text_buffer.hpp similarity index 82% rename from include/llmr/geometry/text_buffer.hpp rename to include/mbgl/geometry/text_buffer.hpp index 8d4cba285..159f3207a 100644 --- a/include/llmr/geometry/text_buffer.hpp +++ b/include/mbgl/geometry/text_buffer.hpp @@ -1,10 +1,10 @@ -#ifndef LLMR_GEOMETRY_TEXT_BUFFER -#define LLMR_GEOMETRY_TEXT_BUFFER +#ifndef MBGL_GEOMETRY_TEXT_BUFFER +#define MBGL_GEOMETRY_TEXT_BUFFER #include "buffer.hpp" #include -namespace llmr { +namespace mbgl { class TextVertexBuffer : public Buffer < 16, diff --git a/include/llmr/geometry/vao.hpp b/include/mbgl/geometry/vao.hpp similarity index 96% rename from include/llmr/geometry/vao.hpp rename to include/mbgl/geometry/vao.hpp index 64b324372..71d7ff89f 100644 --- a/include/llmr/geometry/vao.hpp +++ b/include/mbgl/geometry/vao.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_GEOMETRY_VAO -#define LLMR_GEOMETRY_VAO +#ifndef MBGL_GEOMETRY_VAO +#define MBGL_GEOMETRY_VAO -#include +#include #include -namespace llmr { +namespace mbgl { class VertexArrayObject { public: diff --git a/include/llmr/geometry/vertex_buffer.hpp b/include/mbgl/geometry/vertex_buffer.hpp similarity index 87% rename from include/llmr/geometry/vertex_buffer.hpp rename to include/mbgl/geometry/vertex_buffer.hpp index 9478d7b15..58fd4a9d0 100644 --- a/include/llmr/geometry/vertex_buffer.hpp +++ b/include/mbgl/geometry/vertex_buffer.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_GEOMETRY_VERTEX_BUFFER -#define LLMR_GEOMETRY_VERTEX_BUFFER +#ifndef MBGL_GEOMETRY_VERTEX_BUFFER +#define MBGL_GEOMETRY_VERTEX_BUFFER #include #include #include #include -namespace llmr { +namespace mbgl { class VertexBuffer { public: diff --git a/include/llmr/map/map.hpp b/include/mbgl/map/map.hpp similarity index 94% rename from include/llmr/map/map.hpp rename to include/mbgl/map/map.hpp index af4250c35..774e5e129 100644 --- a/include/llmr/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -1,23 +1,23 @@ -#ifndef LLMR_MAP_MAP -#define LLMR_MAP_MAP +#ifndef MBGL_MAP_MAP +#define MBGL_MAP_MAP #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include -namespace llmr { +namespace mbgl { class Source; class SpriteAtlas; diff --git a/include/llmr/map/raster_tile_data.hpp b/include/mbgl/map/raster_tile_data.hpp similarity index 71% rename from include/llmr/map/raster_tile_data.hpp rename to include/mbgl/map/raster_tile_data.hpp index f84b540d4..976faa91b 100644 --- a/include/llmr/map/raster_tile_data.hpp +++ b/include/mbgl/map/raster_tile_data.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_MAP_RASTER_TILE_DATA -#define LLMR_MAP_RASTER_TILE_DATA +#ifndef MBGL_MAP_RASTER_TILE_DATA +#define MBGL_MAP_RASTER_TILE_DATA -#include +#include -#include +#include -namespace llmr { +namespace mbgl { class RasterTileData : public TileData { friend class TileParser; diff --git a/include/llmr/map/source.hpp b/include/mbgl/map/source.hpp similarity index 88% rename from include/llmr/map/source.hpp rename to include/mbgl/map/source.hpp index b8ffc27f5..be5fad3af 100644 --- a/include/llmr/map/source.hpp +++ b/include/mbgl/map/source.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_MAP_SOURCE -#define LLMR_MAP_SOURCE +#ifndef MBGL_MAP_SOURCE +#define MBGL_MAP_SOURCE -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include @@ -16,7 +16,7 @@ #include #include -namespace llmr { +namespace mbgl { class TransformState; class Texturepool; diff --git a/include/llmr/map/sprite.hpp b/include/mbgl/map/sprite.hpp similarity index 89% rename from include/llmr/map/sprite.hpp rename to include/mbgl/map/sprite.hpp index 07f5903e5..22126eb6a 100644 --- a/include/llmr/map/sprite.hpp +++ b/include/mbgl/map/sprite.hpp @@ -1,8 +1,8 @@ -#ifndef LLMR_STYLE_SPRITE -#define LLMR_STYLE_SPRITE +#ifndef MBGL_STYLE_SPRITE +#define MBGL_STYLE_SPRITE -#include -#include +#include +#include #include #include @@ -10,7 +10,7 @@ #include #include -namespace llmr { +namespace mbgl { class Map; @@ -52,6 +52,7 @@ private: private: Map ↦ + std::string url; std::string body; std::string image; std::atomic loaded; diff --git a/include/llmr/map/tile.hpp b/include/mbgl/map/tile.hpp similarity index 91% rename from include/llmr/map/tile.hpp rename to include/mbgl/map/tile.hpp index 9681c3637..7e868afad 100644 --- a/include/llmr/map/tile.hpp +++ b/include/mbgl/map/tile.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_MAP_TILE -#define LLMR_MAP_TILE +#ifndef MBGL_MAP_TILE +#define MBGL_MAP_TILE -#include -#include -#include +#include +#include +#include #include #include @@ -11,7 +11,7 @@ #include #include -namespace llmr { +namespace mbgl { class TileData; diff --git a/include/llmr/map/tile_data.hpp b/include/mbgl/map/tile_data.hpp similarity index 84% rename from include/llmr/map/tile_data.hpp rename to include/mbgl/map/tile_data.hpp index 09f36d59b..a4b73c339 100644 --- a/include/llmr/map/tile_data.hpp +++ b/include/mbgl/map/tile_data.hpp @@ -1,18 +1,18 @@ -#ifndef LLMR_MAP_TILE_DATA -#define LLMR_MAP_TILE_DATA +#ifndef MBGL_MAP_TILE_DATA +#define MBGL_MAP_TILE_DATA -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include #include -namespace llmr { +namespace mbgl { class Map; class Painter; diff --git a/include/llmr/map/tile_parser.hpp b/include/mbgl/map/tile_parser.hpp similarity index 88% rename from include/llmr/map/tile_parser.hpp rename to include/mbgl/map/tile_parser.hpp index e18c2746a..14e00946b 100644 --- a/include/llmr/map/tile_parser.hpp +++ b/include/mbgl/map/tile_parser.hpp @@ -1,14 +1,14 @@ -#ifndef LLMR_MAP_TILE_PARSER -#define LLMR_MAP_TILE_PARSER +#ifndef MBGL_MAP_TILE_PARSER +#define MBGL_MAP_TILE_PARSER -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -namespace llmr { +namespace mbgl { class Style; class GlyphAtlas; diff --git a/include/llmr/map/transform.hpp b/include/mbgl/map/transform.hpp similarity index 93% rename from include/llmr/map/transform.hpp rename to include/mbgl/map/transform.hpp index c4474ff02..61bef7656 100644 --- a/include/llmr/map/transform.hpp +++ b/include/mbgl/map/transform.hpp @@ -1,21 +1,22 @@ -#ifndef LLMR_MAP_TRANSFORM -#define LLMR_MAP_TRANSFORM +#ifndef MBGL_MAP_TRANSFORM +#define MBGL_MAP_TRANSFORM -#include -#include -#include +#include +#include +#include +#include "view.hpp" #include "transform_state.hpp" #include -namespace llmr { +namespace mbgl { struct box; class Transform : private util::noncopyable { public: - Transform(); + Transform(View &view); // Map view // Note: width * ratio does not necessarily equal fb_width @@ -74,6 +75,8 @@ private: void constrain(double& scale, double& y) const; private: + View &view; + mutable uv::rwlock mtx; // This reflects the current state of the transform, representing the actual position of the diff --git a/include/llmr/map/transform_state.hpp b/include/mbgl/map/transform_state.hpp similarity index 89% rename from include/llmr/map/transform_state.hpp rename to include/mbgl/map/transform_state.hpp index 29d0f59c4..85dd2eb87 100644 --- a/include/llmr/map/transform_state.hpp +++ b/include/mbgl/map/transform_state.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_MAP_TRANSFORM_STATE -#define LLMR_MAP_TRANSFORM_STATE +#ifndef MBGL_MAP_TRANSFORM_STATE +#define MBGL_MAP_TRANSFORM_STATE -#include -#include +#include +#include #include -namespace llmr { +namespace mbgl { class Transform; diff --git a/include/llmr/map/vector_tile.hpp b/include/mbgl/map/vector_tile.hpp similarity index 88% rename from include/llmr/map/vector_tile.hpp rename to include/mbgl/map/vector_tile.hpp index ad7a0eea1..77e379865 100644 --- a/include/llmr/map/vector_tile.hpp +++ b/include/mbgl/map/vector_tile.hpp @@ -1,18 +1,18 @@ -#ifndef LLMR_MAP_VECTOR_TILE -#define LLMR_MAP_VECTOR_TILE +#ifndef MBGL_MAP_VECTOR_TILE +#define MBGL_MAP_VECTOR_TILE -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include #include #include -namespace llmr { +namespace mbgl { class BucketDescription; class VectorTileLayer; @@ -46,7 +46,7 @@ public: VectorTileTagExtractor(const VectorTileLayer &layer); void setTags(const pbf &pbf); - std::forward_list getValues(const std::string &key) const; + std::vector getValues(const std::string &key) const; void setType(FilterExpression::GeometryType type); FilterExpression::GeometryType getType() const; diff --git a/include/llmr/map/vector_tile_data.hpp b/include/mbgl/map/vector_tile_data.hpp similarity index 70% rename from include/llmr/map/vector_tile_data.hpp rename to include/mbgl/map/vector_tile_data.hpp index d6f5391c2..dd55e8dae 100644 --- a/include/llmr/map/vector_tile_data.hpp +++ b/include/mbgl/map/vector_tile_data.hpp @@ -1,22 +1,22 @@ -#ifndef LLMR_MAP_VECTOR_TILE_DATA -#define LLMR_MAP_VECTOR_TILE_DATA +#ifndef MBGL_MAP_VECTOR_TILE_DATA +#define MBGL_MAP_VECTOR_TILE_DATA -#include +#include -#include +#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include -namespace llmr { +namespace mbgl { class VectorTileData : public TileData { diff --git a/include/mbgl/map/view.hpp b/include/mbgl/map/view.hpp new file mode 100644 index 000000000..92d60d4d0 --- /dev/null +++ b/include/mbgl/map/view.hpp @@ -0,0 +1,54 @@ +#ifndef MBGL_MAP_VIEW +#define MBGL_MAP_VIEW + +#include + +namespace mbgl { + +class Map; + +enum MapChange : uint8_t { + MapChangeRegionWillChange = 0, + MapChangeRegionWillChangeAnimated = 1, + MapChangeRegionDidChange = 2, + MapChangeRegionDidChangeAnimated = 3, + MapChangeWillStartLoadingMap = 4, + MapChangeDidFinishLoadingMap = 5, + MapChangeDidFailLoadingMap = 6, + MapChangeWillStartRenderingMap = 7, + MapChangeDidFinishRenderingMap = 8, + MapChangeDidFinishRenderingMapFullyRendered = 9 +}; + +class View { +public: + virtual void initialize(Map *map) { + this->map = map; + } + + // Called from the render (=GL) thread. Signals that the context should + // swap the front and the back buffer. + virtual void swap() = 0; + + // Called from the render thread. Makes the GL context active in the current + // thread. This is typically just called once at the beginning of the + // renderer setup since the render thread doesn't switch the contexts. + virtual void make_active() = 0; + + // Returns the base framebuffer object, if any, and 0 if using the system + // provided framebuffer. + virtual unsigned int root_fbo() { + return 0; + } + + // Notifies a watcher of map x/y/scale/rotation changes. + // Must only be called from the same thread that caused the change. + // Must not be called from the render thread. + virtual void notify_map_change(MapChange change, timestamp delay = 0) = 0; + +protected: + mbgl::Map *map = nullptr; +}; +} + +#endif diff --git a/include/llmr/llmr.hpp b/include/mbgl/mbgl.hpp similarity index 60% rename from include/llmr/llmr.hpp rename to include/mbgl/mbgl.hpp index 349b15d8c..90abd4e11 100644 --- a/include/llmr/llmr.hpp +++ b/include/mbgl/mbgl.hpp @@ -1,5 +1,5 @@ -#ifndef LLMR_MAIN -#define LLMR_MAIN +#ifndef MBGL_MAIN +#define MBGL_MAIN #include "map/map.hpp" #include "map/view.hpp" diff --git a/include/llmr/platform/event.hpp b/include/mbgl/platform/event.hpp similarity index 83% rename from include/llmr/platform/event.hpp rename to include/mbgl/platform/event.hpp index 133cfc3c5..b55c721c9 100644 --- a/include/llmr/platform/event.hpp +++ b/include/mbgl/platform/event.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_PLATFORM_EVENT -#define LLMR_PLATFORM_EVENT +#ifndef MBGL_PLATFORM_EVENT +#define MBGL_PLATFORM_EVENT -#include +#include #include -namespace llmr { +namespace mbgl { enum class EventSeverity : uint8_t { Debug, @@ -15,7 +15,7 @@ enum class EventSeverity : uint8_t { Error, }; -LLMR_DEFINE_ENUM_CLASS(EventSeverityClass, EventSeverity, { +MBGL_DEFINE_ENUM_CLASS(EventSeverityClass, EventSeverity, { { EventSeverity::Debug, "DEBUG" }, { EventSeverity::Info, "INFO" }, { EventSeverity::Test, "TEST" }, @@ -32,9 +32,10 @@ enum class Event : uint8_t { ParseTile, Render, HttpRequest, + Sprite, }; -LLMR_DEFINE_ENUM_CLASS(EventClass, Event, { +MBGL_DEFINE_ENUM_CLASS(EventClass, Event, { { Event::General, "General" }, { Event::Setup, "Setup" }, { Event::Shader, "Shader" }, @@ -42,6 +43,7 @@ LLMR_DEFINE_ENUM_CLASS(EventClass, Event, { { Event::ParseTile, "ParseTile" }, { Event::Render, "Render" }, { Event::HttpRequest, "HttpRequest" }, + { Event::Sprite, "Sprite" }, { Event(-1), "Unknown" }, }); diff --git a/include/llmr/platform/gl.hpp b/include/mbgl/platform/gl.hpp similarity index 97% rename from include/llmr/platform/gl.hpp rename to include/mbgl/platform/gl.hpp index b1e2d5d5a..a29b230db 100644 --- a/include/llmr/platform/gl.hpp +++ b/include/mbgl/platform/gl.hpp @@ -1,5 +1,5 @@ -#ifndef LLMR_RENDERER_GL -#define LLMR_RENDERER_GL +#ifndef MBGL_RENDERER_GL +#define MBGL_RENDERER_GL #include @@ -39,7 +39,7 @@ #include #endif -namespace llmr { +namespace mbgl { namespace gl { // Debug group markers, useful for debuggin on iOS #if defined(__APPLE__) && defined(DEBUG) && defined(GL_EXT_debug_marker) diff --git a/include/llmr/platform/log.hpp b/include/mbgl/platform/log.hpp similarity index 96% rename from include/llmr/platform/log.hpp rename to include/mbgl/platform/log.hpp index 7b3937004..dc000b4d5 100644 --- a/include/llmr/platform/log.hpp +++ b/include/mbgl/platform/log.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_PLATFORM_LOG -#define LLMR_PLATFORM_LOG +#ifndef MBGL_PLATFORM_LOG +#define MBGL_PLATFORM_LOG #include "event.hpp" #include #include -namespace llmr { +namespace mbgl { class LogBackend { public: diff --git a/include/llmr/platform/platform.hpp b/include/mbgl/platform/platform.hpp similarity index 70% rename from include/llmr/platform/platform.hpp rename to include/mbgl/platform/platform.hpp index 138843fee..02aeb594b 100644 --- a/include/llmr/platform/platform.hpp +++ b/include/mbgl/platform/platform.hpp @@ -1,5 +1,5 @@ -#ifndef LLMR_PLATFORM_PLATFORM -#define LLMR_PLATFORM_PLATFORM +#ifndef MBGL_PLATFORM_PLATFORM +#define MBGL_PLATFORM_PLATFORM #include #include @@ -11,7 +11,7 @@ namespace uv { class loop; } -namespace llmr { +namespace mbgl { namespace platform { class Request; @@ -24,19 +24,6 @@ struct Response { std::function callback; }; -enum MapChange : uint8_t { - MapChangeRegionWillChange = 0, - MapChangeRegionWillChangeAnimated = 1, - MapChangeRegionDidChange = 2, - MapChangeRegionDidChangeAnimated = 3, - MapChangeWillStartLoadingMap = 4, - MapChangeDidFinishLoadingMap = 5, - MapChangeDidFailLoadingMap = 6, - MapChangeWillStartRenderingMap = 7, - MapChangeDidFinishRenderingMap = 8, - MapChangeDidFinishRenderingMapFullyRendered = 9 -}; - // Makes an HTTP request of a URL, preferrably on a background thread, and calls a function with the // results in the original thread (which runs the libuv loop). // If the loop pointer is NULL, the callback function will be called on an arbitrary thread. @@ -48,9 +35,6 @@ std::shared_ptr request_http(const std::string &url, // Cancels an HTTP request. void cancel_request_http(const std::shared_ptr &req); -// Notifies a watcher of map changes. -void notify_map_change(MapChange key); - // Shows an alpha image with the specified dimensions in a named window. void show_debug_image(std::string name, const char *data, size_t width, size_t height); diff --git a/include/llmr/platform/request.hpp b/include/mbgl/platform/request.hpp similarity index 87% rename from include/llmr/platform/request.hpp rename to include/mbgl/platform/request.hpp index 5ba00830b..7d2da8888 100644 --- a/include/llmr/platform/request.hpp +++ b/include/mbgl/platform/request.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_PLATFORM_REQUEST -#define LLMR_PLATFORM_REQUEST +#ifndef MBGL_PLATFORM_REQUEST +#define MBGL_PLATFORM_REQUEST #include #include #include #include -#include +#include // Forward definition. typedef struct uv_loop_s uv_loop_t; @@ -16,7 +16,7 @@ namespace uv { class loop; } -namespace llmr { +namespace mbgl { namespace platform { struct Response; diff --git a/include/llmr/renderer/bucket.hpp b/include/mbgl/renderer/bucket.hpp similarity index 65% rename from include/llmr/renderer/bucket.hpp rename to include/mbgl/renderer/bucket.hpp index c135b8ee1..18f58ee46 100644 --- a/include/llmr/renderer/bucket.hpp +++ b/include/mbgl/renderer/bucket.hpp @@ -1,13 +1,13 @@ -#ifndef LLMR_RENDERER_BUCKET -#define LLMR_RENDERER_BUCKET +#ifndef MBGL_RENDERER_BUCKET +#define MBGL_RENDERER_BUCKET #include #include -#include -#include -#include +#include +#include +#include -namespace llmr { +namespace mbgl { class Painter; class StyleLayer; diff --git a/include/llmr/renderer/debug_bucket.hpp b/include/mbgl/renderer/debug_bucket.hpp similarity index 72% rename from include/llmr/renderer/debug_bucket.hpp rename to include/mbgl/renderer/debug_bucket.hpp index d72a645ee..ac4f18cc2 100644 --- a/include/llmr/renderer/debug_bucket.hpp +++ b/include/mbgl/renderer/debug_bucket.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_RENDERER_DEBUGBUCKET -#define LLMR_RENDERER_DEBUGBUCKET +#ifndef MBGL_RENDERER_DEBUGBUCKET +#define MBGL_RENDERER_DEBUGBUCKET -#include -#include -#include +#include +#include +#include #include #include @@ -12,7 +12,7 @@ #define BUFFER_OFFSET(i) ((char *)nullptr + (i)) #endif -namespace llmr { +namespace mbgl { class PlainShader; diff --git a/include/llmr/renderer/fill_bucket.hpp b/include/mbgl/renderer/fill_bucket.hpp similarity index 89% rename from include/llmr/renderer/fill_bucket.hpp rename to include/mbgl/renderer/fill_bucket.hpp index db0e9c104..9193b0914 100644 --- a/include/llmr/renderer/fill_bucket.hpp +++ b/include/mbgl/renderer/fill_bucket.hpp @@ -1,10 +1,10 @@ -#ifndef LLMR_RENDERER_FILLBUCKET -#define LLMR_RENDERER_FILLBUCKET +#ifndef MBGL_RENDERER_FILLBUCKET +#define MBGL_RENDERER_FILLBUCKET -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -16,7 +16,7 @@ #define BUFFER_OFFSET(i) ((char *)nullptr + (i)) #endif -namespace llmr { +namespace mbgl { class Style; class FillVertexBuffer; diff --git a/include/llmr/renderer/frame_history.hpp b/include/mbgl/renderer/frame_history.hpp similarity index 73% rename from include/llmr/renderer/frame_history.hpp rename to include/mbgl/renderer/frame_history.hpp index 35ef3cdf4..a5dbe21bc 100644 --- a/include/llmr/renderer/frame_history.hpp +++ b/include/mbgl/renderer/frame_history.hpp @@ -1,14 +1,14 @@ -#ifndef LLMR_RENDERER_FRAME_HISTORY -#define LLMR_RENDERER_FRAME_HISTORY +#ifndef MBGL_RENDERER_FRAME_HISTORY +#define MBGL_RENDERER_FRAME_HISTORY #include #include #include -#include -#include +#include +#include -namespace llmr { +namespace mbgl { struct FrameSnapshot { explicit inline FrameSnapshot(timestamp t, float z) : t(t), z(z) {} diff --git a/include/llmr/renderer/icon_bucket.hpp b/include/mbgl/renderer/icon_bucket.hpp similarity index 78% rename from include/llmr/renderer/icon_bucket.hpp rename to include/mbgl/renderer/icon_bucket.hpp index d13f53586..e3b311332 100644 --- a/include/llmr/renderer/icon_bucket.hpp +++ b/include/mbgl/renderer/icon_bucket.hpp @@ -1,10 +1,10 @@ -#ifndef LLMR_RENDERER_ICONBUCKET -#define LLMR_RENDERER_ICONBUCKET +#ifndef MBGL_RENDERER_ICONBUCKET +#define MBGL_RENDERER_ICONBUCKET -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -13,7 +13,7 @@ #define BUFFER_OFFSET(i) ((char *)nullptr + (i)) #endif -namespace llmr { +namespace mbgl { class Style; class IconVertexBuffer; diff --git a/include/llmr/renderer/line_bucket.hpp b/include/mbgl/renderer/line_bucket.hpp similarity index 84% rename from include/llmr/renderer/line_bucket.hpp rename to include/mbgl/renderer/line_bucket.hpp index 881bd23eb..d42b10bfb 100644 --- a/include/llmr/renderer/line_bucket.hpp +++ b/include/mbgl/renderer/line_bucket.hpp @@ -1,16 +1,16 @@ -#ifndef LLMR_RENDERER_LINEBUCKET -#define LLMR_RENDERER_LINEBUCKET +#ifndef MBGL_RENDERER_LINEBUCKET +#define MBGL_RENDERER_LINEBUCKET #include "bucket.hpp" -#include -#include -#include -#include +#include +#include +#include +#include #include #include -namespace llmr { +namespace mbgl { class Style; class LineVertexBuffer; diff --git a/include/llmr/renderer/painter.hpp b/include/mbgl/renderer/painter.hpp similarity index 87% rename from include/llmr/renderer/painter.hpp rename to include/mbgl/renderer/painter.hpp index ef160eddd..9868b5d9d 100644 --- a/include/llmr/renderer/painter.hpp +++ b/include/mbgl/renderer/painter.hpp @@ -1,33 +1,33 @@ -#ifndef LLMR_RENDERER_PAINTER -#define LLMR_RENDERER_PAINTER +#ifndef MBGL_RENDERER_PAINTER +#define MBGL_RENDERER_PAINTER -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include +#include #include #include #include -namespace llmr { +namespace mbgl { class Transform; class Style; diff --git a/include/llmr/renderer/prerendered_texture.hpp b/include/mbgl/renderer/prerendered_texture.hpp similarity index 70% rename from include/llmr/renderer/prerendered_texture.hpp rename to include/mbgl/renderer/prerendered_texture.hpp index 168284e1d..9c72e14b8 100644 --- a/include/llmr/renderer/prerendered_texture.hpp +++ b/include/mbgl/renderer/prerendered_texture.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_RENDERER_PRERENDERED_TEXTURE -#define LLMR_RENDERER_PRERENDERED_TEXTURE +#ifndef MBGL_RENDERER_PRERENDERED_TEXTURE +#define MBGL_RENDERER_PRERENDERED_TEXTURE -#include -#include -#include +#include +#include +#include -namespace llmr { +namespace mbgl { class Painter; diff --git a/include/llmr/renderer/raster_bucket.hpp b/include/mbgl/renderer/raster_bucket.hpp similarity index 76% rename from include/llmr/renderer/raster_bucket.hpp rename to include/mbgl/renderer/raster_bucket.hpp index 86bb1d925..c11119312 100644 --- a/include/llmr/renderer/raster_bucket.hpp +++ b/include/mbgl/renderer/raster_bucket.hpp @@ -1,10 +1,10 @@ -#ifndef LLMR_RENDERER_RASTERBUCKET -#define LLMR_RENDERER_RASTERBUCKET +#ifndef MBGL_RENDERER_RASTERBUCKET +#define MBGL_RENDERER_RASTERBUCKET -#include -#include +#include +#include -namespace llmr { +namespace mbgl { class RasterShader; class VertexBuffer; diff --git a/include/llmr/renderer/text_bucket.hpp b/include/mbgl/renderer/text_bucket.hpp similarity index 80% rename from include/llmr/renderer/text_bucket.hpp rename to include/mbgl/renderer/text_bucket.hpp index 4d9bf382d..cb4b8f2cd 100644 --- a/include/llmr/renderer/text_bucket.hpp +++ b/include/mbgl/renderer/text_bucket.hpp @@ -1,19 +1,19 @@ -#ifndef LLMR_RENDERER_TEXTBUCKET -#define LLMR_RENDERER_TEXTBUCKET +#ifndef MBGL_RENDERER_TEXTBUCKET +#define MBGL_RENDERER_TEXTBUCKET #include "bucket.hpp" -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include -namespace llmr { +namespace mbgl { class Style; class TextVertexBuffer; diff --git a/include/llmr/shader/composite_shader.hpp b/include/mbgl/shader/composite_shader.hpp similarity index 72% rename from include/llmr/shader/composite_shader.hpp rename to include/mbgl/shader/composite_shader.hpp index 31156485c..c0c1704f3 100644 --- a/include/llmr/shader/composite_shader.hpp +++ b/include/mbgl/shader/composite_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_SHADER_COMPOSITE_SHADER -#define LLMR_SHADER_COMPOSITE_SHADER +#ifndef MBGL_SHADER_COMPOSITE_SHADER +#define MBGL_SHADER_COMPOSITE_SHADER -#include +#include -namespace llmr { +namespace mbgl { class CompositeShader : public Shader { public: diff --git a/include/llmr/shader/dot_shader.hpp b/include/mbgl/shader/dot_shader.hpp similarity index 80% rename from include/llmr/shader/dot_shader.hpp rename to include/mbgl/shader/dot_shader.hpp index 5e817c09c..d8d649db9 100644 --- a/include/llmr/shader/dot_shader.hpp +++ b/include/mbgl/shader/dot_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_SHADER_SHADER_DOT -#define LLMR_SHADER_SHADER_DOT +#ifndef MBGL_SHADER_SHADER_DOT +#define MBGL_SHADER_SHADER_DOT -#include +#include -namespace llmr { +namespace mbgl { class DotShader : public Shader { public: diff --git a/include/llmr/shader/gaussian_shader.hpp b/include/mbgl/shader/gaussian_shader.hpp similarity index 73% rename from include/llmr/shader/gaussian_shader.hpp rename to include/mbgl/shader/gaussian_shader.hpp index c3589c153..a4b9d09f3 100644 --- a/include/llmr/shader/gaussian_shader.hpp +++ b/include/mbgl/shader/gaussian_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_RENDERER_SHADER_GAUSSIAN -#define LLMR_RENDERER_SHADER_GAUSSIAN +#ifndef MBGL_RENDERER_SHADER_GAUSSIAN +#define MBGL_RENDERER_SHADER_GAUSSIAN -#include +#include -namespace llmr { +namespace mbgl { class GaussianShader : public Shader { public: diff --git a/include/llmr/shader/icon_shader.hpp b/include/mbgl/shader/icon_shader.hpp similarity index 85% rename from include/llmr/shader/icon_shader.hpp rename to include/mbgl/shader/icon_shader.hpp index daf37b374..b97b3c2be 100644 --- a/include/llmr/shader/icon_shader.hpp +++ b/include/mbgl/shader/icon_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_SHADER_SHADER_ICON -#define LLMR_SHADER_SHADER_ICON +#ifndef MBGL_SHADER_SHADER_ICON +#define MBGL_SHADER_SHADER_ICON -#include +#include -namespace llmr { +namespace mbgl { class IconShader : public Shader { public: diff --git a/include/llmr/shader/line_shader.hpp b/include/mbgl/shader/line_shader.hpp similarity index 88% rename from include/llmr/shader/line_shader.hpp rename to include/mbgl/shader/line_shader.hpp index 234c70a64..38efe0b71 100644 --- a/include/llmr/shader/line_shader.hpp +++ b/include/mbgl/shader/line_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_SHADER_SHADER_LINE -#define LLMR_SHADER_SHADER_LINE +#ifndef MBGL_SHADER_SHADER_LINE +#define MBGL_SHADER_SHADER_LINE -#include +#include -namespace llmr { +namespace mbgl { class LineShader : public Shader { public: diff --git a/include/llmr/shader/linejoin_shader.hpp b/include/mbgl/shader/linejoin_shader.hpp similarity index 83% rename from include/llmr/shader/linejoin_shader.hpp rename to include/mbgl/shader/linejoin_shader.hpp index 82ec3b59a..5a5c97e92 100644 --- a/include/llmr/shader/linejoin_shader.hpp +++ b/include/mbgl/shader/linejoin_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_SHADER_SHADER_LINEJOIN -#define LLMR_SHADER_SHADER_LINEJOIN +#ifndef MBGL_SHADER_SHADER_LINEJOIN +#define MBGL_SHADER_SHADER_LINEJOIN -#include +#include -namespace llmr { +namespace mbgl { class LinejoinShader : public Shader { public: diff --git a/include/llmr/shader/outline_shader.hpp b/include/mbgl/shader/outline_shader.hpp similarity index 76% rename from include/llmr/shader/outline_shader.hpp rename to include/mbgl/shader/outline_shader.hpp index 5b52b3005..551e31ca5 100644 --- a/include/llmr/shader/outline_shader.hpp +++ b/include/mbgl/shader/outline_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_SHADER_SHADER_OUTLINE -#define LLMR_SHADER_SHADER_OUTLINE +#ifndef MBGL_SHADER_SHADER_OUTLINE +#define MBGL_SHADER_SHADER_OUTLINE -#include +#include -namespace llmr { +namespace mbgl { class OutlineShader : public Shader { public: diff --git a/include/llmr/shader/pattern_shader.hpp b/include/mbgl/shader/pattern_shader.hpp similarity index 88% rename from include/llmr/shader/pattern_shader.hpp rename to include/mbgl/shader/pattern_shader.hpp index d0142ebca..b1b49b54d 100644 --- a/include/llmr/shader/pattern_shader.hpp +++ b/include/mbgl/shader/pattern_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_SHADER_SHADER_PATTERN -#define LLMR_SHADER_SHADER_PATTERN +#ifndef MBGL_SHADER_SHADER_PATTERN +#define MBGL_SHADER_SHADER_PATTERN -#include +#include -namespace llmr { +namespace mbgl { class PatternShader : public Shader { public: diff --git a/include/llmr/shader/plain_shader.hpp b/include/mbgl/shader/plain_shader.hpp similarity index 73% rename from include/llmr/shader/plain_shader.hpp rename to include/mbgl/shader/plain_shader.hpp index bf768f884..277788431 100644 --- a/include/llmr/shader/plain_shader.hpp +++ b/include/mbgl/shader/plain_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_SHADER_SHADER_PLAIN -#define LLMR_SHADER_SHADER_PLAIN +#ifndef MBGL_SHADER_SHADER_PLAIN +#define MBGL_SHADER_SHADER_PLAIN -#include +#include -namespace llmr { +namespace mbgl { class PlainShader : public Shader { public: diff --git a/include/llmr/shader/raster_shader.hpp b/include/mbgl/shader/raster_shader.hpp similarity index 76% rename from include/llmr/shader/raster_shader.hpp rename to include/mbgl/shader/raster_shader.hpp index adc945e46..ec69fa723 100644 --- a/include/llmr/shader/raster_shader.hpp +++ b/include/mbgl/shader/raster_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_RENDERER_SHADER_RASTER -#define LLMR_RENDERER_SHADER_RASTER +#ifndef MBGL_RENDERER_SHADER_RASTER +#define MBGL_RENDERER_SHADER_RASTER -#include +#include -namespace llmr { +namespace mbgl { class RasterShader : public Shader { public: diff --git a/include/llmr/shader/shader.hpp b/include/mbgl/shader/shader.hpp similarity index 79% rename from include/llmr/shader/shader.hpp rename to include/mbgl/shader/shader.hpp index f4713c59f..2398cb12e 100644 --- a/include/llmr/shader/shader.hpp +++ b/include/mbgl/shader/shader.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_RENDERER_SHADER -#define LLMR_RENDERER_SHADER +#ifndef MBGL_RENDERER_SHADER +#define MBGL_RENDERER_SHADER #include #include -#include +#include -namespace llmr { +namespace mbgl { class Shader : private util::noncopyable { public: diff --git a/include/llmr/shader/text_shader.hpp b/include/mbgl/shader/text_shader.hpp similarity index 94% rename from include/llmr/shader/text_shader.hpp rename to include/mbgl/shader/text_shader.hpp index d232ef9a0..554b890fb 100644 --- a/include/llmr/shader/text_shader.hpp +++ b/include/mbgl/shader/text_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_SHADER_TEXT_SHADER -#define LLMR_SHADER_TEXT_SHADER +#ifndef MBGL_SHADER_TEXT_SHADER +#define MBGL_SHADER_TEXT_SHADER #include "shader.hpp" -namespace llmr { +namespace mbgl { class TextShader : public Shader { public: diff --git a/include/llmr/style/applied_class_properties.hpp b/include/mbgl/style/applied_class_properties.hpp similarity index 74% rename from include/llmr/style/applied_class_properties.hpp rename to include/mbgl/style/applied_class_properties.hpp index 20edadc0a..827f15a2a 100644 --- a/include/llmr/style/applied_class_properties.hpp +++ b/include/mbgl/style/applied_class_properties.hpp @@ -1,13 +1,13 @@ -#ifndef LLMR_STYLE_APPLIED_CLASS_PROPERTIES -#define LLMR_STYLE_APPLIED_CLASS_PROPERTIES +#ifndef MBGL_STYLE_APPLIED_CLASS_PROPERTIES +#define MBGL_STYLE_APPLIED_CLASS_PROPERTIES -#include -#include -#include +#include +#include +#include #include -namespace llmr { +namespace mbgl { class AppliedClassProperty { public: diff --git a/include/llmr/style/class_dictionary.hpp b/include/mbgl/style/class_dictionary.hpp similarity index 90% rename from include/llmr/style/class_dictionary.hpp rename to include/mbgl/style/class_dictionary.hpp index 772eb9c70..c7f9c6a28 100644 --- a/include/llmr/style/class_dictionary.hpp +++ b/include/mbgl/style/class_dictionary.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_STYLE_CLASS_DICTIONARY -#define LLMR_STYLE_CLASS_DICTIONARY +#ifndef MBGL_STYLE_CLASS_DICTIONARY +#define MBGL_STYLE_CLASS_DICTIONARY #include #include #include -namespace llmr { +namespace mbgl { enum class ClassID : uint32_t { Fallback = 0, // These values are from the fallback properties diff --git a/include/llmr/style/class_properties.hpp b/include/mbgl/style/class_properties.hpp similarity index 82% rename from include/llmr/style/class_properties.hpp rename to include/mbgl/style/class_properties.hpp index 55d6aa2cc..84b6f483b 100644 --- a/include/llmr/style/class_properties.hpp +++ b/include/mbgl/style/class_properties.hpp @@ -1,13 +1,13 @@ -#ifndef LLMR_STYLE_CLASS_PROPERTIES -#define LLMR_STYLE_CLASS_PROPERTIES +#ifndef MBGL_STYLE_CLASS_PROPERTIES +#define MBGL_STYLE_CLASS_PROPERTIES -#include -#include -#include +#include +#include +#include #include -namespace llmr { +namespace mbgl { class ClassProperties { public: diff --git a/include/mbgl/style/filter_comparison.hpp b/include/mbgl/style/filter_comparison.hpp new file mode 100644 index 000000000..bf48744f1 --- /dev/null +++ b/include/mbgl/style/filter_comparison.hpp @@ -0,0 +1,65 @@ +#ifndef MBGL_STYLE_FILTER_COMPARISON +#define MBGL_STYLE_FILTER_COMPARISON + +#include + +#include +#include +#include + +namespace mbgl { + +class FilterComparison { +public: + enum class Operator : uint8_t { + Equal, + NotEqual, + Greater, + GreaterEqual, + Less, + LessEqual, + In, + NotIn + }; + + class Instance { + public: + Instance(Operator op, std::vector &&values) + : op(op), values(values) {} + + bool compare(const std::vector &property_values) const; + + private: + Operator op = Operator::Equal; + std::vector values; + + friend std::ostream& operator <<(std::ostream &, const Instance &); + }; + +public: + FilterComparison(const std::string &field) : field(field) {}; + + const std::string &getField() const; + template inline bool compare(const Extractor &extractor) const; + + template + inline void add(Args&& ...args) { + instances.emplace_back(::std::forward(args)...); + } + +private: + std::string field; + std::vector instances; + + friend std::ostream& operator <<(std::ostream &, const FilterComparison &); +}; + +std::ostream& operator <<(std::ostream &s, const FilterComparison &comparison); +std::ostream& operator <<(std::ostream &s, const FilterComparison::Instance &instance); + + +FilterComparison::Operator parseFilterComparisonOperator(const std::string &op); + +} + +#endif diff --git a/include/mbgl/style/filter_comparison_private.hpp b/include/mbgl/style/filter_comparison_private.hpp new file mode 100644 index 000000000..648683242 --- /dev/null +++ b/include/mbgl/style/filter_comparison_private.hpp @@ -0,0 +1,23 @@ +#ifndef MBGL_STYLE_FILTER_COMPARISON_PRIVATE +#define MBGL_STYLE_FILTER_COMPARISON_PRIVATE + +#include "filter_comparison.hpp" + +namespace mbgl { + +template +inline bool FilterComparison::compare(const Extractor &extractor) const { + const std::vector values = extractor.getValues(field); + + // All instances are ANDed together. + for (const Instance &instance : instances) { + if (!instance.compare(values)) { + return false; + } + } + return true; +} + +} + +#endif diff --git a/include/mbgl/style/filter_expression.hpp b/include/mbgl/style/filter_expression.hpp new file mode 100644 index 000000000..2a6a2927e --- /dev/null +++ b/include/mbgl/style/filter_expression.hpp @@ -0,0 +1,54 @@ +#ifndef MBGL_STYLE_FILTER_EXPRESSION +#define MBGL_STYLE_FILTER_EXPRESSION + +#include +#include + +#include + +namespace mbgl { + +class FilterExpression { +public: + typedef util::recursive_wrapper Wrapper; + + enum class Operator : uint8_t { + And, + Or, + Xor, + Nor + }; + + enum class GeometryType : uint8_t { + Any, + Point, + LineString, + Polygon + }; + +public: + FilterExpression() = default; + FilterExpression(Operator op) : op(op) {}; + + bool empty() const; + + template bool compare(const Extractor &extractor) const; + void add(const FilterComparison &comparison); + void add(const FilterExpression &expression); + void setGeometryType(GeometryType g); + +private: + Operator op = Operator::And; + GeometryType type = GeometryType::Any; + std::vector comparisons; + std::vector expressions; + + friend std::ostream& operator <<(std::ostream &, const FilterExpression &); +}; + +std::ostream& operator <<(std::ostream &s, const FilterExpression &expression); + +FilterExpression::GeometryType parseGeometryType(const std::string &geometry); +} + +#endif diff --git a/include/mbgl/style/filter_expression_private.hpp b/include/mbgl/style/filter_expression_private.hpp new file mode 100644 index 000000000..9379d250b --- /dev/null +++ b/include/mbgl/style/filter_expression_private.hpp @@ -0,0 +1,75 @@ +#ifndef MBGL_STYLE_FILTER_EXPRESSION_PRIVATE +#define MBGL_STYLE_FILTER_EXPRESSION_PRIVATE + +#include "filter_expression.hpp" +#include "filter_comparison_private.hpp" + +namespace mbgl { + +template +bool FilterExpression::compare(const Extractor &extractor) const { + if (type != GeometryType::Any && extractor.getType() != type && extractor.getType() != GeometryType::Any) { + return false; + } + + switch (op) { + case Operator::And: + for (const FilterComparison &comparison : comparisons) { + if (!comparison.compare(extractor)) { + return false; + } + } + for (const FilterExpression &expression: expressions) { + if (!expression.compare(extractor)) { + return false; + } + } + return true; + case Operator::Or: + for (const FilterComparison &comparison : comparisons) { + if (comparison.compare(extractor)) { + return true; + } + } + for (const FilterExpression &expression: expressions) { + if (expression.compare(extractor)) { + return true; + } + } + return false; + case Operator::Xor: { + int count = 0; + for (const FilterComparison &comparison : comparisons) { + count += comparison.compare(extractor); + if (count > 1) { + return false; + } + } + for (const FilterExpression &expression: expressions) { + count += expression.compare(extractor); + if (count > 1) { + return false; + } + } + return count == 1; + } + case Operator::Nor: + for (const FilterComparison &comparison : comparisons) { + if (comparison.compare(extractor)) { + return false; + } + } + for (const FilterExpression &expression: expressions) { + if (expression.compare(extractor)) { + return false; + } + } + return true; + default: + return true; + } +} + +} + +#endif diff --git a/include/llmr/style/function_properties.hpp b/include/mbgl/style/function_properties.hpp similarity index 93% rename from include/llmr/style/function_properties.hpp rename to include/mbgl/style/function_properties.hpp index e72ced0b0..74ac80f83 100644 --- a/include/llmr/style/function_properties.hpp +++ b/include/mbgl/style/function_properties.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_STYLE_FUNCTION_PROPERTIES -#define LLMR_STYLE_FUNCTION_PROPERTIES +#ifndef MBGL_STYLE_FUNCTION_PROPERTIES +#define MBGL_STYLE_FUNCTION_PROPERTIES -#include +#include #include -namespace llmr { +namespace mbgl { template struct ConstantFunction { diff --git a/include/llmr/style/property_fallback.hpp b/include/mbgl/style/property_fallback.hpp similarity index 71% rename from include/llmr/style/property_fallback.hpp rename to include/mbgl/style/property_fallback.hpp index eb6bb15c9..5c5eae0cd 100644 --- a/include/llmr/style/property_fallback.hpp +++ b/include/mbgl/style/property_fallback.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_STYLE_PROPERTY_FALLBACK -#define LLMR_STYLE_PROPERTY_FALLBACK +#ifndef MBGL_STYLE_PROPERTY_FALLBACK +#define MBGL_STYLE_PROPERTY_FALLBACK -#include -#include +#include +#include #include -namespace llmr { +namespace mbgl { class PropertyFallbackValue { public: diff --git a/include/llmr/style/property_key.hpp b/include/mbgl/style/property_key.hpp similarity index 91% rename from include/llmr/style/property_key.hpp rename to include/mbgl/style/property_key.hpp index e52c33ad1..d9005f2f4 100644 --- a/include/llmr/style/property_key.hpp +++ b/include/mbgl/style/property_key.hpp @@ -1,7 +1,7 @@ -#ifndef LLMR_STYLE_PROPERTY_KEY -#define LLMR_STYLE_PROPERTY_KEY +#ifndef MBGL_STYLE_PROPERTY_KEY +#define MBGL_STYLE_PROPERTY_KEY -namespace llmr { +namespace mbgl { enum class PropertyKey { FillAntialias, diff --git a/include/llmr/style/property_transition.hpp b/include/mbgl/style/property_transition.hpp similarity index 54% rename from include/llmr/style/property_transition.hpp rename to include/mbgl/style/property_transition.hpp index 017527443..07b7cfe28 100644 --- a/include/llmr/style/property_transition.hpp +++ b/include/mbgl/style/property_transition.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_STYLE_PROPERTY_TRANSITION -#define LLMR_STYLE_PROPERTY_TRANSITION +#ifndef MBGL_STYLE_PROPERTY_TRANSITION +#define MBGL_STYLE_PROPERTY_TRANSITION #include -namespace llmr { +namespace mbgl { struct PropertyTransition { uint16_t duration = 0; diff --git a/include/mbgl/style/property_value.hpp b/include/mbgl/style/property_value.hpp new file mode 100644 index 000000000..4d148dc02 --- /dev/null +++ b/include/mbgl/style/property_value.hpp @@ -0,0 +1,21 @@ +#ifndef MBGL_STYLE_PROPERTY_VALUE +#define MBGL_STYLE_PROPERTY_VALUE + +#include +#include +#include + +namespace mbgl { + +typedef util::variant< + std::string, + TranslateAnchorType, + RotateAnchorType, + Function, + Function, + Function +> PropertyValue; + +} + +#endif diff --git a/include/llmr/style/rasterize_properties.hpp b/include/mbgl/style/rasterize_properties.hpp similarity index 87% rename from include/llmr/style/rasterize_properties.hpp rename to include/mbgl/style/rasterize_properties.hpp index 440f3e530..aea90dfbd 100644 --- a/include/llmr/style/rasterize_properties.hpp +++ b/include/mbgl/style/rasterize_properties.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_STYLE_RASTERIZE_PROPERTIES -#define LLMR_STYLE_RASTERIZE_PROPERTIES +#ifndef MBGL_STYLE_RASTERIZE_PROPERTIES +#define MBGL_STYLE_RASTERIZE_PROPERTIES -#include +#include -namespace llmr { +namespace mbgl { // The calculated properties for a layer in a tile. class RasterizedProperties { diff --git a/include/llmr/style/style.hpp b/include/mbgl/style/style.hpp similarity index 86% rename from include/llmr/style/style.hpp rename to include/mbgl/style/style.hpp index cf091ad81..6aab71a4c 100644 --- a/include/llmr/style/style.hpp +++ b/include/mbgl/style/style.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_STYLE_STYLE -#define LLMR_STYLE_STYLE +#ifndef MBGL_STYLE_STYLE +#define MBGL_STYLE_STYLE -#include -#include +#include +#include -#include -#include +#include +#include #include #include @@ -15,7 +15,7 @@ #include #include -namespace llmr { +namespace mbgl { class Sprite; class StyleLayer; diff --git a/include/llmr/style/style_bucket.hpp b/include/mbgl/style/style_bucket.hpp similarity index 87% rename from include/llmr/style/style_bucket.hpp rename to include/mbgl/style/style_bucket.hpp index 5d8c9d6bb..62f072d9c 100644 --- a/include/llmr/style/style_bucket.hpp +++ b/include/mbgl/style/style_bucket.hpp @@ -1,16 +1,16 @@ -#ifndef LLMR_STYLE_STYLE_BUCKET -#define LLMR_STYLE_STYLE_BUCKET +#ifndef MBGL_STYLE_STYLE_BUCKET +#define MBGL_STYLE_STYLE_BUCKET -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include -namespace llmr { +namespace mbgl { class Source; diff --git a/include/llmr/style/style_layer.hpp b/include/mbgl/style/style_layer.hpp similarity index 90% rename from include/llmr/style/style_layer.hpp rename to include/mbgl/style/style_layer.hpp index 4d6b8d1fa..14d60ed9b 100644 --- a/include/llmr/style/style_layer.hpp +++ b/include/mbgl/style/style_layer.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_STYLE_STYLE_LAYER -#define LLMR_STYLE_STYLE_LAYER +#ifndef MBGL_STYLE_STYLE_LAYER +#define MBGL_STYLE_STYLE_LAYER -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include @@ -13,7 +13,7 @@ #include #include -namespace llmr { +namespace mbgl { class StyleBucket; class StyleLayerGroup; diff --git a/include/llmr/style/style_layer_group.hpp b/include/mbgl/style/style_layer_group.hpp similarity index 73% rename from include/llmr/style/style_layer_group.hpp rename to include/mbgl/style/style_layer_group.hpp index 90c02bc1f..983dd136f 100644 --- a/include/llmr/style/style_layer_group.hpp +++ b/include/mbgl/style/style_layer_group.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_STYLE_STYLE_LAYER_GROUP -#define LLMR_STYLE_STYLE_LAYER_GROUP +#ifndef MBGL_STYLE_STYLE_LAYER_GROUP +#define MBGL_STYLE_STYLE_LAYER_GROUP -#include +#include #include -namespace llmr { +namespace mbgl { class StyleLayerGroup { public: diff --git a/include/llmr/style/style_parser.hpp b/include/mbgl/style/style_parser.hpp similarity index 90% rename from include/llmr/style/style_parser.hpp rename to include/mbgl/style/style_parser.hpp index 38ef343e5..431e3af8d 100644 --- a/include/llmr/style/style_parser.hpp +++ b/include/mbgl/style/style_parser.hpp @@ -1,19 +1,19 @@ -#ifndef LLMR_STYLE_STYLE_PARSER -#define LLMR_STYLE_STYLE_PARSER +#ifndef MBGL_STYLE_STYLE_PARSER +#define MBGL_STYLE_STYLE_PARSER #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include -namespace llmr { +namespace mbgl { enum class ClassID : uint32_t; @@ -91,7 +91,7 @@ private: FilterExpression parseFilter(JSVal, FilterExpression::Operator op); FilterExpression parseFilter(JSVal); Value parseValue(JSVal value); - std::forward_list parseValues(JSVal values); + std::vector parseValues(JSVal values); private: std::unordered_map constants; diff --git a/include/llmr/style/style_properties.hpp b/include/mbgl/style/style_properties.hpp similarity index 92% rename from include/llmr/style/style_properties.hpp rename to include/mbgl/style/style_properties.hpp index bc46e2d85..c7606be25 100644 --- a/include/llmr/style/style_properties.hpp +++ b/include/mbgl/style/style_properties.hpp @@ -1,16 +1,16 @@ -#ifndef LLMR_STYLE_STYLE_PROPERTIES -#define LLMR_STYLE_STYLE_PROPERTIES +#ifndef MBGL_STYLE_STYLE_PROPERTIES +#define MBGL_STYLE_STYLE_PROPERTIES -#include -#include -#include +#include +#include +#include #include #include #include #include -namespace llmr { +namespace mbgl { struct FillProperties { FillProperties() {} diff --git a/include/llmr/style/style_source.hpp b/include/mbgl/style/style_source.hpp similarity index 82% rename from include/llmr/style/style_source.hpp rename to include/mbgl/style/style_source.hpp index 25a8218df..6b86c3090 100644 --- a/include/llmr/style/style_source.hpp +++ b/include/mbgl/style/style_source.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_STYLE_STYLE_SOURCE -#define LLMR_STYLE_STYLE_SOURCE +#ifndef MBGL_STYLE_STYLE_SOURCE +#define MBGL_STYLE_STYLE_SOURCE -#include +#include #include -namespace llmr { +namespace mbgl { class Source; diff --git a/include/llmr/style/types.hpp b/include/mbgl/style/types.hpp similarity index 95% rename from include/llmr/style/types.hpp rename to include/mbgl/style/types.hpp index 82632849a..ca2061fa9 100644 --- a/include/llmr/style/types.hpp +++ b/include/mbgl/style/types.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_STYLE_TYPES -#define LLMR_STYLE_TYPES +#ifndef MBGL_STYLE_TYPES +#define MBGL_STYLE_TYPES -#include +#include #include #include -namespace llmr { +namespace mbgl { // Stores a premultiplied color, with all four channels ranging from 0..1 typedef std::array Color; @@ -22,7 +22,7 @@ enum class StyleLayerType : uint8_t { Background }; -LLMR_DEFINE_ENUM_CLASS(StyleLayerTypeClass, StyleLayerType, { +MBGL_DEFINE_ENUM_CLASS(StyleLayerTypeClass, StyleLayerType, { { StyleLayerType::Unknown, "unknown" }, { StyleLayerType::Fill, "fill" }, { StyleLayerType::Line, "line" }, diff --git a/include/mbgl/style/value.hpp b/include/mbgl/style/value.hpp new file mode 100644 index 000000000..5e6260e5a --- /dev/null +++ b/include/mbgl/style/value.hpp @@ -0,0 +1,43 @@ +#ifndef MBGL_STYLE_VALUE +#define MBGL_STYLE_VALUE + +#include +#include + +#include +#include + +namespace mbgl { + +typedef util::variant Value; + +std::string toString(const Value &value); + +Value parseValue(pbf data); + +namespace util { +inline bool parseNumericString(const std::string &str, double &result) { + char *end = nullptr; + const char *begin = str.c_str(); + result = std::strtod(begin, &end); + while (*end != '\0' && isspace(*end)) end++; // eat whitespace after the end + return errno == 0 && end - begin == long(str.size()); +} +} + +template +T toNumber(const Value &value) { + if (value.is()) { + double val; + return util::parseNumericString(value.get(), val) ? val : 0; + } + else if (value.is()) return value.get(); + else if (value.is()) return value.get(); + else if (value.is()) return value.get(); + else if (value.is()) return value.get(); + else return 0; +} + +} + +#endif diff --git a/include/mbgl/style/value_comparison.hpp b/include/mbgl/style/value_comparison.hpp new file mode 100644 index 000000000..41c1d4412 --- /dev/null +++ b/include/mbgl/style/value_comparison.hpp @@ -0,0 +1,109 @@ +#ifndef MBGL_STYLE_VALUE_COMPARISON +#define MBGL_STYLE_VALUE_COMPARISON + +#include "value.hpp" +#include +#include + +namespace mbgl { + +namespace util { + +namespace detail { + +template +struct relaxed_operator_visitor { + typedef bool result_type; + + inline bool operator()(bool lhs, bool rhs) const { return Operator()(lhs, rhs); } + + template ::value>::type> + inline bool operator()(bool lhs, T rhs) const { return Operator()(T(lhs), rhs); } + + template ::value>::type> + inline bool operator()(T lhs, bool rhs) const { return Operator()(lhs, T(rhs)); } + + inline bool operator()(int64_t lhs, uint64_t rhs) const { + return lhs < 0 ? false : Operator()(uint64_t(lhs), rhs); + } + inline bool operator()(uint64_t lhs, int64_t rhs) const { + return rhs < 0 ? false : Operator()(lhs, uint64_t(rhs)); + } + + template ::value>::type> + inline bool operator()(const std::string &lhs, T rhs) const { + double value; + return parseNumericString(lhs, value) ? Operator()(value, double(rhs)) : false; + } + + template ::value>::type> + inline bool operator()(T lhs, const std::string &rhs) const { + double value; + return parseNumericString(rhs, value) ? Operator()(double(lhs), value) : false; + } + + template + inline bool operator()(T0 lhs, T1 rhs) const { return Operator()(lhs, rhs); } +}; + +struct relaxed_equal_operator { + template + inline bool operator()(T0 lhs, T1 rhs) const { return lhs == rhs; } +}; + +struct relaxed_not_equal_operator { + template + inline bool operator()(T0 lhs, T1 rhs) const { return lhs != rhs; } +}; + +struct relaxed_greater_operator { + template + inline bool operator()(T0 lhs, T1 rhs) const { return lhs > rhs; } +}; + +struct relaxed_greater_equal_operator { + template + inline bool operator()(T0 lhs, T1 rhs) const { return lhs >= rhs; } +}; + +struct relaxed_less_operator { + template + inline bool operator()(T0 lhs, T1 rhs) const { return lhs < rhs; } +}; + +struct relaxed_less_equal_operator { + template + inline bool operator()(T0 lhs, T1 rhs) const { return lhs <= rhs; } +}; + +} // end namespace detail + +inline bool relaxed_equal(Value const &lhs, Value const &rhs) { + return apply_visitor(detail::relaxed_operator_visitor(), lhs, rhs); +} + +inline bool relaxed_not_equal(Value const &lhs, Value const &rhs) { + return apply_visitor(detail::relaxed_operator_visitor(), lhs, rhs); +} + +inline bool relaxed_greater(Value const &lhs, Value const &rhs) { + return apply_visitor(detail::relaxed_operator_visitor(), lhs, rhs); +} + +inline bool relaxed_greater_equal(Value const &lhs, Value const &rhs) { + return apply_visitor(detail::relaxed_operator_visitor(), lhs, rhs); +} + +inline bool relaxed_less(Value const &lhs, Value const &rhs) { + return apply_visitor(detail::relaxed_operator_visitor(), lhs, rhs); +} + +inline bool relaxed_less_equal(Value const &lhs, Value const &rhs) { + return apply_visitor(detail::relaxed_operator_visitor(), lhs, rhs); +} + +} + +} + +#endif diff --git a/include/llmr/text/collision.hpp b/include/mbgl/text/collision.hpp similarity index 89% rename from include/llmr/text/collision.hpp rename to include/mbgl/text/collision.hpp index c9dafdd38..31103a743 100644 --- a/include/llmr/text/collision.hpp +++ b/include/mbgl/text/collision.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_TEXT_COLLISION -#define LLMR_TEXT_COLLISION +#ifndef MBGL_TEXT_COLLISION +#define MBGL_TEXT_COLLISION -#include +#include -namespace llmr { +namespace mbgl { class Collision { diff --git a/include/llmr/text/glyph.hpp b/include/mbgl/text/glyph.hpp similarity index 92% rename from include/llmr/text/glyph.hpp rename to include/mbgl/text/glyph.hpp index 99c896470..899c8fffe 100644 --- a/include/llmr/text/glyph.hpp +++ b/include/mbgl/text/glyph.hpp @@ -1,13 +1,13 @@ -#ifndef LLMR_TEXT_GLYPH -#define LLMR_TEXT_GLYPH +#ifndef MBGL_TEXT_GLYPH +#define MBGL_TEXT_GLYPH -#include +#include #include #include #include -namespace llmr { +namespace mbgl { typedef std::pair GlyphRange; diff --git a/include/llmr/text/glyph_store.hpp b/include/mbgl/text/glyph_store.hpp similarity index 94% rename from include/llmr/text/glyph_store.hpp rename to include/mbgl/text/glyph_store.hpp index a1d1046b7..9c874b31b 100644 --- a/include/llmr/text/glyph_store.hpp +++ b/include/mbgl/text/glyph_store.hpp @@ -1,8 +1,8 @@ -#ifndef LLMR_TEXT_GLYPH_STORE -#define LLMR_TEXT_GLYPH_STORE +#ifndef MBGL_TEXT_GLYPH_STORE +#define MBGL_TEXT_GLYPH_STORE -#include -#include +#include +#include #include #include @@ -11,7 +11,7 @@ #include #include -namespace llmr { +namespace mbgl { class SDFGlyph { diff --git a/include/llmr/text/placement.hpp b/include/mbgl/text/placement.hpp similarity index 73% rename from include/llmr/text/placement.hpp rename to include/mbgl/text/placement.hpp index c245e260f..69a1a10b7 100644 --- a/include/llmr/text/placement.hpp +++ b/include/mbgl/text/placement.hpp @@ -1,13 +1,13 @@ -#ifndef LLMR_TEXT_PLACEMENT -#define LLMR_TEXT_PLACEMENT +#ifndef MBGL_TEXT_PLACEMENT +#define MBGL_TEXT_PLACEMENT -#include -#include -#include -#include +#include +#include +#include +#include #include -namespace llmr { +namespace mbgl { class TextBucket; class StyleBucketText; diff --git a/include/llmr/text/rotation_range.hpp b/include/mbgl/text/rotation_range.hpp similarity index 91% rename from include/llmr/text/rotation_range.hpp rename to include/mbgl/text/rotation_range.hpp index dcdcc0143..4968fda16 100644 --- a/include/llmr/text/rotation_range.hpp +++ b/include/mbgl/text/rotation_range.hpp @@ -1,13 +1,13 @@ -#ifndef LLMR_TEXT_ROTATION_RANGE -#define LLMR_TEXT_ROTATION_RANGE +#ifndef MBGL_TEXT_ROTATION_RANGE +#define MBGL_TEXT_ROTATION_RANGE -#include -#include +#include +#include #include #include -namespace llmr { +namespace mbgl { /* * Combine an array of collision ranges to form a continuous diff --git a/include/llmr/text/types.hpp b/include/mbgl/text/types.hpp similarity index 96% rename from include/llmr/text/types.hpp rename to include/mbgl/text/types.hpp index 46a130d0e..9a9284b58 100644 --- a/include/llmr/text/types.hpp +++ b/include/mbgl/text/types.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_TEXT_TYPES -#define LLMR_TEXT_TYPES +#ifndef MBGL_TEXT_TYPES +#define MBGL_TEXT_TYPES -#include -#include +#include +#include #include #include -namespace llmr { +namespace mbgl { typedef vec2 CollisionPoint; typedef vec2 CollisionAnchor; diff --git a/include/llmr/util/clip_ids.hpp b/include/mbgl/util/clip_ids.hpp similarity index 74% rename from include/llmr/util/clip_ids.hpp rename to include/mbgl/util/clip_ids.hpp index 4e4d0abe3..748d3d8f5 100644 --- a/include/llmr/util/clip_ids.hpp +++ b/include/mbgl/util/clip_ids.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_UTIL_CLIP_IDS -#define LLMR_UTIL_CLIP_IDS +#ifndef MBGL_UTIL_CLIP_IDS +#define MBGL_UTIL_CLIP_IDS -#include +#include #include #include #include -namespace llmr { +namespace mbgl { static constexpr uint8_t clipMask[9] { 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF }; diff --git a/include/llmr/util/constants.hpp b/include/mbgl/util/constants.hpp similarity index 87% rename from include/llmr/util/constants.hpp rename to include/mbgl/util/constants.hpp index 999ef05fc..89e8af2ef 100644 --- a/include/llmr/util/constants.hpp +++ b/include/mbgl/util/constants.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_UTIL_CONSTANTS -#define LLMR_UTIL_CONSTANTS +#ifndef MBGL_UTIL_CONSTANTS +#define MBGL_UTIL_CONSTANTS #include #include "vec.hpp" -namespace llmr { +namespace mbgl { namespace util { diff --git a/include/llmr/util/enum.hpp b/include/mbgl/util/enum.hpp similarity index 85% rename from include/llmr/util/enum.hpp rename to include/mbgl/util/enum.hpp index 85a2d7c89..195aaab5a 100644 --- a/include/llmr/util/enum.hpp +++ b/include/mbgl/util/enum.hpp @@ -1,10 +1,10 @@ -#ifndef LLMR_UTIL_ENUM -#define LLMR_UTIL_ENUM +#ifndef MBGL_UTIL_ENUM +#define MBGL_UTIL_ENUM #include #include -namespace llmr { +namespace mbgl { template struct EnumValue { @@ -44,9 +44,9 @@ public: inline constexpr operator Type() const { return value; } }; -#define LLMR_DEFINE_ENUM_CLASS(name, type, strings...) \ - const constexpr ::llmr::EnumValue type##_names[] = strings; \ - using name = ::llmr::Enum)>; \ +#define MBGL_DEFINE_ENUM_CLASS(name, type, strings...) \ + const constexpr ::mbgl::EnumValue type##_names[] = strings; \ + using name = ::mbgl::Enum)>; \ inline std::ostream& operator<<(std::ostream& os, type t) { return os << name(t).str(); } } diff --git a/include/llmr/util/error.hpp b/include/mbgl/util/error.hpp similarity index 83% rename from include/llmr/util/error.hpp rename to include/mbgl/util/error.hpp index 95106ff2c..99e27f770 100644 --- a/include/llmr/util/error.hpp +++ b/include/mbgl/util/error.hpp @@ -1,10 +1,10 @@ -#ifndef LLMR_UTIL_ERROR -#define LLMR_UTIL_ERROR +#ifndef MBGL_UTIL_ERROR +#define MBGL_UTIL_ERROR #include #include -namespace llmr { +namespace mbgl { namespace error { struct style_parse : std::exception { diff --git a/include/llmr/util/image.hpp b/include/mbgl/util/image.hpp similarity index 89% rename from include/llmr/util/image.hpp rename to include/mbgl/util/image.hpp index ac20473e8..dc8f6a815 100644 --- a/include/llmr/util/image.hpp +++ b/include/mbgl/util/image.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_UTIL_IMAGE -#define LLMR_UTIL_IMAGE +#ifndef MBGL_UTIL_IMAGE +#define MBGL_UTIL_IMAGE #include #include #include -namespace llmr { +namespace mbgl { namespace util { std::string compress_png(int width, int height, void *rgba, bool flip = false); diff --git a/include/llmr/util/io.hpp b/include/mbgl/util/io.hpp similarity index 74% rename from include/llmr/util/io.hpp rename to include/mbgl/util/io.hpp index cdad97913..e95fc16d9 100644 --- a/include/llmr/util/io.hpp +++ b/include/mbgl/util/io.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_UTIL_IO -#define LLMR_UTIL_IO +#ifndef MBGL_UTIL_IO +#define MBGL_UTIL_IO #include -namespace llmr { +namespace mbgl { namespace util { void write_file(const std::string &filename, const std::string &data); diff --git a/include/llmr/util/mat4.hpp b/include/mbgl/util/mat4.hpp similarity index 95% rename from include/llmr/util/mat4.hpp rename to include/mbgl/util/mat4.hpp index a5dc83f7d..4279113d2 100644 --- a/include/llmr/util/mat4.hpp +++ b/include/mbgl/util/mat4.hpp @@ -20,12 +20,12 @@ // // 3. This notice may not be removed or altered from any source distribution. -#ifndef LLMR_UTIL_MAT4 -#define LLMR_UTIL_MAT4 +#ifndef MBGL_UTIL_MAT4 +#define MBGL_UTIL_MAT4 #include -namespace llmr { +namespace mbgl { typedef std::array mat4; diff --git a/include/llmr/util/math.hpp b/include/mbgl/util/math.hpp similarity index 97% rename from include/llmr/util/math.hpp rename to include/mbgl/util/math.hpp index ab8e392c4..277fdc8fc 100644 --- a/include/llmr/util/math.hpp +++ b/include/mbgl/util/math.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_UTIL_MATH -#define LLMR_UTIL_MATH +#ifndef MBGL_UTIL_MATH +#define MBGL_UTIL_MATH #include #include #include "vec.hpp" -namespace llmr { +namespace mbgl { namespace util { diff --git a/include/llmr/util/noncopyable.hpp b/include/mbgl/util/noncopyable.hpp similarity index 70% rename from include/llmr/util/noncopyable.hpp rename to include/mbgl/util/noncopyable.hpp index 7891e529e..ada701efc 100644 --- a/include/llmr/util/noncopyable.hpp +++ b/include/mbgl/util/noncopyable.hpp @@ -1,7 +1,7 @@ -#ifndef LLMR_UTIL_NONCOPYABLE -#define LLMR_UTIL_NONCOPYABLE +#ifndef MBGL_UTIL_NONCOPYABLE +#define MBGL_UTIL_NONCOPYABLE -namespace llmr { namespace util { +namespace mbgl { namespace util { namespace non_copyable_ { @@ -20,4 +20,4 @@ typedef non_copyable_::noncopyable noncopyable; }} -#endif //LLMR_UTIL_NONCOPYABLE +#endif diff --git a/include/llmr/util/pbf.hpp b/include/mbgl/util/pbf.hpp similarity index 97% rename from include/llmr/util/pbf.hpp rename to include/mbgl/util/pbf.hpp index 13fe8d6ee..1f78a0072 100644 --- a/include/llmr/util/pbf.hpp +++ b/include/mbgl/util/pbf.hpp @@ -1,5 +1,5 @@ -#ifndef LLMR_UTIL_PBF -#define LLMR_UTIL_PBF +#ifndef MBGL_UTIL_PBF +#define MBGL_UTIL_PBF /* * Some parts are from upb - a minimalist implementation of protocol buffers. @@ -11,7 +11,7 @@ #include #include -namespace llmr { +namespace mbgl { struct pbf { struct exception : std::exception { const char *what() const noexcept { return "pbf exception"; } }; @@ -179,6 +179,6 @@ void pbf::skipBytes(uint32_t bytes) { data += bytes; } -} // end namespace llmr +} // end namespace mbgl #endif diff --git a/include/llmr/util/raster.hpp b/include/mbgl/util/raster.hpp similarity index 87% rename from include/llmr/util/raster.hpp rename to include/mbgl/util/raster.hpp index cbc342d56..04c85169e 100644 --- a/include/llmr/util/raster.hpp +++ b/include/mbgl/util/raster.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_UTIL_RASTER -#define LLMR_UTIL_RASTER +#ifndef MBGL_UTIL_RASTER +#define MBGL_UTIL_RASTER -#include -#include -#include +#include +#include +#include #include #include @@ -11,7 +11,7 @@ typedef struct uv_loop_s uv_loop_t; -namespace llmr { +namespace mbgl { class Raster : public std::enable_shared_from_this { diff --git a/include/llmr/util/rect.hpp b/include/mbgl/util/rect.hpp similarity index 85% rename from include/llmr/util/rect.hpp rename to include/mbgl/util/rect.hpp index 2e142c301..a216b8e14 100644 --- a/include/llmr/util/rect.hpp +++ b/include/mbgl/util/rect.hpp @@ -1,7 +1,7 @@ -#ifndef LLMR_UTIL_RECT -#define LLMR_UTIL_RECT +#ifndef MBGL_UTIL_RECT +#define MBGL_UTIL_RECT -namespace llmr { +namespace mbgl { template struct Rect { diff --git a/include/llmr/util/recursive_wrapper.hpp b/include/mbgl/util/recursive_wrapper.hpp similarity index 98% rename from include/llmr/util/recursive_wrapper.hpp rename to include/mbgl/util/recursive_wrapper.hpp index b87dc5699..a616805c0 100644 --- a/include/llmr/util/recursive_wrapper.hpp +++ b/include/mbgl/util/recursive_wrapper.hpp @@ -3,7 +3,7 @@ #include -namespace llmr { namespace util { +namespace mbgl { namespace util { template class recursive_wrapper diff --git a/include/llmr/util/std.hpp b/include/mbgl/util/std.hpp similarity index 92% rename from include/llmr/util/std.hpp rename to include/mbgl/util/std.hpp index fad3380bc..051f89bb6 100644 --- a/include/llmr/util/std.hpp +++ b/include/mbgl/util/std.hpp @@ -1,5 +1,5 @@ -#ifndef LLMR_UTIL_STD -#define LLMR_UTIL_STD +#ifndef MBGL_UTIL_STD +#define MBGL_UTIL_STD #include @@ -13,7 +13,7 @@ template } -namespace llmr { +namespace mbgl { namespace util { template diff --git a/include/llmr/util/string.hpp b/include/mbgl/util/string.hpp similarity index 86% rename from include/llmr/util/string.hpp rename to include/mbgl/util/string.hpp index 50293b9f4..f17d55cec 100644 --- a/include/llmr/util/string.hpp +++ b/include/mbgl/util/string.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_UTIL_STRING -#define LLMR_UTIL_STRING +#ifndef MBGL_UTIL_STRING +#define MBGL_UTIL_STRING #include -namespace llmr { +namespace mbgl { namespace util { template diff --git a/include/llmr/util/texturepool.hpp b/include/mbgl/util/texturepool.hpp similarity index 63% rename from include/llmr/util/texturepool.hpp rename to include/mbgl/util/texturepool.hpp index 348d25d29..566d8c175 100644 --- a/include/llmr/util/texturepool.hpp +++ b/include/mbgl/util/texturepool.hpp @@ -1,13 +1,13 @@ -#ifndef LLMR_UTIL_TEXTUREPOOL -#define LLMR_UTIL_TEXTUREPOOL +#ifndef MBGL_UTIL_TEXTUREPOOL +#define MBGL_UTIL_TEXTUREPOOL -#include -#include +#include +#include #include #include -namespace llmr { +namespace mbgl { class Texturepool : private util::noncopyable { diff --git a/include/llmr/util/threadpool.hpp b/include/mbgl/util/threadpool.hpp similarity index 91% rename from include/llmr/util/threadpool.hpp rename to include/mbgl/util/threadpool.hpp index c3649c60e..497d4e308 100644 --- a/include/llmr/util/threadpool.hpp +++ b/include/mbgl/util/threadpool.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_UTIL_THREADPOOL -#define LLMR_UTIL_THREADPOOL +#ifndef MBGL_UTIL_THREADPOOL +#define MBGL_UTIL_THREADPOOL #include #include #include -namespace llmr { +namespace mbgl { namespace util { class Threadpool { diff --git a/include/llmr/util/time.hpp b/include/mbgl/util/time.hpp similarity index 96% rename from include/llmr/util/time.hpp rename to include/mbgl/util/time.hpp index 9a27cdbe3..eacee2c98 100644 --- a/include/llmr/util/time.hpp +++ b/include/mbgl/util/time.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_UTIL_TIME -#define LLMR_UTIL_TIME +#ifndef MBGL_UTIL_TIME +#define MBGL_UTIL_TIME #include -namespace llmr { +namespace mbgl { typedef uint64_t timestamp; diff --git a/include/llmr/util/timer.hpp b/include/mbgl/util/timer.hpp similarity index 90% rename from include/llmr/util/timer.hpp rename to include/mbgl/util/timer.hpp index 5dc0cfaf3..8171c2f5d 100644 --- a/include/llmr/util/timer.hpp +++ b/include/mbgl/util/timer.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_UTIL_TIMER -#define LLMR_UTIL_TIMER +#ifndef MBGL_UTIL_TIMER +#define MBGL_UTIL_TIMER -#include +#include #include -namespace llmr { +namespace mbgl { namespace util { #ifndef DISABLE_TIMER diff --git a/include/llmr/util/token.hpp b/include/mbgl/util/token.hpp similarity index 93% rename from include/llmr/util/token.hpp rename to include/mbgl/util/token.hpp index 6795b97d1..a794e0489 100644 --- a/include/llmr/util/token.hpp +++ b/include/mbgl/util/token.hpp @@ -1,5 +1,5 @@ -#ifndef LLMR_UTIL_TOKEN -#define LLMR_UTIL_TOKEN +#ifndef MBGL_UTIL_TOKEN +#define MBGL_UTIL_TOKEN #ifdef __linux__ #include @@ -11,7 +11,7 @@ namespace regex_impl = std; #include -namespace llmr { +namespace mbgl { namespace util { namespace detail { @@ -47,6 +47,6 @@ inline std::string replaceTokens(const std::string &source, const std::map -#include -#include +#include +#include +#include -namespace llmr { +namespace mbgl { namespace util { class transition : private noncopyable { diff --git a/include/llmr/util/unitbezier.hpp b/include/mbgl/util/unitbezier.hpp similarity index 97% rename from include/llmr/util/unitbezier.hpp rename to include/mbgl/util/unitbezier.hpp index 6acae7a3d..095e15f80 100644 --- a/include/llmr/util/unitbezier.hpp +++ b/include/mbgl/util/unitbezier.hpp @@ -23,12 +23,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef LLMR_UTIL_UNITBEZIER -#define LLMR_UTIL_UNITBEZIER +#ifndef MBGL_UTIL_UNITBEZIER +#define MBGL_UTIL_UNITBEZIER #include -namespace llmr { +namespace mbgl { namespace util { struct UnitBezier { diff --git a/include/llmr/util/utf.hpp b/include/mbgl/util/utf.hpp similarity index 93% rename from include/llmr/util/utf.hpp rename to include/mbgl/util/utf.hpp index fc9fb57d5..5dfc4ad2d 100644 --- a/include/llmr/util/utf.hpp +++ b/include/mbgl/util/utf.hpp @@ -1,5 +1,5 @@ -#ifndef LLMR_UTIL_UTF -#define LLMR_UTIL_UTF +#ifndef MBGL_UTIL_UTF +#define MBGL_UTIL_UTF #include @@ -16,7 +16,7 @@ #include #endif -namespace llmr { +namespace mbgl { namespace util { diff --git a/include/llmr/util/uv.hpp b/include/mbgl/util/uv.hpp similarity index 98% rename from include/llmr/util/uv.hpp rename to include/mbgl/util/uv.hpp index 69d1e8ef9..f36da83e4 100644 --- a/include/llmr/util/uv.hpp +++ b/include/mbgl/util/uv.hpp @@ -1,5 +1,5 @@ -#ifndef LLMR_UTIL_UV -#define LLMR_UTIL_UV +#ifndef MBGL_UTIL_UV +#define MBGL_UTIL_UV #include #include diff --git a/include/llmr/util/variant.hpp b/include/mbgl/util/variant.hpp similarity index 99% rename from include/llmr/util/variant.hpp rename to include/mbgl/util/variant.hpp index 57f859343..ddc82ee31 100644 --- a/include/llmr/util/variant.hpp +++ b/include/mbgl/util/variant.hpp @@ -35,7 +35,7 @@ // translates to 100 #define VARIANT_VERSION (VARIANT_MAJOR_VERSION*100000) + (VARIANT_MINOR_VERSION*100) + (VARIANT_PATCH_VERSION) -namespace llmr { namespace util { namespace detail { +namespace mbgl { namespace util { namespace detail { static constexpr std::size_t invalid_value = std::size_t(-1); diff --git a/include/llmr/util/vec.hpp b/include/mbgl/util/vec.hpp similarity index 98% rename from include/llmr/util/vec.hpp rename to include/mbgl/util/vec.hpp index 828a6a5fb..0b9bf63d5 100644 --- a/include/llmr/util/vec.hpp +++ b/include/mbgl/util/vec.hpp @@ -1,5 +1,5 @@ -#ifndef LLMR_UTIL_VEC -#define LLMR_UTIL_VEC +#ifndef MBGL_UTIL_VEC +#define MBGL_UTIL_VEC #include #include @@ -7,7 +7,7 @@ #include #include -namespace llmr { +namespace mbgl { template struct vec2 { diff --git a/ios/mapbox-gl-cocoa b/ios/mapbox-gl-cocoa index 9d403d2ce..6d29b1a2b 160000 --- a/ios/mapbox-gl-cocoa +++ b/ios/mapbox-gl-cocoa @@ -1 +1 @@ -Subproject commit 9d403d2cefcd63797a3da2c67d4b653e287aeec5 +Subproject commit 6d29b1a2be6cf29e84349605a42140c038d80c8e diff --git a/linux/main.cpp b/linux/main.cpp index 11a21880f..e603be55e 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include #include @@ -23,7 +23,7 @@ void quit_handler(int) { } int main(int argc, char *argv[]) { - llmr::Log::Set(); + mbgl::Log::Set(); int fullscreen_flag = 0; @@ -55,10 +55,10 @@ int main(int argc, char *argv[]) { stylejson << stylefile.rdbuf(); view = new GLFWView(); - llmr::Map map(*view); + mbgl::Map map(*view); // Load settings - llmr::Settings_JSON settings; + mbgl::Settings_JSON settings; map.setLonLatZoom(settings.longitude, settings.latitude, settings.zoom); map.setAngle(settings.angle); map.setDebug(settings.debug); @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) { // Set access token if present const char *token = getenv("MAPBOX_ACCESS_TOKEN"); if (token == nullptr) { - llmr::Log::Warning(llmr::Event::Setup, "no access token set. mapbox.com tiles won't work."); + mbgl::Log::Warning(mbgl::Event::Setup, "no access token set. mapbox.com tiles won't work."); } else { map.setAccessToken(std::string(token)); } diff --git a/linux/llmr-app.gyp b/linux/mapboxgl-app.gyp similarity index 90% rename from linux/llmr-app.gyp rename to linux/mapboxgl-app.gyp index e53a12224..1d09b5444 100644 --- a/linux/llmr-app.gyp +++ b/linux/mapboxgl-app.gyp @@ -52,9 +52,9 @@ }], ], 'dependencies': [ - '../llmr.gyp:llmr-x86', - '../llmr.gyp:copy_default_stylesheet', - '../llmr.gyp:copy_certificate_bundle', + '../mapboxgl.gyp:mapboxgl', + '../mapboxgl.gyp:copy_default_stylesheet', + '../mapboxgl.gyp:copy_certificate_bundle', ], }, ], diff --git a/macosx/Info.plist b/macosx/Info.plist index 88b4c3876..366a5d8ab 100644 --- a/macosx/Info.plist +++ b/macosx/Info.plist @@ -23,7 +23,7 @@ CFBundleShortVersionString 0.0.1 CFBundleSignature - LLMR + MBGL CFBundleVersion 0.0.1 CSResourcesFileMapped diff --git a/macosx/main.mm b/macosx/main.mm index e12103f35..da78f089c 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -5,20 +5,20 @@ #import int main() { - llmr::Log::Set(); + mbgl::Log::Set(); GLFWView view; - llmr::Map map(view); + mbgl::Map map(view); // Load settings - llmr::Settings_NSUserDefaults settings; + mbgl::Settings_NSUserDefaults settings; map.setLonLatZoom(settings.longitude, settings.latitude, settings.zoom); map.setAngle(settings.angle); map.setDebug(settings.debug); // Set access token if present NSString *accessToken = [[NSProcessInfo processInfo] environment][@"MAPBOX_ACCESS_TOKEN"]; - if ( ! accessToken) llmr::Log::Warning(llmr::Event::Setup, "No access token set. Mapbox vector tiles won't work."); + if ( ! accessToken) mbgl::Log::Warning(mbgl::Event::Setup, "No access token set. Mapbox vector tiles won't work."); if (accessToken) map.setAccessToken([accessToken cStringUsingEncoding:[NSString defaultCStringEncoding]]); // Load style diff --git a/macosx/llmr-app.gyp b/macosx/mapboxgl-app.gyp similarity index 97% rename from macosx/llmr-app.gyp rename to macosx/mapboxgl-app.gyp index 139cb744c..59dfc6647 100644 --- a/macosx/llmr-app.gyp +++ b/macosx/mapboxgl-app.gyp @@ -40,7 +40,7 @@ 'CLANG_ENABLE_OBJC_ARC': 'YES' }, 'dependencies': [ - '../llmr.gyp:llmr-x86' + '../mapboxgl.gyp:mapboxgl' ] } ] diff --git a/llmr.gyp b/mapboxgl.gyp similarity index 96% rename from llmr.gyp rename to mapboxgl.gyp index 2e17c2c6a..9930cd3fb 100644 --- a/llmr.gyp +++ b/mapboxgl.gyp @@ -18,7 +18,7 @@ ' -#include +#include +#include #include #include #include "debug_font.cpp" -using namespace llmr; +using namespace mbgl; void DebugFontBuffer::addText(const char *text, double left, double baseline, double scale) { uint16_t *coords = nullptr; diff --git a/src/geometry/elements_buffer.cpp b/src/geometry/elements_buffer.cpp index 71a3a12b1..79af1b7e3 100644 --- a/src/geometry/elements_buffer.cpp +++ b/src/geometry/elements_buffer.cpp @@ -1,6 +1,6 @@ -#include +#include -using namespace llmr; +using namespace mbgl; void TriangleElementsBuffer::add(element_type a, element_type b, element_type c) { element_type *elements = static_cast(addElement()); diff --git a/src/geometry/fill_buffer.cpp b/src/geometry/fill_buffer.cpp index 61aee76c5..c75ad3477 100644 --- a/src/geometry/fill_buffer.cpp +++ b/src/geometry/fill_buffer.cpp @@ -1,9 +1,9 @@ -#include -#include +#include +#include #include -using namespace llmr; +using namespace mbgl; void FillVertexBuffer::add(vertex_type x, vertex_type y) { vertex_type *vertices = static_cast(addElement()); diff --git a/src/geometry/glyph_atlas.cpp b/src/geometry/glyph_atlas.cpp index afb904407..76df941d9 100644 --- a/src/geometry/glyph_atlas.cpp +++ b/src/geometry/glyph_atlas.cpp @@ -1,13 +1,13 @@ -#include -#include -#include -#include +#include +#include +#include +#include #include #include -using namespace llmr; +using namespace mbgl; GlyphAtlas::GlyphAtlas(uint16_t width, uint16_t height) : width(width), diff --git a/src/geometry/icon_buffer.cpp b/src/geometry/icon_buffer.cpp index 22a47ff09..a25b2de06 100644 --- a/src/geometry/icon_buffer.cpp +++ b/src/geometry/icon_buffer.cpp @@ -1,9 +1,9 @@ -#include -#include +#include +#include #include -using namespace llmr; +using namespace mbgl; void IconVertexBuffer::add(vertex_type x, vertex_type y, uint16_t tx, uint16_t ty) { void *data = addElement(); diff --git a/src/geometry/interpolate.cpp b/src/geometry/interpolate.cpp index cb4165cf2..d9cfdfa1d 100644 --- a/src/geometry/interpolate.cpp +++ b/src/geometry/interpolate.cpp @@ -1,6 +1,6 @@ -#include +#include -namespace llmr { +namespace mbgl { Anchors interpolate(const std::vector &vertices, float spacing, float minScale, int start) { diff --git a/src/geometry/line_buffer.cpp b/src/geometry/line_buffer.cpp index a80ded5fb..50a6e66b9 100644 --- a/src/geometry/line_buffer.cpp +++ b/src/geometry/line_buffer.cpp @@ -1,9 +1,9 @@ -#include -#include +#include +#include #include -using namespace llmr; +using namespace mbgl; size_t LineVertexBuffer::add(vertex_type x, vertex_type y, float ex, float ey, int8_t tx, int8_t ty, int32_t linesofar) { size_t idx = index(); diff --git a/src/geometry/sprite_atlas.cpp b/src/geometry/sprite_atlas.cpp index 8a055e5a6..8fa3e8388 100644 --- a/src/geometry/sprite_atlas.cpp +++ b/src/geometry/sprite_atlas.cpp @@ -1,18 +1,18 @@ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include +#include #include #include #include -using namespace llmr; +using namespace mbgl; SpriteAtlas::SpriteAtlas(dimension width, dimension height) : width(width), @@ -128,9 +128,7 @@ Rect SpriteAtlas::allocateImage(size_t width, size_t hei Rect SpriteAtlas::getIcon(const int size, const std::string &name) { std::lock_guard lock(mtx); - const std::string id = name + "-" + std::to_string(size); - - auto rect_it = images.find(id); + auto rect_it = images.find(name); if (rect_it != images.end()) { return rect_it->second; } @@ -143,7 +141,7 @@ Rect SpriteAtlas::getIcon(const int size, const std::str return rect; } - images.emplace(id, rect); + images.emplace(name, rect); allocate(); @@ -158,7 +156,7 @@ Rect SpriteAtlas::getIcon(const int size, const std::str 1.0f / size / pixelRatio ); - uninitialized.emplace(id); + uninitialized.emplace(name); dirty = true; @@ -251,11 +249,13 @@ void SpriteAtlas::update(const Sprite &sprite) { } void SpriteAtlas::bind(bool linear) { + bool first = false; if (!texture) { glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + first = true; } else { glBindTexture(GL_TEXTURE_2D, texture); } @@ -270,20 +270,34 @@ void SpriteAtlas::bind(bool linear) { if (dirty) { std::lock_guard lock(mtx); allocate(); - glTexImage2D( - GL_TEXTURE_2D, // GLenum target - 0, // GLint level - GL_RGBA, // GLint internalformat - width * pixelRatio, // GLsizei width - height * pixelRatio, // GLsizei height - 0, // GLint border - GL_RGBA, // GLenum format - GL_UNSIGNED_BYTE, // GLenum type - data // const GLvoid * data - ); + + if (first) { + glTexImage2D( + GL_TEXTURE_2D, // GLenum target + 0, // GLint level + GL_RGBA, // GLint internalformat + width * pixelRatio, // GLsizei width + height * pixelRatio, // GLsizei height + 0, // GLint border + GL_RGBA, // GLenum format + GL_UNSIGNED_BYTE, // GLenum type + data // const GLvoid * data + ); + } else { + glTexSubImage2D(GL_TEXTURE_2D, // GLenum target + 0, // GLint level + 0, // GLint xoffset + 0, // GLint yoffset + width * pixelRatio, // GLsizei width + height * pixelRatio, // GLsizei height + GL_RGBA, // GLenum format + GL_UNSIGNED_BYTE, // GLenum type + data // const GLvoid *pixels + ); + } #if defined(DEBUG) - // platform::show_color_debug_image("Sprite Atlas", data, width, height, width * pixelRatio, height * pixelRatio); + // platform::show_color_debug_image("Sprite Atlas", reinterpret_cast(data), width, height, width * pixelRatio, height * pixelRatio); #endif dirty = false; } @@ -291,6 +305,10 @@ void SpriteAtlas::bind(bool linear) { SpriteAtlas::~SpriteAtlas() { std::lock_guard lock(mtx); + + glDeleteTextures(1, &texture); + texture = 0; + if (data) { free(data); data = nullptr; diff --git a/src/geometry/text_buffer.cpp b/src/geometry/text_buffer.cpp index d3529c560..cb3010183 100644 --- a/src/geometry/text_buffer.cpp +++ b/src/geometry/text_buffer.cpp @@ -1,10 +1,10 @@ -#include -#include -#include +#include +#include +#include #include -using namespace llmr; +using namespace mbgl; const double TextVertexBuffer::angleFactor = 128.0 / M_PI; diff --git a/src/geometry/vertex_buffer.cpp b/src/geometry/vertex_buffer.cpp index 0ce21fd51..56072e161 100644 --- a/src/geometry/vertex_buffer.cpp +++ b/src/geometry/vertex_buffer.cpp @@ -1,7 +1,7 @@ -#include -#include +#include +#include -using namespace llmr; +using namespace mbgl; VertexBuffer::VertexBuffer(std::initializer_list init) : array(init) {} diff --git a/src/map/map.cpp b/src/map/map.cpp index 68db66370..c7039cc92 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -1,28 +1,28 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include -using namespace llmr; +using namespace mbgl; Map::Map(View& view) : view(view), - transform(), + transform(view), style(std::make_shared