diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2020-03-19 17:21:21 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2020-03-20 11:43:59 +0200 |
commit | 2ae96ad6879a00eba0b9115590f58e3eb3cbd019 (patch) | |
tree | d0363140001903fd200341441c573c3eee6b627f /test | |
parent | bc45d65c58692cf0e21b4a932e4ba7bb674f12ba (diff) | |
download | qtlocation-mapboxgl-2ae96ad6879a00eba0b9115590f58e3eb3cbd019.tar.gz |
[core] Introduce Renderer::clearData() instead of keepRenderData map options
`Renderer::clearData()` is a better API than the removed `MapOptions::keepRenderData()`:
- gives more flexibility to the client
- similar to the existing `Renderer::reduceMemoryUse()`
- the `MapOptions::keepRenderData()` API implementation could not handle the raise condition, which
happened if the new still image request had come before all tiles from the previous requests were loaded.
Co-authored-by: Dane Springmeyer <dane@mapbox.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/map/map.test.cpp | 44 |
1 files changed, 17 insertions, 27 deletions
diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index 0e619d3d1f..baf1cd03a6 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -10,6 +10,7 @@ #include <mbgl/gl/context.hpp> #include <mbgl/map/map_options.hpp> #include <mbgl/math/log2.hpp> +#include <mbgl/renderer/renderer.hpp> #include <mbgl/renderer/update_parameters.hpp> #include <mbgl/storage/file_source_manager.hpp> #include <mbgl/storage/main_resource_loader.hpp> @@ -1362,26 +1363,7 @@ constexpr auto styleJSON = R"STYLE({ } TEST(Map, KeepRenderData) { - MapTest<> test{std::move(MapOptions().withMapMode(MapMode::Static).withKeepRenderData(true))}; - int requestsCount = 0; - test.fileSource->tileResponse = [&](const Resource&) { - ++requestsCount; - Response res; - res.noContent = true; - return res; - }; - test.map.jumpTo(CameraOptions().withZoom(10)); - test.map.getStyle().loadJSON(styleJSON); - test.frontend.render(test.map); - EXPECT_EQ(4, requestsCount); - - test.map.getStyle().loadJSON(styleJSON); - test.frontend.render(test.map); - EXPECT_EQ(4, requestsCount); -} - -TEST(Map, DontKeepRenderData) { - MapTest<> test{std::move(MapOptions().withMapMode(MapMode::Static).withKeepRenderData(false))}; + MapTest<> test; int requestsCount = 0; test.fileSource->tileResponse = [&](const Resource&) { ++requestsCount; @@ -1390,11 +1372,19 @@ TEST(Map, DontKeepRenderData) { return res; }; test.map.jumpTo(CameraOptions().withZoom(10)); - test.map.getStyle().loadJSON(styleJSON); - test.frontend.render(test.map); - EXPECT_EQ(4, requestsCount); - - test.map.getStyle().loadJSON(styleJSON); - test.frontend.render(test.map); - EXPECT_EQ(8, requestsCount); + const int iterations = 3; + // Keep render data. + for (int i = 1; i <= iterations; ++i) { + test.map.getStyle().loadJSON(styleJSON); + test.frontend.render(test.map); + EXPECT_EQ(4, requestsCount); + } + requestsCount = 0; + // Clear render data. + for (int i = 1; i <= iterations; ++i) { + test.frontend.getRenderer()->clearData(); + test.map.getStyle().loadJSON(styleJSON); + test.frontend.render(test.map); + EXPECT_EQ(4 * i, requestsCount); + } }
\ No newline at end of file |