6 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___ __ _| |
7 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \ \ \ /\ / / |
8 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/ \ V V /| |
9 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___| \_/\_/ |_|
14 // __| (_)___ _ __ | | __ _ _ _
15 // / _` | / __| '_ \| |/ _` | | | |
16 // | (_| | \__ \ |_) | | (_| | |_| |
17 // \__,_|_|___/ .__/|_|\__,_|\__, |
20 : d(std::unique_ptr<struct wl_display, void (*)(struct wl_display *)>(
21 wl_display_connect(nullptr), &wl_display_disconnect)),
24 bool display::ok() const { return d && wl_display_get_error(d.get()) == 0; }
26 void display::roundtrip() { wl_display_roundtrip(this->d.get()); }
28 int display::dispatch() { return wl_display_dispatch(this->d.get()); }
30 void display::flush() { wl_display_flush(this->d.get()); }
32 int display::get_fd() const { return wl_display_get_fd(this->d.get()); }
35 // _ __ ___ __ _(_)___| |_ _ __ _ _
36 // | '__/ _ \/ _` | / __| __| '__| | | |
37 // | | | __/ (_| | \__ \ |_| | | |_| |
38 // |_| \___|\__, |_|___/\__|_| \__, |
41 void registry_global(void *data, struct wl_registry * /*r*/, uint32_t name,
42 char const *iface, uint32_t v) {
43 static_cast<struct registry *>(data)->global(name, iface, v);
46 void registry_global_remove(void *data, struct wl_registry * /*r*/,
48 static_cast<struct registry *>(data)->global_remove(name);
51 constexpr struct wl_registry_listener registry_listener = {
52 registry_global, registry_global_remove};
55 registry::registry(struct wl_display *d)
56 : wayland_proxy(d == nullptr ? nullptr : wl_display_get_registry(d)) {
57 if (this->proxy != nullptr) {
58 wl_registry_add_listener(this->proxy.get(), ®istry_listener, this);
62 void registry::add_global_handler(char const *iface, binder bind) {
63 this->bindings[iface] = std::move(bind);
66 void registry::global(uint32_t name, char const *iface, uint32_t v) {
67 auto b = this->bindings.find(iface);
68 if (b != this->bindings.end()) {
69 b->second(this->proxy.get(), name, v);
71 logdebug("wl::registry @ %p global n %u i %s v %u", this->proxy.get(), name,
75 void registry::global_remove(uint32_t /*name*/) {}
78 // ___ _ _| |_ _ __ _ _| |_
79 // / _ \| | | | __| '_ \| | | | __|
80 // | (_) | |_| | |_| |_) | |_| | |_
81 // \___/ \__,_|\__| .__/ \__,_|\__|
84 void output_geometry(void *data, struct wl_output * /*wl_output*/, int32_t x,
85 int32_t y, int32_t physical_width, int32_t physical_height,
86 int32_t subpixel, const char *make, const char *model,
88 static_cast<struct output *>(data)->geometry(
89 x, y, physical_width, physical_height, subpixel, make, model, transform);
92 void output_mode(void *data, struct wl_output * /*wl_output*/, uint32_t flags,
93 int32_t width, int32_t height, int32_t refresh) {
94 static_cast<struct output *>(data)->mode(flags, width, height, refresh);
97 void output_done(void *data, struct wl_output * /*wl_output*/) {
98 static_cast<struct output *>(data)->done();
101 void output_scale(void *data, struct wl_output * /*wl_output*/,
103 static_cast<struct output *>(data)->scale(factor);
106 constexpr struct wl_output_listener output_listener = {
107 output_geometry, output_mode, output_done, output_scale};
110 output::output(struct wl_registry *r, uint32_t name, uint32_t v)
111 : wayland_proxy(wl_registry_bind(r, name, &wl_output_interface, v)) {
112 wl_output_add_listener(this->proxy.get(), &output_listener, this);
115 void output::geometry(int32_t x, int32_t y, int32_t pw, int32_t ph,
116 int32_t subpel, char const *make, char const *model,
119 "wl::output %s @ %p x %i y %i w %i h %i spel %x make %s model %s tx %i",
120 __func__, this->proxy.get(), x, y, pw, ph, subpel, make, model, tx);
123 void output::mode(uint32_t flags, int32_t w, int32_t h, int32_t r) {
124 logdebug("wl::output %s @ %p f %x w %i h %i r %i", __func__,
125 this->proxy.get(), flags, w, h, r);
126 if ((flags & WL_OUTPUT_MODE_CURRENT) != 0u) {
133 void output::done() {
134 logdebug("wl::output %s @ %p done", __func__, this->proxy.get());
137 void output::scale(int32_t factor) {
138 logdebug("wl::output %s @ %p f %i", __func__, this->proxy.get(), factor);
142 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___
143 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \
144 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/
145 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___|
148 // __ _ ___ _ __ (_)_ _(_)
149 // / _` |/ _ \ '_ \| \ \ / / |
150 // | (_| | __/ | | | |\ V /| |
151 // \__, |\___|_| |_|_| \_/ |_|
156 // ___ ___ _ __ | |_ _ __ ___ | | | ___ _ __
157 // / __/ _ \| '_ \| __| '__/ _ \| | |/ _ \ '__|
158 // | (_| (_) | | | | |_| | | (_) | | | __/ |
159 // \___\___/|_| |_|\__|_| \___/|_|_|\___|_|
162 void controller_screen(void *data, struct ivi_controller * /*ivi_controller*/,
164 struct ivi_controller_screen *screen) {
165 static_cast<struct controller *>(data)->controller_screen(id_screen, screen);
168 void controller_layer(void *data, struct ivi_controller * /*ivi_controller*/,
170 static_cast<struct controller *>(data)->controller_layer(id_layer);
173 void controller_surface(void *data, struct ivi_controller * /*ivi_controller*/,
174 uint32_t id_surface) {
175 static_cast<struct controller *>(data)->controller_surface(id_surface);
178 void controller_error(void *data, struct ivi_controller * /*ivi_controller*/,
179 int32_t object_id, int32_t object_type,
180 int32_t error_code, const char *error_text) {
181 static_cast<struct controller *>(data)->controller_error(
182 object_id, object_type, error_code, error_text);
185 constexpr struct ivi_controller_listener listener = {
186 controller_screen, controller_layer, controller_surface, controller_error};
189 controller::controller(struct wl_registry *r, uint32_t name, uint32_t version)
191 wl_registry_bind(r, name, &ivi_controller_interface, version)),
192 surface_proxy_to_id{},
194 screen_proxy_to_id{},
200 ivi_controller_add_listener(this->proxy.get(), &listener, this);
203 void controller::layer_create(uint32_t id, int32_t w, int32_t h) {
204 this->layers[id] = std::make_unique<struct layer>(id, w, h, this);
207 void controller::surface_create(uint32_t id) {
208 this->surfaces[id] = std::make_unique<struct surface>(id, this);
211 void controller::controller_screen(uint32_t id,
212 struct ivi_controller_screen *screen) {
213 logdebug("genivi::controller @ %p screen %u (%x) @ %p", this->proxy.get(),
215 this->screens[id] = std::make_unique<struct screen>(id, this, screen);
218 void controller::controller_layer(uint32_t id) {
219 logdebug("genivi::controller @ %p layer %u (%x)", this->proxy.get(), id, id);
220 auto &l = this->layers[id] = std::make_unique<struct layer>(id, this);
224 void controller::controller_surface(uint32_t id) {
225 logdebug("genivi::controller @ %p surface %u (%x)", this->proxy.get(), id,
227 this->surfaces[id] = std::make_unique<struct surface>(id, this);
229 add_task("fullscreen surface", [id](struct controller *c) {
230 auto &s = c->surfaces[id];
231 s->set_destination_rectangle(0, 0, c->output_size.w, c->output_size.h);
232 s->set_visibility(1);
233 uint32_t lid = id == 0x16180 ? 1000 : 100;
234 c->layers[lid]->add_surface(s.get());
235 logdebug("Surface %u now fullscreen on layer %u", id, lid);
239 void controller::controller_error(int32_t object_id, int32_t object_type,
240 int32_t error_code, const char *error_text) {
241 logdebug("genivi::controller @ %p error o %i t %i c %i text %s",
242 this->proxy.get(), object_id, object_type, error_code, error_text);
246 // | | __ _ _ _ ___ _ __
247 // | |/ _` | | | |/ _ \ '__|
248 // | | (_| | |_| | __/ |
249 // |_|\__,_|\__, |\___|_|
252 void layer_visibility(void *data,
253 struct ivi_controller_layer * /*ivi_controller_layer*/,
254 int32_t visibility) {
255 auto l = static_cast<struct layer *>(data);
256 l->parent->layer_visibility(l, visibility);
259 void layer_opacity(void *data,
260 struct ivi_controller_layer * /*ivi_controller_layer*/,
261 wl_fixed_t opacity) {
262 auto l = static_cast<struct layer *>(data);
263 l->parent->layer_opacity(l, float(wl_fixed_to_double(opacity)));
266 void layer_source_rectangle(
267 void *data, struct ivi_controller_layer * /*ivi_controller_layer*/,
268 int32_t x, int32_t y, int32_t width, int32_t height) {
269 auto l = static_cast<struct layer *>(data);
270 l->parent->layer_source_rectangle(l, x, y, width, height);
273 void layer_destination_rectangle(
274 void *data, struct ivi_controller_layer * /*ivi_controller_layer*/,
275 int32_t x, int32_t y, int32_t width, int32_t height) {
276 auto l = static_cast<struct layer *>(data);
277 l->parent->layer_destination_rectangle(l, x, y, width, height);
280 void layer_configuration(void *data,
281 struct ivi_controller_layer * /*ivi_controller_layer*/,
282 int32_t width, int32_t height) {
283 auto l = static_cast<struct layer *>(data);
284 l->parent->layer_configuration(l, width, height);
287 void layer_orientation(void *data,
288 struct ivi_controller_layer * /*ivi_controller_layer*/,
289 int32_t orientation) {
290 auto l = static_cast<struct layer *>(data);
291 l->parent->layer_orientation(l, orientation);
294 void layer_screen(void *data,
295 struct ivi_controller_layer * /*ivi_controller_layer*/,
296 struct wl_output *screen) {
297 auto l = static_cast<struct layer *>(data);
298 l->parent->layer_screen(l, screen);
301 void layer_destroyed(void *data,
302 struct ivi_controller_layer * /*ivi_controller_layer*/) {
303 auto l = static_cast<struct layer *>(data);
304 l->parent->layer_destroyed(l);
307 constexpr struct ivi_controller_layer_listener layer_listener = {
308 layer_visibility, layer_opacity,
309 layer_source_rectangle, layer_destination_rectangle,
310 layer_configuration, layer_orientation,
311 layer_screen, layer_destroyed,
315 layer::layer(uint32_t i, struct controller *c) : layer(i, 0, 0, c) {}
317 layer::layer(uint32_t i, int32_t w, int32_t h, struct controller *c)
318 : wayland_proxy(ivi_controller_layer_create(c->proxy.get(), i, w, h),
319 [c, i](ivi_controller_layer *l) {
320 logdebug("~layer layer %i @ %p", i, l);
321 c->remove_proxy_to_id_mapping(l);
322 ivi_controller_layer_destroy(l, 1);
324 controller_child(c, i),
331 this->parent->add_proxy_to_id_mapping(this->proxy.get(), i);
332 ivi_controller_layer_add_listener(this->proxy.get(), &layer_listener, this);
335 void layer::set_visibility(uint32_t visibility) {
336 ivi_controller_layer_set_visibility(this->proxy.get(), visibility);
339 void layer::set_opacity(wl_fixed_t opacity) {
340 ivi_controller_layer_set_opacity(this->proxy.get(), opacity);
343 void layer::set_source_rectangle(int32_t x, int32_t y, int32_t width,
345 ivi_controller_layer_set_source_rectangle(this->proxy.get(), x, y, width,
349 void layer::set_destination_rectangle(int32_t x, int32_t y, int32_t width,
351 ivi_controller_layer_set_destination_rectangle(this->proxy.get(), x, y,
355 void layer::set_configuration(int32_t width, int32_t height) {
356 ivi_controller_layer_set_configuration(this->proxy.get(), width, height);
359 void layer::set_orientation(int32_t orientation) {
360 ivi_controller_layer_set_orientation(this->proxy.get(), orientation);
363 void layer::screenshot(const char *filename) {
364 ivi_controller_layer_screenshot(this->proxy.get(), filename);
367 void layer::clear_surfaces() {
368 ivi_controller_layer_clear_surfaces(this->proxy.get());
371 void layer::add_surface(struct surface *surface) {
372 ivi_controller_layer_add_surface(this->proxy.get(), surface->proxy.get());
375 void layer::remove_surface(struct surface *surface) {
376 ivi_controller_layer_remove_surface(this->proxy.get(), surface->proxy.get());
379 void layer::set_render_order(std::vector<uint32_t> const &ro) {
380 struct wl_array wlro {
381 .size = ro.size() * sizeof(ro[0]), .alloc = ro.capacity() * sizeof(ro[0]),
382 .data = const_cast<void *>(static_cast<void const *>(ro.data()))
384 ivi_controller_layer_set_render_order(this->proxy.get(), &wlro);
387 void controller::layer_visibility(struct layer *l, int32_t visibility) {
388 logdebug("genivi::layer %s @ %p v %i", __func__, this->proxy.get(),
390 l->visibility = visibility;
393 void controller::layer_opacity(struct layer *l, float opacity) {
394 logdebug("genivi::layer %s @ %p o %f", __func__, this->proxy.get(), opacity);
395 l->opacity = opacity;
398 void controller::layer_source_rectangle(struct layer *l, int32_t x, int32_t y,
399 int32_t width, int32_t height) {
400 logdebug("genivi::layer %s @ %p x %i y %i w %i h %i", __func__,
401 this->proxy.get(), x, y, width, height);
402 l->src_rect = rect{uint32_t(width), uint32_t(height), x, y};
405 void controller::layer_destination_rectangle(struct layer *l, int32_t x,
406 int32_t y, int32_t width,
408 logdebug("genivi::layer %s @ %p x %i y %i w %i h %i", __func__,
409 this->proxy.get(), x, y, width, height);
410 l->dst_rect = rect{uint32_t(width), uint32_t(height), x, y};
413 void controller::layer_configuration(struct layer *l, int32_t width,
415 logdebug("genivi::layer %s @ %p w %i h %i", __func__, this->proxy.get(),
417 l->size = size{uint32_t(width), uint32_t(height)};
420 void controller::layer_orientation(struct layer *l, int32_t orientation) {
421 logdebug("genivi::layer %s @ %p o %i", __func__, this->proxy.get(),
423 l->orientation = orientation;
426 void controller::layer_screen(struct layer * /*l*/, struct wl_output *screen) {
427 logdebug("genivi::layer %s @ %p s %p", __func__, this->proxy.get(), screen);
430 void controller::layer_destroyed(struct layer *l) {
431 logdebug("genivi::layer %s @ %p", __func__, this->proxy.get());
432 add_task("remove layer",
433 [l](struct controller *c) { c->layers.erase(l->id); });
437 // ___ _ _ _ __ / _| __ _ ___ ___
438 // / __| | | | '__| |_ / _` |/ __/ _ \
439 // \__ \ |_| | | | _| (_| | (_| __/
440 // |___/\__,_|_| |_| \__,_|\___\___|
444 void surface_visibility(
445 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
446 int32_t visibility) {
447 auto s = static_cast<struct surface *>(data);
448 s->parent->surface_visibility(s, visibility);
451 void surface_opacity(void *data,
452 struct ivi_controller_surface * /*ivi_controller_surface*/,
453 wl_fixed_t opacity) {
454 auto s = static_cast<struct surface *>(data);
455 s->parent->surface_opacity(s, float(wl_fixed_to_double(opacity)));
458 void surface_source_rectangle(
459 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
460 int32_t x, int32_t y, int32_t width, int32_t height) {
461 auto s = static_cast<struct surface *>(data);
462 s->parent->surface_source_rectangle(s, x, y, width, height);
465 void surface_destination_rectangle(
466 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
467 int32_t x, int32_t y, int32_t width, int32_t height) {
468 auto s = static_cast<struct surface *>(data);
469 s->parent->surface_destination_rectangle(s, x, y, width, height);
472 void surface_configuration(
473 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
474 int32_t width, int32_t height) {
475 auto s = static_cast<struct surface *>(data);
476 s->parent->surface_configuration(s, width, height);
479 void surface_orientation(
480 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
481 int32_t orientation) {
482 auto s = static_cast<struct surface *>(data);
483 s->parent->surface_orientation(s, orientation);
486 void surface_pixelformat(
487 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
488 int32_t pixelformat) {
489 auto s = static_cast<struct surface *>(data);
490 s->parent->surface_pixelformat(s, pixelformat);
493 void surface_layer(void *data,
494 struct ivi_controller_surface * /*ivi_controller_surface*/,
495 struct ivi_controller_layer *layer) {
496 auto s = static_cast<struct surface *>(data);
497 s->parent->surface_layer(s, layer);
500 void surface_stats(void *data,
501 struct ivi_controller_surface * /*ivi_controller_surface*/,
502 uint32_t redraw_count, uint32_t frame_count,
503 uint32_t update_count, uint32_t pid,
504 const char *process_name) {
505 auto s = static_cast<struct surface *>(data);
506 s->parent->surface_stats(s, redraw_count, frame_count, update_count, pid,
510 void surface_destroyed(
511 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/) {
512 auto s = static_cast<struct surface *>(data);
513 s->parent->surface_destroyed(s);
516 void surface_content(void *data,
517 struct ivi_controller_surface * /*ivi_controller_surface*/,
518 int32_t content_state) {
519 auto s = static_cast<struct surface *>(data);
520 s->parent->surface_content(s, content_state);
523 constexpr struct ivi_controller_surface_listener surface_listener = {
526 surface_source_rectangle,
527 surface_destination_rectangle,
528 surface_configuration,
538 surface::surface(uint32_t i, struct controller *c)
539 : wayland_proxy(ivi_controller_surface_create(c->proxy.get(), i),
540 [c, i](ivi_controller_surface *s) {
541 logdebug("~surface surface %i @ %p", i, s);
542 c->remove_proxy_to_id_mapping(s);
543 ivi_controller_surface_destroy(s, 1);
545 controller_child(c, i),
552 this->parent->add_proxy_to_id_mapping(this->proxy.get(), i);
553 ivi_controller_surface_add_listener(this->proxy.get(), &surface_listener,
557 void surface::set_visibility(uint32_t visibility) {
558 ivi_controller_surface_set_visibility(this->proxy.get(), visibility);
561 void surface::set_opacity(wl_fixed_t opacity) {
562 ivi_controller_surface_set_opacity(this->proxy.get(), opacity);
565 void surface::set_source_rectangle(int32_t x, int32_t y, int32_t width,
567 ivi_controller_surface_set_source_rectangle(this->proxy.get(), x, y, width,
571 void surface::set_destination_rectangle(int32_t x, int32_t y, int32_t width,
573 ivi_controller_surface_set_destination_rectangle(this->proxy.get(), x, y,
577 void surface::set_configuration(int32_t width, int32_t height) {
578 ivi_controller_surface_set_configuration(this->proxy.get(), width, height);
581 void surface::set_orientation(int32_t orientation) {
582 ivi_controller_surface_set_orientation(this->proxy.get(), orientation);
585 void surface::screenshot(const char *filename) {
586 ivi_controller_surface_screenshot(this->proxy.get(), filename);
589 void surface::send_stats() {
590 ivi_controller_surface_send_stats(this->proxy.get());
593 void surface::destroy(int32_t destroy_scene_object) {
594 ivi_controller_surface_destroy(this->proxy.get(), destroy_scene_object);
597 void controller::surface_visibility(struct surface *s, int32_t visibility) {
598 logdebug("genivi::surface %s @ %p v %i", __func__, this->proxy.get(),
600 s->visibility = visibility;
603 void controller::surface_opacity(struct surface *s, float opacity) {
604 logdebug("genivi::surface %s @ %p o %f", __func__, this->proxy.get(),
606 s->opacity = opacity;
609 void controller::surface_source_rectangle(struct surface *s, int32_t x,
610 int32_t y, int32_t width,
612 logdebug("genivi::surface %s @ %p x %i y %i w %i h %i", __func__,
613 this->proxy.get(), x, y, width, height);
614 s->src_rect = rect{uint32_t(width), uint32_t(height), x, y};
617 void controller::surface_destination_rectangle(struct surface *s, int32_t x,
618 int32_t y, int32_t width,
620 logdebug("genivi::surface %s @ %p x %i y %i w %i h %i", __func__,
621 this->proxy.get(), x, y, width, height);
622 s->dst_rect = rect{uint32_t(width), uint32_t(height), x, y};
625 void controller::surface_configuration(struct surface *s, int32_t width,
627 logdebug("genivi::surface %s @ %p w %i h %i", __func__, this->proxy.get(),
629 s->size = size{uint32_t(width), uint32_t(height)};
632 void controller::surface_orientation(struct surface *s, int32_t orientation) {
633 logdebug("genivi::surface %s @ %p o %i", __func__, this->proxy.get(),
635 s->orientation = orientation;
638 void controller::surface_pixelformat(struct surface * /*s*/,
639 int32_t pixelformat) {
640 logdebug("genivi::surface %s @ %p f %i", __func__, this->proxy.get(),
644 void controller::surface_layer(struct surface * /*s*/,
645 struct ivi_controller_layer *layer) {
646 logdebug("genivi::surface %s @ %p l %u @ %p", __func__, this->proxy.get(),
647 this->layer_proxy_to_id[uintptr_t(layer)], layer);
650 void controller::surface_stats(struct surface * /*s*/, uint32_t redraw_count,
651 uint32_t frame_count, uint32_t update_count,
652 uint32_t pid, const char *process_name) {
653 logdebug("genivi::surface %s @ %p r %u f %u u %u pid %u p %s", __func__,
654 this->proxy.get(), redraw_count, frame_count, update_count, pid,
658 void controller::surface_destroyed(struct surface *s) {
659 logdebug("genivi::surface %s @ %p", __func__, this->proxy.get());
660 this->surfaces.erase(s->id);
663 void controller::surface_content(struct surface *s, int32_t content_state) {
664 logdebug("genivi::surface %s @ %p s %i", __func__, this->proxy.get(),
666 if (content_state == IVI_CONTROLLER_SURFACE_CONTENT_STATE_CONTENT_REMOVED) {
667 add_task("remove surface",
668 [s](struct controller *c) { c->surfaces.erase(s->id); });
672 void controller::add_proxy_to_id_mapping(struct ivi_controller_surface *p,
674 this->surface_proxy_to_id[uintptr_t(p)] = id;
675 logdebug("Add surface proxy mapping for %p (%u)", p, id);
678 void controller::remove_proxy_to_id_mapping(struct ivi_controller_surface *p) {
679 logdebug("Remove surface proxy mapping for %p", p);
680 this->surface_proxy_to_id.erase(uintptr_t(p));
683 void controller::add_proxy_to_id_mapping(struct ivi_controller_layer *p,
685 logdebug("Add layer proxy mapping for %p (%u)", p, id);
686 this->layer_proxy_to_id[uintptr_t(p)] = id;
689 void controller::remove_proxy_to_id_mapping(struct ivi_controller_layer *p) {
690 logdebug("Remove layer proxy mapping for %p", p);
691 this->layer_proxy_to_id.erase(uintptr_t(p));
694 void controller::add_proxy_to_id_mapping(struct wl_output *p, uint32_t id) {
695 logdebug("Add screen proxy mapping for %p (%u)", p, id);
696 this->screen_proxy_to_id[uintptr_t(p)] = id;
699 void controller::remove_proxy_to_id_mapping(struct wl_output *p) {
700 logdebug("Remove screen proxy mapping for %p", p);
701 this->screen_proxy_to_id.erase(uintptr_t(p));
704 void controller::add_task(char const *name,
705 std::function<void(struct controller *)> &&f) {
706 this->pending.emplace_back(std::make_pair(name, f));
709 void controller::execute_pending() {
710 if (!this->pending.empty()) {
711 for (auto &t : this->pending) {
712 logdebug("executing task '%s'", t.first);
715 this->pending.clear();
716 ivi_controller_commit_changes(this->proxy.get());
717 // XXX: No flush here...
721 void controller::debug_dump_current_status() {
722 if (!this->surfaces.empty()) {
724 for (auto const &i : this->surfaces) {
725 auto const &r = i.second->dst_rect;
726 auto const &s = i.second->size;
727 printf("%d [%ux%u] (%ux%u@%dx%d), ", i.first, s.w, s.h, r.w, r.h, r.x,
733 if (!this->layers.empty()) {
735 for (auto const &i : this->layers) {
736 auto const &r = i.second->dst_rect;
737 auto const &s = i.second->size;
738 printf("%d [%ux%u] (%ux%u@%dx%d), ", i.first, s.w, s.h, r.w, r.h, r.x,
745 // ___ ___ _ __ ___ ___ _ __
746 // / __|/ __| '__/ _ \/ _ \ '_ \
747 // \__ \ (__| | | __/ __/ | | |
748 // |___/\___|_| \___|\___|_| |_|
750 screen::screen(uint32_t i, struct controller *c,
751 struct ivi_controller_screen *p)
752 : wayland_proxy(p), controller_child(c, i) {
753 logdebug("genivi::screen @ %p id %u", p, i);
756 void screen::clear() { ivi_controller_screen_clear(this->proxy.get()); }
758 void screen::add_layer(layer *l) {
759 ivi_controller_screen_add_layer(this->proxy.get(), l->proxy.get());
762 void screen::set_render_order(std::vector<uint32_t> const &ro) {
763 struct wl_array wlro {
764 .size = ro.size() * sizeof(ro[0]), .alloc = ro.capacity() * sizeof(ro[0]),
765 .data = const_cast<void *>(static_cast<void const *>(ro.data()))
767 ivi_controller_screen_set_render_order(this->proxy.get(), &wlro);
770 } // namespace genivi