X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwayland.cpp;h=e7ba1573d16d533407fcd59986009aed7848e865;hb=8c712205657ceceb8644065735b5fff06bedfbb5;hp=800c8daffc6861d0da525b10b56807f5b25d8f0e;hpb=eca853b284d4e1c099555de10b96f3424f6f28a1;p=staging%2Fwindowmanager.git diff --git a/src/wayland.cpp b/src/wayland.cpp index 800c8da..e7ba157 100644 --- a/src/wayland.cpp +++ b/src/wayland.cpp @@ -18,17 +18,8 @@ namespace wl { // |_| |___/ display::display() : d(std::unique_ptr( - wl_display_connect(nullptr), -#ifdef DEBUG_OUTPUT - [](struct wl_display *d) { - logdebug("wl::display ~display @ %p", d); - wl_display_disconnect(d); - })), -#else - &wl_display_disconnect)), -#endif - r(d.get()) { -} + wl_display_connect(nullptr), &wl_display_disconnect)), + r(d.get()) {} bool display::ok() const { return d && wl_display_get_error(d.get()) == 0; } @@ -262,55 +253,55 @@ void layer_visibility(void *data, struct ivi_controller_layer * /*ivi_controller_layer*/, int32_t visibility) { auto l = static_cast(data); - l->parent->layer_visibility(l->id, visibility); + l->parent->layer_visibility(l, visibility); } void layer_opacity(void *data, struct ivi_controller_layer * /*ivi_controller_layer*/, wl_fixed_t opacity) { auto l = static_cast(data); - l->parent->layer_opacity(l->id, float(wl_fixed_to_double(opacity))); + l->parent->layer_opacity(l, float(wl_fixed_to_double(opacity))); } void layer_source_rectangle( void *data, struct ivi_controller_layer * /*ivi_controller_layer*/, int32_t x, int32_t y, int32_t width, int32_t height) { auto l = static_cast(data); - l->parent->layer_source_rectangle(l->id, x, y, width, height); + l->parent->layer_source_rectangle(l, x, y, width, height); } void layer_destination_rectangle( void *data, struct ivi_controller_layer * /*ivi_controller_layer*/, int32_t x, int32_t y, int32_t width, int32_t height) { auto l = static_cast(data); - l->parent->layer_destination_rectangle(l->id, x, y, width, height); + l->parent->layer_destination_rectangle(l, x, y, width, height); } void layer_configuration(void *data, struct ivi_controller_layer * /*ivi_controller_layer*/, int32_t width, int32_t height) { auto l = static_cast(data); - l->parent->layer_configuration(l->id, width, height); + l->parent->layer_configuration(l, width, height); } void layer_orientation(void *data, struct ivi_controller_layer * /*ivi_controller_layer*/, int32_t orientation) { auto l = static_cast(data); - l->parent->layer_orientation(l->id, orientation); + l->parent->layer_orientation(l, orientation); } void layer_screen(void *data, struct ivi_controller_layer * /*ivi_controller_layer*/, struct wl_output *screen) { auto l = static_cast(data); - l->parent->layer_screen(l->id, screen); + l->parent->layer_screen(l, screen); } void layer_destroyed(void *data, struct ivi_controller_layer * /*ivi_controller_layer*/) { auto l = static_cast(data); - l->parent->layer_destroyed(l->id); + l->parent->layer_destroyed(l); } constexpr struct ivi_controller_layer_listener layer_listener = { @@ -393,52 +384,54 @@ void layer::set_render_order(std::vector const &ro) { ivi_controller_layer_set_render_order(this->proxy.get(), &wlro); } -void controller::layer_visibility(uint32_t id, int32_t visibility) { +void controller::layer_visibility(struct layer *l, int32_t visibility) { logdebug("genivi::layer %s @ %p v %i", __func__, this->proxy.get(), visibility); - this->layers[id]->visibility = visibility; + l->visibility = visibility; } -void controller::layer_opacity(uint32_t id, float opacity) { +void controller::layer_opacity(struct layer *l, float opacity) { logdebug("genivi::layer %s @ %p o %f", __func__, this->proxy.get(), opacity); - this->layers[id]->opacity = opacity; + l->opacity = opacity; } -void controller::layer_source_rectangle(uint32_t id, int32_t x, int32_t y, +void controller::layer_source_rectangle(struct layer *l, int32_t x, int32_t y, int32_t width, int32_t height) { logdebug("genivi::layer %s @ %p x %i y %i w %i h %i", __func__, this->proxy.get(), x, y, width, height); - this->layers[id]->src_rect = rect{uint32_t(width), uint32_t(height), x, y}; + l->src_rect = rect{uint32_t(width), uint32_t(height), x, y}; } -void controller::layer_destination_rectangle(uint32_t id, int32_t x, int32_t y, - int32_t width, int32_t height) { +void controller::layer_destination_rectangle(struct layer *l, int32_t x, + int32_t y, int32_t width, + int32_t height) { logdebug("genivi::layer %s @ %p x %i y %i w %i h %i", __func__, this->proxy.get(), x, y, width, height); - this->layers[id]->dst_rect = rect{uint32_t(width), uint32_t(height), x, y}; + l->dst_rect = rect{uint32_t(width), uint32_t(height), x, y}; } -void controller::layer_configuration(uint32_t id, int32_t width, +void controller::layer_configuration(struct layer *l, int32_t width, int32_t height) { logdebug("genivi::layer %s @ %p w %i h %i", __func__, this->proxy.get(), width, height); - this->layers[id]->size = size{uint32_t(width), uint32_t(height)}; + l->size = size{uint32_t(width), uint32_t(height)}; } -void controller::layer_orientation(uint32_t id, int32_t orientation) { +void controller::layer_orientation(struct layer *l, int32_t orientation) { logdebug("genivi::layer %s @ %p o %i", __func__, this->proxy.get(), orientation); - this->layers[id]->orientation = orientation; + l->orientation = orientation; } -void controller::layer_screen(uint32_t /*id*/, struct wl_output *screen) { +void controller::layer_screen(struct layer *l, struct wl_output *screen) { logdebug("genivi::layer %s @ %p s %p", __func__, this->proxy.get(), screen); + } -void controller::layer_destroyed(uint32_t id) { +void controller::layer_destroyed(struct layer *l) { logdebug("genivi::layer %s @ %p", __func__, this->proxy.get()); add_task("remove layer", - [id](struct controller *c) { c->layers.erase(id); }); + [l](struct controller *c) { c->layers.erase(l->id); }); } // __ @@ -453,56 +446,56 @@ void surface_visibility( void *data, struct ivi_controller_surface * /*ivi_controller_surface*/, int32_t visibility) { auto s = static_cast(data); - s->parent->surface_visibility(s->id, visibility); + s->parent->surface_visibility(s, visibility); } void surface_opacity(void *data, struct ivi_controller_surface * /*ivi_controller_surface*/, wl_fixed_t opacity) { auto s = static_cast(data); - s->parent->surface_opacity(s->id, float(wl_fixed_to_double(opacity))); + s->parent->surface_opacity(s, float(wl_fixed_to_double(opacity))); } void surface_source_rectangle( void *data, struct ivi_controller_surface * /*ivi_controller_surface*/, int32_t x, int32_t y, int32_t width, int32_t height) { auto s = static_cast(data); - s->parent->surface_source_rectangle(s->id, x, y, width, height); + s->parent->surface_source_rectangle(s, x, y, width, height); } void surface_destination_rectangle( void *data, struct ivi_controller_surface * /*ivi_controller_surface*/, int32_t x, int32_t y, int32_t width, int32_t height) { auto s = static_cast(data); - s->parent->surface_destination_rectangle(s->id, x, y, width, height); + s->parent->surface_destination_rectangle(s, x, y, width, height); } void surface_configuration( void *data, struct ivi_controller_surface * /*ivi_controller_surface*/, int32_t width, int32_t height) { auto s = static_cast(data); - s->parent->surface_configuration(s->id, width, height); + s->parent->surface_configuration(s, width, height); } void surface_orientation( void *data, struct ivi_controller_surface * /*ivi_controller_surface*/, int32_t orientation) { auto s = static_cast(data); - s->parent->surface_orientation(s->id, orientation); + s->parent->surface_orientation(s, orientation); } void surface_pixelformat( void *data, struct ivi_controller_surface * /*ivi_controller_surface*/, int32_t pixelformat) { auto s = static_cast(data); - s->parent->surface_pixelformat(s->id, pixelformat); + s->parent->surface_pixelformat(s, pixelformat); } void surface_layer(void *data, struct ivi_controller_surface * /*ivi_controller_surface*/, struct ivi_controller_layer *layer) { auto s = static_cast(data); - s->parent->surface_layer(s->id, layer); + s->parent->surface_layer(s, layer); } void surface_stats(void *data, @@ -511,21 +504,21 @@ void surface_stats(void *data, uint32_t update_count, uint32_t pid, const char *process_name) { auto s = static_cast(data); - s->parent->surface_stats(s->id, redraw_count, frame_count, update_count, pid, + s->parent->surface_stats(s, redraw_count, frame_count, update_count, pid, process_name); } void surface_destroyed( void *data, struct ivi_controller_surface * /*ivi_controller_surface*/) { auto s = static_cast(data); - s->parent->surface_destroyed(s->id); + s->parent->surface_destroyed(s); } void surface_content(void *data, struct ivi_controller_surface * /*ivi_controller_surface*/, int32_t content_state) { auto s = static_cast(data); - s->parent->surface_content(s->id, content_state); + s->parent->surface_content(s, content_state); } constexpr struct ivi_controller_surface_listener surface_listener = { @@ -602,58 +595,59 @@ void surface::destroy(int32_t destroy_scene_object) { ivi_controller_surface_destroy(this->proxy.get(), destroy_scene_object); } -void controller::surface_visibility(uint32_t id, int32_t visibility) { +void controller::surface_visibility(struct surface *s, int32_t visibility) { logdebug("genivi::surface %s @ %p v %i", __func__, this->proxy.get(), visibility); - this->surfaces[id]->visibility = visibility; + s->visibility = visibility; } -void controller::surface_opacity(uint32_t id, float opacity) { +void controller::surface_opacity(struct surface *s, float opacity) { logdebug("genivi::surface %s @ %p o %f", __func__, this->proxy.get(), opacity); - this->surfaces[id]->opacity = opacity; + s->opacity = opacity; } -void controller::surface_source_rectangle(uint32_t id, int32_t x, int32_t y, - int32_t width, int32_t height) { +void controller::surface_source_rectangle(struct surface *s, int32_t x, + int32_t y, int32_t width, + int32_t height) { logdebug("genivi::surface %s @ %p x %i y %i w %i h %i", __func__, this->proxy.get(), x, y, width, height); - this->surfaces[id]->src_rect = rect{uint32_t(width), uint32_t(height), x, y}; + s->src_rect = rect{uint32_t(width), uint32_t(height), x, y}; } -void controller::surface_destination_rectangle(uint32_t id, int32_t x, +void controller::surface_destination_rectangle(struct surface *s, int32_t x, int32_t y, int32_t width, int32_t height) { logdebug("genivi::surface %s @ %p x %i y %i w %i h %i", __func__, this->proxy.get(), x, y, width, height); - this->surfaces[id]->dst_rect = rect{uint32_t(width), uint32_t(height), x, y}; + s->dst_rect = rect{uint32_t(width), uint32_t(height), x, y}; } -void controller::surface_configuration(uint32_t id, int32_t width, +void controller::surface_configuration(struct surface *s, int32_t width, int32_t height) { logdebug("genivi::surface %s @ %p w %i h %i", __func__, this->proxy.get(), width, height); - this->surfaces[id]->size = size{uint32_t(width), uint32_t(height)}; + s->size = size{uint32_t(width), uint32_t(height)}; } -void controller::surface_orientation(uint32_t id, int32_t orientation) { +void controller::surface_orientation(struct surface *s, int32_t orientation) { logdebug("genivi::surface %s @ %p o %i", __func__, this->proxy.get(), orientation); - this->surfaces[id]->orientation = orientation; + s->orientation = orientation; } -void controller::surface_pixelformat(uint32_t /*id*/, int32_t pixelformat) { +void controller::surface_pixelformat(struct surface *s, int32_t pixelformat) { logdebug("genivi::surface %s @ %p f %i", __func__, this->proxy.get(), pixelformat); } -void controller::surface_layer(uint32_t /*id*/, +void controller::surface_layer(struct surface *s, struct ivi_controller_layer *layer) { logdebug("genivi::surface %s @ %p l %u @ %p", __func__, this->proxy.get(), this->layer_proxy_to_id[uintptr_t(layer)], layer); } -void controller::surface_stats(uint32_t /*id*/, uint32_t redraw_count, +void controller::surface_stats(struct surface *s, uint32_t redraw_count, uint32_t frame_count, uint32_t update_count, uint32_t pid, const char *process_name) { logdebug("genivi::surface %s @ %p r %u f %u u %u pid %u p %s", __func__, @@ -661,17 +655,17 @@ void controller::surface_stats(uint32_t /*id*/, uint32_t redraw_count, process_name); } -void controller::surface_destroyed(uint32_t id) { +void controller::surface_destroyed(struct surface *s) { logdebug("genivi::surface %s @ %p", __func__, this->proxy.get()); - this->surfaces.erase(id); + this->surfaces.erase(s->id); } -void controller::surface_content(uint32_t id, int32_t content_state) { +void controller::surface_content(struct surface *s, int32_t content_state) { logdebug("genivi::surface %s @ %p s %i", __func__, this->proxy.get(), content_state); if (content_state == IVI_CONTROLLER_SURFACE_CONTENT_STATE_CONTENT_REMOVED) { add_task("remove surface", - [id](struct controller *c) { c->surfaces.erase(id); }); + [s](struct controller *c) { c->surfaces.erase(s->id); }); } } @@ -724,6 +718,29 @@ void controller::execute_pending() { } } +void controller::debug_dump_current_status() { + if (!this->surfaces.empty()) { + puts("Surfaces:"); + for (auto const &i : this->surfaces) { + auto const &r = i.second->dst_rect; + auto const &s = i.second->size; + printf("%d [%ux%u] (%ux%u@%dx%d), ", i.first, s.w, s.h, r.w, r.h, + r.x, r.y); + } + puts("\b\b "); + } + + if (!this->layers.empty()) { + puts("Layers:"); + for (auto const &i : this->layers) { + auto const &r = i.second->dst_rect; + auto const &s = i.second->size; + printf("%d [%ux%u] (%ux%u@%dx%d), ", i.first, s.w, s.h, r.w, r.h, + r.x, r.y); + } + puts("\b\b "); + } +} // // ___ ___ _ __ ___ ___ _ __ // / __|/ __| '__/ _ \/ _ \ '_ \