From 705ddf68a5957a84c0e96beaf5a6e25b1166dc74 Mon Sep 17 00:00:00 2001 From: Young Hahn Date: Sun, 1 Jun 2014 13:15:36 -0400 Subject: [PATCH 01/10] Add gyp entry to copy style.min.js to PRODUCT_DIR --- linux/llmr-app.gyp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/linux/llmr-app.gyp b/linux/llmr-app.gyp index 93b08364e..231061358 100644 --- a/linux/llmr-app.gyp +++ b/linux/llmr-app.gyp @@ -51,7 +51,22 @@ ], 'dependencies': [ '../llmr.gyp:llmr-x86', + 'default_stylesheet', ], }, + { + 'target_name': 'default_stylesheet', + 'type': 'none', + 'hard_dependency': 1, + 'dependencies': [ + '../llmr.gyp:build_stylesheet' + ], + 'copies': [ + { + 'files': [ '<(SHARED_INTERMEDIATE_DIR)/bin/style.min.js' ], + 'destination': '<(PRODUCT_DIR)' + } + ] + } ], } From 04610023deab950a2bbca9d5f04129d981c5d6b2 Mon Sep 17 00:00:00 2001 From: Young Hahn Date: Sun, 1 Jun 2014 13:50:32 -0400 Subject: [PATCH 02/10] Load stylesheet from disk. --- linux/main.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/linux/main.cpp b/linux/main.cpp index 2c7440c87..f796a2351 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -3,6 +3,8 @@ #include #include +#include +#include #include "../common/settings_json.hpp" #include "../common/glfw_view.hpp" @@ -40,6 +42,11 @@ int main(int argc, char *argv[]) { sigIntHandler.sa_flags = 0; sigaction(SIGINT, &sigIntHandler, NULL); + // read default stylesheet from disk + std::ifstream stylefile("./build/Release/style.min.js"); + std::stringstream stylejson; + stylejson << stylefile.rdbuf(); + view = new GLFWView(); llmr::Map map(*view); @@ -49,6 +56,9 @@ int main(int argc, char *argv[]) { map.setAngle(settings.angle); map.setDebug(settings.debug); + // Load style + map.setStyleJSON(stylejson.str()); + int ret = view->run(); // Save settings From 552246f4b037650b0cc57e42444ccea2b5356fd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Sun, 1 Jun 2014 22:10:41 +0200 Subject: [PATCH 03/10] handle all CURL actions --- common/curl_request.cpp | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/common/curl_request.cpp b/common/curl_request.cpp index 7eae7fd95..e5edb5aba 100644 --- a/common/curl_request.cpp +++ b/common/curl_request.cpp @@ -190,32 +190,27 @@ void curl_perform(uv_poll_t *req, int /*status*/, int events) { } int handle_socket(CURL * /*easy*/, curl_socket_t s, int action, void * /*userp*/, void *socketp) { - curl_context *context; - if (action == CURL_POLL_IN || action == CURL_POLL_OUT) { - if (socketp) { - context = (curl_context *)socketp; - } else { - context = create_curl_context(s); - } - curl_multi_assign(curl_multi, s, (void *)context); + curl_context *context = nullptr; + + if (socketp) { + context = (curl_context *)socketp; + } else if (action != CURL_POLL_REMOVE) { + context = create_curl_context(s); } - switch (action) { - case CURL_POLL_IN: - uv_poll_start(&context->poll_handle, UV_READABLE, curl_perform); - break; - case CURL_POLL_OUT: - uv_poll_start(&context->poll_handle, UV_WRITABLE, curl_perform); - break; - case CURL_POLL_REMOVE: - if (socketp) { - uv_poll_stop(&((curl_context *)socketp)->poll_handle); - destroy_curl_context((curl_context *)socketp); + if (context) { + curl_multi_assign(curl_multi, s, (void *)context); + if (action == CURL_POLL_IN || action == CURL_POLL_INOUT) { + uv_poll_start(&context->poll_handle, UV_READABLE, curl_perform); + } + if (action == CURL_POLL_OUT || action == CURL_POLL_INOUT) { + uv_poll_start(&context->poll_handle, UV_WRITABLE, curl_perform); + } + if (action == CURL_POLL_REMOVE && socketp) { + uv_poll_stop(&context->poll_handle); + destroy_curl_context(context); curl_multi_assign(curl_multi, s, NULL); } - break; - default: - abort(); } return 0; From 6bbac8559f385043f59af25dd6517a5ae080498d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Sun, 1 Jun 2014 22:28:12 +0200 Subject: [PATCH 04/10] run executable with correct working dir --- Makefile | 2 +- linux/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 26d3d67fd..b6e034da8 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ linux: config.gypi linux/llmr-app.gyp node # Executes the Linux binary run-linux: linux - build/$(BUILDTYPE)/mapbox-gl + (cd build/$(BUILDTYPE) && ./mapbox-gl) diff --git a/linux/main.cpp b/linux/main.cpp index f796a2351..bee52d901 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) { sigaction(SIGINT, &sigIntHandler, NULL); // read default stylesheet from disk - std::ifstream stylefile("./build/Release/style.min.js"); + std::ifstream stylefile("./style.min.js"); std::stringstream stylejson; stylejson << stylefile.rdbuf(); From 7ab3ef875fbad9b7bee8a25a5a253b1246cf4db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 2 Jun 2014 11:49:36 +0200 Subject: [PATCH 05/10] update hipchat notifications --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 70540e02b..130965cba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,9 @@ script: notifications: hipchat: rooms: - secure: H/Z51pvNrTgdePfHpF66obRy2JF+yBCmp70MWjGnW8RZDyUQ+U5HgcVe/HBeCYFRg81hjSr3TxV70WrTUHP1NNPQ4+kcuW194bjZqq8TACwXOasFGNQ5L32izthfGto6rKtgNz6TzR5t44BpJnJhJMmqh46ybZvNTN2XBIaYkDQ= + secure: "ZKtTiFjXgXfrAO8eMU1nJBe46OBLgk0H7VAVmk84QwAb6DuoqT+mGMs+1yrWtjLwZI8vayZyaucupp1siM7lBWCOADx5GXA6GCCLOuE7fYLSNJFrXHa1u70IUBLOU8b5bDWRn8tcd5CM754R609l4ckTzBH3y4CIh9YNFrB0b+g=" + template: + - '%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}' git: submodules: false From 15c12701e3dacb40aa3a1bead587e9f8fb6433d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 2 Jun 2014 12:01:33 +0200 Subject: [PATCH 06/10] error early when it can't read the style file --- linux/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/linux/main.cpp b/linux/main.cpp index bee52d901..ec4dd4957 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -44,6 +44,10 @@ int main(int argc, char *argv[]) { // read default stylesheet from disk std::ifstream stylefile("./style.min.js"); + if (!stylefile.good()) { + fprintf(stder, "Cannot read style file\n"); + return 1; + } std::stringstream stylejson; stylejson << stylefile.rdbuf(); From 3019cc502a59a13eaa01c442c779e1e4aba4a887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 2 Jun 2014 12:34:04 +0200 Subject: [PATCH 07/10] typo --- linux/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/main.cpp b/linux/main.cpp index ec4dd4957..25898fab2 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -45,7 +45,7 @@ int main(int argc, char *argv[]) { // read default stylesheet from disk std::ifstream stylefile("./style.min.js"); if (!stylefile.good()) { - fprintf(stder, "Cannot read style file\n"); + fprintf(stderr, "Cannot read style file\n"); return 1; } std::stringstream stylejson; From 3f6075711fffa7a9727bfa7004f19fdf0b7e17f4 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Mon, 2 Jun 2014 13:12:32 -0400 Subject: [PATCH 08/10] draw motorway casing below roads --- bin/style.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/style.js b/bin/style.js index d851c1f16..eb055196f 100644 --- a/bin/style.js +++ b/bin/style.js @@ -1262,6 +1262,10 @@ module.exports = { "name": "road_street_casing", "bucket": "street" }, + { + "name": "road_motorway_casing", + "bucket": "motorway" + }, { "name": "road_motorway_link", "bucket": "motorway_link" @@ -1278,10 +1282,6 @@ module.exports = { "name": "road_main", "bucket": "main" }, - { - "name": "road_motorway_casing", - "bucket": "motorway" - }, { "name": "road_motorway", "bucket": "motorway" From 1dd3fdfba3aef7ce93b2e2e11e56b5967f3cef8e Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Mon, 2 Jun 2014 11:42:00 -0700 Subject: [PATCH 09/10] background grid --- include/llmr/map/source.hpp | 1 + src/map/source.cpp | 13 +++++++ src/renderer/painter_clipping.cpp | 62 ++++++++++++++++++++++++++----- 3 files changed, 66 insertions(+), 10 deletions(-) diff --git a/include/llmr/map/source.hpp b/include/llmr/map/source.hpp index 7ce6aa632..4a506ecac 100644 --- a/include/llmr/map/source.hpp +++ b/include/llmr/map/source.hpp @@ -37,6 +37,7 @@ public: bool update(); void updateMatrices(const TransformState &transform); + bool viewportTileParsed(); void drawClippingMasks(); size_t getTileCount() const; void render(const LayerDescription& layer_desc, const BucketDescription &bucket_desc); diff --git a/src/map/source.cpp b/src/map/source.cpp index 2491e083e..e8a2fb4a7 100644 --- a/src/map/source.cpp +++ b/src/map/source.cpp @@ -57,6 +57,19 @@ size_t Source::getTileCount() const { return tiles.size(); } +bool Source::viewportTileParsed() { + bool parsed = false; + + for (auto &pair : tiles) { + Tile::ID id = pair.first; + if (hasTile(id) == TileData::State::parsed) { + parsed = true; + } + } + + return parsed; +} + void Source::drawClippingMasks() { for (std::pair> &pair : tiles) { Tile &tile = *pair.second; diff --git a/src/renderer/painter_clipping.cpp b/src/renderer/painter_clipping.cpp index 3a4a24b11..5a28befb6 100644 --- a/src/renderer/painter_clipping.cpp +++ b/src/renderer/painter_clipping.cpp @@ -9,22 +9,64 @@ using namespace llmr; void Painter::drawClippingMasks(const Sources &sources) { gl::group group("clipping masks"); - useProgram(plainShader->program); glDisable(GL_DEPTH_TEST); depthMask(false); glDepthRange(1.0f, 1.0f); glStencilMask(0xFF); - const BackgroundProperties &properties = map.getStyle()->computed.background; - Color background = properties.color; - const float opacity = properties.opacity; - background[0] *= opacity; - background[1] *= opacity; - background[2] *= opacity; - background[3] *= opacity; - plainShader->setColor(background); + bool ready = false; - coveringPlainArray.bind(*plainShader, tileStencilBuffer, BUFFER_OFFSET(0)); + for (const auto &pair : sources) { + Source &source = *pair.second; + if (source.viewportTileParsed()) { + ready = true; + } + } + + if (ready) { + // At least one viewport tile is parsed. Draw the background. + useProgram(plainShader->program); + + const BackgroundProperties &properties = map.getStyle()->computed.background; + Color background = properties.color; + const float opacity = properties.opacity; + background[0] *= opacity; + background[1] *= opacity; + background[2] *= opacity; + background[3] *= opacity; + plainShader->setColor(background); + + coveringPlainArray.bind(*plainShader, tileStencilBuffer, BUFFER_OFFSET(0)); + } else { + // No viewport tiles are parsed. Draw the grid pattern. + const std::shared_ptr &sprite = map.getStyle()->sprite; + if (sprite) { + SpriteAtlas &spriteAtlas = *map.getSpriteAtlas(); + Rect imagePos = spriteAtlas.getImage("matte-256", *sprite); + + std::array imageSize = {{ + (float)(imagePos.w * 0.5), + (float)(imagePos.h * 0.5) + } + }; + + useProgram(patternShader->program); + patternShader->setPatternSize(imageSize); + patternShader->setPatternTopLeft({{ + float(imagePos.x) / spriteAtlas.getWidth(), + float(imagePos.y) / spriteAtlas.getHeight(), + }}); + patternShader->setPatternBottomRight({{ + float(imagePos.x + imagePos.w) / spriteAtlas.getWidth(), + float(imagePos.y + imagePos.h) / spriteAtlas.getHeight(), + }}); + std::array color = {{ 1, 1, 1, 1 }}; + patternShader->setColor(color); + spriteAtlas.bind(true); + + coveringPatternArray.bind(*patternShader, tileStencilBuffer, BUFFER_OFFSET(0)); + } + } for (const auto &pair : sources) { Source &source = *pair.second; From 331b726db4d4fcf5770657107b32fee8df90addb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Tue, 3 Jun 2014 00:00:15 +0200 Subject: [PATCH 10/10] fix comparison order error --- include/llmr/map/filter_expression.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/llmr/map/filter_expression.hpp b/include/llmr/map/filter_expression.hpp index bf6d41480..50e6ce1d7 100644 --- a/include/llmr/map/filter_expression.hpp +++ b/include/llmr/map/filter_expression.hpp @@ -87,17 +87,17 @@ public: inline bool compare(const Value &other) const { switch (op) { case FilterOperator::Equal: - return util::relaxed_equal(value, other); + return util::relaxed_equal(other, value); case FilterOperator::NotEqual: - return !util::relaxed_equal(value, other); + return !util::relaxed_equal(other, value); case FilterOperator::Greater: - return util::relaxed_greater(value, other); + return util::relaxed_greater(other, value); case FilterOperator::GreaterEqual: - return util::relaxed_greater_equal(value, other); + return util::relaxed_greater_equal(other, value); case FilterOperator::Less: - return util::relaxed_less(value, other); + return util::relaxed_less(other, value); case FilterOperator::LessEqual: - return util::relaxed_less_equal(value, other); + return util::relaxed_less_equal(other, value); default: return false; }