+void surface_configuration(
+ void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
+ int32_t width, int32_t height) {
+ auto s = static_cast<struct surface *>(data);
+ 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<struct surface *>(data);
+ 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<struct surface *>(data);
+ 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<struct surface *>(data);
+ s->parent->surface_layer(s, layer);
+}
+
+void surface_stats(void *data,
+ struct ivi_controller_surface * /*ivi_controller_surface*/,
+ uint32_t redraw_count, uint32_t frame_count,
+ uint32_t update_count, uint32_t pid,
+ const char *process_name) {
+ auto s = static_cast<struct surface *>(data);
+ 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<struct surface *>(data);
+ 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<struct surface *>(data);
+ s->parent->surface_content(s, content_state);
+}
+
+constexpr struct ivi_controller_surface_listener surface_listener = {
+ surface_visibility,
+ surface_opacity,
+ surface_source_rectangle,
+ surface_destination_rectangle,
+ surface_configuration,
+ surface_orientation,
+ surface_pixelformat,
+ surface_layer,
+ surface_stats,
+ surface_destroyed,
+ surface_content,
+};
+} // namespace
+
+surface::surface(uint32_t i, struct controller *c)
+ : wayland_proxy(ivi_controller_surface_create(c->proxy.get(), i),
+ [c, i](ivi_controller_surface *s) {
+ logdebug("~surface surface %i @ %p", i, s);
+ c->remove_proxy_to_id_mapping(s);
+ ivi_controller_surface_destroy(s, 1);
+ }),
+ controller_child(c, i),
+ dst_rect{},
+ src_rect{},
+ size{},
+ orientation{},
+ visibility{},
+ opacity{1.f} {
+ this->parent->add_proxy_to_id_mapping(this->proxy.get(), i);
+ ivi_controller_surface_add_listener(this->proxy.get(), &surface_listener,
+ this);
+}
+
+void surface::set_visibility(uint32_t visibility) {
+ ivi_controller_surface_set_visibility(this->proxy.get(), visibility);
+}
+
+void surface::set_opacity(wl_fixed_t opacity) {
+ ivi_controller_surface_set_opacity(this->proxy.get(), opacity);
+}
+
+void surface::set_source_rectangle(int32_t x, int32_t y, int32_t width,
+ int32_t height) {
+ ivi_controller_surface_set_source_rectangle(this->proxy.get(), x, y, width,
+ height);
+}
+
+void surface::set_destination_rectangle(int32_t x, int32_t y, int32_t width,
+ int32_t height) {
+ ivi_controller_surface_set_destination_rectangle(this->proxy.get(), x, y,
+ width, height);
+}
+
+void surface::set_configuration(int32_t width, int32_t height) {
+ ivi_controller_surface_set_configuration(this->proxy.get(), width, height);
+}
+
+void surface::set_orientation(int32_t orientation) {
+ ivi_controller_surface_set_orientation(this->proxy.get(), orientation);
+}
+
+void surface::screenshot(const char *filename) {
+ ivi_controller_surface_screenshot(this->proxy.get(), filename);
+}
+
+void surface::send_stats() {
+ ivi_controller_surface_send_stats(this->proxy.get());
+}
+
+void surface::destroy(int32_t destroy_scene_object) {
+ ivi_controller_surface_destroy(this->proxy.get(), destroy_scene_object);
+}
+
+void controller::surface_visibility(struct surface *s, int32_t visibility) {
+ logdebug("genivi::surface %s @ %p v %i", __func__, this->proxy.get(),
+ visibility);
+ s->visibility = visibility;
+}
+
+void controller::surface_opacity(struct surface *s, float opacity) {
+ logdebug("genivi::surface %s @ %p o %f", __func__, this->proxy.get(),
+ opacity);
+ s->opacity = opacity;