[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.
This commit is contained in:
Thiago Marcos P. Santos
2019-03-19 15:55:06 +02:00
parent f86cc81680
commit 3122df7e50
6 changed files with 23 additions and 0 deletions

View File

@@ -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;

View File

@@ -787,5 +787,9 @@ void Context::performCleanup() {
}
}
void Context::flush() {
MBGL_CHECK_ERROR(glFinish());
}
} // namespace gl
} // namespace mbgl

View File

@@ -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()

View File

@@ -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);
}

View File

@@ -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) {

View File

@@ -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;