summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-08-01 14:49:15 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-08-01 18:20:21 +0300
commit187962e4259c3a9d3c29fefe29533358face4ed0 (patch)
treea2fb310a0df60ffd0c22a5ab950c5f5db6b08256
parent9cf1746e350048177487406328ff7815287ede61 (diff)
downloadqtlocation-mapboxgl-187962e4259c3a9d3c29fefe29533358face4ed0.tar.gz
[core] Fix render tile set source update
Before this change, the `RenderTileSetSource` implementation ignored update calls for the sources whose description was not yet loaded and it lead to missing of relayout requests.
-rw-r--r--src/mbgl/renderer/sources/render_tile_source.cpp2
-rw-r--r--test/style/source.test.cpp39
2 files changed, 40 insertions, 1 deletions
diff --git a/src/mbgl/renderer/sources/render_tile_source.cpp b/src/mbgl/renderer/sources/render_tile_source.cpp
index ef3f34f595..c5afb38435 100644
--- a/src/mbgl/renderer/sources/render_tile_source.cpp
+++ b/src/mbgl/renderer/sources/render_tile_source.cpp
@@ -176,7 +176,7 @@ void RenderTileSetSource::update(Immutable<style::Source::Impl> baseImpl_,
tilePyramid.clearAll();
}
- if (!implTileset) return;
+ if (!cachedTileset) return;
updateInternal(*cachedTileset, layers, needsRendering, needsRelayout, parameters);
}
diff --git a/test/style/source.test.cpp b/test/style/source.test.cpp
index 09c433b6a4..ca0e79f46a 100644
--- a/test/style/source.test.cpp
+++ b/test/style/source.test.cpp
@@ -42,6 +42,7 @@
#include <mbgl/text/glyph_manager.hpp>
#include <cstdint>
+#include <gmock/gmock.h>
using namespace mbgl;
using SourceType = mbgl::style::SourceType;
@@ -793,3 +794,41 @@ TEST(Source, CustomGeometrySourceSetTileData) {
test.run();
}
+TEST(Source, RenderTileSetSourceUpdate) {
+ SourceTest test;
+
+ class FakeRenderTileSetSource : public RenderTileSetSource {
+ public:
+ explicit FakeRenderTileSetSource(Immutable<style::Source::Impl> impl_)
+ : RenderTileSetSource(std::move(impl_)) {}
+
+ MOCK_METHOD0(mockedUpdateInternal, void());
+
+ void updateInternal(const Tileset&,
+ const std::vector<Immutable<style::LayerProperties>>&,
+ const bool, const bool, const TileParameters&) override {
+ mockedUpdateInternal();
+ }
+
+ const optional<Tileset>& getTileset() const override {
+ return static_cast<const style::VectorSource::Impl&>(*baseImpl).tileset;
+ }
+ };
+
+ VectorSource initialized("source", Tileset{ {"tiles"} });
+ initialized.loadDescription(*test.fileSource);
+
+ FakeRenderTileSetSource renderTilesetSource { initialized.baseImpl };
+
+ LineLayer layer("id", "source");
+ Immutable<LayerProperties> layerProperties = makeMutable<LineLayerProperties>(staticImmutableCast<LineLayer::Impl>(layer.baseImpl));
+ std::vector<Immutable<LayerProperties>> layers { layerProperties };
+
+ // Check that `updateInternal()` is called even if the updated source has not yet loaded description.
+ EXPECT_CALL(renderTilesetSource, mockedUpdateInternal()).Times(2);
+ RenderSource* renderSource = &renderTilesetSource;
+ renderSource->update(initialized.baseImpl, layers, true, true, test.tileParameters);
+
+ VectorSource uninitialized("source", "http://url");
+ renderSource->update(uninitialized.baseImpl, layers, true, true, test.tileParameters);
+}