[core] renderer interface
This commit is contained in:
committed by
Ivo van Dongen
parent
39a732d7ae
commit
3832f8d0d8
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user