diff options
author | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2019-03-19 15:55:06 +0200 |
---|---|---|
committer | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2019-03-20 18:47:15 +0200 |
commit | 3122df7e5075bb05c99d7033fceb9e561e795874 (patch) | |
tree | 5ab1ef8a85225b63f09922dd3b014d4eadbe7841 /src | |
parent | f86cc81680dd64f135f4f7b813c6cbb1e7e822d8 (diff) | |
download | qtlocation-mapboxgl-3122df7e5075bb05c99d7033fceb9e561e795874.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.
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/gl/context.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/gl/context.hpp | 5 | ||||
-rw-r--r-- | src/mbgl/renderer/renderer.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/renderer/renderer_impl.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/renderer/renderer_impl.hpp | 2 |
5 files changed, 21 insertions, 0 deletions
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index bc703db401..5ce035f691 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -787,5 +787,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 338a294b47..d9f27eacc0 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 aa47d56b47..311008507b 100644 --- a/src/mbgl/renderer/renderer_impl.cpp +++ b/src/mbgl/renderer/renderer_impl.cpp @@ -605,6 +605,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; |