summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-09-12 11:29:35 +0200
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-09-12 11:29:35 +0200
commit83b9b4e86d1193d820dfd67a3c0e1cbe0c29bb17 (patch)
tree65316d6130ca30b6019dbb9be10ddd8b40467e3b
parent616ac2c0016f3936c1e8634c134807044e7bba68 (diff)
app/binding: implement crude syndraw/enddraw/flushdraw sequence
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
-rw-r--r--src/afb_binding_api.cpp7
-rw-r--r--src/app.cpp37
-rw-r--r--src/app.hpp4
3 files changed, 41 insertions, 7 deletions
diff --git a/src/afb_binding_api.cpp b/src/afb_binding_api.cpp
index 7554cf0..f49d826 100644
--- a/src/afb_binding_api.cpp
+++ b/src/afb_binding_api.cpp
@@ -64,7 +64,12 @@ binding_api::result_type binding_api::deactivate_surface(char const* drawing_nam
binding_api::result_type binding_api::enddraw(char const* drawing_name) {
logdebug("%s drawing_name %s", __func__, drawing_name);
- return Err<json_object*>("not implemented");
+ auto r = this->app->enddraw(drawing_name);
+ if (r != nullptr) {
+ logdebug("%s failed with error: %s", __func__, r);
+ return Err<json_object *>(r);
+ }
+ return Ok(json_object_new_object());
}
binding_api::result_type binding_api::list_drawing_names() {
diff --git a/src/app.cpp b/src/app.cpp
index 596391c..ee02717 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -444,7 +444,8 @@ char const *App::activate_surface(char const *drawing_name) {
state.sub = -1;
state.s = LayoutState::Single;
- this->emit_flushdraw(drawing_name);
+ //////this->emit_flushdraw(drawing_name);
+ this->pending_end_draw.push_back(state.main);
} else {
bool can_split = this->can_split(state, *surface_id);
@@ -459,9 +460,11 @@ char const *App::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->emit_flushdraw(drawing_name);
+ //////this->emit_flushdraw(main.c_str());
}
} else {
this->emit_syncdraw(drawing_name);
@@ -474,7 +477,8 @@ char const *App::activate_surface(char const *drawing_name) {
state.sub = -1;
state.s = LayoutState::Single;
- this->emit_flushdraw(drawing_name);
+ //////this->emit_flushdraw(drawing_name);
+ this->pending_end_draw.push_back(state.main);
}
}
}
@@ -527,7 +531,8 @@ char const *App::deactivate_surface(char const *drawing_name) {
state.sub = -1;
state.s = LayoutState::Single;
- this->emit_flushdraw(sub.c_str());
+ //////this->emit_flushdraw(sub.c_str());
+ this->pending_end_draw.push_back(state.sub);
} else {
this->deactivate(*surface_id);
state.main = -1;
@@ -542,7 +547,8 @@ char const *App::deactivate_surface(char const *drawing_name) {
state.sub = -1;
state.s = LayoutState::Single;
- this->emit_flushdraw(main.c_str());
+ //////this->emit_flushdraw(main.c_str());
+ this->pending_end_draw.push_back(state.main);
} else {
return "Surface is not active";
}
@@ -553,6 +559,20 @@ char const *App::deactivate_surface(char const *drawing_name) {
return nullptr;
}
+char const *App::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]);
+ if (n && *n == drawing_name) {
+ std::swap(this->pending_end_draw[i], this->pending_end_draw[iend - 1]);
+ this->pending_end_draw.resize(iend - 1);
+ // XXX: Please tell the compositor to thaw the surface...
+ this->emit_flushdraw(drawing_name);
+ return nullptr;
+ }
+ }
+ return "No EndDraw pending for surface";
+}
+
// _ _ _____ _
// _ __ _ __ _____ _(_) ___ __| | | ____|_ _____ _ __ | |_ ___
// | '_ \| '__/ _ \ \/ / |/ _ \/ _` | | _| \ \ / / _ \ '_ \| __/ __|
@@ -583,6 +603,11 @@ void App::surface_created(uint32_t surface_id) {
void App::surface_removed(uint32_t surface_id) {
logdebug("surface_id is %u", surface_id);
+ auto drawing_name = this->lookup_name(surface_id);
+ if (drawing_name) {
+ this->deactivate_surface(drawing_name->c_str());
+ }
+
this->id_alloc.remove_id(surface_id);
}
diff --git a/src/app.hpp b/src/app.hpp
index 2e5478b..e661794 100644
--- a/src/app.hpp
+++ b/src/app.hpp
@@ -138,6 +138,8 @@ struct App {
x, false, std::memory_order_consume);
}
+ std::vector<int> pending_end_draw;
+
explicit App(wl::display *d);
~App();
@@ -162,6 +164,8 @@ struct App {
char const *activate_surface(char const *drawing_name);
char const *deactivate_surface(char const *drawing_name);
+ char const *enddraw(char const *drawing_name);
+
// Events from the compositor we are interested in
void surface_created(uint32_t surface_id);
void surface_removed(uint32_t surface_id);