summaryrefslogtreecommitdiff
path: root/platform/default
diff options
context:
space:
mode:
authorMikko Pulkki <mikko.pulkki@mapbox.com>2019-10-15 12:03:04 +0300
committerMikko Pulkki <55925868+mpulkki-mapbox@users.noreply.github.com>2019-10-30 14:32:27 +0200
commita7a7e8cbe29e672d020db1d150e887f33d584a2d (patch)
tree1c686fb6b2a91e0ef70d62b129545c1077e15a7f /platform/default
parentfb062bb23e66af3d5a889b767aae380884b259e5 (diff)
downloadqtlocation-mapboxgl-a7a7e8cbe29e672d020db1d150e887f33d584a2d.tar.gz
[render-test] Implement gfx probe for tracking gpu resources
Diffstat (limited to 'platform/default')
-rw-r--r--platform/default/include/mbgl/gfx/headless_frontend.hpp8
-rw-r--r--platform/default/src/mbgl/gfx/headless_frontend.cpp11
2 files changed, 13 insertions, 6 deletions
diff --git a/platform/default/include/mbgl/gfx/headless_frontend.hpp b/platform/default/include/mbgl/gfx/headless_frontend.hpp
index 353452123d..8a98b4112d 100644
--- a/platform/default/include/mbgl/gfx/headless_frontend.hpp
+++ b/platform/default/include/mbgl/gfx/headless_frontend.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <mbgl/gfx/headless_backend.hpp>
+#include <mbgl/gfx/rendering_stats.hpp>
#include <mbgl/map/camera.hpp>
#include <mbgl/renderer/renderer_frontend.hpp>
#include <mbgl/util/async_task.hpp>
@@ -17,6 +18,11 @@ class TransformState;
class HeadlessFrontend : public RendererFrontend {
public:
+ struct RenderResult {
+ PremultipliedImage image;
+ gfx::RenderingStats stats;
+ };
+
HeadlessFrontend(float pixelRatio_,
gfx::HeadlessBackend::SwapBehaviour swapBehviour = gfx::HeadlessBackend::SwapBehaviour::NoFlush,
gfx::ContextMode mode = gfx::ContextMode::Unique,
@@ -48,7 +54,7 @@ public:
LatLng latLngForPixel(const ScreenCoordinate&);
PremultipliedImage readStillImage();
- PremultipliedImage render(Map&);
+ RenderResult render(Map&);
void renderOnce(Map&);
optional<TransformState> getTransformState() const;
diff --git a/platform/default/src/mbgl/gfx/headless_frontend.cpp b/platform/default/src/mbgl/gfx/headless_frontend.cpp
index 9e819f6653..5235b2f408 100644
--- a/platform/default/src/mbgl/gfx/headless_frontend.cpp
+++ b/platform/default/src/mbgl/gfx/headless_frontend.cpp
@@ -1,6 +1,6 @@
#include <mbgl/gfx/backend_scope.hpp>
-#include <mbgl/gfx/headless_frontend.hpp>
#include <mbgl/gfx/context.hpp>
+#include <mbgl/gfx/headless_frontend.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/transform_state.hpp>
#include <mbgl/renderer/renderer.hpp>
@@ -140,19 +140,20 @@ PremultipliedImage HeadlessFrontend::readStillImage() {
return backend->readStillImage();
}
-PremultipliedImage HeadlessFrontend::render(Map& map) {
- PremultipliedImage result;
+HeadlessFrontend::RenderResult HeadlessFrontend::render(Map& map) {
+ HeadlessFrontend::RenderResult result;
std::exception_ptr error;
map.renderStill([&](std::exception_ptr e) {
if (e) {
error = e;
} else {
- result = backend->readStillImage();
+ result.image = backend->readStillImage();
+ result.stats = getBackend()->getContext().renderingStats();
}
});
- while (!result.valid() && !error) {
+ while (!result.image.valid() && !error) {
util::RunLoop::Get()->runOnce();
}