summaryrefslogtreecommitdiff
path: root/test/util
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-06-13 10:50:16 +0300
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2017-07-18 10:45:12 +0200
commit3832f8d0d8194b81ea34a045e19b0d5bc7a89e25 (patch)
treebbb4b277e1e74bde457271b9b9a5b6a9ec3ad5fb /test/util
parent39a732d7ae3cb1b927d94c4b1154b42d9565356a (diff)
downloadqtlocation-mapboxgl-3832f8d0d8194b81ea34a045e19b0d5bc7a89e25.tar.gz
[core] renderer interface
Diffstat (limited to 'test/util')
-rw-r--r--test/util/memory.test.cpp48
1 files changed, 35 insertions, 13 deletions
diff --git a/test/util/memory.test.cpp b/test/util/memory.test.cpp
index 8fd27f2462..fb93699d7f 100644
--- a/test/util/memory.test.cpp
+++ b/test/util/memory.test.cpp
@@ -10,6 +10,8 @@
#include <mbgl/util/io.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/style/style.hpp>
+#include <mbgl/renderer/renderer.hpp>
+#include <mbgl/test/stub_renderer_frontend.hpp>
#include <algorithm>
#include <iostream>
@@ -38,7 +40,7 @@ public:
util::RunLoop runLoop;
HeadlessBackend backend { test::sharedDisplay() };
BackendScope scope { backend };
- OffscreenView view{ backend.getContext(), { 512, 512 } };
+ OffscreenView view { backend.getContext(), { 512, 512 } };
StubFileSource fileSource;
ThreadPool threadPool { 4 };
@@ -73,8 +75,13 @@ private:
TEST(Memory, Vector) {
MemoryTest test;
+ float ratio { 2 };
- Map map(test.backend, MapObserver::nullObserver(), { 256, 256 }, 2, test.fileSource, test.threadPool, MapMode::Still);
+ StubRendererFrontend rendererFrontend {
+ std::make_unique<Renderer>(test.backend, ratio, test.fileSource, test.threadPool),
+ test.view };
+ Map map(rendererFrontend, MapObserver::nullObserver(), { 256, 256 }, ratio, test.fileSource,
+ test.threadPool, MapMode::Still);
map.setZoom(16); // more map features
map.getStyle().loadURL("mapbox://streets");
@@ -83,8 +90,14 @@ TEST(Memory, Vector) {
TEST(Memory, Raster) {
MemoryTest test;
+ float ratio { 2 };
- Map map(test.backend, MapObserver::nullObserver(), { 256, 256 }, 2, test.fileSource, test.threadPool, MapMode::Still);
+ StubRendererFrontend rendererFrontend {
+ std::make_unique<Renderer>(test.backend, ratio, test.fileSource, test.threadPool),
+ test.view };
+
+ Map map(rendererFrontend, MapObserver::nullObserver(), { 256, 256 }, ratio, test.fileSource,
+ test.threadPool, MapMode::Still);
map.getStyle().loadURL("mapbox://satellite");
test::render(map, test.view);
@@ -116,6 +129,7 @@ TEST(Memory, Footprint) {
}
MemoryTest test;
+ float ratio { 2 };
auto renderMap = [&](Map& map, const char* style){
map.setZoom(16);
@@ -125,7 +139,11 @@ TEST(Memory, Footprint) {
// Warm up buffers and cache.
for (unsigned i = 0; i < 10; ++i) {
- Map map(test.backend, MapObserver::nullObserver(), { 256, 256 }, 2, test.fileSource, test.threadPool, MapMode::Still);
+ StubRendererFrontend rendererFrontend {
+ std::make_unique<Renderer>(test.backend, ratio, test.fileSource, test.threadPool),
+ test.view };
+ Map map(rendererFrontend, MapObserver::nullObserver(), { 256, 256 }, ratio, test.fileSource,
+ test.threadPool, MapMode::Still);
renderMap(map, "mapbox://streets");
renderMap(map, "mapbox://satellite");
};
@@ -134,27 +152,31 @@ TEST(Memory, Footprint) {
// libuv runloop.
test.runLoop.runOnce();
- std::vector<std::unique_ptr<Map>> maps;
+ std::vector<std::pair<std::unique_ptr<Map>, std::unique_ptr<RendererFrontend>>> maps;
unsigned runs = 15;
long vectorInitialRSS = mbgl::test::getCurrentRSS();
for (unsigned i = 0; i < runs; ++i) {
- auto vector = std::make_unique<Map>(test.backend, MapObserver::nullObserver(),
- Size{ 256, 256 }, 2, test.fileSource, test.threadPool,
- MapMode::Still);
+ auto frontend = std::make_unique<StubRendererFrontend>(
+ std::make_unique<Renderer>(test.backend, ratio, test.fileSource, test.threadPool), test.view);
+ auto vector = std::make_unique<Map>(*frontend, MapObserver::nullObserver(),
+ Size{ 256, 256 }, ratio, test.fileSource,
+ test.threadPool, MapMode::Still);
renderMap(*vector, "mapbox://streets");
- maps.push_back(std::move(vector));
+ maps.push_back({std::move(vector), std::move(frontend)});
};
double vectorFootprint = (mbgl::test::getCurrentRSS() - vectorInitialRSS) / double(runs);
long rasterInitialRSS = mbgl::test::getCurrentRSS();
for (unsigned i = 0; i < runs; ++i) {
- auto raster = std::make_unique<Map>(test.backend, MapObserver::nullObserver(),
- Size{ 256, 256 }, 2, test.fileSource, test.threadPool,
- MapMode::Still);
+ auto frontend = std::make_unique<StubRendererFrontend>(
+ std::make_unique<Renderer>(test.backend, ratio, test.fileSource, test.threadPool), test.view);
+ auto raster = std::make_unique<Map>(*frontend, MapObserver::nullObserver(),
+ Size{ 256, 256 }, ratio, test.fileSource,
+ test.threadPool, MapMode::Still);
renderMap(*raster, "mapbox://satellite");
- maps.push_back(std::move(raster));
+ maps.push_back({std::move(raster), std::move(frontend)});
};
double rasterFootprint = (mbgl::test::getCurrentRSS() - rasterInitialRSS) / double(runs);