diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2017-06-13 10:50:16 +0300 |
---|---|---|
committer | Ivo van Dongen <ivovandongen@users.noreply.github.com> | 2017-07-18 10:45:12 +0200 |
commit | 57351c068b133ed140ac7b991181672019fe5c24 (patch) | |
tree | 2a0be8819c2bc57b1cda7d5c6f98e725a030daa2 | |
parent | e35cbbae55ab01f33690b1bb2e918c5f8393b854 (diff) | |
download | qtlocation-mapboxgl-57351c068b133ed140ac7b991181672019fe5c24.tar.gz |
[core] split backend from mapobserver
-rw-r--r-- | benchmark/api/query.benchmark.cpp | 2 | ||||
-rw-r--r-- | benchmark/api/render.benchmark.cpp | 7 | ||||
-rw-r--r-- | bin/render.cpp | 2 | ||||
-rw-r--r-- | include/mbgl/map/backend.hpp | 4 | ||||
-rw-r--r-- | include/mbgl/map/map.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/map/map.cpp | 6 | ||||
-rw-r--r-- | test/api/annotations.test.cpp | 2 | ||||
-rw-r--r-- | test/api/api_misuse.test.cpp | 2 | ||||
-rw-r--r-- | test/api/custom_layer.test.cpp | 2 | ||||
-rw-r--r-- | test/api/query.test.cpp | 2 | ||||
-rw-r--r-- | test/api/render_missing.test.cpp | 2 | ||||
-rw-r--r-- | test/api/repeated_render.test.cpp | 4 | ||||
-rw-r--r-- | test/map/map.test.cpp | 110 | ||||
-rw-r--r-- | test/map/prefetch.test.cpp | 2 | ||||
-rw-r--r-- | test/util/memory.test.cpp | 16 |
15 files changed, 81 insertions, 83 deletions
diff --git a/benchmark/api/query.benchmark.cpp b/benchmark/api/query.benchmark.cpp index 4c11a56da5..b88ecb7749 100644 --- a/benchmark/api/query.benchmark.cpp +++ b/benchmark/api/query.benchmark.cpp @@ -38,7 +38,7 @@ public: OffscreenView view{ backend.getContext(), { 1000, 1000 } }; DefaultFileSource fileSource{ "benchmark/fixtures/api/cache.db", "." }; ThreadPool threadPool{ 4 }; - Map map{ backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still }; + Map map{ backend, MapObserver::nullObserver(), view.getSize(), 1, fileSource, threadPool, MapMode::Still }; ScreenBox box{{ 0, 0 }, { 1000, 1000 }}; }; diff --git a/benchmark/api/render.benchmark.cpp b/benchmark/api/render.benchmark.cpp index 8c71c1a9bf..aea2af745a 100644 --- a/benchmark/api/render.benchmark.cpp +++ b/benchmark/api/render.benchmark.cpp @@ -2,6 +2,7 @@ #include <mbgl/benchmark/util.hpp> #include <mbgl/map/map.hpp> +#include <mbgl/map/map_observer.hpp> #include <mbgl/map/backend_scope.hpp> #include <mbgl/gl/headless_backend.hpp> #include <mbgl/gl/offscreen_view.hpp> @@ -44,7 +45,7 @@ static void prepare(Map& map, optional<std::string> json = {}) { static void API_renderStill_reuse_map(::benchmark::State& state) { RenderBenchmark bench; - Map map { bench.backend, bench.view.getSize(), 1, bench.fileSource, bench.threadPool, MapMode::Still }; + Map map { bench.backend, MapObserver::nullObserver(), bench.view.getSize(), 1, bench.fileSource, bench.threadPool, MapMode::Still }; prepare(map); while (state.KeepRunning()) { @@ -54,7 +55,7 @@ static void API_renderStill_reuse_map(::benchmark::State& state) { static void API_renderStill_reuse_map_switch_styles(::benchmark::State& state) { RenderBenchmark bench; - Map map { bench.backend, bench.view.getSize(), 1, bench.fileSource, bench.threadPool, MapMode::Still }; + Map map { bench.backend, MapObserver::nullObserver(), bench.view.getSize(), 1, bench.fileSource, bench.threadPool, MapMode::Still }; while (state.KeepRunning()) { prepare(map, { "{}" }); @@ -68,7 +69,7 @@ static void API_renderStill_recreate_map(::benchmark::State& state) { RenderBenchmark bench; while (state.KeepRunning()) { - Map map { bench.backend, bench.view.getSize(), 1, bench.fileSource, bench.threadPool, MapMode::Still }; + Map map { bench.backend, MapObserver::nullObserver(), bench.view.getSize(), 1, bench.fileSource, bench.threadPool, MapMode::Still }; prepare(map); mbgl::benchmark::render(map, bench.view); } diff --git a/bin/render.cpp b/bin/render.cpp index 51c6faef56..74fd6fdcc4 100644 --- a/bin/render.cpp +++ b/bin/render.cpp @@ -88,7 +88,7 @@ int main(int argc, char *argv[]) { OffscreenView view(backend.getContext(), { static_cast<uint32_t>(width * pixelRatio), static_cast<uint32_t>(height * pixelRatio) }); ThreadPool threadPool(4); - Map map(backend, mbgl::Size { width, height }, pixelRatio, fileSource, threadPool, MapMode::Still); + Map map(backend, MapObserver::nullObserver(), mbgl::Size { width, height }, pixelRatio, fileSource, threadPool, MapMode::Still); if (style_path.find("://") == std::string::npos) { style_path = std::string("file://") + style_path; diff --git a/include/mbgl/map/backend.hpp b/include/mbgl/map/backend.hpp index 2e73ad994c..434f68779c 100644 --- a/include/mbgl/map/backend.hpp +++ b/include/mbgl/map/backend.hpp @@ -1,6 +1,6 @@ #pragma once -#include <mbgl/map/map_observer.hpp> +#include <mbgl/map/view.hpp> #include <mbgl/util/image.hpp> #include <mbgl/util/size.hpp> @@ -17,7 +17,7 @@ using FramebufferID = uint32_t; class BackendScope; -class Backend : public MapObserver { +class Backend { public: Backend(); virtual ~Backend(); diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index d82a260362..22ac100c40 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -33,6 +33,7 @@ class Style; class Map : private util::noncopyable { public: explicit Map(Backend&, + MapObserver&, Size size, float pixelRatio, FileSource&, diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index e644f91c4f..172b2bf851 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -49,6 +49,7 @@ class Map::Impl : public style::Observer, public: Impl(Map&, Backend&, + MapObserver&, float pixelRatio, FileSource&, Scheduler&, @@ -104,6 +105,7 @@ public: }; Map::Map(Backend& backend, + MapObserver& mapObserver, const Size size, const float pixelRatio, FileSource& fileSource, @@ -115,6 +117,7 @@ Map::Map(Backend& backend, optional<std::string> programCacheDir) : impl(std::make_unique<Impl>(*this, backend, + mapObserver, pixelRatio, fileSource, scheduler, @@ -128,6 +131,7 @@ Map::Map(Backend& backend, Map::Impl::Impl(Map& map_, Backend& backend_, + MapObserver& mapObserver, float pixelRatio_, FileSource& fileSource_, Scheduler& scheduler_, @@ -137,7 +141,7 @@ Map::Impl::Impl(Map& map_, ViewportMode viewportMode_, optional<std::string> programCacheDir_) : map(map_), - observer(backend_), + observer(mapObserver), backend(backend_), fileSource(fileSource_), scheduler(scheduler_), diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp index 7594d5ed73..42fbcc0a8b 100644 --- a/test/api/annotations.test.cpp +++ b/test/api/annotations.test.cpp @@ -33,7 +33,7 @@ public: OffscreenView view { backend.getContext() }; StubFileSource fileSource; ThreadPool threadPool { 4 }; - Map map { backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still }; + Map map { backend, MapObserver::nullObserver(), view.getSize(), 1, fileSource, threadPool, MapMode::Still }; void checkRendering(const char * name) { test::checkImage(std::string("test/fixtures/annotations/") + name, diff --git a/test/api/api_misuse.test.cpp b/test/api/api_misuse.test.cpp index 54cde8d9b5..e5498576a8 100644 --- a/test/api/api_misuse.test.cpp +++ b/test/api/api_misuse.test.cpp @@ -29,7 +29,7 @@ TEST(API, RenderWithoutCallback) { ThreadPool threadPool(4); std::unique_ptr<Map> map = - std::make_unique<Map>(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still); + std::make_unique<Map>(backend, MapObserver::nullObserver(), view.getSize(), 1, fileSource, threadPool, MapMode::Still); map->renderStill(view, nullptr); // Force Map thread to join. diff --git a/test/api/custom_layer.test.cpp b/test/api/custom_layer.test.cpp index 2b1138a1d3..b5d94f2786 100644 --- a/test/api/custom_layer.test.cpp +++ b/test/api/custom_layer.test.cpp @@ -93,7 +93,7 @@ TEST(CustomLayer, Basic) { DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets"); ThreadPool threadPool(4); - Map map(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still); + Map map(backend, MapObserver::nullObserver(), view.getSize(), 1, fileSource, threadPool, MapMode::Still); map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); map.setLatLngZoom({ 37.8, -122.5 }, 10); map.getStyle().addLayer(std::make_unique<CustomLayer>( diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp index 0b6d75ec4f..0b02e47219 100644 --- a/test/api/query.test.cpp +++ b/test/api/query.test.cpp @@ -33,7 +33,7 @@ public: OffscreenView view { backend.getContext() }; StubFileSource fileSource; ThreadPool threadPool { 4 }; - Map map { backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still }; + Map map { backend, MapObserver::nullObserver(), view.getSize(), 1, fileSource, threadPool, MapMode::Still }; }; } // end namespace diff --git a/test/api/render_missing.test.cpp b/test/api/render_missing.test.cpp index 2e0c4401f4..9cba1dcac7 100644 --- a/test/api/render_missing.test.cpp +++ b/test/api/render_missing.test.cpp @@ -35,7 +35,7 @@ TEST(API, TEST_REQUIRES_SERVER(RenderMissingTile)) { Log::setObserver(std::make_unique<FixtureLogObserver>()); - Map map(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still); + Map map(backend, MapObserver::nullObserver(), view.getSize(), 1, fileSource, threadPool, MapMode::Still); std::string message; diff --git a/test/api/repeated_render.test.cpp b/test/api/repeated_render.test.cpp index dd9085efd7..033b741ab6 100644 --- a/test/api/repeated_render.test.cpp +++ b/test/api/repeated_render.test.cpp @@ -33,7 +33,7 @@ TEST(API, RepeatedRender) { Log::setObserver(std::make_unique<FixtureLogObserver>()); - Map map(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still); + Map map(backend, MapObserver::nullObserver(), view.getSize(), 1, fileSource, threadPool, MapMode::Still); { map.getStyle().loadJSON(style); @@ -86,7 +86,7 @@ TEST(API, ZoomHistory) { Log::setObserver(std::make_unique<FixtureLogObserver>()); - Map map(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still); + Map map(backend, MapObserver::nullObserver(), view.getSize(), 1, fileSource, threadPool, MapMode::Still); map.getStyle().loadJSON(style); auto geojson = mapbox::geojson::parse(R"t({ "type": "FeatureCollection", "features": [{ "type": "Feature", "properties": {}, "geometry": { "type": "LineString", "coordinates": [ [ -150, -75 ], [ 150, 75 ] ] } } ] })t"); diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index a820590fb4..206371613d 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -25,42 +25,46 @@ using namespace mbgl; using namespace mbgl::style; using namespace std::literals::string_literals; -class BackendTest : public HeadlessBackend { +class MockBackend : public HeadlessBackend { public: - BackendTest() : HeadlessBackend(test::sharedDisplay()) {} + MockBackend() + : HeadlessBackend(test::sharedDisplay() ) { + } - void invalidate() { - if (invalidateCallback) { - invalidateCallback(); + std::function<void()> callback; + void invalidate() override { + if (callback) { + callback(); } } +}; - std::function<void()> invalidateCallback; - +class StubMapObserver : public MapObserver { +public: void onWillStartLoadingMap() final { if (onWillStartLoadingMapCallback) { onWillStartLoadingMapCallback(); } } - + void onDidFinishLoadingMap() final { if (onDidFinishLoadingMapCallback) { onDidFinishLoadingMapCallback(); } } - + void onDidFailLoadingMap(std::exception_ptr) final { if (didFailLoadingMapCallback) { didFailLoadingMapCallback(); } } - + void onDidFinishLoadingStyle() final { if (didFinishLoadingStyleCallback) { didFinishLoadingStyleCallback(); } } - + std::function<void()> onWillStartLoadingMapCallback; std::function<void()> onDidFinishLoadingMapCallback; std::function<void()> didFailLoadingMapCallback; @@ -69,7 +73,8 @@ public: struct MapTest { util::RunLoop runLoop; - BackendTest backend; + MockBackend backend; + StubMapObserver observer; BackendScope scope { backend }; OffscreenView view { backend.getContext() }; StubFileSource fileSource; @@ -78,7 +83,7 @@ struct MapTest { TEST(Map, LatLngBehavior) { MapTest test; - Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); map.setLatLngZoom({ 1, 1 }, 0); auto latLng1 = map.getLatLng(); @@ -92,7 +97,7 @@ TEST(Map, LatLngBehavior) { TEST(Map, LatLngBoundsToCamera) { MapTest test; - Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); map.setLatLngZoom({ 40.712730, -74.005953 }, 16.0); @@ -104,7 +109,7 @@ TEST(Map, LatLngBoundsToCamera) { TEST(Map, CameraToLatLngBounds) { MapTest test; - Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); map.setLatLngZoom({ 45, 90 }, 16); @@ -143,7 +148,7 @@ TEST(Map, Offline) { fileSource.put(Resource::glyphs(prefix + "{fontstack}/{range}.pbf", {{"Helvetica"}}, {0, 255}), expiredItem("glyph.pbf")); NetworkStatus::Set(NetworkStatus::Status::Offline); - Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); map.getStyle().loadURL(prefix + "style.json"); test::checkImage("test/fixtures/map/offline", @@ -160,12 +165,12 @@ TEST(Map, SetStyleInvalidJSON) { Log::setObserver(std::make_unique<FixtureLogObserver>()); bool fail = false; - test.backend.didFailLoadingMapCallback = [&]() { + test.observer.didFailLoadingMapCallback = [&]() { fail = true; }; { - Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, + Map map(test.backend, test.observer, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); map.getStyle().loadJSON("invalid"); } @@ -191,11 +196,11 @@ TEST(Map, SetStyleInvalidURL) { return response; }; - test.backend.didFailLoadingMapCallback = [&]() { + test.observer.didFailLoadingMapCallback = [&]() { test.runLoop.stop(); }; - Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); map.getStyle().loadURL("mapbox://bar"); test.runLoop.run(); @@ -204,7 +209,7 @@ TEST(Map, SetStyleInvalidURL) { TEST(Map, DoubleStyleLoad) { MapTest test; - Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); map.getStyle().loadJSON(""); map.getStyle().loadJSON(""); } @@ -215,7 +220,7 @@ TEST(Map, StyleFresh) { MapTest test; FakeFileSource fileSource; - Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); map.getStyle().loadURL("mapbox://styles/test"); EXPECT_EQ(1u, fileSource.requests.size()); @@ -235,7 +240,7 @@ TEST(Map, StyleExpired) { MapTest test; FakeFileSource fileSource; - Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); map.getStyle().loadURL("mapbox://styles/test"); EXPECT_EQ(1u, fileSource.requests.size()); @@ -262,7 +267,7 @@ TEST(Map, StyleExpiredWithAnnotations) { MapTest test; FakeFileSource fileSource; - Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); map.getStyle().loadURL("mapbox://styles/test"); EXPECT_EQ(1u, fileSource.requests.size()); @@ -288,7 +293,7 @@ TEST(Map, StyleExpiredWithRender) { MapTest test; FakeFileSource fileSource; - Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); map.getStyle().loadURL("mapbox://styles/test"); EXPECT_EQ(1u, fileSource.requests.size()); @@ -312,7 +317,7 @@ TEST(Map, StyleEarlyMutation) { MapTest test; FakeFileSource fileSource; - Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); map.getStyle().loadURL("mapbox://styles/test"); map.getStyle().addLayer(std::make_unique<style::BackgroundLayer>("bg")); @@ -326,10 +331,10 @@ TEST(Map, StyleEarlyMutation) { TEST(Map, MapLoadingSignal) { MapTest test; - Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); bool emitted = false; - test.backend.onWillStartLoadingMapCallback = [&]() { + test.observer.onWillStartLoadingMapCallback = [&]() { emitted = true; }; map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); @@ -338,13 +343,13 @@ TEST(Map, MapLoadingSignal) { TEST(Map, MapLoadedSignal) { MapTest test; - Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Continuous); + Map map(test.backend, test.observer, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Continuous); - test.backend.onDidFinishLoadingMapCallback = [&]() { + test.observer.onDidFinishLoadingMapCallback = [&]() { test.runLoop.stop(); }; - test.backend.invalidateCallback = [&]() { + test.backend.callback = [&]() { map.render(test.view); }; @@ -354,11 +359,11 @@ TEST(Map, MapLoadedSignal) { TEST(Map, StyleLoadedSignal) { MapTest test; - Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); // The map should emit a signal on style loaded bool emitted = false; - test.backend.didFinishLoadingStyleCallback = [&]() { + test.observer.didFinishLoadingStyleCallback = [&]() { emitted = true; }; map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); @@ -375,10 +380,10 @@ TEST(Map, TEST_REQUIRES_SERVER(StyleNetworkErrorRetry)) { MapTest test; OnlineFileSource fileSource; - Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); map.getStyle().loadURL("http://127.0.0.1:3000/style-fail-once-500"); - test.backend.didFinishLoadingStyleCallback = [&]() { + test.observer.didFinishLoadingStyleCallback = [&]() { test.runLoop.stop(); }; @@ -389,18 +394,18 @@ TEST(Map, TEST_REQUIRES_SERVER(StyleNotFound)) { MapTest test; OnlineFileSource fileSource; - Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); map.getStyle().loadURL("http://127.0.0.1:3000/style-fail-once-404"); using namespace std::chrono_literals; util::Timer timer; // Not found errors should not trigger a retry like other errors. - test.backend.didFinishLoadingStyleCallback = [&]() { + test.observer.didFinishLoadingStyleCallback = [&]() { FAIL() << "Should not retry on not found!"; }; - test.backend.didFailLoadingMapCallback = [&]() { + test.observer.didFailLoadingMapCallback = [&]() { timer.start(Milliseconds(1100), 0s, [&] { test.runLoop.stop(); }); @@ -416,7 +421,7 @@ TEST(Map, TEST_REQUIRES_SERVER(StyleNotFound)) { TEST(Map, AddLayer) { MapTest test; - Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); auto layer = std::make_unique<BackgroundLayer>("background"); @@ -433,7 +438,7 @@ TEST(Map, WithoutVAOExtension) { DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets"); - Map map(test.backend, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, fileSource, test.threadPool, MapMode::Still); map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); test::checkImage("test/fixtures/map/no_vao", test::render(map, test.view), 0.002); @@ -442,7 +447,7 @@ TEST(Map, WithoutVAOExtension) { TEST(Map, RemoveLayer) { MapTest test; - Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json")); auto layer = std::make_unique<BackgroundLayer>("background"); @@ -467,7 +472,7 @@ TEST(Map, DisabledSources) { return {}; }; - Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); map.setZoom(1); // This stylesheet has two raster layers, one that starts at zoom 1, the other at zoom 0. @@ -517,7 +522,7 @@ TEST(Map, DisabledSources) { TEST(Map, DontLoadUnneededTiles) { MapTest test; - Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, test.observer, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); map.getStyle().loadJSON(R"STYLE({ "sources": { "a": { "type": "vector", "tiles": [ "a/{z}/{x}/{y}" ] } @@ -562,29 +567,14 @@ TEST(Map, DontLoadUnneededTiles) { } } - -class MockBackend : public HeadlessBackend { -public: - MockBackend(std::shared_ptr<HeadlessDisplay> display_) - : HeadlessBackend(display_) { - } - - std::function<void()> callback; - void invalidate() override { - if (callback) { - callback(); - } - } -}; - TEST(Map, TEST_DISABLED_ON_CI(ContinuousRendering)) { util::RunLoop runLoop; - MockBackend backend { test::sharedDisplay() }; + MockBackend backend; BackendScope scope { backend }; OffscreenView view { backend.getContext() }; ThreadPool threadPool { 4 }; DefaultFileSource fileSource(":memory:", "test/fixtures/api/assets"); - Map map(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Continuous); + Map map(backend, MapObserver::nullObserver(), view.getSize(), 1, fileSource, threadPool, MapMode::Continuous); using namespace std::chrono_literals; diff --git a/test/map/prefetch.test.cpp b/test/map/prefetch.test.cpp index af2cd4e92f..47b39f7b88 100644 --- a/test/map/prefetch.test.cpp +++ b/test/map/prefetch.test.cpp @@ -27,7 +27,7 @@ TEST(Map, PrefetchTiles) { OffscreenView view(backend.getContext(), { 512, 512 }); ThreadPool threadPool(4); StubFileSource fileSource; - Map map(backend, view.getSize(), 1, fileSource, threadPool, MapMode::Still); + Map map(backend, MapObserver::nullObserver(), view.getSize(), 1, fileSource, threadPool, MapMode::Still); std::vector<int> tiles; diff --git a/test/util/memory.test.cpp b/test/util/memory.test.cpp index bca538c6c6..8fd27f2462 100644 --- a/test/util/memory.test.cpp +++ b/test/util/memory.test.cpp @@ -74,7 +74,7 @@ private: TEST(Memory, Vector) { MemoryTest test; - Map map(test.backend, { 256, 256 }, 2, test.fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, MapObserver::nullObserver(), { 256, 256 }, 2, test.fileSource, test.threadPool, MapMode::Still); map.setZoom(16); // more map features map.getStyle().loadURL("mapbox://streets"); @@ -84,7 +84,7 @@ TEST(Memory, Vector) { TEST(Memory, Raster) { MemoryTest test; - Map map(test.backend, { 256, 256 }, 2, test.fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, MapObserver::nullObserver(), { 256, 256 }, 2, test.fileSource, test.threadPool, MapMode::Still); map.getStyle().loadURL("mapbox://satellite"); test::render(map, test.view); @@ -125,7 +125,7 @@ TEST(Memory, Footprint) { // Warm up buffers and cache. for (unsigned i = 0; i < 10; ++i) { - Map map(test.backend, { 256, 256 }, 2, test.fileSource, test.threadPool, MapMode::Still); + Map map(test.backend, MapObserver::nullObserver(), { 256, 256 }, 2, test.fileSource, test.threadPool, MapMode::Still); renderMap(map, "mapbox://streets"); renderMap(map, "mapbox://satellite"); }; @@ -139,8 +139,9 @@ TEST(Memory, Footprint) { long vectorInitialRSS = mbgl::test::getCurrentRSS(); for (unsigned i = 0; i < runs; ++i) { - auto vector = std::make_unique<Map>(test.backend, Size{ 256, 256 }, 2, test.fileSource, - test.threadPool, MapMode::Still); + auto vector = std::make_unique<Map>(test.backend, MapObserver::nullObserver(), + Size{ 256, 256 }, 2, test.fileSource, test.threadPool, + MapMode::Still); renderMap(*vector, "mapbox://streets"); maps.push_back(std::move(vector)); }; @@ -149,8 +150,9 @@ TEST(Memory, Footprint) { long rasterInitialRSS = mbgl::test::getCurrentRSS(); for (unsigned i = 0; i < runs; ++i) { - auto raster = std::make_unique<Map>(test.backend, Size{ 256, 256 }, 2, test.fileSource, - test.threadPool, MapMode::Still); + auto raster = std::make_unique<Map>(test.backend, MapObserver::nullObserver(), + Size{ 256, 256 }, 2, test.fileSource, test.threadPool, + MapMode::Still); renderMap(*raster, "mapbox://satellite"); maps.push_back(std::move(raster)); }; |