summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-06-02 23:10:50 +0200
committerKonstantin Käfer <mail@kkaefer.com>2014-06-02 23:10:50 +0200
commitbd4da29a30152b0b7732a29ad54bc1e7240bfa16 (patch)
tree7a6089ea0746c7589dd21e4a29558277f0b43d38
parent3c26f53e63e7e3a9ff9973ebc3d99b39488b0251 (diff)
parentd15fb9ca97e737997f93c69cbebfa54fd9305d8f (diff)
downloadqtlocation-mapboxgl-bd4da29a30152b0b7732a29ad54bc1e7240bfa16.tar.gz
Merge branch 'master' into expressions
-rw-r--r--.travis.yml4
-rw-r--r--Makefile2
-rw-r--r--bin/style.js8
-rw-r--r--common/curl_request.cpp39
-rw-r--r--include/llmr/map/source.hpp1
-rw-r--r--linux/llmr-app.gyp15
-rw-r--r--linux/main.cpp14
-rw-r--r--src/map/source.cpp13
-rw-r--r--src/renderer/painter_clipping.cpp62
9 files changed, 120 insertions, 38 deletions
diff --git a/.travis.yml b/.travis.yml
index 70540e02ba..130965cba5 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
diff --git a/Makefile b/Makefile
index 26d3d67fdf..b6e034da85 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/bin/style.js b/bin/style.js
index 6e17b33381..9398d83145 100644
--- a/bin/style.js
+++ b/bin/style.js
@@ -1268,6 +1268,10 @@ module.exports = {
"bucket": "street"
},
{
+ "name": "road_motorway_casing",
+ "bucket": "motorway"
+ },
+ {
"name": "road_motorway_link",
"bucket": "motorway_link"
},
@@ -1284,10 +1288,6 @@ module.exports = {
"bucket": "main"
},
{
- "name": "road_motorway_casing",
- "bucket": "motorway"
- },
- {
"name": "road_motorway",
"bucket": "motorway"
},
diff --git a/common/curl_request.cpp b/common/curl_request.cpp
index 7eae7fd95e..e5edb5aba9 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;
diff --git a/include/llmr/map/source.hpp b/include/llmr/map/source.hpp
index 7ce6aa632e..4a506ecacb 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/linux/llmr-app.gyp b/linux/llmr-app.gyp
index 93b08364ed..2310613583 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)'
+ }
+ ]
+ }
],
}
diff --git a/linux/main.cpp b/linux/main.cpp
index 2c7440c876..25898fab24 100644
--- a/linux/main.cpp
+++ b/linux/main.cpp
@@ -3,6 +3,8 @@
#include <signal.h>
#include <getopt.h>
+#include <fstream>
+#include <sstream>
#include "../common/settings_json.hpp"
#include "../common/glfw_view.hpp"
@@ -40,6 +42,15 @@ int main(int argc, char *argv[]) {
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
+ // read default stylesheet from disk
+ std::ifstream stylefile("./style.min.js");
+ if (!stylefile.good()) {
+ fprintf(stderr, "Cannot read style file\n");
+ return 1;
+ }
+ std::stringstream stylejson;
+ stylejson << stylefile.rdbuf();
+
view = new GLFWView();
llmr::Map map(*view);
@@ -49,6 +60,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
diff --git a/src/map/source.cpp b/src/map/source.cpp
index 2491e083e6..e8a2fb4a7f 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<const Tile::ID, std::unique_ptr<Tile>> &pair : tiles) {
Tile &tile = *pair.second;
diff --git a/src/renderer/painter_clipping.cpp b/src/renderer/painter_clipping.cpp
index 3a4a24b11d..5a28befb67 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> &sprite = map.getStyle()->sprite;
+ if (sprite) {
+ SpriteAtlas &spriteAtlas = *map.getSpriteAtlas();
+ Rect<uint16_t> imagePos = spriteAtlas.getImage("matte-256", *sprite);
+
+ std::array<float, 2> 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<float, 4> 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;