Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 DENSO CORPORATION |
| 3 | * |
Bryce Harrington | af637c2 | 2015-06-11 12:55:55 -0700 | [diff] [blame] | 4 | * Permission is hereby granted, free of charge, to any person obtaining |
| 5 | * a copy of this software and associated documentation files (the |
| 6 | * "Software"), to deal in the Software without restriction, including |
| 7 | * without limitation the rights to use, copy, modify, merge, publish, |
| 8 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 9 | * permit persons to whom the Software is furnished to do so, subject to |
| 10 | * the following conditions: |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 11 | * |
Bryce Harrington | af637c2 | 2015-06-11 12:55:55 -0700 | [diff] [blame] | 12 | * The above copyright notice and this permission notice (including the |
| 13 | * next paragraph) shall be included in all copies or substantial |
| 14 | * portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 20 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 21 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | * SOFTWARE. |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 24 | */ |
| 25 | |
| 26 | /** |
| 27 | * Implementation of ivi-layout library. The actual view on ivi_screen is |
| 28 | * not updated till calling ivi_layout_commit_changes. A overview from |
| 29 | * calling API for updating properties of ivi_surface/ivi_layer to asking |
| 30 | * compositor to compose them by using weston_compositor_schedule_repaint, |
| 31 | * 0/ initialize this library by ivi_layout_init_with_compositor |
| 32 | * with (struct weston_compositor *ec) from ivi-shell. |
| 33 | * 1/ When a API for updating properties of ivi_surface/ivi_layer, it updates |
| 34 | * pending prop of ivi_surface/ivi_layer/ivi_screen which are structure to |
| 35 | * store properties. |
| 36 | * 2/ Before calling commitChanges, in case of calling a API to get a property, |
| 37 | * return current property, not pending property. |
| 38 | * 3/ At the timing of calling ivi_layout_commitChanges, pending properties |
| 39 | * are applied to properties. |
| 40 | * |
| 41 | * *) ivi_layout_commitChanges is also called by transition animation |
| 42 | * per each frame. See ivi-layout-transition.c in details. Transition |
| 43 | * animation interpolates frames between previous properties of ivi_surface |
| 44 | * and new ones. |
| 45 | * For example, when a property of ivi_surface is changed from invisibility |
| 46 | * to visibility, it behaves like fade-in. When ivi_layout_commitChange is |
| 47 | * called during transition animation, it cancels the transition and |
| 48 | * re-start transition to new properties from current properties of final |
| 49 | * frame just before the the cancellation. |
| 50 | * |
| 51 | * 4/ According properties, set transformation by using weston_matrix and |
| 52 | * weston_view per ivi_surfaces and ivi_layers in while loop. |
| 53 | * 5/ Set damage and trigger transform by using weston_view_geometry_dirty. |
| 54 | * 6/ Notify update of properties. |
| 55 | * 7/ Trigger composition by weston_compositor_schedule_repaint. |
| 56 | * |
| 57 | */ |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 58 | #include "config.h" |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 59 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 60 | #include <string.h> |
Ucan, Emre (ADITG/SW1) | 38fcf38 | 2015-08-20 14:13:29 +0000 | [diff] [blame] | 61 | #include <assert.h> |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 62 | |
| 63 | #include "compositor.h" |
Pekka Paalanen | 1f82193 | 2016-03-15 16:57:51 +0200 | [diff] [blame] | 64 | #include "ivi-shell.h" |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 65 | #include "ivi-layout-export.h" |
| 66 | #include "ivi-layout-private.h" |
Pekka Paalanen | 32ca791 | 2016-03-15 17:21:00 +0200 | [diff] [blame] | 67 | #include "ivi-layout-shell.h" |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 68 | |
Jon Cruz | 867d50e | 2015-06-15 15:37:10 -0700 | [diff] [blame] | 69 | #include "shared/helpers.h" |
Jon Cruz | 4678bab | 2015-06-15 15:37:07 -0700 | [diff] [blame] | 70 | #include "shared/os-compatibility.h" |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 71 | |
Nobuhiko Tanibata | acbcc6c | 2015-08-24 10:24:15 +0900 | [diff] [blame] | 72 | #define max(a, b) ((a) > (b) ? (a) : (b)) |
| 73 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 74 | struct listener_layout_notification { |
| 75 | void *userdata; |
| 76 | struct wl_listener listener; |
| 77 | }; |
| 78 | |
| 79 | struct ivi_layout; |
| 80 | |
| 81 | struct ivi_layout_screen { |
| 82 | struct wl_list link; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 83 | |
| 84 | struct ivi_layout *layout; |
| 85 | struct weston_output *output; |
| 86 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 87 | struct { |
| 88 | struct wl_list layer_list; |
| 89 | struct wl_list link; |
| 90 | } pending; |
| 91 | |
| 92 | struct { |
Ucan, Emre (ADITG/SW1) | 174257b | 2015-08-20 14:13:30 +0000 | [diff] [blame] | 93 | int dirty; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 94 | struct wl_list layer_list; |
| 95 | struct wl_list link; |
| 96 | } order; |
| 97 | }; |
| 98 | |
| 99 | struct ivi_layout_notification_callback { |
| 100 | void *callback; |
| 101 | void *data; |
| 102 | }; |
| 103 | |
Nobuhiko Tanibata | 21deb28 | 2015-07-15 14:05:32 +0900 | [diff] [blame] | 104 | struct ivi_rectangle |
| 105 | { |
| 106 | int32_t x; |
| 107 | int32_t y; |
| 108 | int32_t width; |
| 109 | int32_t height; |
| 110 | }; |
| 111 | |
Nobuhiko Tanibata | 8205170 | 2015-06-22 15:31:26 +0900 | [diff] [blame] | 112 | static void |
| 113 | remove_notification(struct wl_list *listener_list, void *callback, void *userdata); |
| 114 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 115 | static struct ivi_layout ivilayout = {0}; |
| 116 | |
| 117 | struct ivi_layout * |
| 118 | get_instance(void) |
| 119 | { |
| 120 | return &ivilayout; |
| 121 | } |
| 122 | |
| 123 | /** |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 124 | * Internal API to add/remove a ivi_layer to/from ivi_screen. |
| 125 | */ |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 126 | static struct ivi_layout_surface * |
| 127 | get_surface(struct wl_list *surf_list, uint32_t id_surface) |
| 128 | { |
| 129 | struct ivi_layout_surface *ivisurf; |
| 130 | |
| 131 | wl_list_for_each(ivisurf, surf_list, link) { |
| 132 | if (ivisurf->id_surface == id_surface) { |
| 133 | return ivisurf; |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | return NULL; |
| 138 | } |
| 139 | |
| 140 | static struct ivi_layout_layer * |
| 141 | get_layer(struct wl_list *layer_list, uint32_t id_layer) |
| 142 | { |
| 143 | struct ivi_layout_layer *ivilayer; |
| 144 | |
| 145 | wl_list_for_each(ivilayer, layer_list, link) { |
| 146 | if (ivilayer->id_layer == id_layer) { |
| 147 | return ivilayer; |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | return NULL; |
| 152 | } |
| 153 | |
Ucan, Emre (ADITG/SW1) | 64635ee | 2015-08-28 12:59:06 +0000 | [diff] [blame] | 154 | static struct weston_view * |
| 155 | get_weston_view(struct ivi_layout_surface *ivisurf) |
| 156 | { |
| 157 | struct weston_view *view = NULL; |
| 158 | |
| 159 | assert(ivisurf->surface != NULL); |
| 160 | |
| 161 | /* One view per surface */ |
| 162 | if(wl_list_empty(&ivisurf->surface->views)) |
| 163 | view = NULL; |
| 164 | else |
| 165 | view = wl_container_of(ivisurf->surface->views.next, view, surface_link); |
| 166 | |
| 167 | return view; |
| 168 | } |
| 169 | |
Ucan, Emre (ADITG/SW1) | b216c92 | 2016-03-17 15:30:46 +0000 | [diff] [blame] | 170 | static struct ivi_layout_screen * |
| 171 | get_screen_from_output(struct weston_output *output) |
| 172 | { |
| 173 | struct ivi_layout *layout = get_instance(); |
| 174 | struct ivi_layout_screen *iviscrn = NULL; |
| 175 | |
| 176 | wl_list_for_each(iviscrn, &layout->screen_list, link) { |
| 177 | if (iviscrn->output == output) |
| 178 | return iviscrn; |
| 179 | } |
| 180 | |
| 181 | return NULL; |
| 182 | } |
| 183 | |
Nobuhiko Tanibata | ef6c786 | 2014-12-15 13:20:44 +0900 | [diff] [blame] | 184 | static void |
Nobuhiko Tanibata | ef6c786 | 2014-12-15 13:20:44 +0900 | [diff] [blame] | 185 | remove_all_notification(struct wl_list *listener_list) |
| 186 | { |
| 187 | struct wl_listener *listener = NULL; |
| 188 | struct wl_listener *next = NULL; |
| 189 | |
| 190 | wl_list_for_each_safe(listener, next, listener_list, link) { |
| 191 | struct listener_layout_notification *notification = NULL; |
Ucan, Emre (ADITG/SW1) | cf34dc2 | 2015-08-20 14:13:33 +0000 | [diff] [blame] | 192 | wl_list_remove(&listener->link); |
Nobuhiko Tanibata | ef6c786 | 2014-12-15 13:20:44 +0900 | [diff] [blame] | 193 | |
| 194 | notification = |
| 195 | container_of(listener, |
| 196 | struct listener_layout_notification, |
| 197 | listener); |
| 198 | |
| 199 | free(notification->userdata); |
| 200 | free(notification); |
| 201 | } |
| 202 | } |
| 203 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 204 | static void |
Nobuhiko Tanibata | ef6c786 | 2014-12-15 13:20:44 +0900 | [diff] [blame] | 205 | ivi_layout_surface_remove_notification(struct ivi_layout_surface *ivisurf) |
| 206 | { |
| 207 | if (ivisurf == NULL) { |
| 208 | weston_log("ivi_layout_surface_remove_notification: invalid argument\n"); |
| 209 | return; |
| 210 | } |
| 211 | |
| 212 | remove_all_notification(&ivisurf->property_changed.listener_list); |
| 213 | } |
| 214 | |
Nobuhiko Tanibata | 8205170 | 2015-06-22 15:31:26 +0900 | [diff] [blame] | 215 | static void |
| 216 | ivi_layout_surface_remove_notification_by_callback(struct ivi_layout_surface *ivisurf, |
| 217 | surface_property_notification_func callback, |
| 218 | void *userdata) |
| 219 | { |
| 220 | if (ivisurf == NULL) { |
| 221 | weston_log("ivi_layout_surface_remove_notification_by_callback: invalid argument\n"); |
| 222 | return; |
| 223 | } |
| 224 | |
| 225 | remove_notification(&ivisurf->property_changed.listener_list, callback, userdata); |
| 226 | } |
| 227 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 228 | /** |
Nobuhiko Tanibata | 6f6c938 | 2015-06-22 15:30:53 +0900 | [diff] [blame] | 229 | * Called at destruction of wl_surface/ivi_surface |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 230 | */ |
Nobuhiko Tanibata | 6f6c938 | 2015-06-22 15:30:53 +0900 | [diff] [blame] | 231 | void |
| 232 | ivi_layout_surface_destroy(struct ivi_layout_surface *ivisurf) |
Nobuhiko Tanibata | ef6c786 | 2014-12-15 13:20:44 +0900 | [diff] [blame] | 233 | { |
| 234 | struct ivi_layout *layout = get_instance(); |
| 235 | |
| 236 | if (ivisurf == NULL) { |
Nobuhiko Tanibata | 6f6c938 | 2015-06-22 15:30:53 +0900 | [diff] [blame] | 237 | weston_log("%s: invalid argument\n", __func__); |
Nobuhiko Tanibata | ef6c786 | 2014-12-15 13:20:44 +0900 | [diff] [blame] | 238 | return; |
| 239 | } |
| 240 | |
Nobuhiko Tanibata | 21deb28 | 2015-07-15 14:05:32 +0900 | [diff] [blame] | 241 | wl_list_remove(&ivisurf->transform.link); |
Nobuhiko Tanibata | 6f6c938 | 2015-06-22 15:30:53 +0900 | [diff] [blame] | 242 | wl_list_remove(&ivisurf->pending.link); |
| 243 | wl_list_remove(&ivisurf->order.link); |
| 244 | wl_list_remove(&ivisurf->link); |
Nobuhiko Tanibata | ef6c786 | 2014-12-15 13:20:44 +0900 | [diff] [blame] | 245 | |
| 246 | wl_signal_emit(&layout->surface_notification.removed, ivisurf); |
| 247 | |
Mateusz Polrola | dada6e3 | 2016-03-09 09:13:26 +0000 | [diff] [blame] | 248 | ivi_layout_remove_all_surface_transitions(ivisurf); |
| 249 | |
Nobuhiko Tanibata | ef6c786 | 2014-12-15 13:20:44 +0900 | [diff] [blame] | 250 | ivi_layout_surface_remove_notification(ivisurf); |
| 251 | |
Nobuhiko Tanibata | 6f6c938 | 2015-06-22 15:30:53 +0900 | [diff] [blame] | 252 | free(ivisurf); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | /** |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 256 | * Internal API to initialize ivi_screens found from output_list of weston_compositor. |
| 257 | * Called by ivi_layout_init_with_compositor. |
| 258 | */ |
| 259 | static void |
| 260 | create_screen(struct weston_compositor *ec) |
| 261 | { |
| 262 | struct ivi_layout *layout = get_instance(); |
| 263 | struct ivi_layout_screen *iviscrn = NULL; |
| 264 | struct weston_output *output = NULL; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 265 | |
| 266 | wl_list_for_each(output, &ec->output_list, link) { |
| 267 | iviscrn = calloc(1, sizeof *iviscrn); |
| 268 | if (iviscrn == NULL) { |
| 269 | weston_log("fails to allocate memory\n"); |
| 270 | continue; |
| 271 | } |
| 272 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 273 | iviscrn->layout = layout; |
| 274 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 275 | iviscrn->output = output; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 276 | |
| 277 | wl_list_init(&iviscrn->pending.layer_list); |
| 278 | wl_list_init(&iviscrn->pending.link); |
| 279 | |
| 280 | wl_list_init(&iviscrn->order.layer_list); |
| 281 | wl_list_init(&iviscrn->order.link); |
| 282 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 283 | wl_list_insert(&layout->screen_list, &iviscrn->link); |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * Internal APIs to initialize properties of ivi_surface/ivi_layer when they are created. |
| 289 | */ |
| 290 | static void |
| 291 | init_layer_properties(struct ivi_layout_layer_properties *prop, |
| 292 | int32_t width, int32_t height) |
| 293 | { |
| 294 | memset(prop, 0, sizeof *prop); |
| 295 | prop->opacity = wl_fixed_from_double(1.0); |
| 296 | prop->source_width = width; |
| 297 | prop->source_height = height; |
| 298 | prop->dest_width = width; |
| 299 | prop->dest_height = height; |
| 300 | } |
| 301 | |
| 302 | static void |
| 303 | init_surface_properties(struct ivi_layout_surface_properties *prop) |
| 304 | { |
| 305 | memset(prop, 0, sizeof *prop); |
| 306 | prop->opacity = wl_fixed_from_double(1.0); |
Nobuhiko Tanibata | e259a7a | 2015-04-27 17:02:54 +0900 | [diff] [blame] | 307 | /* |
| 308 | * FIXME: this shall be finxed by ivi-layout-transition. |
| 309 | */ |
| 310 | prop->dest_width = 1; |
| 311 | prop->dest_height = 1; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | /** |
| 315 | * Internal APIs to be called from ivi_layout_commit_changes. |
| 316 | */ |
| 317 | static void |
| 318 | update_opacity(struct ivi_layout_layer *ivilayer, |
| 319 | struct ivi_layout_surface *ivisurf) |
| 320 | { |
Ucan, Emre (ADITG/SW1) | 64635ee | 2015-08-28 12:59:06 +0000 | [diff] [blame] | 321 | struct weston_view *tmpview = NULL; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 322 | double layer_alpha = wl_fixed_to_double(ivilayer->prop.opacity); |
| 323 | double surf_alpha = wl_fixed_to_double(ivisurf->prop.opacity); |
| 324 | |
Nobuhiko Tanibata | 90c2789 | 2015-12-26 23:52:51 +0900 | [diff] [blame] | 325 | tmpview = get_weston_view(ivisurf); |
| 326 | assert(tmpview != NULL); |
| 327 | tmpview->alpha = layer_alpha * surf_alpha; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | static void |
Nobuhiko Tanibata | 21deb28 | 2015-07-15 14:05:32 +0900 | [diff] [blame] | 331 | get_rotate_values(enum wl_output_transform orientation, |
| 332 | float *v_sin, |
| 333 | float *v_cos) |
| 334 | { |
| 335 | switch (orientation) { |
| 336 | case WL_OUTPUT_TRANSFORM_90: |
| 337 | *v_sin = 1.0f; |
| 338 | *v_cos = 0.0f; |
| 339 | break; |
| 340 | case WL_OUTPUT_TRANSFORM_180: |
| 341 | *v_sin = 0.0f; |
| 342 | *v_cos = -1.0f; |
| 343 | break; |
| 344 | case WL_OUTPUT_TRANSFORM_270: |
| 345 | *v_sin = -1.0f; |
| 346 | *v_cos = 0.0f; |
| 347 | break; |
| 348 | case WL_OUTPUT_TRANSFORM_NORMAL: |
| 349 | default: |
| 350 | *v_sin = 0.0f; |
| 351 | *v_cos = 1.0f; |
| 352 | break; |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | static void |
| 357 | get_scale(enum wl_output_transform orientation, |
| 358 | float dest_width, |
| 359 | float dest_height, |
| 360 | float source_width, |
| 361 | float source_height, |
| 362 | float *scale_x, |
| 363 | float *scale_y) |
| 364 | { |
| 365 | switch (orientation) { |
| 366 | case WL_OUTPUT_TRANSFORM_90: |
| 367 | *scale_x = dest_width / source_height; |
| 368 | *scale_y = dest_height / source_width; |
| 369 | break; |
| 370 | case WL_OUTPUT_TRANSFORM_180: |
| 371 | *scale_x = dest_width / source_width; |
| 372 | *scale_y = dest_height / source_height; |
| 373 | break; |
| 374 | case WL_OUTPUT_TRANSFORM_270: |
| 375 | *scale_x = dest_width / source_height; |
| 376 | *scale_y = dest_height / source_width; |
| 377 | break; |
| 378 | case WL_OUTPUT_TRANSFORM_NORMAL: |
| 379 | default: |
| 380 | *scale_x = dest_width / source_width; |
| 381 | *scale_y = dest_height / source_height; |
| 382 | break; |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | static void |
| 387 | calc_transformation_matrix(struct ivi_rectangle *source_rect, |
| 388 | struct ivi_rectangle *dest_rect, |
| 389 | enum wl_output_transform orientation, |
| 390 | struct weston_matrix *m) |
| 391 | { |
| 392 | float source_center_x; |
| 393 | float source_center_y; |
| 394 | float vsin; |
| 395 | float vcos; |
| 396 | float scale_x; |
| 397 | float scale_y; |
| 398 | float translate_x; |
| 399 | float translate_y; |
| 400 | |
| 401 | source_center_x = source_rect->x + source_rect->width * 0.5f; |
| 402 | source_center_y = source_rect->y + source_rect->height * 0.5f; |
| 403 | weston_matrix_translate(m, -source_center_x, -source_center_y, 0.0f); |
| 404 | |
| 405 | get_rotate_values(orientation, &vsin, &vcos); |
| 406 | weston_matrix_rotate_xy(m, vcos, vsin); |
| 407 | |
| 408 | get_scale(orientation, |
| 409 | dest_rect->width, |
| 410 | dest_rect->height, |
| 411 | source_rect->width, |
| 412 | source_rect->height, |
| 413 | &scale_x, |
| 414 | &scale_y); |
| 415 | weston_matrix_scale(m, scale_x, scale_y, 1.0f); |
| 416 | |
| 417 | translate_x = dest_rect->width * 0.5f + dest_rect->x; |
| 418 | translate_y = dest_rect->height * 0.5f + dest_rect->y; |
| 419 | weston_matrix_translate(m, translate_x, translate_y, 0.0f); |
| 420 | } |
| 421 | |
Nobuhiko Tanibata | acbcc6c | 2015-08-24 10:24:15 +0900 | [diff] [blame] | 422 | /* |
| 423 | * This computes intersected rect_output from two ivi_rectangles |
Nobuhiko Tanibata | 21deb28 | 2015-07-15 14:05:32 +0900 | [diff] [blame] | 424 | */ |
| 425 | static void |
Nobuhiko Tanibata | acbcc6c | 2015-08-24 10:24:15 +0900 | [diff] [blame] | 426 | ivi_rectangle_intersect(const struct ivi_rectangle *rect1, |
| 427 | const struct ivi_rectangle *rect2, |
| 428 | struct ivi_rectangle *rect_output) |
| 429 | { |
| 430 | int32_t rect1_right = rect1->x + rect1->width; |
| 431 | int32_t rect1_bottom = rect1->y + rect1->height; |
| 432 | int32_t rect2_right = rect2->x + rect2->width; |
| 433 | int32_t rect2_bottom = rect2->y + rect2->height; |
| 434 | |
| 435 | rect_output->x = max(rect1->x, rect2->x); |
| 436 | rect_output->y = max(rect1->y, rect2->y); |
| 437 | rect_output->width = rect1_right < rect2_right ? |
| 438 | rect1_right - rect_output->x : |
| 439 | rect2_right - rect_output->x; |
| 440 | rect_output->height = rect1_bottom < rect2_bottom ? |
| 441 | rect1_bottom - rect_output->y : |
| 442 | rect2_bottom - rect_output->y; |
| 443 | |
| 444 | if (rect_output->width < 0 || rect_output->height < 0) { |
| 445 | rect_output->width = 0; |
| 446 | rect_output->height = 0; |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | /* |
| 451 | * Transform rect_input by the inverse of matrix, intersect with boundingbox, |
| 452 | * and store the result in rect_output. |
| 453 | * The boundingbox must be given in the same coordinate space as rect_output. |
| 454 | * Additionally, there are the following restrictions on the matrix: |
| 455 | * - no projective transformations |
| 456 | * - no skew |
| 457 | * - only multiples of 90-degree rotations supported |
| 458 | * |
| 459 | * In failure case of weston_matrix_invert, rect_output is set to boundingbox |
| 460 | * as a fail-safe with log. |
| 461 | */ |
| 462 | static void |
| 463 | calc_inverse_matrix_transform(const struct weston_matrix *matrix, |
| 464 | const struct ivi_rectangle *rect_input, |
| 465 | const struct ivi_rectangle *boundingbox, |
| 466 | struct ivi_rectangle *rect_output) |
| 467 | { |
| 468 | struct weston_matrix m; |
| 469 | struct weston_vector top_left; |
| 470 | struct weston_vector bottom_right; |
| 471 | |
| 472 | assert(boundingbox != rect_output); |
| 473 | |
| 474 | if (weston_matrix_invert(&m, matrix) < 0) { |
| 475 | weston_log("ivi-shell: calc_inverse_matrix_transform fails to invert a matrix.\n"); |
| 476 | weston_log("ivi-shell: boundingbox is set to the rect_output.\n"); |
| 477 | rect_output->x = boundingbox->x; |
| 478 | rect_output->y = boundingbox->y; |
| 479 | rect_output->width = boundingbox->width; |
| 480 | rect_output->height = boundingbox->height; |
| 481 | } |
| 482 | |
| 483 | /* The vectors and matrices involved will always produce f[3] == 1.0. */ |
| 484 | top_left.f[0] = rect_input->x; |
| 485 | top_left.f[1] = rect_input->y; |
| 486 | top_left.f[2] = 0.0f; |
| 487 | top_left.f[3] = 1.0f; |
| 488 | |
| 489 | bottom_right.f[0] = rect_input->x + rect_input->width; |
| 490 | bottom_right.f[1] = rect_input->y + rect_input->height; |
| 491 | bottom_right.f[2] = 0.0f; |
| 492 | bottom_right.f[3] = 1.0f; |
| 493 | |
| 494 | weston_matrix_transform(&m, &top_left); |
| 495 | weston_matrix_transform(&m, &bottom_right); |
| 496 | |
| 497 | if (top_left.f[0] < bottom_right.f[0]) { |
| 498 | rect_output->x = top_left.f[0]; |
| 499 | rect_output->width = bottom_right.f[0] - rect_output->x; |
| 500 | } else { |
| 501 | rect_output->x = bottom_right.f[0]; |
| 502 | rect_output->width = top_left.f[0] - rect_output->x; |
| 503 | } |
| 504 | |
| 505 | if (top_left.f[1] < bottom_right.f[1]) { |
| 506 | rect_output->y = top_left.f[1]; |
| 507 | rect_output->height = bottom_right.f[1] - rect_output->y; |
| 508 | } else { |
| 509 | rect_output->y = bottom_right.f[1]; |
| 510 | rect_output->height = top_left.f[1] - rect_output->y; |
| 511 | } |
| 512 | |
| 513 | ivi_rectangle_intersect(rect_output, boundingbox, rect_output); |
| 514 | } |
| 515 | |
| 516 | /** |
| 517 | * This computes the whole transformation matrix:m from surface-local |
Nobuhiko Tanibata | 1c2618e | 2015-12-09 15:39:26 +0900 | [diff] [blame] | 518 | * coordinates to multi screens coordinate, which is global coordinates. |
| 519 | * It is assumed that weston_view::geometry.{x,y} are zero. |
Nobuhiko Tanibata | acbcc6c | 2015-08-24 10:24:15 +0900 | [diff] [blame] | 520 | * |
| 521 | * Additionally, this computes the mask on surface-local coordinates as a |
| 522 | * ivi_rectangle. This can be set to weston_view_set_mask. |
| 523 | * |
| 524 | * The mask is computed by following steps |
Nobuhiko Tanibata | 1c2618e | 2015-12-09 15:39:26 +0900 | [diff] [blame] | 525 | * - destination rectangle of layer is tansformed to multi screen coordinate, |
| 526 | * global coordinates. This is done by adding weston_output.{x,y} in simple |
| 527 | * because there is no scaled and rotated transformation. |
| 528 | * - destination rectangle of layer in multi screens coordinate needs to be |
| 529 | * intersected inside of a screen the layer is assigned to. This is because |
| 530 | * overlapped region of weston surface in another screen shall not be |
| 531 | * displayed according to ivi use case. |
| 532 | * - destination rectangle of layer |
| 533 | * - in multi screen coordinates, |
| 534 | * - and intersected inside of an assigned screen, |
| 535 | * is inversed to surface-local cooodinates by inversed matrix:m. |
Nobuhiko Tanibata | acbcc6c | 2015-08-24 10:24:15 +0900 | [diff] [blame] | 536 | * - the area is intersected by intersected area between weston_surface and |
| 537 | * source rectangle of ivi_surface. |
| 538 | */ |
| 539 | static void |
| 540 | calc_surface_to_global_matrix_and_mask_to_weston_surface( |
Nobuhiko Tanibata | 29babdf | 2015-12-09 15:38:41 +0900 | [diff] [blame] | 541 | struct ivi_layout_screen *iviscrn, |
Nobuhiko Tanibata | acbcc6c | 2015-08-24 10:24:15 +0900 | [diff] [blame] | 542 | struct ivi_layout_layer *ivilayer, |
| 543 | struct ivi_layout_surface *ivisurf, |
| 544 | struct weston_matrix *m, |
| 545 | struct ivi_rectangle *result) |
Nobuhiko Tanibata | 21deb28 | 2015-07-15 14:05:32 +0900 | [diff] [blame] | 546 | { |
| 547 | const struct ivi_layout_surface_properties *sp = &ivisurf->prop; |
| 548 | const struct ivi_layout_layer_properties *lp = &ivilayer->prop; |
Nobuhiko Tanibata | 29babdf | 2015-12-09 15:38:41 +0900 | [diff] [blame] | 549 | struct weston_output *output = iviscrn->output; |
Nobuhiko Tanibata | acbcc6c | 2015-08-24 10:24:15 +0900 | [diff] [blame] | 550 | struct ivi_rectangle weston_surface_rect = { 0, |
| 551 | 0, |
| 552 | ivisurf->surface->width, |
| 553 | ivisurf->surface->height }; |
Nobuhiko Tanibata | 21deb28 | 2015-07-15 14:05:32 +0900 | [diff] [blame] | 554 | struct ivi_rectangle surface_source_rect = { sp->source_x, |
| 555 | sp->source_y, |
| 556 | sp->source_width, |
| 557 | sp->source_height }; |
| 558 | struct ivi_rectangle surface_dest_rect = { sp->dest_x, |
| 559 | sp->dest_y, |
| 560 | sp->dest_width, |
| 561 | sp->dest_height }; |
| 562 | struct ivi_rectangle layer_source_rect = { lp->source_x, |
| 563 | lp->source_y, |
| 564 | lp->source_width, |
| 565 | lp->source_height }; |
| 566 | struct ivi_rectangle layer_dest_rect = { lp->dest_x, |
| 567 | lp->dest_y, |
| 568 | lp->dest_width, |
| 569 | lp->dest_height }; |
Nobuhiko Tanibata | 1c2618e | 2015-12-09 15:39:26 +0900 | [diff] [blame] | 570 | struct ivi_rectangle screen_dest_rect = { output->x, |
| 571 | output->y, |
| 572 | output->width, |
| 573 | output->height }; |
| 574 | struct ivi_rectangle layer_dest_rect_in_global = |
| 575 | { lp->dest_x + output->x, |
| 576 | lp->dest_y + output->y, |
| 577 | lp->dest_width, |
| 578 | lp->dest_height }; |
Nobuhiko Tanibata | acbcc6c | 2015-08-24 10:24:15 +0900 | [diff] [blame] | 579 | struct ivi_rectangle surface_result; |
Nobuhiko Tanibata | 1c2618e | 2015-12-09 15:39:26 +0900 | [diff] [blame] | 580 | struct ivi_rectangle layer_dest_rect_in_global_intersected; |
Nobuhiko Tanibata | 21deb28 | 2015-07-15 14:05:32 +0900 | [diff] [blame] | 581 | |
Nobuhiko Tanibata | acbcc6c | 2015-08-24 10:24:15 +0900 | [diff] [blame] | 582 | /* |
| 583 | * the whole transformation matrix:m from surface-local |
| 584 | * coordinates to global coordinates, which is computed by |
| 585 | * two steps, |
| 586 | * - surface-local coordinates to layer-local coordinates |
Nobuhiko Tanibata | 29babdf | 2015-12-09 15:38:41 +0900 | [diff] [blame] | 587 | * - layer-local coordinates to a single screen-local coordinates |
| 588 | * - a single screen-local coordinates to multi screen coordinates, |
| 589 | * which is global coordinates. |
Nobuhiko Tanibata | acbcc6c | 2015-08-24 10:24:15 +0900 | [diff] [blame] | 590 | */ |
Nobuhiko Tanibata | 21deb28 | 2015-07-15 14:05:32 +0900 | [diff] [blame] | 591 | calc_transformation_matrix(&surface_source_rect, |
| 592 | &surface_dest_rect, |
| 593 | sp->orientation, m); |
| 594 | |
| 595 | calc_transformation_matrix(&layer_source_rect, |
| 596 | &layer_dest_rect, |
| 597 | lp->orientation, m); |
Nobuhiko Tanibata | acbcc6c | 2015-08-24 10:24:15 +0900 | [diff] [blame] | 598 | |
Nobuhiko Tanibata | 29babdf | 2015-12-09 15:38:41 +0900 | [diff] [blame] | 599 | weston_matrix_translate(m, output->x, output->y, 0.0f); |
| 600 | |
Nobuhiko Tanibata | acbcc6c | 2015-08-24 10:24:15 +0900 | [diff] [blame] | 601 | /* this intersected ivi_rectangle would be used for masking |
| 602 | * weston_surface |
| 603 | */ |
| 604 | ivi_rectangle_intersect(&surface_source_rect, &weston_surface_rect, |
| 605 | &surface_result); |
| 606 | |
Nobuhiko Tanibata | 1c2618e | 2015-12-09 15:39:26 +0900 | [diff] [blame] | 607 | /* |
| 608 | * destination rectangle of layer in multi screens coordinate |
| 609 | * is intersected to avoid displaying outside of an assigned screen. |
| 610 | */ |
| 611 | ivi_rectangle_intersect(&layer_dest_rect_in_global, &screen_dest_rect, |
| 612 | &layer_dest_rect_in_global_intersected); |
| 613 | |
Nobuhiko Tanibata | acbcc6c | 2015-08-24 10:24:15 +0900 | [diff] [blame] | 614 | /* calc masking area of weston_surface from m */ |
| 615 | calc_inverse_matrix_transform(m, |
Nobuhiko Tanibata | 1c2618e | 2015-12-09 15:39:26 +0900 | [diff] [blame] | 616 | &layer_dest_rect_in_global_intersected, |
Nobuhiko Tanibata | acbcc6c | 2015-08-24 10:24:15 +0900 | [diff] [blame] | 617 | &surface_result, |
| 618 | result); |
Nobuhiko Tanibata | 21deb28 | 2015-07-15 14:05:32 +0900 | [diff] [blame] | 619 | } |
| 620 | |
| 621 | static void |
Nobuhiko Tanibata | b4cb25d | 2015-12-09 15:36:58 +0900 | [diff] [blame] | 622 | update_prop(struct ivi_layout_screen *iviscrn, |
| 623 | struct ivi_layout_layer *ivilayer, |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 624 | struct ivi_layout_surface *ivisurf) |
| 625 | { |
Nobuhiko Tanibata | 4c1dbf7 | 2015-07-15 13:55:50 +0900 | [diff] [blame] | 626 | struct weston_view *tmpview; |
Nobuhiko Tanibata | acbcc6c | 2015-08-24 10:24:15 +0900 | [diff] [blame] | 627 | struct ivi_rectangle r; |
Nobuhiko Tanibata | 21deb28 | 2015-07-15 14:05:32 +0900 | [diff] [blame] | 628 | bool can_calc = true; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 629 | |
Nobuhiko Tanibata | b4cb25d | 2015-12-09 15:36:58 +0900 | [diff] [blame] | 630 | /*In case of no prop change, this just returns*/ |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 631 | if (!ivilayer->prop.event_mask && !ivisurf->prop.event_mask) |
Nobuhiko Tanibata | 4c1dbf7 | 2015-07-15 13:55:50 +0900 | [diff] [blame] | 632 | return; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 633 | |
Nobuhiko Tanibata | 4c1dbf7 | 2015-07-15 13:55:50 +0900 | [diff] [blame] | 634 | update_opacity(ivilayer, ivisurf); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 635 | |
Ucan, Emre (ADITG/SW1) | 64635ee | 2015-08-28 12:59:06 +0000 | [diff] [blame] | 636 | tmpview = get_weston_view(ivisurf); |
| 637 | assert(tmpview != NULL); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 638 | |
Nobuhiko Tanibata | 21deb28 | 2015-07-15 14:05:32 +0900 | [diff] [blame] | 639 | if (ivisurf->prop.source_width == 0 || ivisurf->prop.source_height == 0) { |
| 640 | weston_log("ivi-shell: source rectangle is not yet set by ivi_layout_surface_set_source_rectangle\n"); |
| 641 | can_calc = false; |
| 642 | } |
| 643 | |
| 644 | if (ivisurf->prop.dest_width == 0 || ivisurf->prop.dest_height == 0) { |
| 645 | weston_log("ivi-shell: destination rectangle is not yet set by ivi_layout_surface_set_destination_rectangle\n"); |
| 646 | can_calc = false; |
| 647 | } |
| 648 | |
| 649 | if (can_calc) { |
| 650 | wl_list_remove(&ivisurf->transform.link); |
| 651 | weston_matrix_init(&ivisurf->transform.matrix); |
| 652 | |
Nobuhiko Tanibata | acbcc6c | 2015-08-24 10:24:15 +0900 | [diff] [blame] | 653 | calc_surface_to_global_matrix_and_mask_to_weston_surface( |
Nobuhiko Tanibata | 29babdf | 2015-12-09 15:38:41 +0900 | [diff] [blame] | 654 | iviscrn, ivilayer, ivisurf, &ivisurf->transform.matrix, &r); |
Nobuhiko Tanibata | 21deb28 | 2015-07-15 14:05:32 +0900 | [diff] [blame] | 655 | |
Ucan, Emre (ADITG/SW1) | 64635ee | 2015-08-28 12:59:06 +0000 | [diff] [blame] | 656 | weston_view_set_mask(tmpview, r.x, r.y, r.width, r.height); |
| 657 | wl_list_insert(&tmpview->geometry.transformation_list, |
| 658 | &ivisurf->transform.link); |
Nobuhiko Tanibata | 21deb28 | 2015-07-15 14:05:32 +0900 | [diff] [blame] | 659 | |
Ucan, Emre (ADITG/SW1) | 64635ee | 2015-08-28 12:59:06 +0000 | [diff] [blame] | 660 | weston_view_set_transform_parent(tmpview, NULL); |
Nobuhiko Tanibata | 21deb28 | 2015-07-15 14:05:32 +0900 | [diff] [blame] | 661 | } |
| 662 | |
| 663 | ivisurf->update_count++; |
| 664 | |
Ucan, Emre (ADITG/SW1) | 64635ee | 2015-08-28 12:59:06 +0000 | [diff] [blame] | 665 | weston_view_geometry_dirty(tmpview); |
Nobuhiko Tanibata | 4c1dbf7 | 2015-07-15 13:55:50 +0900 | [diff] [blame] | 666 | |
Ucan, Emre (ADITG/SW1) | 64635ee | 2015-08-28 12:59:06 +0000 | [diff] [blame] | 667 | weston_surface_damage(ivisurf->surface); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 668 | } |
| 669 | |
| 670 | static void |
| 671 | commit_changes(struct ivi_layout *layout) |
| 672 | { |
| 673 | struct ivi_layout_screen *iviscrn = NULL; |
| 674 | struct ivi_layout_layer *ivilayer = NULL; |
| 675 | struct ivi_layout_surface *ivisurf = NULL; |
| 676 | |
| 677 | wl_list_for_each(iviscrn, &layout->screen_list, link) { |
| 678 | wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) { |
Nobuhiko Tanibata | b4cb25d | 2015-12-09 15:36:58 +0900 | [diff] [blame] | 679 | /* |
| 680 | * If ivilayer is invisible, weston_view of ivisurf doesn't |
| 681 | * need to be modified. |
| 682 | */ |
| 683 | if (ivilayer->prop.visibility == false) |
| 684 | continue; |
| 685 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 686 | wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) { |
Nobuhiko Tanibata | b4cb25d | 2015-12-09 15:36:58 +0900 | [diff] [blame] | 687 | /* |
| 688 | * If ivilayer is invisible, weston_view of ivisurf doesn't |
| 689 | * need to be modified. |
| 690 | */ |
| 691 | if (ivisurf->prop.visibility == false) |
| 692 | continue; |
| 693 | |
| 694 | update_prop(iviscrn, ivilayer, ivisurf); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 695 | } |
| 696 | } |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | static void |
| 701 | commit_surface_list(struct ivi_layout *layout) |
| 702 | { |
| 703 | struct ivi_layout_surface *ivisurf = NULL; |
| 704 | int32_t dest_x = 0; |
| 705 | int32_t dest_y = 0; |
| 706 | int32_t dest_width = 0; |
| 707 | int32_t dest_height = 0; |
| 708 | int32_t configured = 0; |
| 709 | |
| 710 | wl_list_for_each(ivisurf, &layout->surface_list, link) { |
Dawid Gajownik | 74a635b | 2015-08-06 17:12:19 -0300 | [diff] [blame] | 711 | if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEFAULT) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 712 | dest_x = ivisurf->prop.dest_x; |
| 713 | dest_y = ivisurf->prop.dest_y; |
| 714 | dest_width = ivisurf->prop.dest_width; |
| 715 | dest_height = ivisurf->prop.dest_height; |
| 716 | |
| 717 | ivi_layout_transition_move_resize_view(ivisurf, |
| 718 | ivisurf->pending.prop.dest_x, |
| 719 | ivisurf->pending.prop.dest_y, |
| 720 | ivisurf->pending.prop.dest_width, |
| 721 | ivisurf->pending.prop.dest_height, |
| 722 | ivisurf->pending.prop.transition_duration); |
| 723 | |
Dawid Gajownik | 74a635b | 2015-08-06 17:12:19 -0300 | [diff] [blame] | 724 | if (ivisurf->pending.prop.visibility) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 725 | ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration); |
| 726 | } else { |
| 727 | ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration); |
| 728 | } |
| 729 | |
| 730 | ivisurf->prop = ivisurf->pending.prop; |
| 731 | ivisurf->prop.dest_x = dest_x; |
| 732 | ivisurf->prop.dest_y = dest_y; |
| 733 | ivisurf->prop.dest_width = dest_width; |
| 734 | ivisurf->prop.dest_height = dest_height; |
| 735 | ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 736 | ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 737 | |
Dawid Gajownik | 74a635b | 2015-08-06 17:12:19 -0300 | [diff] [blame] | 738 | } else if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEST_RECT_ONLY) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 739 | dest_x = ivisurf->prop.dest_x; |
| 740 | dest_y = ivisurf->prop.dest_y; |
| 741 | dest_width = ivisurf->prop.dest_width; |
| 742 | dest_height = ivisurf->prop.dest_height; |
| 743 | |
| 744 | ivi_layout_transition_move_resize_view(ivisurf, |
| 745 | ivisurf->pending.prop.dest_x, |
| 746 | ivisurf->pending.prop.dest_y, |
| 747 | ivisurf->pending.prop.dest_width, |
| 748 | ivisurf->pending.prop.dest_height, |
| 749 | ivisurf->pending.prop.transition_duration); |
| 750 | |
| 751 | ivisurf->prop = ivisurf->pending.prop; |
| 752 | ivisurf->prop.dest_x = dest_x; |
| 753 | ivisurf->prop.dest_y = dest_y; |
| 754 | ivisurf->prop.dest_width = dest_width; |
| 755 | ivisurf->prop.dest_height = dest_height; |
| 756 | |
| 757 | ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 758 | ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 759 | |
Dawid Gajownik | 74a635b | 2015-08-06 17:12:19 -0300 | [diff] [blame] | 760 | } else if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 761 | configured = 0; |
Dawid Gajownik | 74a635b | 2015-08-06 17:12:19 -0300 | [diff] [blame] | 762 | if (ivisurf->pending.prop.visibility) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 763 | ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration); |
| 764 | } else { |
| 765 | ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration); |
| 766 | } |
| 767 | |
| 768 | if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width || |
| 769 | ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) { |
| 770 | configured = 1; |
| 771 | } |
| 772 | |
| 773 | ivisurf->prop = ivisurf->pending.prop; |
| 774 | ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 775 | ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 776 | |
Pekka Paalanen | 1f82193 | 2016-03-15 16:57:51 +0200 | [diff] [blame] | 777 | if (configured && !is_surface_transition(ivisurf)) { |
Pekka Paalanen | 1f82193 | 2016-03-15 16:57:51 +0200 | [diff] [blame] | 778 | shell_surface_send_configure(ivisurf->surface, |
| 779 | ivisurf->prop.dest_width, |
| 780 | ivisurf->prop.dest_height); |
| 781 | } |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 782 | } else { |
| 783 | configured = 0; |
| 784 | if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width || |
| 785 | ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) { |
| 786 | configured = 1; |
| 787 | } |
| 788 | |
| 789 | ivisurf->prop = ivisurf->pending.prop; |
| 790 | ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 791 | ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 792 | |
Pekka Paalanen | 1f82193 | 2016-03-15 16:57:51 +0200 | [diff] [blame] | 793 | if (configured && !is_surface_transition(ivisurf)) { |
Pekka Paalanen | 1f82193 | 2016-03-15 16:57:51 +0200 | [diff] [blame] | 794 | shell_surface_send_configure(ivisurf->surface, |
| 795 | ivisurf->prop.dest_width, |
| 796 | ivisurf->prop.dest_height); |
| 797 | } |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 798 | } |
| 799 | } |
| 800 | } |
| 801 | |
| 802 | static void |
| 803 | commit_layer_list(struct ivi_layout *layout) |
| 804 | { |
| 805 | struct ivi_layout_layer *ivilayer = NULL; |
| 806 | struct ivi_layout_surface *ivisurf = NULL; |
| 807 | struct ivi_layout_surface *next = NULL; |
| 808 | |
| 809 | wl_list_for_each(ivilayer, &layout->layer_list, link) { |
Dawid Gajownik | 74a635b | 2015-08-06 17:12:19 -0300 | [diff] [blame] | 810 | if (ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_MOVE) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 811 | ivi_layout_transition_move_layer(ivilayer, ivilayer->pending.prop.dest_x, ivilayer->pending.prop.dest_y, ivilayer->pending.prop.transition_duration); |
Dawid Gajownik | 74a635b | 2015-08-06 17:12:19 -0300 | [diff] [blame] | 812 | } else if (ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_FADE) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 813 | ivi_layout_transition_fade_layer(ivilayer,ivilayer->pending.prop.is_fade_in, |
| 814 | ivilayer->pending.prop.start_alpha,ivilayer->pending.prop.end_alpha, |
| 815 | NULL, NULL, |
| 816 | ivilayer->pending.prop.transition_duration); |
| 817 | } |
| 818 | ivilayer->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 819 | |
| 820 | ivilayer->prop = ivilayer->pending.prop; |
| 821 | |
Ucan, Emre (ADITG/SW1) | 38fcf38 | 2015-08-20 14:13:29 +0000 | [diff] [blame] | 822 | if (!ivilayer->order.dirty) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 823 | continue; |
| 824 | } |
| 825 | |
Ucan, Emre (ADITG/SW1) | 38fcf38 | 2015-08-20 14:13:29 +0000 | [diff] [blame] | 826 | wl_list_for_each_safe(ivisurf, next, &ivilayer->order.surface_list, |
| 827 | order.link) { |
Ucan, Emre (ADITG/SW1) | dfac375 | 2015-08-28 12:58:58 +0000 | [diff] [blame] | 828 | ivisurf->on_layer = NULL; |
Ucan, Emre (ADITG/SW1) | 38fcf38 | 2015-08-20 14:13:29 +0000 | [diff] [blame] | 829 | wl_list_remove(&ivisurf->order.link); |
| 830 | wl_list_init(&ivisurf->order.link); |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 831 | ivisurf->prop.event_mask |= IVI_NOTIFICATION_REMOVE; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 832 | } |
| 833 | |
Ucan, Emre (ADITG/SW1) | 38fcf38 | 2015-08-20 14:13:29 +0000 | [diff] [blame] | 834 | assert(wl_list_empty(&ivilayer->order.surface_list)); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 835 | |
Ucan, Emre (ADITG/SW1) | 38fcf38 | 2015-08-20 14:13:29 +0000 | [diff] [blame] | 836 | wl_list_for_each(ivisurf, &ivilayer->pending.surface_list, |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 837 | pending.link) { |
Ucan, Emre (ADITG/SW1) | 38fcf38 | 2015-08-20 14:13:29 +0000 | [diff] [blame] | 838 | wl_list_remove(&ivisurf->order.link); |
| 839 | wl_list_insert(&ivilayer->order.surface_list, |
| 840 | &ivisurf->order.link); |
Ucan, Emre (ADITG/SW1) | dfac375 | 2015-08-28 12:58:58 +0000 | [diff] [blame] | 841 | ivisurf->on_layer = ivilayer; |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 842 | ivisurf->prop.event_mask |= IVI_NOTIFICATION_ADD; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 843 | } |
Ucan, Emre (ADITG/SW1) | 38fcf38 | 2015-08-20 14:13:29 +0000 | [diff] [blame] | 844 | |
| 845 | ivilayer->order.dirty = 0; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 846 | } |
| 847 | } |
| 848 | |
| 849 | static void |
| 850 | commit_screen_list(struct ivi_layout *layout) |
| 851 | { |
| 852 | struct ivi_layout_screen *iviscrn = NULL; |
| 853 | struct ivi_layout_layer *ivilayer = NULL; |
| 854 | struct ivi_layout_layer *next = NULL; |
| 855 | struct ivi_layout_surface *ivisurf = NULL; |
Ucan, Emre (ADITG/SW1) | 64635ee | 2015-08-28 12:59:06 +0000 | [diff] [blame] | 856 | struct weston_view *tmpview = NULL; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 857 | |
Nobuhiko Tanibata | fbfa8f2 | 2015-11-25 23:36:57 +0900 | [diff] [blame] | 858 | /* Clear view list of layout ivi_layer */ |
| 859 | wl_list_init(&layout->layout_layer.view_list.link); |
| 860 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 861 | wl_list_for_each(iviscrn, &layout->screen_list, link) { |
Ucan, Emre (ADITG/SW1) | 174257b | 2015-08-20 14:13:30 +0000 | [diff] [blame] | 862 | if (iviscrn->order.dirty) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 863 | wl_list_for_each_safe(ivilayer, next, |
| 864 | &iviscrn->order.layer_list, order.link) { |
Ucan, Emre (ADITG/SW1) | 8a22367 | 2015-08-28 12:58:55 +0000 | [diff] [blame] | 865 | ivilayer->on_screen = NULL; |
Ucan, Emre (ADITG/SW1) | 174257b | 2015-08-20 14:13:30 +0000 | [diff] [blame] | 866 | wl_list_remove(&ivilayer->order.link); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 867 | wl_list_init(&ivilayer->order.link); |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 868 | ivilayer->prop.event_mask |= IVI_NOTIFICATION_REMOVE; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 869 | } |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 870 | |
Ucan, Emre (ADITG/SW1) | 174257b | 2015-08-20 14:13:30 +0000 | [diff] [blame] | 871 | assert(wl_list_empty(&iviscrn->order.layer_list)); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 872 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 873 | wl_list_for_each(ivilayer, &iviscrn->pending.layer_list, |
| 874 | pending.link) { |
Nobuhiko Tanibata | 77b0ee1 | 2015-11-25 23:36:46 +0900 | [diff] [blame] | 875 | /* FIXME: avoid to insert order.link to multiple screens */ |
| 876 | wl_list_remove(&ivilayer->order.link); |
| 877 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 878 | wl_list_insert(&iviscrn->order.layer_list, |
| 879 | &ivilayer->order.link); |
Ucan, Emre (ADITG/SW1) | 8a22367 | 2015-08-28 12:58:55 +0000 | [diff] [blame] | 880 | ivilayer->on_screen = iviscrn; |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 881 | ivilayer->prop.event_mask |= IVI_NOTIFICATION_ADD; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 882 | } |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 883 | |
Ucan, Emre (ADITG/SW1) | 174257b | 2015-08-20 14:13:30 +0000 | [diff] [blame] | 884 | iviscrn->order.dirty = 0; |
| 885 | } |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 886 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 887 | wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) { |
| 888 | if (ivilayer->prop.visibility == false) |
| 889 | continue; |
| 890 | |
| 891 | wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 892 | if (ivisurf->prop.visibility == false) |
| 893 | continue; |
Ucan, Emre (ADITG/SW1) | 64635ee | 2015-08-28 12:59:06 +0000 | [diff] [blame] | 894 | |
| 895 | tmpview = get_weston_view(ivisurf); |
| 896 | assert(tmpview != NULL); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 897 | |
| 898 | weston_layer_entry_insert(&layout->layout_layer.view_list, |
| 899 | &tmpview->layer_link); |
| 900 | |
| 901 | ivisurf->surface->output = iviscrn->output; |
| 902 | } |
| 903 | } |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 904 | } |
| 905 | } |
| 906 | |
| 907 | static void |
| 908 | commit_transition(struct ivi_layout* layout) |
| 909 | { |
Dawid Gajownik | 74a635b | 2015-08-06 17:12:19 -0300 | [diff] [blame] | 910 | if (wl_list_empty(&layout->pending_transition_list)) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 911 | return; |
| 912 | } |
| 913 | |
| 914 | wl_list_insert_list(&layout->transitions->transition_list, |
| 915 | &layout->pending_transition_list); |
| 916 | |
| 917 | wl_list_init(&layout->pending_transition_list); |
| 918 | |
| 919 | wl_event_source_timer_update(layout->transitions->event_source, 1); |
| 920 | } |
| 921 | |
| 922 | static void |
| 923 | send_surface_prop(struct ivi_layout_surface *ivisurf) |
| 924 | { |
| 925 | wl_signal_emit(&ivisurf->property_changed, ivisurf); |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 926 | ivisurf->pending.prop.event_mask = 0; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 927 | } |
| 928 | |
| 929 | static void |
| 930 | send_layer_prop(struct ivi_layout_layer *ivilayer) |
| 931 | { |
| 932 | wl_signal_emit(&ivilayer->property_changed, ivilayer); |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 933 | ivilayer->pending.prop.event_mask = 0; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 934 | } |
| 935 | |
| 936 | static void |
| 937 | send_prop(struct ivi_layout *layout) |
| 938 | { |
| 939 | struct ivi_layout_layer *ivilayer = NULL; |
| 940 | struct ivi_layout_surface *ivisurf = NULL; |
| 941 | |
| 942 | wl_list_for_each_reverse(ivilayer, &layout->layer_list, link) { |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 943 | if (ivilayer->prop.event_mask) |
Nobuhiko Tanibata | 6ce3ef8 | 2015-06-22 15:32:06 +0900 | [diff] [blame] | 944 | send_layer_prop(ivilayer); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 945 | } |
| 946 | |
| 947 | wl_list_for_each_reverse(ivisurf, &layout->surface_list, link) { |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 948 | if (ivisurf->prop.event_mask) |
Nobuhiko Tanibata | 6ce3ef8 | 2015-06-22 15:32:06 +0900 | [diff] [blame] | 949 | send_surface_prop(ivisurf); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 950 | } |
| 951 | } |
| 952 | |
| 953 | static void |
| 954 | clear_surface_pending_list(struct ivi_layout_layer *ivilayer) |
| 955 | { |
| 956 | struct ivi_layout_surface *surface_link = NULL; |
| 957 | struct ivi_layout_surface *surface_next = NULL; |
| 958 | |
| 959 | wl_list_for_each_safe(surface_link, surface_next, |
| 960 | &ivilayer->pending.surface_list, pending.link) { |
Ucan, Emre (ADITG/SW1) | cf34dc2 | 2015-08-20 14:13:33 +0000 | [diff] [blame] | 961 | wl_list_remove(&surface_link->pending.link); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 962 | wl_list_init(&surface_link->pending.link); |
| 963 | } |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 964 | } |
| 965 | |
| 966 | static void |
| 967 | clear_surface_order_list(struct ivi_layout_layer *ivilayer) |
| 968 | { |
| 969 | struct ivi_layout_surface *surface_link = NULL; |
| 970 | struct ivi_layout_surface *surface_next = NULL; |
| 971 | |
| 972 | wl_list_for_each_safe(surface_link, surface_next, |
| 973 | &ivilayer->order.surface_list, order.link) { |
Ucan, Emre (ADITG/SW1) | cf34dc2 | 2015-08-20 14:13:33 +0000 | [diff] [blame] | 974 | wl_list_remove(&surface_link->order.link); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 975 | wl_list_init(&surface_link->order.link); |
| 976 | } |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 977 | } |
| 978 | |
| 979 | static void |
| 980 | layer_created(struct wl_listener *listener, void *data) |
| 981 | { |
| 982 | struct ivi_layout_layer *ivilayer = data; |
| 983 | |
| 984 | struct listener_layout_notification *notification = |
| 985 | container_of(listener, |
| 986 | struct listener_layout_notification, |
| 987 | listener); |
| 988 | |
| 989 | struct ivi_layout_notification_callback *created_callback = |
| 990 | notification->userdata; |
| 991 | |
| 992 | ((layer_create_notification_func)created_callback->callback) |
| 993 | (ivilayer, created_callback->data); |
| 994 | } |
| 995 | |
| 996 | static void |
| 997 | layer_removed(struct wl_listener *listener, void *data) |
| 998 | { |
| 999 | struct ivi_layout_layer *ivilayer = data; |
| 1000 | |
| 1001 | struct listener_layout_notification *notification = |
| 1002 | container_of(listener, |
| 1003 | struct listener_layout_notification, |
| 1004 | listener); |
| 1005 | |
| 1006 | struct ivi_layout_notification_callback *removed_callback = |
| 1007 | notification->userdata; |
| 1008 | |
| 1009 | ((layer_remove_notification_func)removed_callback->callback) |
| 1010 | (ivilayer, removed_callback->data); |
| 1011 | } |
| 1012 | |
| 1013 | static void |
| 1014 | layer_prop_changed(struct wl_listener *listener, void *data) |
| 1015 | { |
| 1016 | struct ivi_layout_layer *ivilayer = data; |
| 1017 | |
| 1018 | struct listener_layout_notification *layout_listener = |
| 1019 | container_of(listener, |
| 1020 | struct listener_layout_notification, |
| 1021 | listener); |
| 1022 | |
| 1023 | struct ivi_layout_notification_callback *prop_callback = |
| 1024 | layout_listener->userdata; |
| 1025 | |
| 1026 | ((layer_property_notification_func)prop_callback->callback) |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1027 | (ivilayer, &ivilayer->prop, ivilayer->prop.event_mask, prop_callback->data); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1028 | } |
| 1029 | |
| 1030 | static void |
| 1031 | surface_created(struct wl_listener *listener, void *data) |
| 1032 | { |
| 1033 | struct ivi_layout_surface *ivisurface = data; |
| 1034 | |
| 1035 | struct listener_layout_notification *notification = |
| 1036 | container_of(listener, |
| 1037 | struct listener_layout_notification, |
| 1038 | listener); |
| 1039 | |
| 1040 | struct ivi_layout_notification_callback *created_callback = |
| 1041 | notification->userdata; |
| 1042 | |
| 1043 | ((surface_create_notification_func)created_callback->callback) |
| 1044 | (ivisurface, created_callback->data); |
| 1045 | } |
| 1046 | |
| 1047 | static void |
| 1048 | surface_removed(struct wl_listener *listener, void *data) |
| 1049 | { |
| 1050 | struct ivi_layout_surface *ivisurface = data; |
| 1051 | |
| 1052 | struct listener_layout_notification *notification = |
| 1053 | container_of(listener, |
| 1054 | struct listener_layout_notification, |
| 1055 | listener); |
| 1056 | |
| 1057 | struct ivi_layout_notification_callback *removed_callback = |
| 1058 | notification->userdata; |
| 1059 | |
| 1060 | ((surface_remove_notification_func)removed_callback->callback) |
| 1061 | (ivisurface, removed_callback->data); |
| 1062 | } |
| 1063 | |
| 1064 | static void |
| 1065 | surface_prop_changed(struct wl_listener *listener, void *data) |
| 1066 | { |
| 1067 | struct ivi_layout_surface *ivisurf = data; |
| 1068 | |
| 1069 | struct listener_layout_notification *layout_listener = |
| 1070 | container_of(listener, |
| 1071 | struct listener_layout_notification, |
| 1072 | listener); |
| 1073 | |
| 1074 | struct ivi_layout_notification_callback *prop_callback = |
| 1075 | layout_listener->userdata; |
| 1076 | |
| 1077 | ((surface_property_notification_func)prop_callback->callback) |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1078 | (ivisurf, &ivisurf->prop, ivisurf->prop.event_mask, prop_callback->data); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1079 | } |
| 1080 | |
| 1081 | static void |
| 1082 | surface_configure_changed(struct wl_listener *listener, |
| 1083 | void *data) |
| 1084 | { |
| 1085 | struct ivi_layout_surface *ivisurface = data; |
| 1086 | |
| 1087 | struct listener_layout_notification *notification = |
| 1088 | container_of(listener, |
| 1089 | struct listener_layout_notification, |
| 1090 | listener); |
| 1091 | |
| 1092 | struct ivi_layout_notification_callback *configure_changed_callback = |
| 1093 | notification->userdata; |
| 1094 | |
| 1095 | ((surface_configure_notification_func)configure_changed_callback->callback) |
| 1096 | (ivisurface, configure_changed_callback->data); |
| 1097 | } |
| 1098 | |
| 1099 | static int32_t |
| 1100 | add_notification(struct wl_signal *signal, |
| 1101 | wl_notify_func_t callback, |
| 1102 | void *userdata) |
| 1103 | { |
| 1104 | struct listener_layout_notification *notification = NULL; |
| 1105 | |
| 1106 | notification = malloc(sizeof *notification); |
| 1107 | if (notification == NULL) { |
| 1108 | weston_log("fails to allocate memory\n"); |
| 1109 | free(userdata); |
| 1110 | return IVI_FAILED; |
| 1111 | } |
| 1112 | |
| 1113 | notification->listener.notify = callback; |
| 1114 | notification->userdata = userdata; |
| 1115 | |
| 1116 | wl_signal_add(signal, ¬ification->listener); |
| 1117 | |
| 1118 | return IVI_SUCCEEDED; |
| 1119 | } |
| 1120 | |
| 1121 | static void |
| 1122 | remove_notification(struct wl_list *listener_list, void *callback, void *userdata) |
| 1123 | { |
| 1124 | struct wl_listener *listener = NULL; |
| 1125 | struct wl_listener *next = NULL; |
| 1126 | |
| 1127 | wl_list_for_each_safe(listener, next, listener_list, link) { |
| 1128 | struct listener_layout_notification *notification = |
| 1129 | container_of(listener, |
| 1130 | struct listener_layout_notification, |
| 1131 | listener); |
| 1132 | |
| 1133 | struct ivi_layout_notification_callback *notification_callback = |
| 1134 | notification->userdata; |
| 1135 | |
| 1136 | if ((notification_callback->callback != callback) || |
| 1137 | (notification_callback->data != userdata)) { |
| 1138 | continue; |
| 1139 | } |
| 1140 | |
Ucan, Emre (ADITG/SW1) | cf34dc2 | 2015-08-20 14:13:33 +0000 | [diff] [blame] | 1141 | wl_list_remove(&listener->link); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1142 | |
| 1143 | free(notification->userdata); |
| 1144 | free(notification); |
| 1145 | } |
| 1146 | } |
| 1147 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1148 | /** |
| 1149 | * Exported APIs of ivi-layout library are implemented from here. |
| 1150 | * Brief of APIs is described in ivi-layout-export.h. |
| 1151 | */ |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1152 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1153 | ivi_layout_add_notification_create_layer(layer_create_notification_func callback, |
| 1154 | void *userdata) |
| 1155 | { |
| 1156 | struct ivi_layout *layout = get_instance(); |
| 1157 | struct ivi_layout_notification_callback *created_callback = NULL; |
| 1158 | |
| 1159 | if (callback == NULL) { |
| 1160 | weston_log("ivi_layout_add_notification_create_layer: invalid argument\n"); |
| 1161 | return IVI_FAILED; |
| 1162 | } |
| 1163 | |
| 1164 | created_callback = malloc(sizeof *created_callback); |
| 1165 | if (created_callback == NULL) { |
| 1166 | weston_log("fails to allocate memory\n"); |
| 1167 | return IVI_FAILED; |
| 1168 | } |
| 1169 | |
| 1170 | created_callback->callback = callback; |
| 1171 | created_callback->data = userdata; |
| 1172 | |
| 1173 | return add_notification(&layout->layer_notification.created, |
| 1174 | layer_created, |
| 1175 | created_callback); |
| 1176 | } |
| 1177 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1178 | static void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1179 | ivi_layout_remove_notification_create_layer(layer_create_notification_func callback, |
| 1180 | void *userdata) |
| 1181 | { |
| 1182 | struct ivi_layout *layout = get_instance(); |
| 1183 | remove_notification(&layout->layer_notification.created.listener_list, callback, userdata); |
| 1184 | } |
| 1185 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1186 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1187 | ivi_layout_add_notification_remove_layer(layer_remove_notification_func callback, |
| 1188 | void *userdata) |
| 1189 | { |
| 1190 | struct ivi_layout *layout = get_instance(); |
| 1191 | struct ivi_layout_notification_callback *removed_callback = NULL; |
| 1192 | |
| 1193 | if (callback == NULL) { |
| 1194 | weston_log("ivi_layout_add_notification_remove_layer: invalid argument\n"); |
| 1195 | return IVI_FAILED; |
| 1196 | } |
| 1197 | |
| 1198 | removed_callback = malloc(sizeof *removed_callback); |
| 1199 | if (removed_callback == NULL) { |
| 1200 | weston_log("fails to allocate memory\n"); |
| 1201 | return IVI_FAILED; |
| 1202 | } |
| 1203 | |
| 1204 | removed_callback->callback = callback; |
| 1205 | removed_callback->data = userdata; |
| 1206 | return add_notification(&layout->layer_notification.removed, |
| 1207 | layer_removed, |
| 1208 | removed_callback); |
| 1209 | } |
| 1210 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1211 | static void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1212 | ivi_layout_remove_notification_remove_layer(layer_remove_notification_func callback, |
| 1213 | void *userdata) |
| 1214 | { |
| 1215 | struct ivi_layout *layout = get_instance(); |
| 1216 | remove_notification(&layout->layer_notification.removed.listener_list, callback, userdata); |
| 1217 | } |
| 1218 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1219 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1220 | ivi_layout_add_notification_create_surface(surface_create_notification_func callback, |
| 1221 | void *userdata) |
| 1222 | { |
| 1223 | struct ivi_layout *layout = get_instance(); |
| 1224 | struct ivi_layout_notification_callback *created_callback = NULL; |
| 1225 | |
| 1226 | if (callback == NULL) { |
| 1227 | weston_log("ivi_layout_add_notification_create_surface: invalid argument\n"); |
| 1228 | return IVI_FAILED; |
| 1229 | } |
| 1230 | |
| 1231 | created_callback = malloc(sizeof *created_callback); |
| 1232 | if (created_callback == NULL) { |
| 1233 | weston_log("fails to allocate memory\n"); |
| 1234 | return IVI_FAILED; |
| 1235 | } |
| 1236 | |
| 1237 | created_callback->callback = callback; |
| 1238 | created_callback->data = userdata; |
| 1239 | |
| 1240 | return add_notification(&layout->surface_notification.created, |
| 1241 | surface_created, |
| 1242 | created_callback); |
| 1243 | } |
| 1244 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1245 | static void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1246 | ivi_layout_remove_notification_create_surface(surface_create_notification_func callback, |
| 1247 | void *userdata) |
| 1248 | { |
| 1249 | struct ivi_layout *layout = get_instance(); |
| 1250 | remove_notification(&layout->surface_notification.created.listener_list, callback, userdata); |
| 1251 | } |
| 1252 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1253 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1254 | ivi_layout_add_notification_remove_surface(surface_remove_notification_func callback, |
| 1255 | void *userdata) |
| 1256 | { |
| 1257 | struct ivi_layout *layout = get_instance(); |
| 1258 | struct ivi_layout_notification_callback *removed_callback = NULL; |
| 1259 | |
| 1260 | if (callback == NULL) { |
| 1261 | weston_log("ivi_layout_add_notification_remove_surface: invalid argument\n"); |
| 1262 | return IVI_FAILED; |
| 1263 | } |
| 1264 | |
| 1265 | removed_callback = malloc(sizeof *removed_callback); |
| 1266 | if (removed_callback == NULL) { |
| 1267 | weston_log("fails to allocate memory\n"); |
| 1268 | return IVI_FAILED; |
| 1269 | } |
| 1270 | |
| 1271 | removed_callback->callback = callback; |
| 1272 | removed_callback->data = userdata; |
| 1273 | |
| 1274 | return add_notification(&layout->surface_notification.removed, |
| 1275 | surface_removed, |
| 1276 | removed_callback); |
| 1277 | } |
| 1278 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1279 | static void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1280 | ivi_layout_remove_notification_remove_surface(surface_remove_notification_func callback, |
| 1281 | void *userdata) |
| 1282 | { |
| 1283 | struct ivi_layout *layout = get_instance(); |
| 1284 | remove_notification(&layout->surface_notification.removed.listener_list, callback, userdata); |
| 1285 | } |
| 1286 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1287 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1288 | ivi_layout_add_notification_configure_surface(surface_configure_notification_func callback, |
| 1289 | void *userdata) |
| 1290 | { |
| 1291 | struct ivi_layout *layout = get_instance(); |
| 1292 | struct ivi_layout_notification_callback *configure_changed_callback = NULL; |
| 1293 | if (callback == NULL) { |
| 1294 | weston_log("ivi_layout_add_notification_configure_surface: invalid argument\n"); |
| 1295 | return IVI_FAILED; |
| 1296 | } |
| 1297 | |
| 1298 | configure_changed_callback = malloc(sizeof *configure_changed_callback); |
| 1299 | if (configure_changed_callback == NULL) { |
| 1300 | weston_log("fails to allocate memory\n"); |
| 1301 | return IVI_FAILED; |
| 1302 | } |
| 1303 | |
| 1304 | configure_changed_callback->callback = callback; |
| 1305 | configure_changed_callback->data = userdata; |
| 1306 | |
| 1307 | return add_notification(&layout->surface_notification.configure_changed, |
| 1308 | surface_configure_changed, |
| 1309 | configure_changed_callback); |
| 1310 | } |
| 1311 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1312 | static void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1313 | ivi_layout_remove_notification_configure_surface(surface_configure_notification_func callback, |
| 1314 | void *userdata) |
| 1315 | { |
| 1316 | struct ivi_layout *layout = get_instance(); |
| 1317 | remove_notification(&layout->surface_notification.configure_changed.listener_list, callback, userdata); |
| 1318 | } |
| 1319 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1320 | uint32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1321 | ivi_layout_get_id_of_surface(struct ivi_layout_surface *ivisurf) |
| 1322 | { |
| 1323 | return ivisurf->id_surface; |
| 1324 | } |
| 1325 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1326 | static uint32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1327 | ivi_layout_get_id_of_layer(struct ivi_layout_layer *ivilayer) |
| 1328 | { |
| 1329 | return ivilayer->id_layer; |
| 1330 | } |
| 1331 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1332 | static struct ivi_layout_layer * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1333 | ivi_layout_get_layer_from_id(uint32_t id_layer) |
| 1334 | { |
| 1335 | struct ivi_layout *layout = get_instance(); |
| 1336 | struct ivi_layout_layer *ivilayer = NULL; |
| 1337 | |
| 1338 | wl_list_for_each(ivilayer, &layout->layer_list, link) { |
| 1339 | if (ivilayer->id_layer == id_layer) { |
| 1340 | return ivilayer; |
| 1341 | } |
| 1342 | } |
| 1343 | |
| 1344 | return NULL; |
| 1345 | } |
| 1346 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1347 | struct ivi_layout_surface * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1348 | ivi_layout_get_surface_from_id(uint32_t id_surface) |
| 1349 | { |
| 1350 | struct ivi_layout *layout = get_instance(); |
| 1351 | struct ivi_layout_surface *ivisurf = NULL; |
| 1352 | |
| 1353 | wl_list_for_each(ivisurf, &layout->surface_list, link) { |
| 1354 | if (ivisurf->id_surface == id_surface) { |
| 1355 | return ivisurf; |
| 1356 | } |
| 1357 | } |
| 1358 | |
| 1359 | return NULL; |
| 1360 | } |
| 1361 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1362 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1363 | ivi_layout_surface_add_notification(struct ivi_layout_surface *ivisurf, |
| 1364 | surface_property_notification_func callback, |
| 1365 | void *userdata) |
| 1366 | { |
| 1367 | struct listener_layout_notification* notification = NULL; |
| 1368 | struct ivi_layout_notification_callback *prop_callback = NULL; |
| 1369 | |
| 1370 | if (ivisurf == NULL || callback == NULL) { |
| 1371 | weston_log("ivi_layout_surface_add_notification: invalid argument\n"); |
| 1372 | return IVI_FAILED; |
| 1373 | } |
| 1374 | |
| 1375 | notification = malloc(sizeof *notification); |
| 1376 | if (notification == NULL) { |
| 1377 | weston_log("fails to allocate memory\n"); |
| 1378 | return IVI_FAILED; |
| 1379 | } |
| 1380 | |
| 1381 | prop_callback = malloc(sizeof *prop_callback); |
| 1382 | if (prop_callback == NULL) { |
| 1383 | weston_log("fails to allocate memory\n"); |
Lucas Tanure | 193c7a5 | 2015-09-19 18:24:58 -0300 | [diff] [blame] | 1384 | free(notification); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1385 | return IVI_FAILED; |
| 1386 | } |
| 1387 | |
| 1388 | prop_callback->callback = callback; |
| 1389 | prop_callback->data = userdata; |
| 1390 | |
| 1391 | notification->listener.notify = surface_prop_changed; |
| 1392 | notification->userdata = prop_callback; |
| 1393 | |
| 1394 | wl_signal_add(&ivisurf->property_changed, ¬ification->listener); |
| 1395 | |
| 1396 | return IVI_SUCCEEDED; |
| 1397 | } |
| 1398 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1399 | static const struct ivi_layout_layer_properties * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1400 | ivi_layout_get_properties_of_layer(struct ivi_layout_layer *ivilayer) |
| 1401 | { |
| 1402 | if (ivilayer == NULL) { |
| 1403 | weston_log("ivi_layout_get_properties_of_layer: invalid argument\n"); |
| 1404 | return NULL; |
| 1405 | } |
| 1406 | |
| 1407 | return &ivilayer->prop; |
| 1408 | } |
| 1409 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1410 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1411 | ivi_layout_get_screens_under_layer(struct ivi_layout_layer *ivilayer, |
| 1412 | int32_t *pLength, |
Ucan, Emre (ADITG/SW1) | 273874e | 2016-03-17 15:30:42 +0000 | [diff] [blame] | 1413 | struct weston_output ***ppArray) |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1414 | { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1415 | int32_t length = 0; |
| 1416 | int32_t n = 0; |
| 1417 | |
| 1418 | if (ivilayer == NULL || pLength == NULL || ppArray == NULL) { |
| 1419 | weston_log("ivi_layout_get_screens_under_layer: invalid argument\n"); |
| 1420 | return IVI_FAILED; |
| 1421 | } |
| 1422 | |
Ucan, Emre (ADITG/SW1) | 8a22367 | 2015-08-28 12:58:55 +0000 | [diff] [blame] | 1423 | if (ivilayer->on_screen != NULL) |
| 1424 | length = 1; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1425 | |
Dawid Gajownik | 74a635b | 2015-08-06 17:12:19 -0300 | [diff] [blame] | 1426 | if (length != 0) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1427 | /* the Array must be free by module which called this function */ |
Ucan, Emre (ADITG/SW1) | 273874e | 2016-03-17 15:30:42 +0000 | [diff] [blame] | 1428 | *ppArray = calloc(length, sizeof(struct weston_output *)); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1429 | if (*ppArray == NULL) { |
| 1430 | weston_log("fails to allocate memory\n"); |
| 1431 | return IVI_FAILED; |
| 1432 | } |
| 1433 | |
Ucan, Emre (ADITG/SW1) | 273874e | 2016-03-17 15:30:42 +0000 | [diff] [blame] | 1434 | (*ppArray)[n++] = ivilayer->on_screen->output; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1435 | } |
| 1436 | |
| 1437 | *pLength = length; |
| 1438 | |
| 1439 | return IVI_SUCCEEDED; |
| 1440 | } |
| 1441 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1442 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1443 | ivi_layout_get_layers(int32_t *pLength, struct ivi_layout_layer ***ppArray) |
| 1444 | { |
| 1445 | struct ivi_layout *layout = get_instance(); |
| 1446 | struct ivi_layout_layer *ivilayer = NULL; |
| 1447 | int32_t length = 0; |
| 1448 | int32_t n = 0; |
| 1449 | |
| 1450 | if (pLength == NULL || ppArray == NULL) { |
| 1451 | weston_log("ivi_layout_get_layers: invalid argument\n"); |
| 1452 | return IVI_FAILED; |
| 1453 | } |
| 1454 | |
| 1455 | length = wl_list_length(&layout->layer_list); |
| 1456 | |
Dawid Gajownik | 74a635b | 2015-08-06 17:12:19 -0300 | [diff] [blame] | 1457 | if (length != 0) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1458 | /* the Array must be free by module which called this function */ |
| 1459 | *ppArray = calloc(length, sizeof(struct ivi_layout_layer *)); |
| 1460 | if (*ppArray == NULL) { |
| 1461 | weston_log("fails to allocate memory\n"); |
| 1462 | return IVI_FAILED; |
| 1463 | } |
| 1464 | |
| 1465 | wl_list_for_each(ivilayer, &layout->layer_list, link) { |
| 1466 | (*ppArray)[n++] = ivilayer; |
| 1467 | } |
| 1468 | } |
| 1469 | |
| 1470 | *pLength = length; |
| 1471 | |
| 1472 | return IVI_SUCCEEDED; |
| 1473 | } |
| 1474 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1475 | static int32_t |
Ucan, Emre (ADITG/SW1) | 273874e | 2016-03-17 15:30:42 +0000 | [diff] [blame] | 1476 | ivi_layout_get_layers_on_screen(struct weston_output *output, |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1477 | int32_t *pLength, |
| 1478 | struct ivi_layout_layer ***ppArray) |
| 1479 | { |
Ucan, Emre (ADITG/SW1) | 273874e | 2016-03-17 15:30:42 +0000 | [diff] [blame] | 1480 | struct ivi_layout_screen *iviscrn = NULL; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1481 | struct ivi_layout_layer *ivilayer = NULL; |
| 1482 | int32_t length = 0; |
| 1483 | int32_t n = 0; |
| 1484 | |
Ucan, Emre (ADITG/SW1) | 273874e | 2016-03-17 15:30:42 +0000 | [diff] [blame] | 1485 | if (output == NULL || pLength == NULL || ppArray == NULL) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1486 | weston_log("ivi_layout_get_layers_on_screen: invalid argument\n"); |
| 1487 | return IVI_FAILED; |
| 1488 | } |
| 1489 | |
Ucan, Emre (ADITG/SW1) | b216c92 | 2016-03-17 15:30:46 +0000 | [diff] [blame] | 1490 | iviscrn = get_screen_from_output(output); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1491 | length = wl_list_length(&iviscrn->order.layer_list); |
| 1492 | |
Dawid Gajownik | 74a635b | 2015-08-06 17:12:19 -0300 | [diff] [blame] | 1493 | if (length != 0) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1494 | /* the Array must be free by module which called this function */ |
| 1495 | *ppArray = calloc(length, sizeof(struct ivi_layout_layer *)); |
| 1496 | if (*ppArray == NULL) { |
| 1497 | weston_log("fails to allocate memory\n"); |
| 1498 | return IVI_FAILED; |
| 1499 | } |
| 1500 | |
Nobuhiko Tanibata | e2b8214 | 2015-06-22 15:30:19 +0900 | [diff] [blame] | 1501 | wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1502 | (*ppArray)[n++] = ivilayer; |
| 1503 | } |
| 1504 | } |
| 1505 | |
| 1506 | *pLength = length; |
| 1507 | |
| 1508 | return IVI_SUCCEEDED; |
| 1509 | } |
| 1510 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1511 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1512 | ivi_layout_get_layers_under_surface(struct ivi_layout_surface *ivisurf, |
| 1513 | int32_t *pLength, |
| 1514 | struct ivi_layout_layer ***ppArray) |
| 1515 | { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1516 | int32_t length = 0; |
| 1517 | int32_t n = 0; |
| 1518 | |
| 1519 | if (ivisurf == NULL || pLength == NULL || ppArray == NULL) { |
| 1520 | weston_log("ivi_layout_getLayers: invalid argument\n"); |
| 1521 | return IVI_FAILED; |
| 1522 | } |
| 1523 | |
Ucan, Emre (ADITG/SW1) | dfac375 | 2015-08-28 12:58:58 +0000 | [diff] [blame] | 1524 | if (ivisurf->on_layer != NULL) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1525 | /* the Array must be free by module which called this function */ |
Ucan, Emre (ADITG/SW1) | dfac375 | 2015-08-28 12:58:58 +0000 | [diff] [blame] | 1526 | length = 1; |
| 1527 | *ppArray = calloc(length, sizeof(struct ivi_layout_screen *)); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1528 | if (*ppArray == NULL) { |
| 1529 | weston_log("fails to allocate memory\n"); |
| 1530 | return IVI_FAILED; |
| 1531 | } |
| 1532 | |
Ucan, Emre (ADITG/SW1) | dfac375 | 2015-08-28 12:58:58 +0000 | [diff] [blame] | 1533 | (*ppArray)[n++] = ivisurf->on_layer; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1534 | } |
| 1535 | |
| 1536 | *pLength = length; |
| 1537 | |
| 1538 | return IVI_SUCCEEDED; |
| 1539 | } |
| 1540 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1541 | static |
| 1542 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1543 | ivi_layout_get_surfaces(int32_t *pLength, struct ivi_layout_surface ***ppArray) |
| 1544 | { |
| 1545 | struct ivi_layout *layout = get_instance(); |
| 1546 | struct ivi_layout_surface *ivisurf = NULL; |
| 1547 | int32_t length = 0; |
| 1548 | int32_t n = 0; |
| 1549 | |
| 1550 | if (pLength == NULL || ppArray == NULL) { |
| 1551 | weston_log("ivi_layout_get_surfaces: invalid argument\n"); |
| 1552 | return IVI_FAILED; |
| 1553 | } |
| 1554 | |
| 1555 | length = wl_list_length(&layout->surface_list); |
| 1556 | |
Dawid Gajownik | 74a635b | 2015-08-06 17:12:19 -0300 | [diff] [blame] | 1557 | if (length != 0) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1558 | /* the Array must be free by module which called this function */ |
| 1559 | *ppArray = calloc(length, sizeof(struct ivi_layout_surface *)); |
| 1560 | if (*ppArray == NULL) { |
| 1561 | weston_log("fails to allocate memory\n"); |
| 1562 | return IVI_FAILED; |
| 1563 | } |
| 1564 | |
| 1565 | wl_list_for_each(ivisurf, &layout->surface_list, link) { |
| 1566 | (*ppArray)[n++] = ivisurf; |
| 1567 | } |
| 1568 | } |
| 1569 | |
| 1570 | *pLength = length; |
| 1571 | |
| 1572 | return IVI_SUCCEEDED; |
| 1573 | } |
| 1574 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1575 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1576 | ivi_layout_get_surfaces_on_layer(struct ivi_layout_layer *ivilayer, |
| 1577 | int32_t *pLength, |
| 1578 | struct ivi_layout_surface ***ppArray) |
| 1579 | { |
| 1580 | struct ivi_layout_surface *ivisurf = NULL; |
| 1581 | int32_t length = 0; |
| 1582 | int32_t n = 0; |
| 1583 | |
| 1584 | if (ivilayer == NULL || pLength == NULL || ppArray == NULL) { |
| 1585 | weston_log("ivi_layout_getSurfaceIDsOnLayer: invalid argument\n"); |
| 1586 | return IVI_FAILED; |
| 1587 | } |
| 1588 | |
| 1589 | length = wl_list_length(&ivilayer->order.surface_list); |
| 1590 | |
| 1591 | if (length != 0) { |
| 1592 | /* the Array must be free by module which called this function */ |
| 1593 | *ppArray = calloc(length, sizeof(struct ivi_layout_surface *)); |
| 1594 | if (*ppArray == NULL) { |
| 1595 | weston_log("fails to allocate memory\n"); |
| 1596 | return IVI_FAILED; |
| 1597 | } |
| 1598 | |
| 1599 | wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) { |
| 1600 | (*ppArray)[n++] = ivisurf; |
| 1601 | } |
| 1602 | } |
| 1603 | |
| 1604 | *pLength = length; |
| 1605 | |
| 1606 | return IVI_SUCCEEDED; |
| 1607 | } |
| 1608 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1609 | static struct ivi_layout_layer * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1610 | ivi_layout_layer_create_with_dimension(uint32_t id_layer, |
| 1611 | int32_t width, int32_t height) |
| 1612 | { |
| 1613 | struct ivi_layout *layout = get_instance(); |
| 1614 | struct ivi_layout_layer *ivilayer = NULL; |
| 1615 | |
| 1616 | ivilayer = get_layer(&layout->layer_list, id_layer); |
| 1617 | if (ivilayer != NULL) { |
| 1618 | weston_log("id_layer is already created\n"); |
Nobuhiko Tanibata | 4b601e1 | 2015-06-22 15:31:16 +0900 | [diff] [blame] | 1619 | ++ivilayer->ref_count; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1620 | return ivilayer; |
| 1621 | } |
| 1622 | |
| 1623 | ivilayer = calloc(1, sizeof *ivilayer); |
| 1624 | if (ivilayer == NULL) { |
| 1625 | weston_log("fails to allocate memory\n"); |
| 1626 | return NULL; |
| 1627 | } |
| 1628 | |
Nobuhiko Tanibata | 4b601e1 | 2015-06-22 15:31:16 +0900 | [diff] [blame] | 1629 | ivilayer->ref_count = 1; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1630 | wl_signal_init(&ivilayer->property_changed); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1631 | ivilayer->layout = layout; |
| 1632 | ivilayer->id_layer = id_layer; |
| 1633 | |
| 1634 | init_layer_properties(&ivilayer->prop, width, height); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1635 | |
| 1636 | wl_list_init(&ivilayer->pending.surface_list); |
| 1637 | wl_list_init(&ivilayer->pending.link); |
| 1638 | ivilayer->pending.prop = ivilayer->prop; |
| 1639 | |
| 1640 | wl_list_init(&ivilayer->order.surface_list); |
| 1641 | wl_list_init(&ivilayer->order.link); |
| 1642 | |
| 1643 | wl_list_insert(&layout->layer_list, &ivilayer->link); |
| 1644 | |
| 1645 | wl_signal_emit(&layout->layer_notification.created, ivilayer); |
| 1646 | |
| 1647 | return ivilayer; |
| 1648 | } |
| 1649 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1650 | static void |
Nobuhiko Tanibata | ef6c786 | 2014-12-15 13:20:44 +0900 | [diff] [blame] | 1651 | ivi_layout_layer_remove_notification(struct ivi_layout_layer *ivilayer) |
| 1652 | { |
| 1653 | if (ivilayer == NULL) { |
| 1654 | weston_log("ivi_layout_layer_remove_notification: invalid argument\n"); |
| 1655 | return; |
| 1656 | } |
| 1657 | |
| 1658 | remove_all_notification(&ivilayer->property_changed.listener_list); |
| 1659 | } |
| 1660 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1661 | static void |
Nobuhiko Tanibata | db8efd1 | 2015-06-22 15:31:39 +0900 | [diff] [blame] | 1662 | ivi_layout_layer_remove_notification_by_callback(struct ivi_layout_layer *ivilayer, |
| 1663 | layer_property_notification_func callback, |
| 1664 | void *userdata) |
| 1665 | { |
| 1666 | if (ivilayer == NULL) { |
| 1667 | weston_log("ivi_layout_layer_remove_notification_by_callback: invalid argument\n"); |
| 1668 | return; |
| 1669 | } |
| 1670 | |
| 1671 | remove_notification(&ivilayer->property_changed.listener_list, callback, userdata); |
| 1672 | } |
| 1673 | |
| 1674 | static void |
Nobuhiko Tanibata | 3aa8aed | 2015-06-22 15:32:23 +0900 | [diff] [blame] | 1675 | ivi_layout_layer_destroy(struct ivi_layout_layer *ivilayer) |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1676 | { |
| 1677 | struct ivi_layout *layout = get_instance(); |
| 1678 | |
| 1679 | if (ivilayer == NULL) { |
| 1680 | weston_log("ivi_layout_layer_remove: invalid argument\n"); |
| 1681 | return; |
| 1682 | } |
| 1683 | |
Nobuhiko Tanibata | 4b601e1 | 2015-06-22 15:31:16 +0900 | [diff] [blame] | 1684 | if (--ivilayer->ref_count > 0) |
| 1685 | return; |
| 1686 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1687 | wl_signal_emit(&layout->layer_notification.removed, ivilayer); |
| 1688 | |
| 1689 | clear_surface_pending_list(ivilayer); |
| 1690 | clear_surface_order_list(ivilayer); |
| 1691 | |
Ucan, Emre (ADITG/SW1) | cf34dc2 | 2015-08-20 14:13:33 +0000 | [diff] [blame] | 1692 | wl_list_remove(&ivilayer->pending.link); |
| 1693 | wl_list_remove(&ivilayer->order.link); |
| 1694 | wl_list_remove(&ivilayer->link); |
| 1695 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1696 | ivi_layout_layer_remove_notification(ivilayer); |
| 1697 | |
| 1698 | free(ivilayer); |
| 1699 | } |
| 1700 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1701 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1702 | ivi_layout_layer_set_visibility(struct ivi_layout_layer *ivilayer, |
| 1703 | bool newVisibility) |
| 1704 | { |
| 1705 | struct ivi_layout_layer_properties *prop = NULL; |
| 1706 | |
| 1707 | if (ivilayer == NULL) { |
| 1708 | weston_log("ivi_layout_layer_set_visibility: invalid argument\n"); |
| 1709 | return IVI_FAILED; |
| 1710 | } |
| 1711 | |
| 1712 | prop = &ivilayer->pending.prop; |
| 1713 | prop->visibility = newVisibility; |
| 1714 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1715 | if (ivilayer->prop.visibility != newVisibility) |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1716 | prop->event_mask |= IVI_NOTIFICATION_VISIBILITY; |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1717 | else |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1718 | prop->event_mask &= ~IVI_NOTIFICATION_VISIBILITY; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1719 | |
| 1720 | return IVI_SUCCEEDED; |
| 1721 | } |
| 1722 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1723 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1724 | ivi_layout_layer_set_opacity(struct ivi_layout_layer *ivilayer, |
| 1725 | wl_fixed_t opacity) |
| 1726 | { |
| 1727 | struct ivi_layout_layer_properties *prop = NULL; |
| 1728 | |
Nobuhiko Tanibata | 7bbacc6 | 2015-06-22 15:30:09 +0900 | [diff] [blame] | 1729 | if (ivilayer == NULL || |
| 1730 | opacity < wl_fixed_from_double(0.0) || |
| 1731 | wl_fixed_from_double(1.0) < opacity) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1732 | weston_log("ivi_layout_layer_set_opacity: invalid argument\n"); |
| 1733 | return IVI_FAILED; |
| 1734 | } |
| 1735 | |
| 1736 | prop = &ivilayer->pending.prop; |
| 1737 | prop->opacity = opacity; |
| 1738 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1739 | if (ivilayer->prop.opacity != opacity) |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1740 | prop->event_mask |= IVI_NOTIFICATION_OPACITY; |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1741 | else |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1742 | prop->event_mask &= ~IVI_NOTIFICATION_OPACITY; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1743 | |
| 1744 | return IVI_SUCCEEDED; |
| 1745 | } |
| 1746 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1747 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1748 | ivi_layout_layer_set_source_rectangle(struct ivi_layout_layer *ivilayer, |
| 1749 | int32_t x, int32_t y, |
| 1750 | int32_t width, int32_t height) |
| 1751 | { |
| 1752 | struct ivi_layout_layer_properties *prop = NULL; |
| 1753 | |
| 1754 | if (ivilayer == NULL) { |
| 1755 | weston_log("ivi_layout_layer_set_source_rectangle: invalid argument\n"); |
| 1756 | return IVI_FAILED; |
| 1757 | } |
| 1758 | |
| 1759 | prop = &ivilayer->pending.prop; |
| 1760 | prop->source_x = x; |
| 1761 | prop->source_y = y; |
| 1762 | prop->source_width = width; |
| 1763 | prop->source_height = height; |
| 1764 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1765 | if (ivilayer->prop.source_x != x || ivilayer->prop.source_y != y || |
| 1766 | ivilayer->prop.source_width != width || |
| 1767 | ivilayer->prop.source_height != height) |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1768 | prop->event_mask |= IVI_NOTIFICATION_SOURCE_RECT; |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1769 | else |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1770 | prop->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1771 | |
| 1772 | return IVI_SUCCEEDED; |
| 1773 | } |
| 1774 | |
Ucan, Emre \(ADITG/SW1\) | e62bfd8 | 2016-03-04 12:50:46 +0000 | [diff] [blame] | 1775 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1776 | ivi_layout_layer_set_destination_rectangle(struct ivi_layout_layer *ivilayer, |
| 1777 | int32_t x, int32_t y, |
| 1778 | int32_t width, int32_t height) |
| 1779 | { |
| 1780 | struct ivi_layout_layer_properties *prop = NULL; |
| 1781 | |
| 1782 | if (ivilayer == NULL) { |
| 1783 | weston_log("ivi_layout_layer_set_destination_rectangle: invalid argument\n"); |
| 1784 | return IVI_FAILED; |
| 1785 | } |
| 1786 | |
| 1787 | prop = &ivilayer->pending.prop; |
| 1788 | prop->dest_x = x; |
| 1789 | prop->dest_y = y; |
| 1790 | prop->dest_width = width; |
| 1791 | prop->dest_height = height; |
| 1792 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1793 | if (ivilayer->prop.dest_x != x || ivilayer->prop.dest_y != y || |
| 1794 | ivilayer->prop.dest_width != width || |
| 1795 | ivilayer->prop.dest_height != height) |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1796 | prop->event_mask |= IVI_NOTIFICATION_DEST_RECT; |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1797 | else |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1798 | prop->event_mask &= ~IVI_NOTIFICATION_DEST_RECT; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1799 | |
| 1800 | return IVI_SUCCEEDED; |
| 1801 | } |
| 1802 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1803 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1804 | ivi_layout_layer_set_orientation(struct ivi_layout_layer *ivilayer, |
| 1805 | enum wl_output_transform orientation) |
| 1806 | { |
| 1807 | struct ivi_layout_layer_properties *prop = NULL; |
| 1808 | |
| 1809 | if (ivilayer == NULL) { |
| 1810 | weston_log("ivi_layout_layer_set_orientation: invalid argument\n"); |
| 1811 | return IVI_FAILED; |
| 1812 | } |
| 1813 | |
| 1814 | prop = &ivilayer->pending.prop; |
| 1815 | prop->orientation = orientation; |
| 1816 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1817 | if (ivilayer->prop.orientation != orientation) |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1818 | prop->event_mask |= IVI_NOTIFICATION_ORIENTATION; |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1819 | else |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1820 | prop->event_mask &= ~IVI_NOTIFICATION_ORIENTATION; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1821 | |
| 1822 | return IVI_SUCCEEDED; |
| 1823 | } |
| 1824 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1825 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1826 | ivi_layout_layer_set_render_order(struct ivi_layout_layer *ivilayer, |
| 1827 | struct ivi_layout_surface **pSurface, |
| 1828 | int32_t number) |
| 1829 | { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1830 | int32_t i = 0; |
| 1831 | |
| 1832 | if (ivilayer == NULL) { |
| 1833 | weston_log("ivi_layout_layer_set_render_order: invalid argument\n"); |
| 1834 | return IVI_FAILED; |
| 1835 | } |
| 1836 | |
Ucan, Emre (ADITG/SW1) | c2be638 | 2015-08-19 11:25:01 +0000 | [diff] [blame] | 1837 | clear_surface_pending_list(ivilayer); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1838 | |
| 1839 | for (i = 0; i < number; i++) { |
Ucan, Emre (ADITG/SW1) | 72ad164 | 2016-03-16 13:37:05 +0000 | [diff] [blame] | 1840 | wl_list_remove(&pSurface[i]->pending.link); |
| 1841 | wl_list_insert(&ivilayer->pending.surface_list, |
| 1842 | &pSurface[i]->pending.link); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1843 | } |
| 1844 | |
Ucan, Emre (ADITG/SW1) | 38fcf38 | 2015-08-20 14:13:29 +0000 | [diff] [blame] | 1845 | ivilayer->order.dirty = 1; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1846 | |
| 1847 | return IVI_SUCCEEDED; |
| 1848 | } |
| 1849 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1850 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1851 | ivi_layout_surface_set_visibility(struct ivi_layout_surface *ivisurf, |
| 1852 | bool newVisibility) |
| 1853 | { |
| 1854 | struct ivi_layout_surface_properties *prop = NULL; |
| 1855 | |
| 1856 | if (ivisurf == NULL) { |
| 1857 | weston_log("ivi_layout_surface_set_visibility: invalid argument\n"); |
| 1858 | return IVI_FAILED; |
| 1859 | } |
| 1860 | |
| 1861 | prop = &ivisurf->pending.prop; |
| 1862 | prop->visibility = newVisibility; |
| 1863 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1864 | if (ivisurf->prop.visibility != newVisibility) |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1865 | prop->event_mask |= IVI_NOTIFICATION_VISIBILITY; |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1866 | else |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1867 | prop->event_mask &= ~IVI_NOTIFICATION_VISIBILITY; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1868 | |
| 1869 | return IVI_SUCCEEDED; |
| 1870 | } |
| 1871 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1872 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1873 | ivi_layout_surface_set_opacity(struct ivi_layout_surface *ivisurf, |
| 1874 | wl_fixed_t opacity) |
| 1875 | { |
| 1876 | struct ivi_layout_surface_properties *prop = NULL; |
| 1877 | |
Nobuhiko Tanibata | a86226c | 2015-06-22 15:29:20 +0900 | [diff] [blame] | 1878 | if (ivisurf == NULL || |
| 1879 | opacity < wl_fixed_from_double(0.0) || |
| 1880 | wl_fixed_from_double(1.0) < opacity) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1881 | weston_log("ivi_layout_surface_set_opacity: invalid argument\n"); |
| 1882 | return IVI_FAILED; |
| 1883 | } |
| 1884 | |
| 1885 | prop = &ivisurf->pending.prop; |
| 1886 | prop->opacity = opacity; |
| 1887 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1888 | if (ivisurf->prop.opacity != opacity) |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1889 | prop->event_mask |= IVI_NOTIFICATION_OPACITY; |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1890 | else |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1891 | prop->event_mask &= ~IVI_NOTIFICATION_OPACITY; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1892 | |
| 1893 | return IVI_SUCCEEDED; |
| 1894 | } |
| 1895 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1896 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1897 | ivi_layout_surface_set_destination_rectangle(struct ivi_layout_surface *ivisurf, |
| 1898 | int32_t x, int32_t y, |
| 1899 | int32_t width, int32_t height) |
| 1900 | { |
| 1901 | struct ivi_layout_surface_properties *prop = NULL; |
| 1902 | |
| 1903 | if (ivisurf == NULL) { |
| 1904 | weston_log("ivi_layout_surface_set_destination_rectangle: invalid argument\n"); |
| 1905 | return IVI_FAILED; |
| 1906 | } |
| 1907 | |
| 1908 | prop = &ivisurf->pending.prop; |
| 1909 | prop->start_x = prop->dest_x; |
| 1910 | prop->start_y = prop->dest_y; |
| 1911 | prop->dest_x = x; |
| 1912 | prop->dest_y = y; |
| 1913 | prop->start_width = prop->dest_width; |
| 1914 | prop->start_height = prop->dest_height; |
| 1915 | prop->dest_width = width; |
| 1916 | prop->dest_height = height; |
| 1917 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1918 | if (ivisurf->prop.dest_x != x || ivisurf->prop.dest_y != y || |
| 1919 | ivisurf->prop.dest_width != width || |
| 1920 | ivisurf->prop.dest_height != height) |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1921 | prop->event_mask |= IVI_NOTIFICATION_DEST_RECT; |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1922 | else |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1923 | prop->event_mask &= ~IVI_NOTIFICATION_DEST_RECT; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1924 | |
| 1925 | return IVI_SUCCEEDED; |
| 1926 | } |
| 1927 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1928 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1929 | ivi_layout_surface_set_orientation(struct ivi_layout_surface *ivisurf, |
| 1930 | enum wl_output_transform orientation) |
| 1931 | { |
| 1932 | struct ivi_layout_surface_properties *prop = NULL; |
| 1933 | |
| 1934 | if (ivisurf == NULL) { |
| 1935 | weston_log("ivi_layout_surface_set_orientation: invalid argument\n"); |
| 1936 | return IVI_FAILED; |
| 1937 | } |
| 1938 | |
| 1939 | prop = &ivisurf->pending.prop; |
| 1940 | prop->orientation = orientation; |
| 1941 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1942 | if (ivisurf->prop.orientation != orientation) |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1943 | prop->event_mask |= IVI_NOTIFICATION_ORIENTATION; |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1944 | else |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 1945 | prop->event_mask &= ~IVI_NOTIFICATION_ORIENTATION; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1946 | |
| 1947 | return IVI_SUCCEEDED; |
| 1948 | } |
| 1949 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1950 | static int32_t |
Ucan, Emre (ADITG/SW1) | 273874e | 2016-03-17 15:30:42 +0000 | [diff] [blame] | 1951 | ivi_layout_screen_add_layer(struct weston_output *output, |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1952 | struct ivi_layout_layer *addlayer) |
| 1953 | { |
Ucan, Emre (ADITG/SW1) | 273874e | 2016-03-17 15:30:42 +0000 | [diff] [blame] | 1954 | struct ivi_layout_screen *iviscrn; |
| 1955 | |
| 1956 | if (output == NULL || addlayer == NULL) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1957 | weston_log("ivi_layout_screen_add_layer: invalid argument\n"); |
| 1958 | return IVI_FAILED; |
| 1959 | } |
| 1960 | |
Ucan, Emre (ADITG/SW1) | b216c92 | 2016-03-17 15:30:46 +0000 | [diff] [blame] | 1961 | iviscrn = get_screen_from_output(output); |
Ucan, Emre (ADITG/SW1) | 273874e | 2016-03-17 15:30:42 +0000 | [diff] [blame] | 1962 | |
Ucan, Emre (ADITG/SW1) | bb4ec0a | 2015-08-28 12:59:01 +0000 | [diff] [blame] | 1963 | if (addlayer->on_screen == iviscrn) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1964 | weston_log("ivi_layout_screen_add_layer: addlayer is already available\n"); |
| 1965 | return IVI_SUCCEEDED; |
| 1966 | } |
| 1967 | |
Ucan, Emre (ADITG/SW1) | f46306f | 2016-03-16 13:37:07 +0000 | [diff] [blame] | 1968 | wl_list_remove(&addlayer->pending.link); |
| 1969 | wl_list_insert(&iviscrn->pending.layer_list, &addlayer->pending.link); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1970 | |
Ucan, Emre (ADITG/SW1) | 174257b | 2015-08-20 14:13:30 +0000 | [diff] [blame] | 1971 | iviscrn->order.dirty = 1; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1972 | |
| 1973 | return IVI_SUCCEEDED; |
| 1974 | } |
| 1975 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1976 | static int32_t |
Ucan, Emre (ADITG/SW1) | 273874e | 2016-03-17 15:30:42 +0000 | [diff] [blame] | 1977 | ivi_layout_screen_set_render_order(struct weston_output *output, |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1978 | struct ivi_layout_layer **pLayer, |
| 1979 | const int32_t number) |
| 1980 | { |
Ucan, Emre (ADITG/SW1) | 273874e | 2016-03-17 15:30:42 +0000 | [diff] [blame] | 1981 | struct ivi_layout_screen *iviscrn; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1982 | struct ivi_layout_layer *ivilayer = NULL; |
| 1983 | struct ivi_layout_layer *next = NULL; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1984 | int32_t i = 0; |
| 1985 | |
Ucan, Emre (ADITG/SW1) | 273874e | 2016-03-17 15:30:42 +0000 | [diff] [blame] | 1986 | if (output == NULL) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1987 | weston_log("ivi_layout_screen_set_render_order: invalid argument\n"); |
| 1988 | return IVI_FAILED; |
| 1989 | } |
| 1990 | |
Ucan, Emre (ADITG/SW1) | b216c92 | 2016-03-17 15:30:46 +0000 | [diff] [blame] | 1991 | iviscrn = get_screen_from_output(output); |
Ucan, Emre (ADITG/SW1) | 273874e | 2016-03-17 15:30:42 +0000 | [diff] [blame] | 1992 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1993 | wl_list_for_each_safe(ivilayer, next, |
| 1994 | &iviscrn->pending.layer_list, pending.link) { |
Ucan, Emre (ADITG/SW1) | 174257b | 2015-08-20 14:13:30 +0000 | [diff] [blame] | 1995 | wl_list_remove(&ivilayer->pending.link); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1996 | wl_list_init(&ivilayer->pending.link); |
| 1997 | } |
| 1998 | |
Ucan, Emre (ADITG/SW1) | 174257b | 2015-08-20 14:13:30 +0000 | [diff] [blame] | 1999 | assert(wl_list_empty(&iviscrn->pending.layer_list)); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2000 | |
| 2001 | for (i = 0; i < number; i++) { |
Ucan, Emre (ADITG/SW1) | 4e221f0 | 2016-03-16 13:37:08 +0000 | [diff] [blame] | 2002 | wl_list_remove(&pLayer[i]->pending.link); |
| 2003 | wl_list_insert(&iviscrn->pending.layer_list, |
| 2004 | &pLayer[i]->pending.link); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2005 | } |
| 2006 | |
Ucan, Emre (ADITG/SW1) | 174257b | 2015-08-20 14:13:30 +0000 | [diff] [blame] | 2007 | iviscrn->order.dirty = 1; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2008 | |
| 2009 | return IVI_SUCCEEDED; |
| 2010 | } |
| 2011 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2012 | /** |
| 2013 | * This function is used by the additional ivi-module because of dumping ivi_surface sceenshot. |
| 2014 | * The ivi-module, e.g. ivi-controller.so, is in wayland-ivi-extension of Genivi's Layer Management. |
| 2015 | * This function is used to get the result of drawing by clients. |
| 2016 | */ |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2017 | static struct weston_surface * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2018 | ivi_layout_surface_get_weston_surface(struct ivi_layout_surface *ivisurf) |
| 2019 | { |
| 2020 | return ivisurf != NULL ? ivisurf->surface : NULL; |
| 2021 | } |
| 2022 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2023 | static int32_t |
Nobuhiko Tanibata | c3fd624 | 2015-04-21 02:13:15 +0900 | [diff] [blame] | 2024 | ivi_layout_surface_get_size(struct ivi_layout_surface *ivisurf, |
| 2025 | int32_t *width, int32_t *height, |
| 2026 | int32_t *stride) |
| 2027 | { |
| 2028 | int32_t w; |
| 2029 | int32_t h; |
| 2030 | const size_t bytespp = 4; /* PIXMAN_a8b8g8r8 */ |
| 2031 | |
| 2032 | if (ivisurf == NULL || ivisurf->surface == NULL) { |
| 2033 | weston_log("%s: invalid argument\n", __func__); |
| 2034 | return IVI_FAILED; |
| 2035 | } |
| 2036 | |
| 2037 | weston_surface_get_content_size(ivisurf->surface, &w, &h); |
| 2038 | |
| 2039 | if (width != NULL) |
| 2040 | *width = w; |
| 2041 | |
| 2042 | if (height != NULL) |
| 2043 | *height = h; |
| 2044 | |
| 2045 | if (stride != NULL) |
| 2046 | *stride = w * bytespp; |
| 2047 | |
| 2048 | return IVI_SUCCEEDED; |
| 2049 | } |
| 2050 | |
| 2051 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2052 | ivi_layout_layer_add_notification(struct ivi_layout_layer *ivilayer, |
| 2053 | layer_property_notification_func callback, |
| 2054 | void *userdata) |
| 2055 | { |
| 2056 | struct ivi_layout_notification_callback *prop_callback = NULL; |
| 2057 | |
| 2058 | if (ivilayer == NULL || callback == NULL) { |
| 2059 | weston_log("ivi_layout_layer_add_notification: invalid argument\n"); |
| 2060 | return IVI_FAILED; |
| 2061 | } |
| 2062 | |
| 2063 | prop_callback = malloc(sizeof *prop_callback); |
| 2064 | if (prop_callback == NULL) { |
| 2065 | weston_log("fails to allocate memory\n"); |
| 2066 | return IVI_FAILED; |
| 2067 | } |
| 2068 | |
| 2069 | prop_callback->callback = callback; |
| 2070 | prop_callback->data = userdata; |
| 2071 | |
| 2072 | return add_notification(&ivilayer->property_changed, |
| 2073 | layer_prop_changed, |
| 2074 | prop_callback); |
| 2075 | } |
| 2076 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2077 | static const struct ivi_layout_surface_properties * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2078 | ivi_layout_get_properties_of_surface(struct ivi_layout_surface *ivisurf) |
| 2079 | { |
| 2080 | if (ivisurf == NULL) { |
| 2081 | weston_log("ivi_layout_get_properties_of_surface: invalid argument\n"); |
| 2082 | return NULL; |
| 2083 | } |
| 2084 | |
| 2085 | return &ivisurf->prop; |
| 2086 | } |
| 2087 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2088 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2089 | ivi_layout_layer_add_surface(struct ivi_layout_layer *ivilayer, |
| 2090 | struct ivi_layout_surface *addsurf) |
| 2091 | { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2092 | if (ivilayer == NULL || addsurf == NULL) { |
| 2093 | weston_log("ivi_layout_layer_add_surface: invalid argument\n"); |
| 2094 | return IVI_FAILED; |
| 2095 | } |
| 2096 | |
Wataru Natsume | 9c926fe | 2016-03-03 19:56:09 +0900 | [diff] [blame] | 2097 | if (addsurf->on_layer == ivilayer) |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2098 | return IVI_SUCCEEDED; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2099 | |
Ucan, Emre (ADITG/SW1) | 1094237 | 2016-03-16 13:37:02 +0000 | [diff] [blame] | 2100 | wl_list_remove(&addsurf->pending.link); |
| 2101 | wl_list_insert(&ivilayer->pending.surface_list, &addsurf->pending.link); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2102 | |
Ucan, Emre (ADITG/SW1) | 38fcf38 | 2015-08-20 14:13:29 +0000 | [diff] [blame] | 2103 | ivilayer->order.dirty = 1; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2104 | |
| 2105 | return IVI_SUCCEEDED; |
| 2106 | } |
| 2107 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2108 | static void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2109 | ivi_layout_layer_remove_surface(struct ivi_layout_layer *ivilayer, |
| 2110 | struct ivi_layout_surface *remsurf) |
| 2111 | { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2112 | if (ivilayer == NULL || remsurf == NULL) { |
| 2113 | weston_log("ivi_layout_layer_remove_surface: invalid argument\n"); |
| 2114 | return; |
| 2115 | } |
| 2116 | |
Ucan, Emre (ADITG/SW1) | 536d833 | 2016-03-16 13:36:59 +0000 | [diff] [blame] | 2117 | wl_list_remove(&remsurf->pending.link); |
| 2118 | wl_list_init(&remsurf->pending.link); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2119 | |
Ucan, Emre (ADITG/SW1) | 38fcf38 | 2015-08-20 14:13:29 +0000 | [diff] [blame] | 2120 | ivilayer->order.dirty = 1; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2121 | } |
| 2122 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2123 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2124 | ivi_layout_surface_set_source_rectangle(struct ivi_layout_surface *ivisurf, |
| 2125 | int32_t x, int32_t y, |
| 2126 | int32_t width, int32_t height) |
| 2127 | { |
| 2128 | struct ivi_layout_surface_properties *prop = NULL; |
| 2129 | |
| 2130 | if (ivisurf == NULL) { |
| 2131 | weston_log("ivi_layout_surface_set_source_rectangle: invalid argument\n"); |
| 2132 | return IVI_FAILED; |
| 2133 | } |
| 2134 | |
| 2135 | prop = &ivisurf->pending.prop; |
| 2136 | prop->source_x = x; |
| 2137 | prop->source_y = y; |
| 2138 | prop->source_width = width; |
| 2139 | prop->source_height = height; |
| 2140 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 2141 | if (ivisurf->prop.source_x != x || ivisurf->prop.source_y != y || |
| 2142 | ivisurf->prop.source_width != width || |
| 2143 | ivisurf->prop.source_height != height) |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 2144 | prop->event_mask |= IVI_NOTIFICATION_SOURCE_RECT; |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 2145 | else |
Ucan, Emre (ADITG/SW1) | 0bd29b6 | 2016-03-31 11:08:52 +0000 | [diff] [blame^] | 2146 | prop->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2147 | |
| 2148 | return IVI_SUCCEEDED; |
| 2149 | } |
| 2150 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2151 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2152 | ivi_layout_commit_changes(void) |
| 2153 | { |
| 2154 | struct ivi_layout *layout = get_instance(); |
| 2155 | |
| 2156 | commit_surface_list(layout); |
| 2157 | commit_layer_list(layout); |
| 2158 | commit_screen_list(layout); |
| 2159 | |
| 2160 | commit_transition(layout); |
| 2161 | |
| 2162 | commit_changes(layout); |
| 2163 | send_prop(layout); |
| 2164 | weston_compositor_schedule_repaint(layout->compositor); |
| 2165 | |
| 2166 | return IVI_SUCCEEDED; |
| 2167 | } |
| 2168 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2169 | static int32_t |
Nobuhiko Tanibata | 3c6796f | 2014-12-15 13:20:58 +0900 | [diff] [blame] | 2170 | ivi_layout_layer_set_transition(struct ivi_layout_layer *ivilayer, |
| 2171 | enum ivi_layout_transition_type type, |
| 2172 | uint32_t duration) |
| 2173 | { |
| 2174 | if (ivilayer == NULL) { |
| 2175 | weston_log("%s: invalid argument\n", __func__); |
| 2176 | return -1; |
| 2177 | } |
| 2178 | |
| 2179 | ivilayer->pending.prop.transition_type = type; |
| 2180 | ivilayer->pending.prop.transition_duration = duration; |
| 2181 | |
| 2182 | return 0; |
| 2183 | } |
| 2184 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2185 | static int32_t |
Nobuhiko Tanibata | 3c6796f | 2014-12-15 13:20:58 +0900 | [diff] [blame] | 2186 | ivi_layout_layer_set_fade_info(struct ivi_layout_layer* ivilayer, |
| 2187 | uint32_t is_fade_in, |
| 2188 | double start_alpha, double end_alpha) |
| 2189 | { |
| 2190 | if (ivilayer == NULL) { |
| 2191 | weston_log("%s: invalid argument\n", __func__); |
| 2192 | return -1; |
| 2193 | } |
| 2194 | |
| 2195 | ivilayer->pending.prop.is_fade_in = is_fade_in; |
| 2196 | ivilayer->pending.prop.start_alpha = start_alpha; |
| 2197 | ivilayer->pending.prop.end_alpha = end_alpha; |
| 2198 | |
| 2199 | return 0; |
| 2200 | } |
| 2201 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2202 | static int32_t |
Nobuhiko Tanibata | 3c6796f | 2014-12-15 13:20:58 +0900 | [diff] [blame] | 2203 | ivi_layout_surface_set_transition_duration(struct ivi_layout_surface *ivisurf, |
| 2204 | uint32_t duration) |
| 2205 | { |
| 2206 | struct ivi_layout_surface_properties *prop; |
| 2207 | |
| 2208 | if (ivisurf == NULL) { |
| 2209 | weston_log("%s: invalid argument\n", __func__); |
| 2210 | return -1; |
| 2211 | } |
| 2212 | |
| 2213 | prop = &ivisurf->pending.prop; |
| 2214 | prop->transition_duration = duration*10; |
| 2215 | return 0; |
| 2216 | } |
| 2217 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2218 | static int32_t |
Nobuhiko Tanibata | 3c6796f | 2014-12-15 13:20:58 +0900 | [diff] [blame] | 2219 | ivi_layout_surface_set_transition(struct ivi_layout_surface *ivisurf, |
| 2220 | enum ivi_layout_transition_type type, |
| 2221 | uint32_t duration) |
| 2222 | { |
| 2223 | struct ivi_layout_surface_properties *prop; |
| 2224 | |
| 2225 | if (ivisurf == NULL) { |
| 2226 | weston_log("%s: invalid argument\n", __func__); |
| 2227 | return -1; |
| 2228 | } |
| 2229 | |
| 2230 | prop = &ivisurf->pending.prop; |
| 2231 | prop->transition_type = type; |
| 2232 | prop->transition_duration = duration; |
| 2233 | return 0; |
| 2234 | } |
| 2235 | |
Nobuhiko Tanibata | c3fd624 | 2015-04-21 02:13:15 +0900 | [diff] [blame] | 2236 | static int32_t |
| 2237 | ivi_layout_surface_dump(struct weston_surface *surface, |
| 2238 | void *target, size_t size,int32_t x, int32_t y, |
| 2239 | int32_t width, int32_t height) |
| 2240 | { |
| 2241 | int result = 0; |
| 2242 | |
| 2243 | if (surface == NULL) { |
| 2244 | weston_log("%s: invalid argument\n", __func__); |
| 2245 | return IVI_FAILED; |
| 2246 | } |
| 2247 | |
| 2248 | result = weston_surface_copy_content( |
| 2249 | surface, target, size, |
| 2250 | x, y, width, height); |
| 2251 | |
| 2252 | return result == 0 ? IVI_SUCCEEDED : IVI_FAILED; |
| 2253 | } |
| 2254 | |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 2255 | /** |
| 2256 | * methods of interaction between ivi-shell with ivi-layout |
| 2257 | */ |
| 2258 | struct weston_view * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2259 | ivi_layout_get_weston_view(struct ivi_layout_surface *surface) |
| 2260 | { |
Dawid Gajownik | 74a635b | 2015-08-06 17:12:19 -0300 | [diff] [blame] | 2261 | if (surface == NULL) |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2262 | return NULL; |
| 2263 | |
Ucan, Emre (ADITG/SW1) | 64635ee | 2015-08-28 12:59:06 +0000 | [diff] [blame] | 2264 | return get_weston_view(surface); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2265 | } |
| 2266 | |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 2267 | void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2268 | ivi_layout_surface_configure(struct ivi_layout_surface *ivisurf, |
| 2269 | int32_t width, int32_t height) |
| 2270 | { |
| 2271 | struct ivi_layout *layout = get_instance(); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2272 | |
Nobuhiko Tanibata | e6cc997 | 2015-04-27 16:54:01 +0900 | [diff] [blame] | 2273 | /* emit callback which is set by ivi-layout api user */ |
| 2274 | wl_signal_emit(&layout->surface_notification.configure_changed, |
| 2275 | ivisurf); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2276 | } |
| 2277 | |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 2278 | struct ivi_layout_surface* |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2279 | ivi_layout_surface_create(struct weston_surface *wl_surface, |
| 2280 | uint32_t id_surface) |
| 2281 | { |
| 2282 | struct ivi_layout *layout = get_instance(); |
| 2283 | struct ivi_layout_surface *ivisurf = NULL; |
| 2284 | struct weston_view *tmpview = NULL; |
| 2285 | |
| 2286 | if (wl_surface == NULL) { |
| 2287 | weston_log("ivi_layout_surface_create: invalid argument\n"); |
| 2288 | return NULL; |
| 2289 | } |
| 2290 | |
| 2291 | ivisurf = get_surface(&layout->surface_list, id_surface); |
| 2292 | if (ivisurf != NULL) { |
| 2293 | if (ivisurf->surface != NULL) { |
| 2294 | weston_log("id_surface(%d) is already created\n", id_surface); |
| 2295 | return NULL; |
| 2296 | } |
| 2297 | } |
| 2298 | |
| 2299 | ivisurf = calloc(1, sizeof *ivisurf); |
| 2300 | if (ivisurf == NULL) { |
| 2301 | weston_log("fails to allocate memory\n"); |
| 2302 | return NULL; |
| 2303 | } |
| 2304 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2305 | wl_signal_init(&ivisurf->property_changed); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2306 | ivisurf->id_surface = id_surface; |
| 2307 | ivisurf->layout = layout; |
| 2308 | |
| 2309 | ivisurf->surface = wl_surface; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2310 | |
| 2311 | tmpview = weston_view_create(wl_surface); |
| 2312 | if (tmpview == NULL) { |
| 2313 | weston_log("fails to allocate memory\n"); |
| 2314 | } |
| 2315 | |
| 2316 | ivisurf->surface->width_from_buffer = 0; |
| 2317 | ivisurf->surface->height_from_buffer = 0; |
| 2318 | |
Nobuhiko Tanibata | 21deb28 | 2015-07-15 14:05:32 +0900 | [diff] [blame] | 2319 | weston_matrix_init(&ivisurf->transform.matrix); |
| 2320 | wl_list_init(&ivisurf->transform.link); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2321 | |
| 2322 | init_surface_properties(&ivisurf->prop); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2323 | |
| 2324 | ivisurf->pending.prop = ivisurf->prop; |
| 2325 | wl_list_init(&ivisurf->pending.link); |
| 2326 | |
| 2327 | wl_list_init(&ivisurf->order.link); |
| 2328 | wl_list_init(&ivisurf->order.layer_list); |
| 2329 | |
| 2330 | wl_list_insert(&layout->surface_list, &ivisurf->link); |
| 2331 | |
| 2332 | wl_signal_emit(&layout->surface_notification.created, ivisurf); |
| 2333 | |
| 2334 | return ivisurf; |
| 2335 | } |
| 2336 | |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 2337 | void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2338 | ivi_layout_init_with_compositor(struct weston_compositor *ec) |
| 2339 | { |
| 2340 | struct ivi_layout *layout = get_instance(); |
| 2341 | |
| 2342 | layout->compositor = ec; |
| 2343 | |
| 2344 | wl_list_init(&layout->surface_list); |
| 2345 | wl_list_init(&layout->layer_list); |
| 2346 | wl_list_init(&layout->screen_list); |
| 2347 | |
| 2348 | wl_signal_init(&layout->layer_notification.created); |
| 2349 | wl_signal_init(&layout->layer_notification.removed); |
| 2350 | |
| 2351 | wl_signal_init(&layout->surface_notification.created); |
| 2352 | wl_signal_init(&layout->surface_notification.removed); |
| 2353 | wl_signal_init(&layout->surface_notification.configure_changed); |
| 2354 | |
| 2355 | /* Add layout_layer at the last of weston_compositor.layer_list */ |
| 2356 | weston_layer_init(&layout->layout_layer, ec->layer_list.prev); |
| 2357 | |
| 2358 | create_screen(ec); |
| 2359 | |
| 2360 | layout->transitions = ivi_layout_transition_set_create(ec); |
| 2361 | wl_list_init(&layout->pending_transition_list); |
| 2362 | } |
| 2363 | |
Ucan, Emre \(ADITG/SW1\) | 0c0e51e | 2015-10-15 14:51:41 +0000 | [diff] [blame] | 2364 | static struct ivi_layout_interface ivi_layout_interface = { |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2365 | /** |
| 2366 | * commit all changes |
| 2367 | */ |
| 2368 | .commit_changes = ivi_layout_commit_changes, |
| 2369 | |
| 2370 | /** |
| 2371 | * surface controller interfaces |
| 2372 | */ |
| 2373 | .add_notification_create_surface = ivi_layout_add_notification_create_surface, |
| 2374 | .remove_notification_create_surface = ivi_layout_remove_notification_create_surface, |
| 2375 | .add_notification_remove_surface = ivi_layout_add_notification_remove_surface, |
| 2376 | .remove_notification_remove_surface = ivi_layout_remove_notification_remove_surface, |
| 2377 | .add_notification_configure_surface = ivi_layout_add_notification_configure_surface, |
| 2378 | .remove_notification_configure_surface = ivi_layout_remove_notification_configure_surface, |
| 2379 | .get_surfaces = ivi_layout_get_surfaces, |
| 2380 | .get_id_of_surface = ivi_layout_get_id_of_surface, |
| 2381 | .get_surface_from_id = ivi_layout_get_surface_from_id, |
| 2382 | .get_properties_of_surface = ivi_layout_get_properties_of_surface, |
| 2383 | .get_surfaces_on_layer = ivi_layout_get_surfaces_on_layer, |
| 2384 | .surface_set_visibility = ivi_layout_surface_set_visibility, |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2385 | .surface_set_opacity = ivi_layout_surface_set_opacity, |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2386 | .surface_set_source_rectangle = ivi_layout_surface_set_source_rectangle, |
| 2387 | .surface_set_destination_rectangle = ivi_layout_surface_set_destination_rectangle, |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2388 | .surface_set_orientation = ivi_layout_surface_set_orientation, |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2389 | .surface_add_notification = ivi_layout_surface_add_notification, |
| 2390 | .surface_remove_notification = ivi_layout_surface_remove_notification, |
| 2391 | .surface_get_weston_surface = ivi_layout_surface_get_weston_surface, |
| 2392 | .surface_set_transition = ivi_layout_surface_set_transition, |
| 2393 | .surface_set_transition_duration = ivi_layout_surface_set_transition_duration, |
| 2394 | |
| 2395 | /** |
| 2396 | * layer controller interfaces |
| 2397 | */ |
| 2398 | .add_notification_create_layer = ivi_layout_add_notification_create_layer, |
| 2399 | .remove_notification_create_layer = ivi_layout_remove_notification_create_layer, |
| 2400 | .add_notification_remove_layer = ivi_layout_add_notification_remove_layer, |
| 2401 | .remove_notification_remove_layer = ivi_layout_remove_notification_remove_layer, |
| 2402 | .layer_create_with_dimension = ivi_layout_layer_create_with_dimension, |
Nobuhiko Tanibata | 3aa8aed | 2015-06-22 15:32:23 +0900 | [diff] [blame] | 2403 | .layer_destroy = ivi_layout_layer_destroy, |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2404 | .get_layers = ivi_layout_get_layers, |
| 2405 | .get_id_of_layer = ivi_layout_get_id_of_layer, |
| 2406 | .get_layer_from_id = ivi_layout_get_layer_from_id, |
| 2407 | .get_properties_of_layer = ivi_layout_get_properties_of_layer, |
| 2408 | .get_layers_under_surface = ivi_layout_get_layers_under_surface, |
| 2409 | .get_layers_on_screen = ivi_layout_get_layers_on_screen, |
| 2410 | .layer_set_visibility = ivi_layout_layer_set_visibility, |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2411 | .layer_set_opacity = ivi_layout_layer_set_opacity, |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2412 | .layer_set_source_rectangle = ivi_layout_layer_set_source_rectangle, |
| 2413 | .layer_set_destination_rectangle = ivi_layout_layer_set_destination_rectangle, |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2414 | .layer_set_orientation = ivi_layout_layer_set_orientation, |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2415 | .layer_add_surface = ivi_layout_layer_add_surface, |
| 2416 | .layer_remove_surface = ivi_layout_layer_remove_surface, |
| 2417 | .layer_set_render_order = ivi_layout_layer_set_render_order, |
| 2418 | .layer_add_notification = ivi_layout_layer_add_notification, |
| 2419 | .layer_remove_notification = ivi_layout_layer_remove_notification, |
| 2420 | .layer_set_transition = ivi_layout_layer_set_transition, |
| 2421 | |
| 2422 | /** |
Ucan, Emre (ADITG/SW1) | 6d89b1c | 2016-03-17 15:30:49 +0000 | [diff] [blame] | 2423 | * screen controller interfaces |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2424 | */ |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2425 | .get_screens_under_layer = ivi_layout_get_screens_under_layer, |
| 2426 | .screen_add_layer = ivi_layout_screen_add_layer, |
| 2427 | .screen_set_render_order = ivi_layout_screen_set_render_order, |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2428 | |
| 2429 | /** |
| 2430 | * animation |
| 2431 | */ |
| 2432 | .transition_move_layer_cancel = ivi_layout_transition_move_layer_cancel, |
Nobuhiko Tanibata | c3fd624 | 2015-04-21 02:13:15 +0900 | [diff] [blame] | 2433 | .layer_set_fade_info = ivi_layout_layer_set_fade_info, |
| 2434 | |
| 2435 | /** |
| 2436 | * surface content dumping for debugging |
| 2437 | */ |
| 2438 | .surface_get_size = ivi_layout_surface_get_size, |
| 2439 | .surface_dump = ivi_layout_surface_dump, |
Nobuhiko Tanibata | 8205170 | 2015-06-22 15:31:26 +0900 | [diff] [blame] | 2440 | |
| 2441 | /** |
Nobuhiko Tanibata | db8efd1 | 2015-06-22 15:31:39 +0900 | [diff] [blame] | 2442 | * remove notification by callback on property changes of ivi_surface/layer |
Nobuhiko Tanibata | 8205170 | 2015-06-22 15:31:26 +0900 | [diff] [blame] | 2443 | */ |
Nobuhiko Tanibata | db8efd1 | 2015-06-22 15:31:39 +0900 | [diff] [blame] | 2444 | .surface_remove_notification_by_callback = ivi_layout_surface_remove_notification_by_callback, |
Ucan, Emre (ADITG/SW1) | d56b90d | 2016-03-17 15:30:32 +0000 | [diff] [blame] | 2445 | .layer_remove_notification_by_callback = ivi_layout_layer_remove_notification_by_callback |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2446 | }; |
| 2447 | |
| 2448 | int |
| 2449 | load_controller_modules(struct weston_compositor *compositor, const char *modules, |
| 2450 | int *argc, char *argv[]) |
| 2451 | { |
| 2452 | const char *p, *end; |
| 2453 | char buffer[256]; |
| 2454 | int (*controller_module_init)(struct weston_compositor *compositor, |
| 2455 | int *argc, char *argv[], |
Ucan, Emre \(ADITG/SW1\) | 0c0e51e | 2015-10-15 14:51:41 +0000 | [diff] [blame] | 2456 | const struct ivi_layout_interface *interface, |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2457 | size_t interface_version); |
| 2458 | |
| 2459 | if (modules == NULL) |
| 2460 | return 0; |
| 2461 | |
| 2462 | p = modules; |
| 2463 | while (*p) { |
| 2464 | end = strchrnul(p, ','); |
| 2465 | snprintf(buffer, sizeof buffer, "%.*s", (int)(end - p), p); |
| 2466 | |
| 2467 | controller_module_init = weston_load_module(buffer, "controller_module_init"); |
Pekka Paalanen | 97246c0 | 2015-03-26 15:47:29 +0200 | [diff] [blame] | 2468 | if (!controller_module_init) |
| 2469 | return -1; |
| 2470 | |
| 2471 | if (controller_module_init(compositor, argc, argv, |
Ucan, Emre \(ADITG/SW1\) | 0c0e51e | 2015-10-15 14:51:41 +0000 | [diff] [blame] | 2472 | &ivi_layout_interface, |
| 2473 | sizeof(struct ivi_layout_interface)) != 0) { |
Pekka Paalanen | 97246c0 | 2015-03-26 15:47:29 +0200 | [diff] [blame] | 2474 | weston_log("ivi-shell: Initialization of controller module fails"); |
| 2475 | return -1; |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2476 | } |
| 2477 | |
| 2478 | p = end; |
| 2479 | while (*p == ',') |
| 2480 | p++; |
| 2481 | } |
| 2482 | |
| 2483 | return 0; |
| 2484 | } |