diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-07-21 16:36:31 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-07-26 09:50:38 -0700 |
commit | 32bd1d54fa777035920b58e653905e4592ef187c (patch) | |
tree | 3f6fa84d6c9369bdd312ba630538a0c7504fce3a /benchmark | |
parent | 11933f6ab81248a884db3b1f69be714a60b6a86c (diff) | |
download | qtlocation-mapboxgl-32bd1d54fa777035920b58e653905e4592ef187c.tar.gz |
[node, tests] Consolidate headless rendering logic in HeadlessFrontend
Diffstat (limited to 'benchmark')
-rw-r--r-- | benchmark/api/query.benchmark.cpp | 21 | ||||
-rw-r--r-- | benchmark/api/render.benchmark.cpp | 29 | ||||
-rw-r--r-- | benchmark/src/mbgl/benchmark/util.cpp | 24 | ||||
-rw-r--r-- | benchmark/src/mbgl/benchmark/util.hpp | 13 |
4 files changed, 18 insertions, 69 deletions
diff --git a/benchmark/api/query.benchmark.cpp b/benchmark/api/query.benchmark.cpp index 8b96d02163..75695c1ad7 100644 --- a/benchmark/api/query.benchmark.cpp +++ b/benchmark/api/query.benchmark.cpp @@ -1,13 +1,9 @@ #include <benchmark/benchmark.h> -#include <mbgl/benchmark/util.hpp> #include <mbgl/map/map.hpp> -#include <mbgl/gl/headless_backend.hpp> -#include <mbgl/gl/offscreen_view.hpp> +#include <mbgl/gl/headless_frontend.hpp> #include <mbgl/util/default_thread_pool.hpp> #include <mbgl/renderer/renderer.hpp> -#include <mbgl/renderer/backend_scope.hpp> -#include <mbgl/renderer/async_renderer_frontend.hpp> #include <mbgl/style/style.hpp> #include <mbgl/style/image.hpp> #include <mbgl/storage/default_file_source.hpp> @@ -31,17 +27,14 @@ public: map.getStyle().addImage(std::make_unique<style::Image>("test-icon", decodeImage(util::read_file("benchmark/fixtures/api/default_marker.png")), 1.0)); - mbgl::benchmark::render(map, view); + frontend.render(map); } util::RunLoop loop; - HeadlessBackend backend; - BackendScope scope { backend }; - OffscreenView view{ backend.getContext(), { 1000, 1000 } }; DefaultFileSource fileSource{ "benchmark/fixtures/api/cache.db", "." }; ThreadPool threadPool{ 4 }; - AsyncRendererFrontend rendererFrontend { std::make_unique<Renderer>(backend, 1, fileSource, threadPool), backend, view }; - Map map { rendererFrontend, MapObserver::nullObserver(), view.getSize(), 1, fileSource, threadPool, MapMode::Still }; + HeadlessFrontend frontend { { 1000, 1000 }, 1, fileSource, threadPool }; + Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1, fileSource, threadPool, MapMode::Still }; ScreenBox box{{ 0, 0 }, { 1000, 1000 }}; }; @@ -51,7 +44,7 @@ static void API_queryRenderedFeaturesAll(::benchmark::State& state) { QueryBenchmark bench; while (state.KeepRunning()) { - bench.rendererFrontend.getRenderer()->queryRenderedFeatures(bench.box, {}); + bench.frontend.getRenderer()->queryRenderedFeatures(bench.box, {}); } } @@ -59,7 +52,7 @@ static void API_queryRenderedFeaturesLayerFromLowDensity(::benchmark::State& sta QueryBenchmark bench; while (state.KeepRunning()) { - bench.rendererFrontend.getRenderer()->queryRenderedFeatures(bench.box, {{{ "testlayer" }}, {}}); + bench.frontend.getRenderer()->queryRenderedFeatures(bench.box, {{{ "testlayer" }}, {}}); } } @@ -67,7 +60,7 @@ static void API_queryRenderedFeaturesLayerFromHighDensity(::benchmark::State& st QueryBenchmark bench; while (state.KeepRunning()) { - bench.rendererFrontend.getRenderer()->queryRenderedFeatures(bench.box, {{{"road-street" }}, {}}); + bench.frontend.getRenderer()->queryRenderedFeatures(bench.box, {{{"road-street" }}, {}}); } } diff --git a/benchmark/api/render.benchmark.cpp b/benchmark/api/render.benchmark.cpp index 90667d4ed4..9f1ea68e0b 100644 --- a/benchmark/api/render.benchmark.cpp +++ b/benchmark/api/render.benchmark.cpp @@ -1,14 +1,10 @@ #include <benchmark/benchmark.h> -#include <mbgl/benchmark/util.hpp> #include <mbgl/map/map.hpp> #include <mbgl/map/map_observer.hpp> -#include <mbgl/gl/headless_backend.hpp> -#include <mbgl/gl/offscreen_view.hpp> +#include <mbgl/gl/headless_frontend.hpp> #include <mbgl/util/default_thread_pool.hpp> #include <mbgl/renderer/renderer.hpp> -#include <mbgl/renderer/backend_scope.hpp> -#include <mbgl/renderer/async_renderer_frontend.hpp> #include <mbgl/style/style.hpp> #include <mbgl/style/image.hpp> #include <mbgl/storage/default_file_source.hpp> @@ -29,9 +25,6 @@ public: } util::RunLoop loop; - HeadlessBackend backend; - BackendScope scope { backend }; - OffscreenView view { backend.getContext(), { 1000, 1000 } }; DefaultFileSource fileSource { "benchmark/fixtures/api/cache.db", "." }; ThreadPool threadPool { 4 }; }; @@ -47,25 +40,25 @@ static void prepare(Map& map, optional<std::string> json = {}) { static void API_renderStill_reuse_map(::benchmark::State& state) { RenderBenchmark bench; - AsyncRendererFrontend frontend { std::make_unique<Renderer>(bench.backend, 1, bench.fileSource, bench.threadPool), bench.backend, bench.view }; - Map map { frontend, MapObserver::nullObserver(), bench.view.getSize(), 1, bench.fileSource, bench.threadPool, MapMode::Still }; + HeadlessFrontend frontend { { 1000, 1000 }, 1, bench.fileSource, bench.threadPool }; + Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1, bench.fileSource, bench.threadPool, MapMode::Still }; prepare(map); while (state.KeepRunning()) { - mbgl::benchmark::render(map, bench.view); + frontend.render(map); } } static void API_renderStill_reuse_map_switch_styles(::benchmark::State& state) { RenderBenchmark bench; - AsyncRendererFrontend frontend { std::make_unique<Renderer>(bench.backend, 1, bench.fileSource, bench.threadPool), bench.backend, bench.view }; - Map map { frontend, MapObserver::nullObserver(), bench.view.getSize(), 1, bench.fileSource, bench.threadPool, MapMode::Still }; + HeadlessFrontend frontend { { 1000, 1000 }, 1, bench.fileSource, bench.threadPool }; + Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1, bench.fileSource, bench.threadPool, MapMode::Still }; while (state.KeepRunning()) { prepare(map, { "{}" }); - mbgl::benchmark::render(map, bench.view); + frontend.render(map); prepare(map); - mbgl::benchmark::render(map, bench.view); + frontend.render(map); } } @@ -73,10 +66,10 @@ static void API_renderStill_recreate_map(::benchmark::State& state) { RenderBenchmark bench; while (state.KeepRunning()) { - AsyncRendererFrontend frontend { std::make_unique<Renderer>(bench.backend, 1, bench.fileSource, bench.threadPool), bench.backend, bench.view }; - Map map { frontend, MapObserver::nullObserver(), bench.view.getSize(), 1, bench.fileSource, bench.threadPool, MapMode::Still }; + HeadlessFrontend frontend { { 1000, 1000 }, 1, bench.fileSource, bench.threadPool }; + Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1, bench.fileSource, bench.threadPool, MapMode::Still }; prepare(map); - mbgl::benchmark::render(map, bench.view); + frontend.render(map); } } diff --git a/benchmark/src/mbgl/benchmark/util.cpp b/benchmark/src/mbgl/benchmark/util.cpp deleted file mode 100644 index a56279886f..0000000000 --- a/benchmark/src/mbgl/benchmark/util.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include <mbgl/benchmark/util.hpp> -#include <mbgl/gl/offscreen_view.hpp> - -#include <mbgl/map/map.hpp> -#include <mbgl/map/view.hpp> -#include <mbgl/util/image.hpp> -#include <mbgl/util/run_loop.hpp> - -namespace mbgl { -namespace benchmark { - -void render(Map& map, OffscreenView& view) { - PremultipliedImage result; - map.renderStill([&](std::exception_ptr) { - result = view.readStillImage(); - }); - - while (!result.valid()) { - util::RunLoop::Get()->runOnce(); - } -} - -} // namespace benchmark -} // namespace mbgl diff --git a/benchmark/src/mbgl/benchmark/util.hpp b/benchmark/src/mbgl/benchmark/util.hpp deleted file mode 100644 index 73acfb69d5..0000000000 --- a/benchmark/src/mbgl/benchmark/util.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -namespace mbgl { - -class Map; -class OffscreenView; - -namespace benchmark { - -void render(Map&, OffscreenView&); - -} // namespace benchmark -} // namespace mbgl |