diff options
author | Marcus Fritzsch <marcus_fritzsch@mentor.com> | 2017-09-12 11:29:36 +0200 |
---|---|---|
committer | Marcus Fritzsch <marcus_fritzsch@mentor.com> | 2017-09-12 11:29:36 +0200 |
commit | 6a10feaafbe80f7c3738535dfd7ca97f00e1f405 (patch) | |
tree | 8a2c89de904d4b14de80ec96bf05753db73a8c66 /src | |
parent | 9a5202f6d3642ea08e1b72340dd4eebad835e082 (diff) |
App: add enqueue_flushdraw() and check_flushdraw()
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/app.cpp | 39 | ||||
-rw-r--r-- | src/app.hpp | 2 |
2 files changed, 28 insertions, 13 deletions
diff --git a/src/app.cpp b/src/app.cpp index 9292585..e58c85d 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -445,8 +445,7 @@ char const *App::api_activate_surface(char const *drawing_name) { state.sub = -1; state.s = LayoutState::Single; - //////this->emit_flushdraw(drawing_name); - this->pending_end_draw.push_back(state.main); + this->enqueue_flushdraw(state.main); } else { bool can_split = this->can_split(state, *surface_id); @@ -461,11 +460,8 @@ char const *App::api_activate_surface(char const *drawing_name) { this->activate(*surface_id); state.sub = *surface_id; - this->pending_end_draw.push_back(state.main); - this->pending_end_draw.push_back(state.sub); - // Should wait for EndDraw event... - //////this->emit_flushdraw(drawing_name); - //////this->emit_flushdraw(main.c_str()); + this->enqueue_flushdraw(state.main); + this->enqueue_flushdraw(state.sub); } } else { this->emit_syncdraw(drawing_name); @@ -478,8 +474,7 @@ char const *App::api_activate_surface(char const *drawing_name) { state.sub = -1; state.s = LayoutState::Single; - //////this->emit_flushdraw(drawing_name); - this->pending_end_draw.push_back(state.main); + this->enqueue_flushdraw(state.main); } } } @@ -532,8 +527,7 @@ char const *App::api_deactivate_surface(char const *drawing_name) { state.sub = -1; state.s = LayoutState::Single; - //////this->emit_flushdraw(sub.c_str()); - this->pending_end_draw.push_back(state.sub); + this->enqueue_flushdraw(state.sub); } else { this->deactivate(*surface_id); state.main = -1; @@ -548,8 +542,7 @@ char const *App::api_deactivate_surface(char const *drawing_name) { state.sub = -1; state.s = LayoutState::Single; - //////this->emit_flushdraw(main.c_str()); - this->pending_end_draw.push_back(state.main); + this->enqueue_flushdraw(state.main); } else { return "Surface is not active"; } @@ -560,6 +553,26 @@ char const *App::api_deactivate_surface(char const *drawing_name) { return nullptr; } +void App::enqueue_flushdraw(int surface_id) { + this->check_flushdraw(surface_id); + logdebug("Enqueuing EndDraw for surface_id %d", surface_id); + this->pending_end_draw.push_back(surface_id); +} + +void App::check_flushdraw(int surface_id) { + auto i = std::find(std::begin(this->pending_end_draw), + std::end(this->pending_end_draw), surface_id); + if (i != std::end(this->pending_end_draw)) { + auto n = this->lookup_name(surface_id); + logerror("Application %s (%d) has pending EndDraw call(s)!", + n ? n->c_str() : "unknown-name", surface_id); + std::swap(this->pending_end_draw[std::distance( + std::begin(this->pending_end_draw), i)], + this->pending_end_draw.back()); + this->pending_end_draw.resize(this->pending_end_draw.size() - 1); + } +} + char const *App::api_enddraw(char const *drawing_name) { for (unsigned i = 0, iend = this->pending_end_draw.size(); i < iend; i++) { auto n = this->lookup_name(this->pending_end_draw[i]); diff --git a/src/app.hpp b/src/app.hpp index 07b029c..5ef7ab4 100644 --- a/src/app.hpp +++ b/src/app.hpp @@ -139,6 +139,8 @@ struct App { } std::vector<int> pending_end_draw; + void enqueue_flushdraw(int surface_id); + void check_flushdraw(int surface_id); explicit App(wl::display *d); ~App(); |