2 * Copyright (C) 2017 Mentor Graphics Development (Deutschland) GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "wayland.hpp"
22 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___ __ _| |
23 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \ \ \ /\ / / |
24 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/ \ V V /| |
25 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___| \_/\_/ |_|
30 // __| (_)___ _ __ | | __ _ _ _
31 // / _` | / __| '_ \| |/ _` | | | |
32 // | (_| | \__ \ |_) | | (_| | |_| |
33 // \__,_|_|___/ .__/|_|\__,_|\__, |
36 : d(std::unique_ptr<struct wl_display, void (*)(struct wl_display *)>(
37 wl_display_connect(nullptr), &wl_display_disconnect)),
40 bool display::ok() const { return d && wl_display_get_error(d.get()) == 0; }
42 void display::roundtrip() { wl_display_roundtrip(this->d.get()); }
44 int display::dispatch() { return wl_display_dispatch(this->d.get()); }
46 void display::flush() { wl_display_flush(this->d.get()); }
48 int display::get_fd() const { return wl_display_get_fd(this->d.get()); }
50 int display::get_error() { return wl_display_get_error(this->d.get()); }
53 // _ __ ___ __ _(_)___| |_ _ __ _ _
54 // | '__/ _ \/ _` | / __| __| '__| | | |
55 // | | | __/ (_| | \__ \ |_| | | |_| |
56 // |_| \___|\__, |_|___/\__|_| \__, |
59 void registry_global(void *data, struct wl_registry * /*r*/, uint32_t name,
60 char const *iface, uint32_t v) {
61 static_cast<struct registry *>(data)->global(name, iface, v);
64 void registry_global_remove(void *data, struct wl_registry * /*r*/,
66 static_cast<struct registry *>(data)->global_remove(name);
69 constexpr struct wl_registry_listener registry_listener = {
70 registry_global, registry_global_remove};
73 registry::registry(struct wl_display *d)
74 : wayland_proxy(d == nullptr ? nullptr : wl_display_get_registry(d)) {
75 if (this->proxy != nullptr) {
76 wl_registry_add_listener(this->proxy.get(), ®istry_listener, this);
80 void registry::add_global_handler(char const *iface, binder bind) {
81 this->bindings[iface] = std::move(bind);
84 void registry::global(uint32_t name, char const *iface, uint32_t v) {
85 auto b = this->bindings.find(iface);
86 if (b != this->bindings.end()) {
87 b->second(this->proxy.get(), name, v);
89 logdebug("wl::registry @ %p global n %u i %s v %u", this->proxy.get(), name,
93 void registry::global_remove(uint32_t /*name*/) {}
96 // ___ _ _| |_ _ __ _ _| |_
97 // / _ \| | | | __| '_ \| | | | __|
98 // | (_) | |_| | |_| |_) | |_| | |_
99 // \___/ \__,_|\__| .__/ \__,_|\__|
102 void output_geometry(void *data, struct wl_output * /*wl_output*/, int32_t x,
103 int32_t y, int32_t physical_width, int32_t physical_height,
104 int32_t subpixel, const char *make, const char *model,
106 static_cast<struct output *>(data)->geometry(
107 x, y, physical_width, physical_height, subpixel, make, model, transform);
110 void output_mode(void *data, struct wl_output * /*wl_output*/, uint32_t flags,
111 int32_t width, int32_t height, int32_t refresh) {
112 static_cast<struct output *>(data)->mode(flags, width, height, refresh);
115 void output_done(void *data, struct wl_output * /*wl_output*/) {
116 static_cast<struct output *>(data)->done();
119 void output_scale(void *data, struct wl_output * /*wl_output*/,
121 static_cast<struct output *>(data)->scale(factor);
124 constexpr struct wl_output_listener output_listener = {
125 output_geometry, output_mode, output_done, output_scale};
128 output::output(struct wl_registry *r, uint32_t name, uint32_t v)
129 : wayland_proxy(wl_registry_bind(r, name, &wl_output_interface, v)) {
130 wl_output_add_listener(this->proxy.get(), &output_listener, this);
133 void output::geometry(int32_t x, int32_t y, int32_t pw, int32_t ph,
134 int32_t subpel, char const *make, char const *model,
137 "wl::output %s @ %p x %i y %i w %i h %i spel %x make %s model %s tx %i",
138 __func__, this->proxy.get(), x, y, pw, ph, subpel, make, model, tx);
139 this->transform = tx;
142 void output::mode(uint32_t flags, int32_t w, int32_t h, int32_t r) {
143 logdebug("wl::output %s @ %p f %x w %i h %i r %i", __func__,
144 this->proxy.get(), flags, w, h, r);
145 if ((flags & WL_OUTPUT_MODE_CURRENT) != 0u) {
152 void output::done() {
153 logdebug("wl::output %s @ %p done", __func__, this->proxy.get());
154 // Let's just disregard the flipped ones...
155 if (this->transform == WL_OUTPUT_TRANSFORM_90 ||
156 this->transform == WL_OUTPUT_TRANSFORM_270) {
157 std::swap(this->width, this->height);
161 void output::scale(int32_t factor) {
162 logdebug("wl::output %s @ %p f %i", __func__, this->proxy.get(), factor);
166 // _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___
167 // | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \
168 // | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/
169 // |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___|
172 // __ _ ___ _ __ (_)_ _(_)
173 // / _` |/ _ \ '_ \| \ \ / / |
174 // | (_| | __/ | | | |\ V /| |
175 // \__, |\___|_| |_|_| \_/ |_|
180 // ___ ___ _ __ | |_ _ __ ___ | | | ___ _ __
181 // / __/ _ \| '_ \| __| '__/ _ \| | |/ _ \ '__|
182 // | (_| (_) | | | | |_| | | (_) | | | __/ |
183 // \___\___/|_| |_|\__|_| \___/|_|_|\___|_|
186 void controller_screen(void *data, struct ivi_controller * /*ivi_controller*/,
188 struct ivi_controller_screen *screen) {
189 static_cast<struct controller *>(data)->controller_screen(id_screen, screen);
192 void controller_layer(void *data, struct ivi_controller * /*ivi_controller*/,
194 static_cast<struct controller *>(data)->controller_layer(id_layer);
197 void controller_surface(void *data, struct ivi_controller * /*ivi_controller*/,
198 uint32_t id_surface) {
199 static_cast<struct controller *>(data)->controller_surface(id_surface);
202 void controller_error(void *data, struct ivi_controller * /*ivi_controller*/,
203 int32_t object_id, int32_t object_type,
204 int32_t error_code, const char *error_text) {
205 static_cast<struct controller *>(data)->controller_error(
206 object_id, object_type, error_code, error_text);
209 constexpr struct ivi_controller_listener listener = {
210 controller_screen, controller_layer, controller_surface, controller_error};
213 controller::controller(struct wl_registry *r, uint32_t name, uint32_t version)
215 wl_registry_bind(r, name, &ivi_controller_interface, version)),
217 ivi_controller_add_listener(this->proxy.get(), &listener, this);
220 void controller::layer_create(uint32_t id, int32_t w, int32_t h) {
221 this->layers[id] = std::make_unique<struct layer>(id, w, h, this);
224 void controller::surface_create(uint32_t id) {
225 this->surfaces[id] = std::make_unique<struct surface>(id, this);
228 void controller::controller_screen(uint32_t id,
229 struct ivi_controller_screen *screen) {
230 logdebug("genivi::controller @ %p screen %u (%x) @ %p", this->proxy.get(),
232 this->screens[id] = std::make_unique<struct screen>(id, this, screen);
235 void controller::controller_layer(uint32_t id) {
236 logdebug("genivi::controller @ %p layer %u (%x)", this->proxy.get(), id, id);
237 if (this->layers.find(id) != this->layers.end()) {
238 logerror("Someone created a layer without asking US! (%d)", id);
240 auto &l = this->layers[id] = std::make_unique<struct layer>(id, this);
245 void controller::controller_surface(uint32_t id) {
246 logdebug("genivi::controller @ %p surface %u (%x)", this->proxy.get(), id,
248 if (this->surfaces.find(id) == this->surfaces.end()) {
249 this->surfaces[id] = std::make_unique<struct surface>(id, this);
250 this->chooks->surface_created(id);
254 void controller::controller_error(int32_t object_id, int32_t object_type,
255 int32_t error_code, const char *error_text) {
256 logdebug("genivi::controller @ %p error o %i t %i c %i text %s",
257 this->proxy.get(), object_id, object_type, error_code, error_text);
261 // | | __ _ _ _ ___ _ __
262 // | |/ _` | | | |/ _ \ '__|
263 // | | (_| | |_| | __/ |
264 // |_|\__,_|\__, |\___|_|
267 void layer_visibility(void *data,
268 struct ivi_controller_layer * /*ivi_controller_layer*/,
269 int32_t visibility) {
270 auto l = static_cast<struct layer *>(data);
271 l->parent->layer_visibility(l, visibility);
274 void layer_opacity(void *data,
275 struct ivi_controller_layer * /*ivi_controller_layer*/,
276 wl_fixed_t opacity) {
277 auto l = static_cast<struct layer *>(data);
278 l->parent->layer_opacity(l, float(wl_fixed_to_double(opacity)));
281 void layer_source_rectangle(
282 void *data, struct ivi_controller_layer * /*ivi_controller_layer*/,
283 int32_t x, int32_t y, int32_t width, int32_t height) {
284 auto l = static_cast<struct layer *>(data);
285 l->parent->layer_source_rectangle(l, x, y, width, height);
288 void layer_destination_rectangle(
289 void *data, struct ivi_controller_layer * /*ivi_controller_layer*/,
290 int32_t x, int32_t y, int32_t width, int32_t height) {
291 auto l = static_cast<struct layer *>(data);
292 l->parent->layer_destination_rectangle(l, x, y, width, height);
295 void layer_configuration(void *data,
296 struct ivi_controller_layer * /*ivi_controller_layer*/,
297 int32_t width, int32_t height) {
298 auto l = static_cast<struct layer *>(data);
299 l->parent->layer_configuration(l, width, height);
302 void layer_orientation(void *data,
303 struct ivi_controller_layer * /*ivi_controller_layer*/,
304 int32_t orientation) {
305 auto l = static_cast<struct layer *>(data);
306 l->parent->layer_orientation(l, orientation);
309 void layer_screen(void *data,
310 struct ivi_controller_layer * /*ivi_controller_layer*/,
311 struct wl_output *screen) {
312 auto l = static_cast<struct layer *>(data);
313 l->parent->layer_screen(l, screen);
316 void layer_destroyed(void *data,
317 struct ivi_controller_layer * /*ivi_controller_layer*/) {
318 auto l = static_cast<struct layer *>(data);
319 l->parent->layer_destroyed(l);
322 constexpr struct ivi_controller_layer_listener layer_listener = {
323 layer_visibility, layer_opacity,
324 layer_source_rectangle, layer_destination_rectangle,
325 layer_configuration, layer_orientation,
326 layer_screen, layer_destroyed,
330 layer::layer(uint32_t i, struct controller *c) : layer(i, 0, 0, c) {}
332 layer::layer(uint32_t i, int32_t w, int32_t h, struct controller *c)
333 : wayland_proxy(ivi_controller_layer_create(c->proxy.get(), i, w, h),
334 [c, i](ivi_controller_layer *l) {
335 logdebug("~layer layer %i @ %p", i, l);
336 c->remove_proxy_to_id_mapping(l);
337 ivi_controller_layer_destroy(l, 1);
339 controller_child(c, i) {
340 this->parent->add_proxy_to_id_mapping(this->proxy.get(), i);
341 ivi_controller_layer_add_listener(this->proxy.get(), &layer_listener, this);
344 void layer::set_visibility(uint32_t visibility) {
345 ivi_controller_layer_set_visibility(this->proxy.get(), visibility);
348 void layer::set_opacity(wl_fixed_t opacity) {
349 ivi_controller_layer_set_opacity(this->proxy.get(), opacity);
352 void layer::set_source_rectangle(int32_t x, int32_t y, int32_t width,
354 ivi_controller_layer_set_source_rectangle(this->proxy.get(), x, y, width,
358 void layer::set_destination_rectangle(int32_t x, int32_t y, int32_t width,
360 ivi_controller_layer_set_destination_rectangle(this->proxy.get(), x, y,
364 void layer::set_configuration(int32_t width, int32_t height) {
365 ivi_controller_layer_set_configuration(this->proxy.get(), width, height);
368 void layer::set_orientation(int32_t orientation) {
369 ivi_controller_layer_set_orientation(this->proxy.get(), orientation);
372 void layer::screenshot(const char *filename) {
373 ivi_controller_layer_screenshot(this->proxy.get(), filename);
376 void layer::clear_surfaces() {
377 ivi_controller_layer_clear_surfaces(this->proxy.get());
380 void layer::add_surface(struct surface *surface) {
381 ivi_controller_layer_add_surface(this->proxy.get(), surface->proxy.get());
384 void layer::remove_surface(struct surface *surface) {
385 ivi_controller_layer_remove_surface(this->proxy.get(), surface->proxy.get());
388 void layer::set_render_order(std::vector<uint32_t> const &ro) {
389 struct wl_array wlro {
390 .size = ro.size() * sizeof(ro[0]), .alloc = ro.capacity() * sizeof(ro[0]),
391 .data = const_cast<void *>(static_cast<void const *>(ro.data()))
393 ivi_controller_layer_set_render_order(this->proxy.get(), &wlro);
396 void controller::layer_visibility(struct layer *l, int32_t visibility) {
397 logdebug("genivi::layer %s @ %p v %i", __func__, this->proxy.get(),
399 this->lprops[l->id].visibility = visibility;
402 void controller::layer_opacity(struct layer *l, float opacity) {
403 logdebug("genivi::layer %s @ %p o %f", __func__, this->proxy.get(), opacity);
404 this->lprops[l->id].opacity = opacity;
407 void controller::layer_source_rectangle(struct layer *l, int32_t x, int32_t y,
408 int32_t width, int32_t height) {
409 logdebug("genivi::layer %s @ %p x %i y %i w %i h %i", __func__,
410 this->proxy.get(), x, y, width, height);
411 this->lprops[l->id].src_rect = rect{width, height, x, y};
414 void controller::layer_destination_rectangle(struct layer *l, int32_t x,
415 int32_t y, int32_t width,
417 logdebug("genivi::layer %s @ %p x %i y %i w %i h %i", __func__,
418 this->proxy.get(), x, y, width, height);
419 this->lprops[l->id].dst_rect = rect{width, height, x, y};
422 void controller::layer_configuration(struct layer *l, int32_t width,
424 logdebug("genivi::layer %s @ %p w %i h %i", __func__, this->proxy.get(),
426 this->lprops[l->id].size = size{uint32_t(width), uint32_t(height)};
429 void controller::layer_orientation(struct layer *l, int32_t orientation) {
430 logdebug("genivi::layer %s @ %p o %i", __func__, this->proxy.get(),
432 this->lprops[l->id].orientation = orientation;
435 void controller::layer_screen(struct layer * /*l*/, struct wl_output *screen) {
436 logdebug("genivi::layer %s @ %p s %p", __func__, this->proxy.get(), screen);
439 void controller::layer_destroyed(struct layer *l) {
440 logdebug("genivi::layer %s @ %p", __func__, this->proxy.get());
441 this->lprops.erase(l->id);
442 this->layers.erase(l->id);
446 // ___ _ _ _ __ / _| __ _ ___ ___
447 // / __| | | | '__| |_ / _` |/ __/ _ \
448 // \__ \ |_| | | | _| (_| | (_| __/
449 // |___/\__,_|_| |_| \__,_|\___\___|
453 void surface_visibility(
454 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
455 int32_t visibility) {
456 auto s = static_cast<struct surface *>(data);
457 s->parent->surface_visibility(s, visibility);
460 void surface_opacity(void *data,
461 struct ivi_controller_surface * /*ivi_controller_surface*/,
462 wl_fixed_t opacity) {
463 auto s = static_cast<struct surface *>(data);
464 s->parent->surface_opacity(s, float(wl_fixed_to_double(opacity)));
467 void surface_source_rectangle(
468 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
469 int32_t x, int32_t y, int32_t width, int32_t height) {
470 auto s = static_cast<struct surface *>(data);
471 s->parent->surface_source_rectangle(s, x, y, width, height);
474 void surface_destination_rectangle(
475 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
476 int32_t x, int32_t y, int32_t width, int32_t height) {
477 auto s = static_cast<struct surface *>(data);
478 s->parent->surface_destination_rectangle(s, x, y, width, height);
481 void surface_configuration(
482 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
483 int32_t width, int32_t height) {
484 auto s = static_cast<struct surface *>(data);
485 s->parent->surface_configuration(s, width, height);
488 void surface_orientation(
489 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
490 int32_t orientation) {
491 auto s = static_cast<struct surface *>(data);
492 s->parent->surface_orientation(s, orientation);
495 void surface_pixelformat(
496 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
497 int32_t pixelformat) {
498 auto s = static_cast<struct surface *>(data);
499 s->parent->surface_pixelformat(s, pixelformat);
502 void surface_layer(void *data,
503 struct ivi_controller_surface * /*ivi_controller_surface*/,
504 struct ivi_controller_layer *layer) {
505 auto s = static_cast<struct surface *>(data);
506 s->parent->surface_layer(s, layer);
509 void surface_stats(void *data,
510 struct ivi_controller_surface * /*ivi_controller_surface*/,
511 uint32_t redraw_count, uint32_t frame_count,
512 uint32_t update_count, uint32_t pid,
513 const char *process_name) {
514 auto s = static_cast<struct surface *>(data);
515 s->parent->surface_stats(s, redraw_count, frame_count, update_count, pid,
519 void surface_destroyed(
520 void *data, struct ivi_controller_surface * /*ivi_controller_surface*/) {
521 auto s = static_cast<struct surface *>(data);
522 s->parent->surface_destroyed(s);
525 void surface_content(void *data,
526 struct ivi_controller_surface * /*ivi_controller_surface*/,
527 int32_t content_state) {
528 auto s = static_cast<struct surface *>(data);
529 s->parent->surface_content(s, content_state);
532 constexpr struct ivi_controller_surface_listener surface_listener = {
535 surface_source_rectangle,
536 surface_destination_rectangle,
537 surface_configuration,
547 surface::surface(uint32_t i, struct controller *c)
548 : wayland_proxy(ivi_controller_surface_create(c->proxy.get(), i),
549 [c, i](ivi_controller_surface *s) {
550 logdebug("~surface surface %i @ %p", i, s);
551 c->remove_proxy_to_id_mapping(s);
552 ivi_controller_surface_destroy(s, 1);
554 controller_child(c, i) {
555 this->parent->add_proxy_to_id_mapping(this->proxy.get(), i);
556 ivi_controller_surface_add_listener(this->proxy.get(), &surface_listener,
560 void surface::set_visibility(uint32_t visibility) {
561 ivi_controller_surface_set_visibility(this->proxy.get(), visibility);
564 void surface::set_opacity(wl_fixed_t opacity) {
565 ivi_controller_surface_set_opacity(this->proxy.get(), opacity);
568 void surface::set_source_rectangle(int32_t x, int32_t y, int32_t width,
570 ivi_controller_surface_set_source_rectangle(this->proxy.get(), x, y, width,
574 void surface::set_destination_rectangle(int32_t x, int32_t y, int32_t width,
576 ivi_controller_surface_set_destination_rectangle(this->proxy.get(), x, y,
580 void surface::set_configuration(int32_t width, int32_t height) {
581 ivi_controller_surface_set_configuration(this->proxy.get(), width, height);
584 void surface::set_orientation(int32_t orientation) {
585 ivi_controller_surface_set_orientation(this->proxy.get(), orientation);
588 void surface::screenshot(const char *filename) {
589 ivi_controller_surface_screenshot(this->proxy.get(), filename);
592 void surface::send_stats() {
593 ivi_controller_surface_send_stats(this->proxy.get());
596 void surface::destroy(int32_t destroy_scene_object) {
597 ivi_controller_surface_destroy(this->proxy.get(), destroy_scene_object);
600 void controller::surface_visibility(struct surface *s, int32_t visibility) {
601 logdebug("genivi::surface %s @ %p v %i", __func__, this->proxy.get(),
603 this->sprops[s->id].visibility = visibility;
606 void controller::surface_opacity(struct surface *s, float opacity) {
607 logdebug("genivi::surface %s @ %p o %f", __func__, this->proxy.get(),
609 this->sprops[s->id].opacity = opacity;
612 void controller::surface_source_rectangle(struct surface *s, int32_t x,
613 int32_t y, int32_t width,
615 logdebug("genivi::surface %s @ %p x %i y %i w %i h %i", __func__,
616 this->proxy.get(), x, y, width, height);
617 this->sprops[s->id].src_rect = rect{width, height, x, y};
620 void controller::surface_destination_rectangle(struct surface *s, int32_t x,
621 int32_t y, int32_t width,
623 logdebug("genivi::surface %s @ %p x %i y %i w %i h %i", __func__,
624 this->proxy.get(), x, y, width, height);
625 this->sprops[s->id].dst_rect = rect{width, height, x, y};
628 void controller::surface_configuration(struct surface *s, int32_t width,
630 logdebug("genivi::surface %s @ %p w %i h %i", __func__, this->proxy.get(),
632 this->sprops[s->id].size = size{uint32_t(width), uint32_t(height)};
635 void controller::surface_orientation(struct surface *s, int32_t orientation) {
636 logdebug("genivi::surface %s @ %p o %i", __func__, this->proxy.get(),
638 this->sprops[s->id].orientation = orientation;
641 void controller::surface_pixelformat(struct surface * /*s*/,
642 int32_t pixelformat) {
643 logdebug("genivi::surface %s @ %p f %i", __func__, this->proxy.get(),
647 void controller::surface_layer(struct surface * /*s*/,
648 struct ivi_controller_layer *layer) {
649 logdebug("genivi::surface %s @ %p l %u @ %p", __func__, this->proxy.get(),
650 this->layer_proxy_to_id[uintptr_t(layer)], layer);
653 void controller::surface_stats(struct surface * /*s*/, uint32_t redraw_count,
654 uint32_t frame_count, uint32_t update_count,
655 uint32_t pid, const char *process_name) {
656 logdebug("genivi::surface %s @ %p r %u f %u u %u pid %u p %s", __func__,
657 this->proxy.get(), redraw_count, frame_count, update_count, pid,
661 void controller::surface_destroyed(struct surface *s) {
662 logdebug("genivi::surface %s @ %p", __func__, this->proxy.get());
663 this->chooks->surface_removed(s->id);
664 // XXX: do I need to actually remove the surface late, i.e. using add_task()?
665 this->sprops.erase(s->id);
666 this->surfaces.erase(s->id);
669 void controller::surface_content(struct surface *s, int32_t content_state) {
670 logdebug("genivi::surface %s @ %p s %i", __func__, this->proxy.get(),
672 if (content_state == IVI_CONTROLLER_SURFACE_CONTENT_STATE_CONTENT_REMOVED) {
673 // XXX is this the right thing to do?
674 this->chooks->surface_removed(s->id);
675 this->sprops.erase(s->id);
676 this->surfaces.erase(s->id);
680 void controller::add_proxy_to_id_mapping(struct ivi_controller_surface *p,
682 logdebug("Add surface proxy mapping for %p (%u)", p, id);
683 this->surface_proxy_to_id[uintptr_t(p)] = id;
684 this->sprops[id].id = id;
687 void controller::remove_proxy_to_id_mapping(struct ivi_controller_surface *p) {
688 logdebug("Remove surface proxy mapping for %p", p);
689 this->surface_proxy_to_id.erase(uintptr_t(p));
692 void controller::add_proxy_to_id_mapping(struct ivi_controller_layer *p,
694 logdebug("Add layer proxy mapping for %p (%u)", p, id);
695 this->layer_proxy_to_id[uintptr_t(p)] = id;
696 this->lprops[id].id = id;
699 void controller::remove_proxy_to_id_mapping(struct ivi_controller_layer *p) {
700 logdebug("Remove layer proxy mapping for %p", p);
701 this->layer_proxy_to_id.erase(uintptr_t(p));
704 void controller::add_proxy_to_id_mapping(struct wl_output *p, uint32_t id) {
705 logdebug("Add screen proxy mapping for %p (%u)", p, id);
706 this->screen_proxy_to_id[uintptr_t(p)] = id;
709 void controller::remove_proxy_to_id_mapping(struct wl_output *p) {
710 logdebug("Remove screen proxy mapping for %p", p);
711 this->screen_proxy_to_id.erase(uintptr_t(p));
715 // ___ ___ _ __ ___ ___ _ __
716 // / __|/ __| '__/ _ \/ _ \ '_ \
717 // \__ \ (__| | | __/ __/ | | |
718 // |___/\___|_| \___|\___|_| |_|
720 screen::screen(uint32_t i, struct controller *c,
721 struct ivi_controller_screen *p)
722 : wayland_proxy(p), controller_child(c, i) {
723 logdebug("genivi::screen @ %p id %u", p, i);
726 void screen::clear() { ivi_controller_screen_clear(this->proxy.get()); }
728 void screen::add_layer(layer *l) {
729 ivi_controller_screen_add_layer(this->proxy.get(), l->proxy.get());
732 void screen::set_render_order(std::vector<uint32_t> const &ro) {
733 struct wl_array wlro {
734 .size = ro.size() * sizeof(ro[0]), .alloc = ro.capacity() * sizeof(ro[0]),
735 .data = const_cast<void *>(static_cast<void const *>(ro.data()))
737 ivi_controller_screen_set_render_order(this->proxy.get(), &wlro);
740 } // namespace genivi