summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2019-03-19 15:55:06 +0200
committerJulian Rex <julian.rex@mapbox.com>2019-03-28 16:51:18 -0400
commit4d21a663b87d7d84daf4440e875d213c0e76b15e (patch)
treef1aac605c48dbd697099696b2cee4812d7fda7d6
parent8d2d145ac92d92d419024be3681354e63d513428 (diff)
downloadqtlocation-mapboxgl-4d21a663b87d7d84daf4440e875d213c0e76b15e.tar.gz
[core] Expose a way of flushing the graphics pipeline
Useful for apps before going to background that are restricted by the OS of performing any operation.
-rw-r--r--include/mbgl/renderer/renderer.hpp2
-rw-r--r--src/mbgl/gl/context.cpp4
-rw-r--r--src/mbgl/gl/context.hpp5
-rw-r--r--src/mbgl/renderer/renderer.cpp4
-rw-r--r--src/mbgl/renderer/renderer_impl.cpp6
-rw-r--r--src/mbgl/renderer/renderer_impl.hpp2
6 files changed, 23 insertions, 0 deletions
diff --git a/include/mbgl/renderer/renderer.hpp b/include/mbgl/renderer/renderer.hpp
index 1d92f9c0cb..0bed4cdaa8 100644
--- a/include/mbgl/renderer/renderer.hpp
+++ b/include/mbgl/renderer/renderer.hpp
@@ -34,6 +34,8 @@ public:
void render(const UpdateParameters&);
+ void flush();
+
// Feature queries
std::vector<Feature> queryRenderedFeatures(const ScreenLineString&, const RenderedQueryOptions& options = {}) const;
std::vector<Feature> queryRenderedFeatures(const ScreenCoordinate& point, const RenderedQueryOptions& options = {}) const;
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp
index 5193381251..c5b9422351 100644
--- a/src/mbgl/gl/context.cpp
+++ b/src/mbgl/gl/context.cpp
@@ -775,5 +775,9 @@ void Context::performCleanup() {
}
}
+void Context::flush() {
+ MBGL_CHECK_ERROR(glFinish());
+}
+
} // namespace gl
} // namespace mbgl
diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp
index fe09390cc6..d40f6e0bca 100644
--- a/src/mbgl/gl/context.hpp
+++ b/src/mbgl/gl/context.hpp
@@ -116,6 +116,11 @@ public:
// Only call this while the OpenGL context is exclusive to this thread.
void reset();
+ // Flush pending graphics commands. Will block until the pipeline
+ // is empty. Should be used only with a very good reason because
+ // it will have a performance impact.
+ void flush();
+
bool empty() const {
return pooledTextures.empty()
&& abandonedPrograms.empty()
diff --git a/src/mbgl/renderer/renderer.cpp b/src/mbgl/renderer/renderer.cpp
index fbd9049207..4da7b78374 100644
--- a/src/mbgl/renderer/renderer.cpp
+++ b/src/mbgl/renderer/renderer.cpp
@@ -34,6 +34,10 @@ void Renderer::render(const UpdateParameters& updateParameters) {
impl->render(updateParameters);
}
+void Renderer::flush() {
+ impl->flush();
+}
+
std::vector<Feature> Renderer::queryRenderedFeatures(const ScreenLineString& geometry, const RenderedQueryOptions& options) const {
return impl->queryRenderedFeatures(geometry, options);
}
diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp
index 471536cf40..987e241c4a 100644
--- a/src/mbgl/renderer/renderer_impl.cpp
+++ b/src/mbgl/renderer/renderer_impl.cpp
@@ -614,6 +614,12 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
parameters.context.performCleanup();
}
+void Renderer::Impl::flush() {
+ assert(BackendScope::exists());
+
+ backend.getContext().flush();
+}
+
std::vector<Feature> Renderer::Impl::queryRenderedFeatures(const ScreenLineString& geometry, const RenderedQueryOptions& options) const {
std::vector<const RenderLayer*> layers;
if (options.layerIDs) {
diff --git a/src/mbgl/renderer/renderer_impl.hpp b/src/mbgl/renderer/renderer_impl.hpp
index 05bf2e9b2b..a036bfc7ff 100644
--- a/src/mbgl/renderer/renderer_impl.hpp
+++ b/src/mbgl/renderer/renderer_impl.hpp
@@ -48,6 +48,8 @@ public:
void render(const UpdateParameters&);
+ void flush();
+
std::vector<Feature> queryRenderedFeatures(const ScreenLineString&, const RenderedQueryOptions&) const;
std::vector<Feature> querySourceFeatures(const std::string& sourceID, const SourceQueryOptions&) const;
std::vector<Feature> queryShapeAnnotations(const ScreenLineString&) const;