diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-07-02 17:31:55 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-07-02 17:31:55 +0200 |
commit | ac57125bd53f045540b08a95b2a4552b13e63318 (patch) | |
tree | c9acd3bf254256c7eea0833db502a27e7ae54271 | |
parent | 415214d75927481570cc3bb9129ab343413a9578 (diff) | |
download | qtlocation-mapboxgl-ac57125bd53f045540b08a95b2a4552b13e63318.tar.gz |
fix background painting
-rw-r--r-- | include/llmr/style/style.hpp | 4 | ||||
-rw-r--r-- | src/renderer/painter.cpp | 3 | ||||
-rw-r--r-- | src/style/style.cpp | 11 | ||||
-rw-r--r-- | src/style/style_parser.cpp | 1 |
4 files changed, 16 insertions, 3 deletions
diff --git a/include/llmr/style/style.hpp b/include/llmr/style/style.hpp index 47539fb0b0..3020a54946 100644 --- a/include/llmr/style/style.hpp +++ b/include/llmr/style/style.hpp @@ -19,6 +19,7 @@ class Sprite; class Source; class StyleLayer; class StyleLayerGroup; +class BackgroundProperties; class Style { public: @@ -45,10 +46,11 @@ public: bool hasTransitions() const; + const BackgroundProperties &getBackgroundProperties() const; + public: std::shared_ptr<Sprite> sprite; std::shared_ptr<StyleLayerGroup> layers; - std::shared_ptr<StyleLayer> background; std::vector<std::string> appliedClasses; std::string sprite_url; std::string glyph_url; diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index 665c7baece..253cb7eeb8 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -137,8 +137,7 @@ void Painter::clear() { glStencilMask(0xFF); depthMask(true); - std::shared_ptr<StyleLayer> background_layer = map.getStyle()->background; - const BackgroundProperties &properties = background_layer ? background_layer->getProperties<BackgroundProperties>() : defaultStyleProperties<BackgroundProperties>(); + const BackgroundProperties &properties = map.getStyle()->getBackgroundProperties(); glClearColor(properties.color[0], properties.color[1], properties.color[2], properties.color[3]); glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } diff --git a/src/style/style.cpp b/src/style/style.cpp index d6894f6e1c..b11cd92260 100644 --- a/src/style/style.cpp +++ b/src/style/style.cpp @@ -108,4 +108,15 @@ void Style::loadJSON(const uint8_t *const data) { updateClasses(); } +const BackgroundProperties &Style::getBackgroundProperties() const { + if (layers && layers->layers.size()) { + const auto first = layers->layers.front(); + if (first && first->id == "background") { + return first->getProperties<BackgroundProperties>(); + } + } + + return defaultStyleProperties<BackgroundProperties>(); +} + } diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp index 26bd54401c..22f71eb7b5 100644 --- a/src/style/style_parser.cpp +++ b/src/style/style_parser.cpp @@ -925,6 +925,7 @@ void StyleParser::parseRender(JSVal value, std::shared_ptr<StyleLayer> &layer) { } break; default: + layer->bucket.reset(); fprintf(stderr, "[WARNING] bucket type of layer '%s' is invalid\n", layer->id.c_str()); break; } |