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> |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 61 | |
| 62 | #include "compositor.h" |
| 63 | #include "ivi-layout-export.h" |
| 64 | #include "ivi-layout-private.h" |
| 65 | |
Jon Cruz | 867d50e | 2015-06-15 15:37:10 -0700 | [diff] [blame] | 66 | #include "shared/helpers.h" |
Jon Cruz | 4678bab | 2015-06-15 15:37:07 -0700 | [diff] [blame] | 67 | #include "shared/os-compatibility.h" |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 68 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 69 | struct link_layer { |
| 70 | struct ivi_layout_layer *ivilayer; |
| 71 | struct wl_list link; |
| 72 | struct wl_list link_to_layer; |
| 73 | }; |
| 74 | |
| 75 | struct link_screen { |
| 76 | struct ivi_layout_screen *iviscrn; |
| 77 | struct wl_list link; |
| 78 | struct wl_list link_to_screen; |
| 79 | }; |
| 80 | |
| 81 | struct listener_layout_notification { |
| 82 | void *userdata; |
| 83 | struct wl_listener listener; |
| 84 | }; |
| 85 | |
| 86 | struct ivi_layout; |
| 87 | |
| 88 | struct ivi_layout_screen { |
| 89 | struct wl_list link; |
| 90 | struct wl_list link_to_layer; |
| 91 | uint32_t id_screen; |
| 92 | |
| 93 | struct ivi_layout *layout; |
| 94 | struct weston_output *output; |
| 95 | |
| 96 | uint32_t event_mask; |
| 97 | |
| 98 | struct { |
| 99 | struct wl_list layer_list; |
| 100 | struct wl_list link; |
| 101 | } pending; |
| 102 | |
| 103 | struct { |
| 104 | struct wl_list layer_list; |
| 105 | struct wl_list link; |
| 106 | } order; |
| 107 | }; |
| 108 | |
| 109 | struct ivi_layout_notification_callback { |
| 110 | void *callback; |
| 111 | void *data; |
| 112 | }; |
| 113 | |
Nobuhiko Tanibata | 8205170 | 2015-06-22 15:31:26 +0900 | [diff] [blame] | 114 | static void |
| 115 | remove_notification(struct wl_list *listener_list, void *callback, void *userdata); |
| 116 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 117 | static struct ivi_layout ivilayout = {0}; |
| 118 | |
| 119 | struct ivi_layout * |
| 120 | get_instance(void) |
| 121 | { |
| 122 | return &ivilayout; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Internal API to add/remove a link to ivi_surface from ivi_layer. |
| 127 | */ |
| 128 | static void |
| 129 | add_link_to_surface(struct ivi_layout_layer *ivilayer, |
| 130 | struct link_layer *link_layer) |
| 131 | { |
| 132 | struct link_layer *link = NULL; |
| 133 | |
| 134 | wl_list_for_each(link, &ivilayer->link_to_surface, link_to_layer) { |
| 135 | if (link == link_layer) |
| 136 | return; |
| 137 | } |
| 138 | |
| 139 | wl_list_insert(&ivilayer->link_to_surface, &link_layer->link_to_layer); |
| 140 | } |
| 141 | |
| 142 | static void |
| 143 | remove_link_to_surface(struct ivi_layout_layer *ivilayer) |
| 144 | { |
| 145 | struct link_layer *link = NULL; |
| 146 | struct link_layer *next = NULL; |
| 147 | |
| 148 | wl_list_for_each_safe(link, next, &ivilayer->link_to_surface, link_to_layer) { |
| 149 | if (!wl_list_empty(&link->link_to_layer)) { |
| 150 | wl_list_remove(&link->link_to_layer); |
| 151 | } |
| 152 | if (!wl_list_empty(&link->link)) { |
| 153 | wl_list_remove(&link->link); |
| 154 | } |
| 155 | free(link); |
| 156 | } |
| 157 | |
| 158 | wl_list_init(&ivilayer->link_to_surface); |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Internal API to add a link to ivi_layer from ivi_screen. |
| 163 | */ |
| 164 | static void |
| 165 | add_link_to_layer(struct ivi_layout_screen *iviscrn, |
| 166 | struct link_screen *link_screen) |
| 167 | { |
| 168 | wl_list_init(&link_screen->link_to_screen); |
| 169 | wl_list_insert(&iviscrn->link_to_layer, &link_screen->link_to_screen); |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * Internal API to add/remove a ivi_surface from ivi_layer. |
| 174 | */ |
| 175 | static void |
| 176 | add_ordersurface_to_layer(struct ivi_layout_surface *ivisurf, |
| 177 | struct ivi_layout_layer *ivilayer) |
| 178 | { |
| 179 | struct link_layer *link_layer = NULL; |
| 180 | |
| 181 | link_layer = malloc(sizeof *link_layer); |
| 182 | if (link_layer == NULL) { |
| 183 | weston_log("fails to allocate memory\n"); |
| 184 | return; |
| 185 | } |
| 186 | |
| 187 | link_layer->ivilayer = ivilayer; |
| 188 | wl_list_init(&link_layer->link); |
| 189 | wl_list_insert(&ivisurf->layer_list, &link_layer->link); |
| 190 | add_link_to_surface(ivilayer, link_layer); |
| 191 | } |
| 192 | |
| 193 | static void |
| 194 | remove_ordersurface_from_layer(struct ivi_layout_surface *ivisurf) |
| 195 | { |
| 196 | struct link_layer *link_layer = NULL; |
| 197 | struct link_layer *next = NULL; |
| 198 | |
| 199 | wl_list_for_each_safe(link_layer, next, &ivisurf->layer_list, link) { |
| 200 | if (!wl_list_empty(&link_layer->link)) { |
| 201 | wl_list_remove(&link_layer->link); |
| 202 | } |
| 203 | if (!wl_list_empty(&link_layer->link_to_layer)) { |
| 204 | wl_list_remove(&link_layer->link_to_layer); |
| 205 | } |
| 206 | free(link_layer); |
| 207 | } |
| 208 | wl_list_init(&ivisurf->layer_list); |
| 209 | } |
| 210 | |
| 211 | /** |
| 212 | * Internal API to add/remove a ivi_layer to/from ivi_screen. |
| 213 | */ |
| 214 | static void |
| 215 | add_orderlayer_to_screen(struct ivi_layout_layer *ivilayer, |
| 216 | struct ivi_layout_screen *iviscrn) |
| 217 | { |
| 218 | struct link_screen *link_scrn = NULL; |
| 219 | |
| 220 | link_scrn = malloc(sizeof *link_scrn); |
| 221 | if (link_scrn == NULL) { |
| 222 | weston_log("fails to allocate memory\n"); |
| 223 | return; |
| 224 | } |
| 225 | |
| 226 | link_scrn->iviscrn = iviscrn; |
| 227 | wl_list_init(&link_scrn->link); |
| 228 | wl_list_insert(&ivilayer->screen_list, &link_scrn->link); |
| 229 | add_link_to_layer(iviscrn, link_scrn); |
| 230 | } |
| 231 | |
| 232 | static void |
| 233 | remove_orderlayer_from_screen(struct ivi_layout_layer *ivilayer) |
| 234 | { |
| 235 | struct link_screen *link_scrn = NULL; |
| 236 | struct link_screen *next = NULL; |
| 237 | |
| 238 | wl_list_for_each_safe(link_scrn, next, &ivilayer->screen_list, link) { |
| 239 | if (!wl_list_empty(&link_scrn->link)) { |
| 240 | wl_list_remove(&link_scrn->link); |
| 241 | } |
| 242 | if (!wl_list_empty(&link_scrn->link_to_screen)) { |
| 243 | wl_list_remove(&link_scrn->link_to_screen); |
| 244 | } |
| 245 | free(link_scrn); |
| 246 | } |
| 247 | wl_list_init(&ivilayer->screen_list); |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * Internal API to add/remove a ivi_layer to/from ivi_screen. |
| 252 | */ |
| 253 | static struct ivi_layout_surface * |
| 254 | get_surface(struct wl_list *surf_list, uint32_t id_surface) |
| 255 | { |
| 256 | struct ivi_layout_surface *ivisurf; |
| 257 | |
| 258 | wl_list_for_each(ivisurf, surf_list, link) { |
| 259 | if (ivisurf->id_surface == id_surface) { |
| 260 | return ivisurf; |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | return NULL; |
| 265 | } |
| 266 | |
| 267 | static struct ivi_layout_layer * |
| 268 | get_layer(struct wl_list *layer_list, uint32_t id_layer) |
| 269 | { |
| 270 | struct ivi_layout_layer *ivilayer; |
| 271 | |
| 272 | wl_list_for_each(ivilayer, layer_list, link) { |
| 273 | if (ivilayer->id_layer == id_layer) { |
| 274 | return ivilayer; |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | return NULL; |
| 279 | } |
| 280 | |
Nobuhiko Tanibata | ef6c786 | 2014-12-15 13:20:44 +0900 | [diff] [blame] | 281 | static void |
| 282 | remove_configured_listener(struct ivi_layout_surface *ivisurf) |
| 283 | { |
| 284 | struct wl_listener *link = NULL; |
| 285 | struct wl_listener *next = NULL; |
| 286 | |
| 287 | wl_list_for_each_safe(link, next, &ivisurf->configured.listener_list, link) { |
| 288 | wl_list_remove(&link->link); |
| 289 | } |
| 290 | } |
| 291 | |
Nobuhiko Tanibata | ef6c786 | 2014-12-15 13:20:44 +0900 | [diff] [blame] | 292 | static void |
| 293 | remove_all_notification(struct wl_list *listener_list) |
| 294 | { |
| 295 | struct wl_listener *listener = NULL; |
| 296 | struct wl_listener *next = NULL; |
| 297 | |
| 298 | wl_list_for_each_safe(listener, next, listener_list, link) { |
| 299 | struct listener_layout_notification *notification = NULL; |
| 300 | if (!wl_list_empty(&listener->link)) { |
| 301 | wl_list_remove(&listener->link); |
| 302 | } |
| 303 | |
| 304 | notification = |
| 305 | container_of(listener, |
| 306 | struct listener_layout_notification, |
| 307 | listener); |
| 308 | |
| 309 | free(notification->userdata); |
| 310 | free(notification); |
| 311 | } |
| 312 | } |
| 313 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 314 | static void |
Nobuhiko Tanibata | ef6c786 | 2014-12-15 13:20:44 +0900 | [diff] [blame] | 315 | ivi_layout_surface_remove_notification(struct ivi_layout_surface *ivisurf) |
| 316 | { |
| 317 | if (ivisurf == NULL) { |
| 318 | weston_log("ivi_layout_surface_remove_notification: invalid argument\n"); |
| 319 | return; |
| 320 | } |
| 321 | |
| 322 | remove_all_notification(&ivisurf->property_changed.listener_list); |
| 323 | } |
| 324 | |
Nobuhiko Tanibata | 8205170 | 2015-06-22 15:31:26 +0900 | [diff] [blame] | 325 | static void |
| 326 | ivi_layout_surface_remove_notification_by_callback(struct ivi_layout_surface *ivisurf, |
| 327 | surface_property_notification_func callback, |
| 328 | void *userdata) |
| 329 | { |
| 330 | if (ivisurf == NULL) { |
| 331 | weston_log("ivi_layout_surface_remove_notification_by_callback: invalid argument\n"); |
| 332 | return; |
| 333 | } |
| 334 | |
| 335 | remove_notification(&ivisurf->property_changed.listener_list, callback, userdata); |
| 336 | } |
| 337 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 338 | /** |
Nobuhiko Tanibata | 6f6c938 | 2015-06-22 15:30:53 +0900 | [diff] [blame] | 339 | * Called at destruction of wl_surface/ivi_surface |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 340 | */ |
Nobuhiko Tanibata | 6f6c938 | 2015-06-22 15:30:53 +0900 | [diff] [blame] | 341 | void |
| 342 | ivi_layout_surface_destroy(struct ivi_layout_surface *ivisurf) |
Nobuhiko Tanibata | ef6c786 | 2014-12-15 13:20:44 +0900 | [diff] [blame] | 343 | { |
| 344 | struct ivi_layout *layout = get_instance(); |
| 345 | |
| 346 | if (ivisurf == NULL) { |
Nobuhiko Tanibata | 6f6c938 | 2015-06-22 15:30:53 +0900 | [diff] [blame] | 347 | weston_log("%s: invalid argument\n", __func__); |
Nobuhiko Tanibata | ef6c786 | 2014-12-15 13:20:44 +0900 | [diff] [blame] | 348 | return; |
| 349 | } |
| 350 | |
Nobuhiko Tanibata | 6f6c938 | 2015-06-22 15:30:53 +0900 | [diff] [blame] | 351 | wl_list_remove(&ivisurf->surface_rotation.link); |
| 352 | wl_list_remove(&ivisurf->layer_rotation.link); |
| 353 | wl_list_remove(&ivisurf->surface_pos.link); |
| 354 | wl_list_remove(&ivisurf->layer_pos.link); |
| 355 | wl_list_remove(&ivisurf->scaling.link); |
| 356 | |
| 357 | wl_list_remove(&ivisurf->pending.link); |
| 358 | wl_list_remove(&ivisurf->order.link); |
| 359 | wl_list_remove(&ivisurf->link); |
Nobuhiko Tanibata | ef6c786 | 2014-12-15 13:20:44 +0900 | [diff] [blame] | 360 | remove_ordersurface_from_layer(ivisurf); |
| 361 | |
| 362 | wl_signal_emit(&layout->surface_notification.removed, ivisurf); |
| 363 | |
| 364 | remove_configured_listener(ivisurf); |
| 365 | |
| 366 | ivi_layout_surface_remove_notification(ivisurf); |
| 367 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 368 | ivisurf->surface = NULL; |
Nobuhiko Tanibata | 6f6c938 | 2015-06-22 15:30:53 +0900 | [diff] [blame] | 369 | |
| 370 | free(ivisurf); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | /** |
| 374 | * Internal API to check ivi_layer/ivi_surface already added in ivi_layer/ivi_screen. |
| 375 | * Called by ivi_layout_layer_add_surface/ivi_layout_screenAddLayer |
| 376 | */ |
| 377 | static int |
| 378 | is_surface_in_layer(struct ivi_layout_surface *ivisurf, |
| 379 | struct ivi_layout_layer *ivilayer) |
| 380 | { |
| 381 | struct ivi_layout_surface *surf = NULL; |
| 382 | |
| 383 | wl_list_for_each(surf, &ivilayer->pending.surface_list, pending.link) { |
| 384 | if (surf->id_surface == ivisurf->id_surface) { |
| 385 | return 1; |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | return 0; |
| 390 | } |
| 391 | |
| 392 | static int |
| 393 | is_layer_in_screen(struct ivi_layout_layer *ivilayer, |
| 394 | struct ivi_layout_screen *iviscrn) |
| 395 | { |
| 396 | struct ivi_layout_layer *layer = NULL; |
| 397 | |
| 398 | wl_list_for_each(layer, &iviscrn->pending.layer_list, pending.link) { |
| 399 | if (layer->id_layer == ivilayer->id_layer) { |
| 400 | return 1; |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | return 0; |
| 405 | } |
| 406 | |
| 407 | /** |
| 408 | * Internal API to initialize ivi_screens found from output_list of weston_compositor. |
| 409 | * Called by ivi_layout_init_with_compositor. |
| 410 | */ |
| 411 | static void |
| 412 | create_screen(struct weston_compositor *ec) |
| 413 | { |
| 414 | struct ivi_layout *layout = get_instance(); |
| 415 | struct ivi_layout_screen *iviscrn = NULL; |
| 416 | struct weston_output *output = NULL; |
| 417 | int32_t count = 0; |
| 418 | |
| 419 | wl_list_for_each(output, &ec->output_list, link) { |
| 420 | iviscrn = calloc(1, sizeof *iviscrn); |
| 421 | if (iviscrn == NULL) { |
| 422 | weston_log("fails to allocate memory\n"); |
| 423 | continue; |
| 424 | } |
| 425 | |
| 426 | wl_list_init(&iviscrn->link); |
| 427 | iviscrn->layout = layout; |
| 428 | |
| 429 | iviscrn->id_screen = count; |
| 430 | count++; |
| 431 | |
| 432 | iviscrn->output = output; |
| 433 | iviscrn->event_mask = 0; |
| 434 | |
| 435 | wl_list_init(&iviscrn->pending.layer_list); |
| 436 | wl_list_init(&iviscrn->pending.link); |
| 437 | |
| 438 | wl_list_init(&iviscrn->order.layer_list); |
| 439 | wl_list_init(&iviscrn->order.link); |
| 440 | |
| 441 | wl_list_init(&iviscrn->link_to_layer); |
| 442 | |
| 443 | wl_list_insert(&layout->screen_list, &iviscrn->link); |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | /** |
| 448 | * Internal APIs to initialize properties of ivi_surface/ivi_layer when they are created. |
| 449 | */ |
| 450 | static void |
| 451 | init_layer_properties(struct ivi_layout_layer_properties *prop, |
| 452 | int32_t width, int32_t height) |
| 453 | { |
| 454 | memset(prop, 0, sizeof *prop); |
| 455 | prop->opacity = wl_fixed_from_double(1.0); |
| 456 | prop->source_width = width; |
| 457 | prop->source_height = height; |
| 458 | prop->dest_width = width; |
| 459 | prop->dest_height = height; |
| 460 | } |
| 461 | |
| 462 | static void |
| 463 | init_surface_properties(struct ivi_layout_surface_properties *prop) |
| 464 | { |
| 465 | memset(prop, 0, sizeof *prop); |
| 466 | prop->opacity = wl_fixed_from_double(1.0); |
Nobuhiko Tanibata | e259a7a | 2015-04-27 17:02:54 +0900 | [diff] [blame] | 467 | /* |
| 468 | * FIXME: this shall be finxed by ivi-layout-transition. |
| 469 | */ |
| 470 | prop->dest_width = 1; |
| 471 | prop->dest_height = 1; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | /** |
| 475 | * Internal APIs to be called from ivi_layout_commit_changes. |
| 476 | */ |
| 477 | static void |
| 478 | update_opacity(struct ivi_layout_layer *ivilayer, |
| 479 | struct ivi_layout_surface *ivisurf) |
| 480 | { |
| 481 | double layer_alpha = wl_fixed_to_double(ivilayer->prop.opacity); |
| 482 | double surf_alpha = wl_fixed_to_double(ivisurf->prop.opacity); |
| 483 | |
| 484 | if ((ivilayer->event_mask & IVI_NOTIFICATION_OPACITY) || |
| 485 | (ivisurf->event_mask & IVI_NOTIFICATION_OPACITY)) { |
| 486 | struct weston_view *tmpview = NULL; |
| 487 | wl_list_for_each(tmpview, &ivisurf->surface->views, surface_link) { |
| 488 | if (tmpview == NULL) { |
| 489 | continue; |
| 490 | } |
| 491 | tmpview->alpha = layer_alpha * surf_alpha; |
| 492 | } |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | static void |
| 497 | update_surface_orientation(struct ivi_layout_layer *ivilayer, |
| 498 | struct ivi_layout_surface *ivisurf) |
| 499 | { |
| 500 | struct weston_view *view; |
| 501 | struct weston_matrix *matrix = &ivisurf->surface_rotation.matrix; |
| 502 | float width = 0.0f; |
| 503 | float height = 0.0f; |
| 504 | float v_sin = 0.0f; |
| 505 | float v_cos = 0.0f; |
| 506 | float cx = 0.0f; |
| 507 | float cy = 0.0f; |
| 508 | float sx = 1.0f; |
| 509 | float sy = 1.0f; |
| 510 | |
| 511 | wl_list_for_each(view, &ivisurf->surface->views, surface_link) { |
| 512 | if (view != NULL) { |
| 513 | break; |
| 514 | } |
| 515 | } |
| 516 | |
| 517 | if (view == NULL) { |
| 518 | return; |
| 519 | } |
| 520 | |
| 521 | if ((ivilayer->prop.dest_width == 0) || |
| 522 | (ivilayer->prop.dest_height == 0)) { |
| 523 | return; |
| 524 | } |
| 525 | width = (float)ivilayer->prop.dest_width; |
| 526 | height = (float)ivilayer->prop.dest_height; |
| 527 | |
| 528 | switch (ivisurf->prop.orientation) { |
| 529 | case WL_OUTPUT_TRANSFORM_NORMAL: |
| 530 | v_sin = 0.0f; |
| 531 | v_cos = 1.0f; |
| 532 | break; |
| 533 | case WL_OUTPUT_TRANSFORM_90: |
| 534 | v_sin = 1.0f; |
| 535 | v_cos = 0.0f; |
| 536 | sx = width / height; |
| 537 | sy = height / width; |
| 538 | break; |
| 539 | case WL_OUTPUT_TRANSFORM_180: |
| 540 | v_sin = 0.0f; |
| 541 | v_cos = -1.0f; |
| 542 | break; |
| 543 | case WL_OUTPUT_TRANSFORM_270: |
| 544 | default: |
| 545 | v_sin = -1.0f; |
| 546 | v_cos = 0.0f; |
| 547 | sx = width / height; |
| 548 | sy = height / width; |
| 549 | break; |
| 550 | } |
| 551 | wl_list_remove(&ivisurf->surface_rotation.link); |
| 552 | weston_view_geometry_dirty(view); |
| 553 | |
| 554 | weston_matrix_init(matrix); |
| 555 | cx = 0.5f * width; |
| 556 | cy = 0.5f * height; |
| 557 | weston_matrix_translate(matrix, -cx, -cy, 0.0f); |
| 558 | weston_matrix_rotate_xy(matrix, v_cos, v_sin); |
| 559 | weston_matrix_scale(matrix, sx, sy, 1.0); |
| 560 | weston_matrix_translate(matrix, cx, cy, 0.0f); |
| 561 | wl_list_insert(&view->geometry.transformation_list, |
| 562 | &ivisurf->surface_rotation.link); |
| 563 | |
| 564 | weston_view_set_transform_parent(view, NULL); |
| 565 | weston_view_update_transform(view); |
| 566 | } |
| 567 | |
| 568 | static void |
| 569 | update_layer_orientation(struct ivi_layout_layer *ivilayer, |
| 570 | struct ivi_layout_surface *ivisurf) |
| 571 | { |
| 572 | struct weston_surface *es = ivisurf->surface; |
| 573 | struct weston_view *view; |
| 574 | struct weston_matrix *matrix = &ivisurf->layer_rotation.matrix; |
| 575 | struct weston_output *output = NULL; |
| 576 | float width = 0.0f; |
| 577 | float height = 0.0f; |
| 578 | float v_sin = 0.0f; |
| 579 | float v_cos = 0.0f; |
| 580 | float cx = 0.0f; |
| 581 | float cy = 0.0f; |
| 582 | float sx = 1.0f; |
| 583 | float sy = 1.0f; |
| 584 | |
| 585 | wl_list_for_each(view, &ivisurf->surface->views, surface_link) { |
| 586 | if (view != NULL) { |
| 587 | break; |
| 588 | } |
| 589 | } |
| 590 | |
| 591 | if (es == NULL || view == NULL) { |
| 592 | return; |
| 593 | } |
| 594 | |
| 595 | output = es->output; |
| 596 | if (output == NULL) { |
| 597 | return; |
| 598 | } |
| 599 | if ((output->width == 0) || (output->height == 0)) { |
| 600 | return; |
| 601 | } |
| 602 | width = (float)output->width; |
| 603 | height = (float)output->height; |
| 604 | |
| 605 | switch (ivilayer->prop.orientation) { |
| 606 | case WL_OUTPUT_TRANSFORM_NORMAL: |
| 607 | v_sin = 0.0f; |
| 608 | v_cos = 1.0f; |
| 609 | break; |
| 610 | case WL_OUTPUT_TRANSFORM_90: |
| 611 | v_sin = 1.0f; |
| 612 | v_cos = 0.0f; |
| 613 | sx = width / height; |
| 614 | sy = height / width; |
| 615 | break; |
| 616 | case WL_OUTPUT_TRANSFORM_180: |
| 617 | v_sin = 0.0f; |
| 618 | v_cos = -1.0f; |
| 619 | break; |
| 620 | case WL_OUTPUT_TRANSFORM_270: |
| 621 | default: |
| 622 | v_sin = -1.0f; |
| 623 | v_cos = 0.0f; |
| 624 | sx = width / height; |
| 625 | sy = height / width; |
| 626 | break; |
| 627 | } |
| 628 | wl_list_remove(&ivisurf->layer_rotation.link); |
| 629 | weston_view_geometry_dirty(view); |
| 630 | |
| 631 | weston_matrix_init(matrix); |
| 632 | cx = 0.5f * width; |
| 633 | cy = 0.5f * height; |
| 634 | weston_matrix_translate(matrix, -cx, -cy, 0.0f); |
| 635 | weston_matrix_rotate_xy(matrix, v_cos, v_sin); |
| 636 | weston_matrix_scale(matrix, sx, sy, 1.0); |
| 637 | weston_matrix_translate(matrix, cx, cy, 0.0f); |
| 638 | wl_list_insert(&view->geometry.transformation_list, |
| 639 | &ivisurf->layer_rotation.link); |
| 640 | |
| 641 | weston_view_set_transform_parent(view, NULL); |
| 642 | weston_view_update_transform(view); |
| 643 | } |
| 644 | |
| 645 | static void |
| 646 | update_surface_position(struct ivi_layout_surface *ivisurf) |
| 647 | { |
| 648 | struct weston_view *view; |
| 649 | float tx = (float)ivisurf->prop.dest_x; |
| 650 | float ty = (float)ivisurf->prop.dest_y; |
| 651 | struct weston_matrix *matrix = &ivisurf->surface_pos.matrix; |
| 652 | |
| 653 | wl_list_for_each(view, &ivisurf->surface->views, surface_link) { |
| 654 | if (view != NULL) { |
| 655 | break; |
| 656 | } |
| 657 | } |
| 658 | |
| 659 | if (view == NULL) { |
| 660 | return; |
| 661 | } |
| 662 | |
| 663 | wl_list_remove(&ivisurf->surface_pos.link); |
| 664 | |
| 665 | weston_matrix_init(matrix); |
| 666 | weston_matrix_translate(matrix, tx, ty, 0.0f); |
| 667 | wl_list_insert(&view->geometry.transformation_list, |
| 668 | &ivisurf->surface_pos.link); |
| 669 | |
| 670 | weston_view_set_transform_parent(view, NULL); |
| 671 | weston_view_update_transform(view); |
| 672 | } |
| 673 | |
| 674 | static void |
| 675 | update_layer_position(struct ivi_layout_layer *ivilayer, |
| 676 | struct ivi_layout_surface *ivisurf) |
| 677 | { |
| 678 | struct weston_view *view; |
| 679 | struct weston_matrix *matrix = &ivisurf->layer_pos.matrix; |
| 680 | float tx = (float)ivilayer->prop.dest_x; |
| 681 | float ty = (float)ivilayer->prop.dest_y; |
| 682 | |
| 683 | wl_list_for_each(view, &ivisurf->surface->views, surface_link) { |
| 684 | if (view != NULL) { |
| 685 | break; |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | if (view == NULL) { |
| 690 | return; |
| 691 | } |
| 692 | |
| 693 | wl_list_remove(&ivisurf->layer_pos.link); |
| 694 | |
| 695 | weston_matrix_init(matrix); |
| 696 | weston_matrix_translate(matrix, tx, ty, 0.0f); |
| 697 | wl_list_insert(&view->geometry.transformation_list, |
| 698 | &ivisurf->layer_pos.link); |
| 699 | |
| 700 | weston_view_set_transform_parent(view, NULL); |
| 701 | weston_view_update_transform(view); |
| 702 | } |
| 703 | |
| 704 | static void |
| 705 | update_scale(struct ivi_layout_layer *ivilayer, |
| 706 | struct ivi_layout_surface *ivisurf) |
| 707 | { |
| 708 | struct weston_view *view; |
| 709 | struct weston_matrix *matrix = &ivisurf->scaling.matrix; |
| 710 | float sx = 0.0f; |
| 711 | float sy = 0.0f; |
| 712 | float lw = 0.0f; |
| 713 | float sw = 0.0f; |
| 714 | float lh = 0.0f; |
| 715 | float sh = 0.0f; |
| 716 | |
| 717 | wl_list_for_each(view, &ivisurf->surface->views, surface_link) { |
| 718 | if (view != NULL) { |
| 719 | break; |
| 720 | } |
| 721 | } |
| 722 | |
| 723 | if (view == NULL) { |
| 724 | return; |
| 725 | } |
| 726 | |
Nobuhiko Tanibata | bcff632 | 2015-04-27 16:57:26 +0900 | [diff] [blame] | 727 | if (ivisurf->prop.source_width == 0 || ivisurf->prop.source_height == 0) { |
| 728 | weston_log("ivi-shell: source rectangle is not yet set by ivi_layout_surface_set_source_rectangle\n"); |
| 729 | return; |
| 730 | } |
| 731 | |
| 732 | if (ivisurf->prop.dest_width == 0 || ivisurf->prop.dest_height == 0) { |
| 733 | weston_log("ivi-shell: destination rectangle is not yet set by ivi_layout_surface_set_destination_rectangle\n"); |
| 734 | return; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 735 | } |
| 736 | |
| 737 | lw = ((float)ivilayer->prop.dest_width / (float)ivilayer->prop.source_width ); |
| 738 | sw = ((float)ivisurf->prop.dest_width / (float)ivisurf->prop.source_width ); |
| 739 | lh = ((float)ivilayer->prop.dest_height / (float)ivilayer->prop.source_height); |
| 740 | sh = ((float)ivisurf->prop.dest_height / (float)ivisurf->prop.source_height ); |
| 741 | sx = sw * lw; |
| 742 | sy = sh * lh; |
| 743 | |
| 744 | wl_list_remove(&ivisurf->scaling.link); |
| 745 | weston_matrix_init(matrix); |
| 746 | weston_matrix_scale(matrix, sx, sy, 1.0f); |
| 747 | |
| 748 | wl_list_insert(&view->geometry.transformation_list, |
| 749 | &ivisurf->scaling.link); |
| 750 | |
| 751 | weston_view_set_transform_parent(view, NULL); |
| 752 | weston_view_update_transform(view); |
| 753 | } |
| 754 | |
| 755 | static void |
| 756 | update_prop(struct ivi_layout_layer *ivilayer, |
| 757 | struct ivi_layout_surface *ivisurf) |
| 758 | { |
Nobuhiko Tanibata | 4c1dbf7 | 2015-07-15 13:55:50 +0900 | [diff] [blame^] | 759 | struct weston_view *tmpview; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 760 | |
Nobuhiko Tanibata | 4c1dbf7 | 2015-07-15 13:55:50 +0900 | [diff] [blame^] | 761 | if (!ivilayer->event_mask && !ivisurf->event_mask) { |
| 762 | return; |
| 763 | } |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 764 | |
Nobuhiko Tanibata | 4c1dbf7 | 2015-07-15 13:55:50 +0900 | [diff] [blame^] | 765 | update_opacity(ivilayer, ivisurf); |
| 766 | update_layer_orientation(ivilayer, ivisurf); |
| 767 | update_layer_position(ivilayer, ivisurf); |
| 768 | update_surface_position(ivisurf); |
| 769 | update_surface_orientation(ivilayer, ivisurf); |
| 770 | update_scale(ivilayer, ivisurf); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 771 | |
Nobuhiko Tanibata | 4c1dbf7 | 2015-07-15 13:55:50 +0900 | [diff] [blame^] | 772 | ivisurf->update_count++; |
| 773 | |
| 774 | wl_list_for_each(tmpview, &ivisurf->surface->views, surface_link) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 775 | if (tmpview != NULL) { |
Nobuhiko Tanibata | 4c1dbf7 | 2015-07-15 13:55:50 +0900 | [diff] [blame^] | 776 | break; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 777 | } |
Nobuhiko Tanibata | 4c1dbf7 | 2015-07-15 13:55:50 +0900 | [diff] [blame^] | 778 | } |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 779 | |
Nobuhiko Tanibata | 4c1dbf7 | 2015-07-15 13:55:50 +0900 | [diff] [blame^] | 780 | if (tmpview != NULL) { |
| 781 | weston_view_geometry_dirty(tmpview); |
| 782 | } |
| 783 | |
| 784 | if (ivisurf->surface != NULL) { |
| 785 | weston_surface_damage(ivisurf->surface); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 786 | } |
| 787 | } |
| 788 | |
| 789 | static void |
| 790 | commit_changes(struct ivi_layout *layout) |
| 791 | { |
| 792 | struct ivi_layout_screen *iviscrn = NULL; |
| 793 | struct ivi_layout_layer *ivilayer = NULL; |
| 794 | struct ivi_layout_surface *ivisurf = NULL; |
| 795 | |
| 796 | wl_list_for_each(iviscrn, &layout->screen_list, link) { |
| 797 | wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) { |
| 798 | wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) { |
| 799 | update_prop(ivilayer, ivisurf); |
| 800 | } |
| 801 | } |
| 802 | } |
| 803 | } |
| 804 | |
| 805 | static void |
| 806 | commit_surface_list(struct ivi_layout *layout) |
| 807 | { |
| 808 | struct ivi_layout_surface *ivisurf = NULL; |
| 809 | int32_t dest_x = 0; |
| 810 | int32_t dest_y = 0; |
| 811 | int32_t dest_width = 0; |
| 812 | int32_t dest_height = 0; |
| 813 | int32_t configured = 0; |
| 814 | |
| 815 | wl_list_for_each(ivisurf, &layout->surface_list, link) { |
| 816 | if(ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEFAULT) { |
| 817 | dest_x = ivisurf->prop.dest_x; |
| 818 | dest_y = ivisurf->prop.dest_y; |
| 819 | dest_width = ivisurf->prop.dest_width; |
| 820 | dest_height = ivisurf->prop.dest_height; |
| 821 | |
| 822 | ivi_layout_transition_move_resize_view(ivisurf, |
| 823 | ivisurf->pending.prop.dest_x, |
| 824 | ivisurf->pending.prop.dest_y, |
| 825 | ivisurf->pending.prop.dest_width, |
| 826 | ivisurf->pending.prop.dest_height, |
| 827 | ivisurf->pending.prop.transition_duration); |
| 828 | |
| 829 | if(ivisurf->pending.prop.visibility) { |
| 830 | ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration); |
| 831 | } else { |
| 832 | ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration); |
| 833 | } |
| 834 | |
| 835 | ivisurf->prop = ivisurf->pending.prop; |
| 836 | ivisurf->prop.dest_x = dest_x; |
| 837 | ivisurf->prop.dest_y = dest_y; |
| 838 | ivisurf->prop.dest_width = dest_width; |
| 839 | ivisurf->prop.dest_height = dest_height; |
| 840 | ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 841 | ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 842 | |
| 843 | } else if(ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEST_RECT_ONLY){ |
| 844 | dest_x = ivisurf->prop.dest_x; |
| 845 | dest_y = ivisurf->prop.dest_y; |
| 846 | dest_width = ivisurf->prop.dest_width; |
| 847 | dest_height = ivisurf->prop.dest_height; |
| 848 | |
| 849 | ivi_layout_transition_move_resize_view(ivisurf, |
| 850 | ivisurf->pending.prop.dest_x, |
| 851 | ivisurf->pending.prop.dest_y, |
| 852 | ivisurf->pending.prop.dest_width, |
| 853 | ivisurf->pending.prop.dest_height, |
| 854 | ivisurf->pending.prop.transition_duration); |
| 855 | |
| 856 | ivisurf->prop = ivisurf->pending.prop; |
| 857 | ivisurf->prop.dest_x = dest_x; |
| 858 | ivisurf->prop.dest_y = dest_y; |
| 859 | ivisurf->prop.dest_width = dest_width; |
| 860 | ivisurf->prop.dest_height = dest_height; |
| 861 | |
| 862 | ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 863 | ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 864 | |
| 865 | } else if(ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY){ |
| 866 | configured = 0; |
| 867 | if(ivisurf->pending.prop.visibility) { |
| 868 | ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration); |
| 869 | } else { |
| 870 | ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration); |
| 871 | } |
| 872 | |
| 873 | if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width || |
| 874 | ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) { |
| 875 | configured = 1; |
| 876 | } |
| 877 | |
| 878 | ivisurf->prop = ivisurf->pending.prop; |
| 879 | ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 880 | ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 881 | |
| 882 | if (configured && !is_surface_transition(ivisurf)) |
| 883 | wl_signal_emit(&ivisurf->configured, ivisurf); |
| 884 | } else { |
| 885 | configured = 0; |
| 886 | if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width || |
| 887 | ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) { |
| 888 | configured = 1; |
| 889 | } |
| 890 | |
| 891 | ivisurf->prop = ivisurf->pending.prop; |
| 892 | ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 893 | ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 894 | |
| 895 | if (configured && !is_surface_transition(ivisurf)) |
| 896 | wl_signal_emit(&ivisurf->configured, ivisurf); |
| 897 | } |
| 898 | } |
| 899 | } |
| 900 | |
| 901 | static void |
| 902 | commit_layer_list(struct ivi_layout *layout) |
| 903 | { |
| 904 | struct ivi_layout_layer *ivilayer = NULL; |
| 905 | struct ivi_layout_surface *ivisurf = NULL; |
| 906 | struct ivi_layout_surface *next = NULL; |
| 907 | |
| 908 | wl_list_for_each(ivilayer, &layout->layer_list, link) { |
| 909 | if(ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_MOVE) { |
| 910 | ivi_layout_transition_move_layer(ivilayer, ivilayer->pending.prop.dest_x, ivilayer->pending.prop.dest_y, ivilayer->pending.prop.transition_duration); |
| 911 | } else if(ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_FADE) { |
| 912 | ivi_layout_transition_fade_layer(ivilayer,ivilayer->pending.prop.is_fade_in, |
| 913 | ivilayer->pending.prop.start_alpha,ivilayer->pending.prop.end_alpha, |
| 914 | NULL, NULL, |
| 915 | ivilayer->pending.prop.transition_duration); |
| 916 | } |
| 917 | ivilayer->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 918 | |
| 919 | ivilayer->prop = ivilayer->pending.prop; |
| 920 | |
| 921 | if (!(ivilayer->event_mask & |
| 922 | (IVI_NOTIFICATION_ADD | IVI_NOTIFICATION_REMOVE)) ) { |
| 923 | continue; |
| 924 | } |
| 925 | |
| 926 | if (ivilayer->event_mask & IVI_NOTIFICATION_REMOVE) { |
| 927 | wl_list_for_each_safe(ivisurf, next, |
| 928 | &ivilayer->order.surface_list, order.link) { |
| 929 | remove_ordersurface_from_layer(ivisurf); |
| 930 | |
| 931 | if (!wl_list_empty(&ivisurf->order.link)) { |
| 932 | wl_list_remove(&ivisurf->order.link); |
| 933 | } |
| 934 | |
| 935 | wl_list_init(&ivisurf->order.link); |
| 936 | ivisurf->event_mask |= IVI_NOTIFICATION_REMOVE; |
| 937 | } |
| 938 | |
| 939 | wl_list_init(&ivilayer->order.surface_list); |
| 940 | } |
| 941 | |
| 942 | if (ivilayer->event_mask & IVI_NOTIFICATION_ADD) { |
| 943 | wl_list_for_each_safe(ivisurf, next, |
| 944 | &ivilayer->order.surface_list, order.link) { |
| 945 | remove_ordersurface_from_layer(ivisurf); |
| 946 | |
| 947 | if (!wl_list_empty(&ivisurf->order.link)) { |
| 948 | wl_list_remove(&ivisurf->order.link); |
| 949 | } |
| 950 | |
| 951 | wl_list_init(&ivisurf->order.link); |
| 952 | } |
| 953 | |
| 954 | wl_list_init(&ivilayer->order.surface_list); |
| 955 | wl_list_for_each(ivisurf, &ivilayer->pending.surface_list, |
| 956 | pending.link) { |
| 957 | if(!wl_list_empty(&ivisurf->order.link)){ |
| 958 | wl_list_remove(&ivisurf->order.link); |
| 959 | wl_list_init(&ivisurf->order.link); |
| 960 | } |
| 961 | |
| 962 | wl_list_insert(&ivilayer->order.surface_list, |
| 963 | &ivisurf->order.link); |
| 964 | add_ordersurface_to_layer(ivisurf, ivilayer); |
| 965 | ivisurf->event_mask |= IVI_NOTIFICATION_ADD; |
| 966 | } |
| 967 | } |
| 968 | } |
| 969 | } |
| 970 | |
| 971 | static void |
| 972 | commit_screen_list(struct ivi_layout *layout) |
| 973 | { |
| 974 | struct ivi_layout_screen *iviscrn = NULL; |
| 975 | struct ivi_layout_layer *ivilayer = NULL; |
| 976 | struct ivi_layout_layer *next = NULL; |
| 977 | struct ivi_layout_surface *ivisurf = NULL; |
| 978 | |
| 979 | wl_list_for_each(iviscrn, &layout->screen_list, link) { |
| 980 | if (iviscrn->event_mask & IVI_NOTIFICATION_REMOVE) { |
| 981 | wl_list_for_each_safe(ivilayer, next, |
| 982 | &iviscrn->order.layer_list, order.link) { |
| 983 | remove_orderlayer_from_screen(ivilayer); |
| 984 | |
| 985 | if (!wl_list_empty(&ivilayer->order.link)) { |
| 986 | wl_list_remove(&ivilayer->order.link); |
| 987 | } |
| 988 | |
| 989 | wl_list_init(&ivilayer->order.link); |
| 990 | ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE; |
| 991 | } |
| 992 | } |
| 993 | |
| 994 | if (iviscrn->event_mask & IVI_NOTIFICATION_ADD) { |
| 995 | wl_list_for_each_safe(ivilayer, next, |
| 996 | &iviscrn->order.layer_list, order.link) { |
| 997 | remove_orderlayer_from_screen(ivilayer); |
| 998 | |
| 999 | if (!wl_list_empty(&ivilayer->order.link)) { |
| 1000 | wl_list_remove(&ivilayer->order.link); |
| 1001 | } |
| 1002 | |
| 1003 | wl_list_init(&ivilayer->order.link); |
| 1004 | } |
| 1005 | |
| 1006 | wl_list_init(&iviscrn->order.layer_list); |
| 1007 | wl_list_for_each(ivilayer, &iviscrn->pending.layer_list, |
| 1008 | pending.link) { |
| 1009 | wl_list_insert(&iviscrn->order.layer_list, |
| 1010 | &ivilayer->order.link); |
| 1011 | add_orderlayer_to_screen(ivilayer, iviscrn); |
| 1012 | ivilayer->event_mask |= IVI_NOTIFICATION_ADD; |
| 1013 | } |
| 1014 | } |
| 1015 | |
| 1016 | iviscrn->event_mask = 0; |
| 1017 | |
| 1018 | /* Clear view list of layout ivi_layer */ |
| 1019 | wl_list_init(&layout->layout_layer.view_list.link); |
| 1020 | |
| 1021 | wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) { |
| 1022 | if (ivilayer->prop.visibility == false) |
| 1023 | continue; |
| 1024 | |
| 1025 | wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) { |
| 1026 | struct weston_view *tmpview = NULL; |
| 1027 | wl_list_for_each(tmpview, &ivisurf->surface->views, surface_link) { |
| 1028 | if (tmpview != NULL) { |
| 1029 | break; |
| 1030 | } |
| 1031 | } |
| 1032 | |
| 1033 | if (ivisurf->prop.visibility == false) |
| 1034 | continue; |
| 1035 | if (ivisurf->surface == NULL || tmpview == NULL) |
| 1036 | continue; |
| 1037 | |
| 1038 | weston_layer_entry_insert(&layout->layout_layer.view_list, |
| 1039 | &tmpview->layer_link); |
| 1040 | |
| 1041 | ivisurf->surface->output = iviscrn->output; |
| 1042 | } |
| 1043 | } |
| 1044 | |
| 1045 | break; |
| 1046 | } |
| 1047 | } |
| 1048 | |
| 1049 | static void |
| 1050 | commit_transition(struct ivi_layout* layout) |
| 1051 | { |
| 1052 | if(wl_list_empty(&layout->pending_transition_list)){ |
| 1053 | return; |
| 1054 | } |
| 1055 | |
| 1056 | wl_list_insert_list(&layout->transitions->transition_list, |
| 1057 | &layout->pending_transition_list); |
| 1058 | |
| 1059 | wl_list_init(&layout->pending_transition_list); |
| 1060 | |
| 1061 | wl_event_source_timer_update(layout->transitions->event_source, 1); |
| 1062 | } |
| 1063 | |
| 1064 | static void |
| 1065 | send_surface_prop(struct ivi_layout_surface *ivisurf) |
| 1066 | { |
| 1067 | wl_signal_emit(&ivisurf->property_changed, ivisurf); |
| 1068 | ivisurf->event_mask = 0; |
| 1069 | } |
| 1070 | |
| 1071 | static void |
| 1072 | send_layer_prop(struct ivi_layout_layer *ivilayer) |
| 1073 | { |
| 1074 | wl_signal_emit(&ivilayer->property_changed, ivilayer); |
| 1075 | ivilayer->event_mask = 0; |
| 1076 | } |
| 1077 | |
| 1078 | static void |
| 1079 | send_prop(struct ivi_layout *layout) |
| 1080 | { |
| 1081 | struct ivi_layout_layer *ivilayer = NULL; |
| 1082 | struct ivi_layout_surface *ivisurf = NULL; |
| 1083 | |
| 1084 | wl_list_for_each_reverse(ivilayer, &layout->layer_list, link) { |
Nobuhiko Tanibata | 6ce3ef8 | 2015-06-22 15:32:06 +0900 | [diff] [blame] | 1085 | if (ivilayer->event_mask) |
| 1086 | send_layer_prop(ivilayer); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1087 | } |
| 1088 | |
| 1089 | wl_list_for_each_reverse(ivisurf, &layout->surface_list, link) { |
Nobuhiko Tanibata | 6ce3ef8 | 2015-06-22 15:32:06 +0900 | [diff] [blame] | 1090 | if (ivisurf->event_mask) |
| 1091 | send_surface_prop(ivisurf); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1092 | } |
| 1093 | } |
| 1094 | |
| 1095 | static void |
| 1096 | clear_surface_pending_list(struct ivi_layout_layer *ivilayer) |
| 1097 | { |
| 1098 | struct ivi_layout_surface *surface_link = NULL; |
| 1099 | struct ivi_layout_surface *surface_next = NULL; |
| 1100 | |
| 1101 | wl_list_for_each_safe(surface_link, surface_next, |
| 1102 | &ivilayer->pending.surface_list, pending.link) { |
| 1103 | if (!wl_list_empty(&surface_link->pending.link)) { |
| 1104 | wl_list_remove(&surface_link->pending.link); |
| 1105 | } |
| 1106 | |
| 1107 | wl_list_init(&surface_link->pending.link); |
| 1108 | } |
| 1109 | |
| 1110 | ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE; |
| 1111 | } |
| 1112 | |
| 1113 | static void |
| 1114 | clear_surface_order_list(struct ivi_layout_layer *ivilayer) |
| 1115 | { |
| 1116 | struct ivi_layout_surface *surface_link = NULL; |
| 1117 | struct ivi_layout_surface *surface_next = NULL; |
| 1118 | |
| 1119 | wl_list_for_each_safe(surface_link, surface_next, |
| 1120 | &ivilayer->order.surface_list, order.link) { |
| 1121 | if (!wl_list_empty(&surface_link->order.link)) { |
| 1122 | wl_list_remove(&surface_link->order.link); |
| 1123 | } |
| 1124 | |
| 1125 | wl_list_init(&surface_link->order.link); |
| 1126 | } |
| 1127 | |
| 1128 | ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE; |
| 1129 | } |
| 1130 | |
| 1131 | static void |
| 1132 | layer_created(struct wl_listener *listener, void *data) |
| 1133 | { |
| 1134 | struct ivi_layout_layer *ivilayer = data; |
| 1135 | |
| 1136 | struct listener_layout_notification *notification = |
| 1137 | container_of(listener, |
| 1138 | struct listener_layout_notification, |
| 1139 | listener); |
| 1140 | |
| 1141 | struct ivi_layout_notification_callback *created_callback = |
| 1142 | notification->userdata; |
| 1143 | |
| 1144 | ((layer_create_notification_func)created_callback->callback) |
| 1145 | (ivilayer, created_callback->data); |
| 1146 | } |
| 1147 | |
| 1148 | static void |
| 1149 | layer_removed(struct wl_listener *listener, void *data) |
| 1150 | { |
| 1151 | struct ivi_layout_layer *ivilayer = data; |
| 1152 | |
| 1153 | struct listener_layout_notification *notification = |
| 1154 | container_of(listener, |
| 1155 | struct listener_layout_notification, |
| 1156 | listener); |
| 1157 | |
| 1158 | struct ivi_layout_notification_callback *removed_callback = |
| 1159 | notification->userdata; |
| 1160 | |
| 1161 | ((layer_remove_notification_func)removed_callback->callback) |
| 1162 | (ivilayer, removed_callback->data); |
| 1163 | } |
| 1164 | |
| 1165 | static void |
| 1166 | layer_prop_changed(struct wl_listener *listener, void *data) |
| 1167 | { |
| 1168 | struct ivi_layout_layer *ivilayer = data; |
| 1169 | |
| 1170 | struct listener_layout_notification *layout_listener = |
| 1171 | container_of(listener, |
| 1172 | struct listener_layout_notification, |
| 1173 | listener); |
| 1174 | |
| 1175 | struct ivi_layout_notification_callback *prop_callback = |
| 1176 | layout_listener->userdata; |
| 1177 | |
| 1178 | ((layer_property_notification_func)prop_callback->callback) |
| 1179 | (ivilayer, &ivilayer->prop, ivilayer->event_mask, prop_callback->data); |
| 1180 | } |
| 1181 | |
| 1182 | static void |
| 1183 | surface_created(struct wl_listener *listener, void *data) |
| 1184 | { |
| 1185 | struct ivi_layout_surface *ivisurface = data; |
| 1186 | |
| 1187 | struct listener_layout_notification *notification = |
| 1188 | container_of(listener, |
| 1189 | struct listener_layout_notification, |
| 1190 | listener); |
| 1191 | |
| 1192 | struct ivi_layout_notification_callback *created_callback = |
| 1193 | notification->userdata; |
| 1194 | |
| 1195 | ((surface_create_notification_func)created_callback->callback) |
| 1196 | (ivisurface, created_callback->data); |
| 1197 | } |
| 1198 | |
| 1199 | static void |
| 1200 | surface_removed(struct wl_listener *listener, void *data) |
| 1201 | { |
| 1202 | struct ivi_layout_surface *ivisurface = data; |
| 1203 | |
| 1204 | struct listener_layout_notification *notification = |
| 1205 | container_of(listener, |
| 1206 | struct listener_layout_notification, |
| 1207 | listener); |
| 1208 | |
| 1209 | struct ivi_layout_notification_callback *removed_callback = |
| 1210 | notification->userdata; |
| 1211 | |
| 1212 | ((surface_remove_notification_func)removed_callback->callback) |
| 1213 | (ivisurface, removed_callback->data); |
| 1214 | } |
| 1215 | |
| 1216 | static void |
| 1217 | surface_prop_changed(struct wl_listener *listener, void *data) |
| 1218 | { |
| 1219 | struct ivi_layout_surface *ivisurf = data; |
| 1220 | |
| 1221 | struct listener_layout_notification *layout_listener = |
| 1222 | container_of(listener, |
| 1223 | struct listener_layout_notification, |
| 1224 | listener); |
| 1225 | |
| 1226 | struct ivi_layout_notification_callback *prop_callback = |
| 1227 | layout_listener->userdata; |
| 1228 | |
| 1229 | ((surface_property_notification_func)prop_callback->callback) |
| 1230 | (ivisurf, &ivisurf->prop, ivisurf->event_mask, prop_callback->data); |
| 1231 | |
| 1232 | ivisurf->event_mask = 0; |
| 1233 | } |
| 1234 | |
| 1235 | static void |
| 1236 | surface_configure_changed(struct wl_listener *listener, |
| 1237 | void *data) |
| 1238 | { |
| 1239 | struct ivi_layout_surface *ivisurface = data; |
| 1240 | |
| 1241 | struct listener_layout_notification *notification = |
| 1242 | container_of(listener, |
| 1243 | struct listener_layout_notification, |
| 1244 | listener); |
| 1245 | |
| 1246 | struct ivi_layout_notification_callback *configure_changed_callback = |
| 1247 | notification->userdata; |
| 1248 | |
| 1249 | ((surface_configure_notification_func)configure_changed_callback->callback) |
| 1250 | (ivisurface, configure_changed_callback->data); |
| 1251 | } |
| 1252 | |
| 1253 | static int32_t |
| 1254 | add_notification(struct wl_signal *signal, |
| 1255 | wl_notify_func_t callback, |
| 1256 | void *userdata) |
| 1257 | { |
| 1258 | struct listener_layout_notification *notification = NULL; |
| 1259 | |
| 1260 | notification = malloc(sizeof *notification); |
| 1261 | if (notification == NULL) { |
| 1262 | weston_log("fails to allocate memory\n"); |
| 1263 | free(userdata); |
| 1264 | return IVI_FAILED; |
| 1265 | } |
| 1266 | |
| 1267 | notification->listener.notify = callback; |
| 1268 | notification->userdata = userdata; |
| 1269 | |
| 1270 | wl_signal_add(signal, ¬ification->listener); |
| 1271 | |
| 1272 | return IVI_SUCCEEDED; |
| 1273 | } |
| 1274 | |
| 1275 | static void |
| 1276 | remove_notification(struct wl_list *listener_list, void *callback, void *userdata) |
| 1277 | { |
| 1278 | struct wl_listener *listener = NULL; |
| 1279 | struct wl_listener *next = NULL; |
| 1280 | |
| 1281 | wl_list_for_each_safe(listener, next, listener_list, link) { |
| 1282 | struct listener_layout_notification *notification = |
| 1283 | container_of(listener, |
| 1284 | struct listener_layout_notification, |
| 1285 | listener); |
| 1286 | |
| 1287 | struct ivi_layout_notification_callback *notification_callback = |
| 1288 | notification->userdata; |
| 1289 | |
| 1290 | if ((notification_callback->callback != callback) || |
| 1291 | (notification_callback->data != userdata)) { |
| 1292 | continue; |
| 1293 | } |
| 1294 | |
| 1295 | if (!wl_list_empty(&listener->link)) { |
| 1296 | wl_list_remove(&listener->link); |
| 1297 | } |
| 1298 | |
| 1299 | free(notification->userdata); |
| 1300 | free(notification); |
| 1301 | } |
| 1302 | } |
| 1303 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1304 | /** |
| 1305 | * Exported APIs of ivi-layout library are implemented from here. |
| 1306 | * Brief of APIs is described in ivi-layout-export.h. |
| 1307 | */ |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1308 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1309 | ivi_layout_add_notification_create_layer(layer_create_notification_func callback, |
| 1310 | void *userdata) |
| 1311 | { |
| 1312 | struct ivi_layout *layout = get_instance(); |
| 1313 | struct ivi_layout_notification_callback *created_callback = NULL; |
| 1314 | |
| 1315 | if (callback == NULL) { |
| 1316 | weston_log("ivi_layout_add_notification_create_layer: invalid argument\n"); |
| 1317 | return IVI_FAILED; |
| 1318 | } |
| 1319 | |
| 1320 | created_callback = malloc(sizeof *created_callback); |
| 1321 | if (created_callback == NULL) { |
| 1322 | weston_log("fails to allocate memory\n"); |
| 1323 | return IVI_FAILED; |
| 1324 | } |
| 1325 | |
| 1326 | created_callback->callback = callback; |
| 1327 | created_callback->data = userdata; |
| 1328 | |
| 1329 | return add_notification(&layout->layer_notification.created, |
| 1330 | layer_created, |
| 1331 | created_callback); |
| 1332 | } |
| 1333 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1334 | static void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1335 | ivi_layout_remove_notification_create_layer(layer_create_notification_func callback, |
| 1336 | void *userdata) |
| 1337 | { |
| 1338 | struct ivi_layout *layout = get_instance(); |
| 1339 | remove_notification(&layout->layer_notification.created.listener_list, callback, userdata); |
| 1340 | } |
| 1341 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1342 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1343 | ivi_layout_add_notification_remove_layer(layer_remove_notification_func callback, |
| 1344 | void *userdata) |
| 1345 | { |
| 1346 | struct ivi_layout *layout = get_instance(); |
| 1347 | struct ivi_layout_notification_callback *removed_callback = NULL; |
| 1348 | |
| 1349 | if (callback == NULL) { |
| 1350 | weston_log("ivi_layout_add_notification_remove_layer: invalid argument\n"); |
| 1351 | return IVI_FAILED; |
| 1352 | } |
| 1353 | |
| 1354 | removed_callback = malloc(sizeof *removed_callback); |
| 1355 | if (removed_callback == NULL) { |
| 1356 | weston_log("fails to allocate memory\n"); |
| 1357 | return IVI_FAILED; |
| 1358 | } |
| 1359 | |
| 1360 | removed_callback->callback = callback; |
| 1361 | removed_callback->data = userdata; |
| 1362 | return add_notification(&layout->layer_notification.removed, |
| 1363 | layer_removed, |
| 1364 | removed_callback); |
| 1365 | } |
| 1366 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1367 | static void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1368 | ivi_layout_remove_notification_remove_layer(layer_remove_notification_func callback, |
| 1369 | void *userdata) |
| 1370 | { |
| 1371 | struct ivi_layout *layout = get_instance(); |
| 1372 | remove_notification(&layout->layer_notification.removed.listener_list, callback, userdata); |
| 1373 | } |
| 1374 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1375 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1376 | ivi_layout_add_notification_create_surface(surface_create_notification_func callback, |
| 1377 | void *userdata) |
| 1378 | { |
| 1379 | struct ivi_layout *layout = get_instance(); |
| 1380 | struct ivi_layout_notification_callback *created_callback = NULL; |
| 1381 | |
| 1382 | if (callback == NULL) { |
| 1383 | weston_log("ivi_layout_add_notification_create_surface: invalid argument\n"); |
| 1384 | return IVI_FAILED; |
| 1385 | } |
| 1386 | |
| 1387 | created_callback = malloc(sizeof *created_callback); |
| 1388 | if (created_callback == NULL) { |
| 1389 | weston_log("fails to allocate memory\n"); |
| 1390 | return IVI_FAILED; |
| 1391 | } |
| 1392 | |
| 1393 | created_callback->callback = callback; |
| 1394 | created_callback->data = userdata; |
| 1395 | |
| 1396 | return add_notification(&layout->surface_notification.created, |
| 1397 | surface_created, |
| 1398 | created_callback); |
| 1399 | } |
| 1400 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1401 | static void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1402 | ivi_layout_remove_notification_create_surface(surface_create_notification_func callback, |
| 1403 | void *userdata) |
| 1404 | { |
| 1405 | struct ivi_layout *layout = get_instance(); |
| 1406 | remove_notification(&layout->surface_notification.created.listener_list, callback, userdata); |
| 1407 | } |
| 1408 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1409 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1410 | ivi_layout_add_notification_remove_surface(surface_remove_notification_func callback, |
| 1411 | void *userdata) |
| 1412 | { |
| 1413 | struct ivi_layout *layout = get_instance(); |
| 1414 | struct ivi_layout_notification_callback *removed_callback = NULL; |
| 1415 | |
| 1416 | if (callback == NULL) { |
| 1417 | weston_log("ivi_layout_add_notification_remove_surface: invalid argument\n"); |
| 1418 | return IVI_FAILED; |
| 1419 | } |
| 1420 | |
| 1421 | removed_callback = malloc(sizeof *removed_callback); |
| 1422 | if (removed_callback == NULL) { |
| 1423 | weston_log("fails to allocate memory\n"); |
| 1424 | return IVI_FAILED; |
| 1425 | } |
| 1426 | |
| 1427 | removed_callback->callback = callback; |
| 1428 | removed_callback->data = userdata; |
| 1429 | |
| 1430 | return add_notification(&layout->surface_notification.removed, |
| 1431 | surface_removed, |
| 1432 | removed_callback); |
| 1433 | } |
| 1434 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1435 | static void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1436 | ivi_layout_remove_notification_remove_surface(surface_remove_notification_func callback, |
| 1437 | void *userdata) |
| 1438 | { |
| 1439 | struct ivi_layout *layout = get_instance(); |
| 1440 | remove_notification(&layout->surface_notification.removed.listener_list, callback, userdata); |
| 1441 | } |
| 1442 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1443 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1444 | ivi_layout_add_notification_configure_surface(surface_configure_notification_func callback, |
| 1445 | void *userdata) |
| 1446 | { |
| 1447 | struct ivi_layout *layout = get_instance(); |
| 1448 | struct ivi_layout_notification_callback *configure_changed_callback = NULL; |
| 1449 | if (callback == NULL) { |
| 1450 | weston_log("ivi_layout_add_notification_configure_surface: invalid argument\n"); |
| 1451 | return IVI_FAILED; |
| 1452 | } |
| 1453 | |
| 1454 | configure_changed_callback = malloc(sizeof *configure_changed_callback); |
| 1455 | if (configure_changed_callback == NULL) { |
| 1456 | weston_log("fails to allocate memory\n"); |
| 1457 | return IVI_FAILED; |
| 1458 | } |
| 1459 | |
| 1460 | configure_changed_callback->callback = callback; |
| 1461 | configure_changed_callback->data = userdata; |
| 1462 | |
| 1463 | return add_notification(&layout->surface_notification.configure_changed, |
| 1464 | surface_configure_changed, |
| 1465 | configure_changed_callback); |
| 1466 | } |
| 1467 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1468 | static void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1469 | ivi_layout_remove_notification_configure_surface(surface_configure_notification_func callback, |
| 1470 | void *userdata) |
| 1471 | { |
| 1472 | struct ivi_layout *layout = get_instance(); |
| 1473 | remove_notification(&layout->surface_notification.configure_changed.listener_list, callback, userdata); |
| 1474 | } |
| 1475 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1476 | uint32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1477 | ivi_layout_get_id_of_surface(struct ivi_layout_surface *ivisurf) |
| 1478 | { |
| 1479 | return ivisurf->id_surface; |
| 1480 | } |
| 1481 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1482 | static uint32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1483 | ivi_layout_get_id_of_layer(struct ivi_layout_layer *ivilayer) |
| 1484 | { |
| 1485 | return ivilayer->id_layer; |
| 1486 | } |
| 1487 | |
Nobuhiko Tanibata | 4d0116e | 2015-06-22 15:31:57 +0900 | [diff] [blame] | 1488 | static uint32_t |
| 1489 | ivi_layout_get_id_of_screen(struct ivi_layout_screen *iviscrn) |
| 1490 | { |
| 1491 | return iviscrn->id_screen; |
| 1492 | } |
| 1493 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1494 | static struct ivi_layout_layer * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1495 | ivi_layout_get_layer_from_id(uint32_t id_layer) |
| 1496 | { |
| 1497 | struct ivi_layout *layout = get_instance(); |
| 1498 | struct ivi_layout_layer *ivilayer = NULL; |
| 1499 | |
| 1500 | wl_list_for_each(ivilayer, &layout->layer_list, link) { |
| 1501 | if (ivilayer->id_layer == id_layer) { |
| 1502 | return ivilayer; |
| 1503 | } |
| 1504 | } |
| 1505 | |
| 1506 | return NULL; |
| 1507 | } |
| 1508 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1509 | struct ivi_layout_surface * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1510 | ivi_layout_get_surface_from_id(uint32_t id_surface) |
| 1511 | { |
| 1512 | struct ivi_layout *layout = get_instance(); |
| 1513 | struct ivi_layout_surface *ivisurf = NULL; |
| 1514 | |
| 1515 | wl_list_for_each(ivisurf, &layout->surface_list, link) { |
| 1516 | if (ivisurf->id_surface == id_surface) { |
| 1517 | return ivisurf; |
| 1518 | } |
| 1519 | } |
| 1520 | |
| 1521 | return NULL; |
| 1522 | } |
| 1523 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1524 | static struct ivi_layout_screen * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1525 | ivi_layout_get_screen_from_id(uint32_t id_screen) |
| 1526 | { |
| 1527 | struct ivi_layout *layout = get_instance(); |
| 1528 | struct ivi_layout_screen *iviscrn = NULL; |
| 1529 | |
| 1530 | wl_list_for_each(iviscrn, &layout->screen_list, link) { |
| 1531 | /* FIXME : select iviscrn from screen_list by id_screen */ |
| 1532 | return iviscrn; |
| 1533 | break; |
| 1534 | } |
| 1535 | |
| 1536 | return NULL; |
| 1537 | } |
| 1538 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1539 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1540 | ivi_layout_get_screen_resolution(struct ivi_layout_screen *iviscrn, |
| 1541 | int32_t *pWidth, int32_t *pHeight) |
| 1542 | { |
| 1543 | struct weston_output *output = NULL; |
| 1544 | |
Nobuhiko Tanibata | 0c217cb | 2015-06-22 15:30:32 +0900 | [diff] [blame] | 1545 | if (iviscrn == NULL || pWidth == NULL || pHeight == NULL) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1546 | weston_log("ivi_layout_get_screen_resolution: invalid argument\n"); |
| 1547 | return IVI_FAILED; |
| 1548 | } |
| 1549 | |
| 1550 | output = iviscrn->output; |
| 1551 | *pWidth = output->current_mode->width; |
| 1552 | *pHeight = output->current_mode->height; |
| 1553 | |
| 1554 | return IVI_SUCCEEDED; |
| 1555 | } |
| 1556 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1557 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1558 | ivi_layout_surface_add_notification(struct ivi_layout_surface *ivisurf, |
| 1559 | surface_property_notification_func callback, |
| 1560 | void *userdata) |
| 1561 | { |
| 1562 | struct listener_layout_notification* notification = NULL; |
| 1563 | struct ivi_layout_notification_callback *prop_callback = NULL; |
| 1564 | |
| 1565 | if (ivisurf == NULL || callback == NULL) { |
| 1566 | weston_log("ivi_layout_surface_add_notification: invalid argument\n"); |
| 1567 | return IVI_FAILED; |
| 1568 | } |
| 1569 | |
| 1570 | notification = malloc(sizeof *notification); |
| 1571 | if (notification == NULL) { |
| 1572 | weston_log("fails to allocate memory\n"); |
| 1573 | return IVI_FAILED; |
| 1574 | } |
| 1575 | |
| 1576 | prop_callback = malloc(sizeof *prop_callback); |
| 1577 | if (prop_callback == NULL) { |
| 1578 | weston_log("fails to allocate memory\n"); |
| 1579 | return IVI_FAILED; |
| 1580 | } |
| 1581 | |
| 1582 | prop_callback->callback = callback; |
| 1583 | prop_callback->data = userdata; |
| 1584 | |
| 1585 | notification->listener.notify = surface_prop_changed; |
| 1586 | notification->userdata = prop_callback; |
| 1587 | |
| 1588 | wl_signal_add(&ivisurf->property_changed, ¬ification->listener); |
| 1589 | |
| 1590 | return IVI_SUCCEEDED; |
| 1591 | } |
| 1592 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1593 | static const struct ivi_layout_layer_properties * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1594 | ivi_layout_get_properties_of_layer(struct ivi_layout_layer *ivilayer) |
| 1595 | { |
| 1596 | if (ivilayer == NULL) { |
| 1597 | weston_log("ivi_layout_get_properties_of_layer: invalid argument\n"); |
| 1598 | return NULL; |
| 1599 | } |
| 1600 | |
| 1601 | return &ivilayer->prop; |
| 1602 | } |
| 1603 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1604 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1605 | ivi_layout_get_screens(int32_t *pLength, struct ivi_layout_screen ***ppArray) |
| 1606 | { |
| 1607 | struct ivi_layout *layout = get_instance(); |
| 1608 | struct ivi_layout_screen *iviscrn = NULL; |
| 1609 | int32_t length = 0; |
| 1610 | int32_t n = 0; |
| 1611 | |
| 1612 | if (pLength == NULL || ppArray == NULL) { |
| 1613 | weston_log("ivi_layout_get_screens: invalid argument\n"); |
| 1614 | return IVI_FAILED; |
| 1615 | } |
| 1616 | |
| 1617 | length = wl_list_length(&layout->screen_list); |
| 1618 | |
| 1619 | if (length != 0){ |
| 1620 | /* the Array must be free by module which called this function */ |
| 1621 | *ppArray = calloc(length, sizeof(struct ivi_layout_screen *)); |
| 1622 | if (*ppArray == NULL) { |
| 1623 | weston_log("fails to allocate memory\n"); |
| 1624 | return IVI_FAILED; |
| 1625 | } |
| 1626 | |
| 1627 | wl_list_for_each(iviscrn, &layout->screen_list, link) { |
| 1628 | (*ppArray)[n++] = iviscrn; |
| 1629 | } |
| 1630 | } |
| 1631 | |
| 1632 | *pLength = length; |
| 1633 | |
| 1634 | return IVI_SUCCEEDED; |
| 1635 | } |
| 1636 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1637 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1638 | ivi_layout_get_screens_under_layer(struct ivi_layout_layer *ivilayer, |
| 1639 | int32_t *pLength, |
| 1640 | struct ivi_layout_screen ***ppArray) |
| 1641 | { |
| 1642 | struct link_screen *link_scrn = NULL; |
| 1643 | int32_t length = 0; |
| 1644 | int32_t n = 0; |
| 1645 | |
| 1646 | if (ivilayer == NULL || pLength == NULL || ppArray == NULL) { |
| 1647 | weston_log("ivi_layout_get_screens_under_layer: invalid argument\n"); |
| 1648 | return IVI_FAILED; |
| 1649 | } |
| 1650 | |
| 1651 | length = wl_list_length(&ivilayer->screen_list); |
| 1652 | |
| 1653 | if (length != 0){ |
| 1654 | /* the Array must be free by module which called this function */ |
| 1655 | *ppArray = calloc(length, sizeof(struct ivi_layout_screen *)); |
| 1656 | if (*ppArray == NULL) { |
| 1657 | weston_log("fails to allocate memory\n"); |
| 1658 | return IVI_FAILED; |
| 1659 | } |
| 1660 | |
| 1661 | wl_list_for_each(link_scrn, &ivilayer->screen_list, link) { |
| 1662 | (*ppArray)[n++] = link_scrn->iviscrn; |
| 1663 | } |
| 1664 | } |
| 1665 | |
| 1666 | *pLength = length; |
| 1667 | |
| 1668 | return IVI_SUCCEEDED; |
| 1669 | } |
| 1670 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1671 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1672 | ivi_layout_get_layers(int32_t *pLength, struct ivi_layout_layer ***ppArray) |
| 1673 | { |
| 1674 | struct ivi_layout *layout = get_instance(); |
| 1675 | struct ivi_layout_layer *ivilayer = NULL; |
| 1676 | int32_t length = 0; |
| 1677 | int32_t n = 0; |
| 1678 | |
| 1679 | if (pLength == NULL || ppArray == NULL) { |
| 1680 | weston_log("ivi_layout_get_layers: invalid argument\n"); |
| 1681 | return IVI_FAILED; |
| 1682 | } |
| 1683 | |
| 1684 | length = wl_list_length(&layout->layer_list); |
| 1685 | |
| 1686 | if (length != 0){ |
| 1687 | /* the Array must be free by module which called this function */ |
| 1688 | *ppArray = calloc(length, sizeof(struct ivi_layout_layer *)); |
| 1689 | if (*ppArray == NULL) { |
| 1690 | weston_log("fails to allocate memory\n"); |
| 1691 | return IVI_FAILED; |
| 1692 | } |
| 1693 | |
| 1694 | wl_list_for_each(ivilayer, &layout->layer_list, link) { |
| 1695 | (*ppArray)[n++] = ivilayer; |
| 1696 | } |
| 1697 | } |
| 1698 | |
| 1699 | *pLength = length; |
| 1700 | |
| 1701 | return IVI_SUCCEEDED; |
| 1702 | } |
| 1703 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1704 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1705 | ivi_layout_get_layers_on_screen(struct ivi_layout_screen *iviscrn, |
| 1706 | int32_t *pLength, |
| 1707 | struct ivi_layout_layer ***ppArray) |
| 1708 | { |
| 1709 | struct ivi_layout_layer *ivilayer = NULL; |
| 1710 | int32_t length = 0; |
| 1711 | int32_t n = 0; |
| 1712 | |
| 1713 | if (iviscrn == NULL || pLength == NULL || ppArray == NULL) { |
| 1714 | weston_log("ivi_layout_get_layers_on_screen: invalid argument\n"); |
| 1715 | return IVI_FAILED; |
| 1716 | } |
| 1717 | |
| 1718 | length = wl_list_length(&iviscrn->order.layer_list); |
| 1719 | |
| 1720 | if (length != 0){ |
| 1721 | /* the Array must be free by module which called this function */ |
| 1722 | *ppArray = calloc(length, sizeof(struct ivi_layout_layer *)); |
| 1723 | if (*ppArray == NULL) { |
| 1724 | weston_log("fails to allocate memory\n"); |
| 1725 | return IVI_FAILED; |
| 1726 | } |
| 1727 | |
Nobuhiko Tanibata | e2b8214 | 2015-06-22 15:30:19 +0900 | [diff] [blame] | 1728 | wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1729 | (*ppArray)[n++] = ivilayer; |
| 1730 | } |
| 1731 | } |
| 1732 | |
| 1733 | *pLength = length; |
| 1734 | |
| 1735 | return IVI_SUCCEEDED; |
| 1736 | } |
| 1737 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1738 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1739 | ivi_layout_get_layers_under_surface(struct ivi_layout_surface *ivisurf, |
| 1740 | int32_t *pLength, |
| 1741 | struct ivi_layout_layer ***ppArray) |
| 1742 | { |
| 1743 | struct link_layer *link_layer = NULL; |
| 1744 | int32_t length = 0; |
| 1745 | int32_t n = 0; |
| 1746 | |
| 1747 | if (ivisurf == NULL || pLength == NULL || ppArray == NULL) { |
| 1748 | weston_log("ivi_layout_getLayers: invalid argument\n"); |
| 1749 | return IVI_FAILED; |
| 1750 | } |
| 1751 | |
| 1752 | length = wl_list_length(&ivisurf->layer_list); |
| 1753 | |
| 1754 | if (length != 0){ |
| 1755 | /* the Array must be free by module which called this function */ |
| 1756 | *ppArray = calloc(length, sizeof(struct ivi_layout_layer *)); |
| 1757 | if (*ppArray == NULL) { |
| 1758 | weston_log("fails to allocate memory\n"); |
| 1759 | return IVI_FAILED; |
| 1760 | } |
| 1761 | |
| 1762 | wl_list_for_each(link_layer, &ivisurf->layer_list, link) { |
| 1763 | (*ppArray)[n++] = link_layer->ivilayer; |
| 1764 | } |
| 1765 | } |
| 1766 | |
| 1767 | *pLength = length; |
| 1768 | |
| 1769 | return IVI_SUCCEEDED; |
| 1770 | } |
| 1771 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1772 | static |
| 1773 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1774 | ivi_layout_get_surfaces(int32_t *pLength, struct ivi_layout_surface ***ppArray) |
| 1775 | { |
| 1776 | struct ivi_layout *layout = get_instance(); |
| 1777 | struct ivi_layout_surface *ivisurf = NULL; |
| 1778 | int32_t length = 0; |
| 1779 | int32_t n = 0; |
| 1780 | |
| 1781 | if (pLength == NULL || ppArray == NULL) { |
| 1782 | weston_log("ivi_layout_get_surfaces: invalid argument\n"); |
| 1783 | return IVI_FAILED; |
| 1784 | } |
| 1785 | |
| 1786 | length = wl_list_length(&layout->surface_list); |
| 1787 | |
| 1788 | if (length != 0){ |
| 1789 | /* the Array must be free by module which called this function */ |
| 1790 | *ppArray = calloc(length, sizeof(struct ivi_layout_surface *)); |
| 1791 | if (*ppArray == NULL) { |
| 1792 | weston_log("fails to allocate memory\n"); |
| 1793 | return IVI_FAILED; |
| 1794 | } |
| 1795 | |
| 1796 | wl_list_for_each(ivisurf, &layout->surface_list, link) { |
| 1797 | (*ppArray)[n++] = ivisurf; |
| 1798 | } |
| 1799 | } |
| 1800 | |
| 1801 | *pLength = length; |
| 1802 | |
| 1803 | return IVI_SUCCEEDED; |
| 1804 | } |
| 1805 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1806 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1807 | ivi_layout_get_surfaces_on_layer(struct ivi_layout_layer *ivilayer, |
| 1808 | int32_t *pLength, |
| 1809 | struct ivi_layout_surface ***ppArray) |
| 1810 | { |
| 1811 | struct ivi_layout_surface *ivisurf = NULL; |
| 1812 | int32_t length = 0; |
| 1813 | int32_t n = 0; |
| 1814 | |
| 1815 | if (ivilayer == NULL || pLength == NULL || ppArray == NULL) { |
| 1816 | weston_log("ivi_layout_getSurfaceIDsOnLayer: invalid argument\n"); |
| 1817 | return IVI_FAILED; |
| 1818 | } |
| 1819 | |
| 1820 | length = wl_list_length(&ivilayer->order.surface_list); |
| 1821 | |
| 1822 | if (length != 0) { |
| 1823 | /* the Array must be free by module which called this function */ |
| 1824 | *ppArray = calloc(length, sizeof(struct ivi_layout_surface *)); |
| 1825 | if (*ppArray == NULL) { |
| 1826 | weston_log("fails to allocate memory\n"); |
| 1827 | return IVI_FAILED; |
| 1828 | } |
| 1829 | |
| 1830 | wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) { |
| 1831 | (*ppArray)[n++] = ivisurf; |
| 1832 | } |
| 1833 | } |
| 1834 | |
| 1835 | *pLength = length; |
| 1836 | |
| 1837 | return IVI_SUCCEEDED; |
| 1838 | } |
| 1839 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1840 | static struct ivi_layout_layer * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1841 | ivi_layout_layer_create_with_dimension(uint32_t id_layer, |
| 1842 | int32_t width, int32_t height) |
| 1843 | { |
| 1844 | struct ivi_layout *layout = get_instance(); |
| 1845 | struct ivi_layout_layer *ivilayer = NULL; |
| 1846 | |
| 1847 | ivilayer = get_layer(&layout->layer_list, id_layer); |
| 1848 | if (ivilayer != NULL) { |
| 1849 | weston_log("id_layer is already created\n"); |
Nobuhiko Tanibata | 4b601e1 | 2015-06-22 15:31:16 +0900 | [diff] [blame] | 1850 | ++ivilayer->ref_count; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1851 | return ivilayer; |
| 1852 | } |
| 1853 | |
| 1854 | ivilayer = calloc(1, sizeof *ivilayer); |
| 1855 | if (ivilayer == NULL) { |
| 1856 | weston_log("fails to allocate memory\n"); |
| 1857 | return NULL; |
| 1858 | } |
| 1859 | |
Nobuhiko Tanibata | 4b601e1 | 2015-06-22 15:31:16 +0900 | [diff] [blame] | 1860 | ivilayer->ref_count = 1; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1861 | wl_list_init(&ivilayer->link); |
| 1862 | wl_signal_init(&ivilayer->property_changed); |
| 1863 | wl_list_init(&ivilayer->screen_list); |
| 1864 | wl_list_init(&ivilayer->link_to_surface); |
| 1865 | ivilayer->layout = layout; |
| 1866 | ivilayer->id_layer = id_layer; |
| 1867 | |
| 1868 | init_layer_properties(&ivilayer->prop, width, height); |
| 1869 | ivilayer->event_mask = 0; |
| 1870 | |
| 1871 | wl_list_init(&ivilayer->pending.surface_list); |
| 1872 | wl_list_init(&ivilayer->pending.link); |
| 1873 | ivilayer->pending.prop = ivilayer->prop; |
| 1874 | |
| 1875 | wl_list_init(&ivilayer->order.surface_list); |
| 1876 | wl_list_init(&ivilayer->order.link); |
| 1877 | |
| 1878 | wl_list_insert(&layout->layer_list, &ivilayer->link); |
| 1879 | |
| 1880 | wl_signal_emit(&layout->layer_notification.created, ivilayer); |
| 1881 | |
| 1882 | return ivilayer; |
| 1883 | } |
| 1884 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1885 | static void |
Nobuhiko Tanibata | ef6c786 | 2014-12-15 13:20:44 +0900 | [diff] [blame] | 1886 | ivi_layout_layer_remove_notification(struct ivi_layout_layer *ivilayer) |
| 1887 | { |
| 1888 | if (ivilayer == NULL) { |
| 1889 | weston_log("ivi_layout_layer_remove_notification: invalid argument\n"); |
| 1890 | return; |
| 1891 | } |
| 1892 | |
| 1893 | remove_all_notification(&ivilayer->property_changed.listener_list); |
| 1894 | } |
| 1895 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1896 | static void |
Nobuhiko Tanibata | db8efd1 | 2015-06-22 15:31:39 +0900 | [diff] [blame] | 1897 | ivi_layout_layer_remove_notification_by_callback(struct ivi_layout_layer *ivilayer, |
| 1898 | layer_property_notification_func callback, |
| 1899 | void *userdata) |
| 1900 | { |
| 1901 | if (ivilayer == NULL) { |
| 1902 | weston_log("ivi_layout_layer_remove_notification_by_callback: invalid argument\n"); |
| 1903 | return; |
| 1904 | } |
| 1905 | |
| 1906 | remove_notification(&ivilayer->property_changed.listener_list, callback, userdata); |
| 1907 | } |
| 1908 | |
| 1909 | static void |
Nobuhiko Tanibata | 3aa8aed | 2015-06-22 15:32:23 +0900 | [diff] [blame] | 1910 | ivi_layout_layer_destroy(struct ivi_layout_layer *ivilayer) |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1911 | { |
| 1912 | struct ivi_layout *layout = get_instance(); |
| 1913 | |
| 1914 | if (ivilayer == NULL) { |
| 1915 | weston_log("ivi_layout_layer_remove: invalid argument\n"); |
| 1916 | return; |
| 1917 | } |
| 1918 | |
Nobuhiko Tanibata | 4b601e1 | 2015-06-22 15:31:16 +0900 | [diff] [blame] | 1919 | if (--ivilayer->ref_count > 0) |
| 1920 | return; |
| 1921 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1922 | wl_signal_emit(&layout->layer_notification.removed, ivilayer); |
| 1923 | |
| 1924 | clear_surface_pending_list(ivilayer); |
| 1925 | clear_surface_order_list(ivilayer); |
| 1926 | |
| 1927 | if (!wl_list_empty(&ivilayer->pending.link)) { |
| 1928 | wl_list_remove(&ivilayer->pending.link); |
| 1929 | } |
| 1930 | if (!wl_list_empty(&ivilayer->order.link)) { |
| 1931 | wl_list_remove(&ivilayer->order.link); |
| 1932 | } |
| 1933 | if (!wl_list_empty(&ivilayer->link)) { |
| 1934 | wl_list_remove(&ivilayer->link); |
| 1935 | } |
| 1936 | remove_orderlayer_from_screen(ivilayer); |
| 1937 | remove_link_to_surface(ivilayer); |
| 1938 | ivi_layout_layer_remove_notification(ivilayer); |
| 1939 | |
| 1940 | free(ivilayer); |
| 1941 | } |
| 1942 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1943 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1944 | ivi_layout_layer_set_visibility(struct ivi_layout_layer *ivilayer, |
| 1945 | bool newVisibility) |
| 1946 | { |
| 1947 | struct ivi_layout_layer_properties *prop = NULL; |
| 1948 | |
| 1949 | if (ivilayer == NULL) { |
| 1950 | weston_log("ivi_layout_layer_set_visibility: invalid argument\n"); |
| 1951 | return IVI_FAILED; |
| 1952 | } |
| 1953 | |
| 1954 | prop = &ivilayer->pending.prop; |
| 1955 | prop->visibility = newVisibility; |
| 1956 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1957 | if (ivilayer->prop.visibility != newVisibility) |
| 1958 | ivilayer->event_mask |= IVI_NOTIFICATION_VISIBILITY; |
| 1959 | else |
| 1960 | ivilayer->event_mask &= ~IVI_NOTIFICATION_VISIBILITY; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1961 | |
| 1962 | return IVI_SUCCEEDED; |
| 1963 | } |
| 1964 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1965 | static bool |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1966 | ivi_layout_layer_get_visibility(struct ivi_layout_layer *ivilayer) |
| 1967 | { |
| 1968 | if (ivilayer == NULL) { |
| 1969 | weston_log("ivi_layout_layer_get_visibility: invalid argument\n"); |
| 1970 | return false; |
| 1971 | } |
| 1972 | |
| 1973 | return ivilayer->prop.visibility; |
| 1974 | } |
| 1975 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1976 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1977 | ivi_layout_layer_set_opacity(struct ivi_layout_layer *ivilayer, |
| 1978 | wl_fixed_t opacity) |
| 1979 | { |
| 1980 | struct ivi_layout_layer_properties *prop = NULL; |
| 1981 | |
Nobuhiko Tanibata | 7bbacc6 | 2015-06-22 15:30:09 +0900 | [diff] [blame] | 1982 | if (ivilayer == NULL || |
| 1983 | opacity < wl_fixed_from_double(0.0) || |
| 1984 | wl_fixed_from_double(1.0) < opacity) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1985 | weston_log("ivi_layout_layer_set_opacity: invalid argument\n"); |
| 1986 | return IVI_FAILED; |
| 1987 | } |
| 1988 | |
| 1989 | prop = &ivilayer->pending.prop; |
| 1990 | prop->opacity = opacity; |
| 1991 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 1992 | if (ivilayer->prop.opacity != opacity) |
| 1993 | ivilayer->event_mask |= IVI_NOTIFICATION_OPACITY; |
| 1994 | else |
| 1995 | ivilayer->event_mask &= ~IVI_NOTIFICATION_OPACITY; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1996 | |
| 1997 | return IVI_SUCCEEDED; |
| 1998 | } |
| 1999 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2000 | wl_fixed_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2001 | ivi_layout_layer_get_opacity(struct ivi_layout_layer *ivilayer) |
| 2002 | { |
| 2003 | if (ivilayer == NULL) { |
| 2004 | weston_log("ivi_layout_layer_get_opacity: invalid argument\n"); |
| 2005 | return wl_fixed_from_double(0.0); |
| 2006 | } |
| 2007 | |
| 2008 | return ivilayer->prop.opacity; |
| 2009 | } |
| 2010 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2011 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2012 | ivi_layout_layer_set_source_rectangle(struct ivi_layout_layer *ivilayer, |
| 2013 | int32_t x, int32_t y, |
| 2014 | int32_t width, int32_t height) |
| 2015 | { |
| 2016 | struct ivi_layout_layer_properties *prop = NULL; |
| 2017 | |
| 2018 | if (ivilayer == NULL) { |
| 2019 | weston_log("ivi_layout_layer_set_source_rectangle: invalid argument\n"); |
| 2020 | return IVI_FAILED; |
| 2021 | } |
| 2022 | |
| 2023 | prop = &ivilayer->pending.prop; |
| 2024 | prop->source_x = x; |
| 2025 | prop->source_y = y; |
| 2026 | prop->source_width = width; |
| 2027 | prop->source_height = height; |
| 2028 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 2029 | if (ivilayer->prop.source_x != x || ivilayer->prop.source_y != y || |
| 2030 | ivilayer->prop.source_width != width || |
| 2031 | ivilayer->prop.source_height != height) |
| 2032 | ivilayer->event_mask |= IVI_NOTIFICATION_SOURCE_RECT; |
| 2033 | else |
| 2034 | ivilayer->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2035 | |
| 2036 | return IVI_SUCCEEDED; |
| 2037 | } |
| 2038 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2039 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2040 | ivi_layout_layer_set_destination_rectangle(struct ivi_layout_layer *ivilayer, |
| 2041 | int32_t x, int32_t y, |
| 2042 | int32_t width, int32_t height) |
| 2043 | { |
| 2044 | struct ivi_layout_layer_properties *prop = NULL; |
| 2045 | |
| 2046 | if (ivilayer == NULL) { |
| 2047 | weston_log("ivi_layout_layer_set_destination_rectangle: invalid argument\n"); |
| 2048 | return IVI_FAILED; |
| 2049 | } |
| 2050 | |
| 2051 | prop = &ivilayer->pending.prop; |
| 2052 | prop->dest_x = x; |
| 2053 | prop->dest_y = y; |
| 2054 | prop->dest_width = width; |
| 2055 | prop->dest_height = height; |
| 2056 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 2057 | if (ivilayer->prop.dest_x != x || ivilayer->prop.dest_y != y || |
| 2058 | ivilayer->prop.dest_width != width || |
| 2059 | ivilayer->prop.dest_height != height) |
| 2060 | ivilayer->event_mask |= IVI_NOTIFICATION_DEST_RECT; |
| 2061 | else |
| 2062 | ivilayer->event_mask &= ~IVI_NOTIFICATION_DEST_RECT; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2063 | |
| 2064 | return IVI_SUCCEEDED; |
| 2065 | } |
| 2066 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2067 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2068 | ivi_layout_layer_get_dimension(struct ivi_layout_layer *ivilayer, |
| 2069 | int32_t *dest_width, int32_t *dest_height) |
| 2070 | { |
| 2071 | if (ivilayer == NULL || dest_width == NULL || dest_height == NULL) { |
| 2072 | weston_log("ivi_layout_layer_get_dimension: invalid argument\n"); |
| 2073 | return IVI_FAILED; |
| 2074 | } |
| 2075 | |
| 2076 | *dest_width = ivilayer->prop.dest_width; |
| 2077 | *dest_height = ivilayer->prop.dest_height; |
| 2078 | |
| 2079 | return IVI_SUCCEEDED; |
| 2080 | } |
| 2081 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2082 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2083 | ivi_layout_layer_set_dimension(struct ivi_layout_layer *ivilayer, |
| 2084 | int32_t dest_width, int32_t dest_height) |
| 2085 | { |
| 2086 | struct ivi_layout_layer_properties *prop = NULL; |
| 2087 | |
| 2088 | if (ivilayer == NULL) { |
| 2089 | weston_log("ivi_layout_layer_set_dimension: invalid argument\n"); |
| 2090 | return IVI_FAILED; |
| 2091 | } |
| 2092 | |
| 2093 | prop = &ivilayer->pending.prop; |
| 2094 | |
| 2095 | prop->dest_width = dest_width; |
| 2096 | prop->dest_height = dest_height; |
| 2097 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 2098 | if (ivilayer->prop.dest_width != dest_width || |
| 2099 | ivilayer->prop.dest_height != dest_height) |
| 2100 | ivilayer->event_mask |= IVI_NOTIFICATION_DIMENSION; |
| 2101 | else |
| 2102 | ivilayer->event_mask &= ~IVI_NOTIFICATION_DIMENSION; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2103 | |
| 2104 | return IVI_SUCCEEDED; |
| 2105 | } |
| 2106 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2107 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2108 | ivi_layout_layer_get_position(struct ivi_layout_layer *ivilayer, |
| 2109 | int32_t *dest_x, int32_t *dest_y) |
| 2110 | { |
| 2111 | if (ivilayer == NULL || dest_x == NULL || dest_y == NULL) { |
| 2112 | weston_log("ivi_layout_layer_get_position: invalid argument\n"); |
| 2113 | return IVI_FAILED; |
| 2114 | } |
| 2115 | |
| 2116 | *dest_x = ivilayer->prop.dest_x; |
| 2117 | *dest_y = ivilayer->prop.dest_y; |
| 2118 | |
| 2119 | return IVI_SUCCEEDED; |
| 2120 | } |
| 2121 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2122 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2123 | ivi_layout_layer_set_position(struct ivi_layout_layer *ivilayer, |
| 2124 | int32_t dest_x, int32_t dest_y) |
| 2125 | { |
| 2126 | struct ivi_layout_layer_properties *prop = NULL; |
| 2127 | |
| 2128 | if (ivilayer == NULL) { |
| 2129 | weston_log("ivi_layout_layer_set_position: invalid argument\n"); |
| 2130 | return IVI_FAILED; |
| 2131 | } |
| 2132 | |
| 2133 | prop = &ivilayer->pending.prop; |
| 2134 | prop->dest_x = dest_x; |
| 2135 | prop->dest_y = dest_y; |
| 2136 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 2137 | if (ivilayer->prop.dest_x != dest_x || ivilayer->prop.dest_y != dest_y) |
| 2138 | ivilayer->event_mask |= IVI_NOTIFICATION_POSITION; |
| 2139 | else |
| 2140 | ivilayer->event_mask &= ~IVI_NOTIFICATION_POSITION; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2141 | |
| 2142 | return IVI_SUCCEEDED; |
| 2143 | } |
| 2144 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2145 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2146 | ivi_layout_layer_set_orientation(struct ivi_layout_layer *ivilayer, |
| 2147 | enum wl_output_transform orientation) |
| 2148 | { |
| 2149 | struct ivi_layout_layer_properties *prop = NULL; |
| 2150 | |
| 2151 | if (ivilayer == NULL) { |
| 2152 | weston_log("ivi_layout_layer_set_orientation: invalid argument\n"); |
| 2153 | return IVI_FAILED; |
| 2154 | } |
| 2155 | |
| 2156 | prop = &ivilayer->pending.prop; |
| 2157 | prop->orientation = orientation; |
| 2158 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 2159 | if (ivilayer->prop.orientation != orientation) |
| 2160 | ivilayer->event_mask |= IVI_NOTIFICATION_ORIENTATION; |
| 2161 | else |
| 2162 | ivilayer->event_mask &= ~IVI_NOTIFICATION_ORIENTATION; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2163 | |
| 2164 | return IVI_SUCCEEDED; |
| 2165 | } |
| 2166 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2167 | static enum wl_output_transform |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2168 | ivi_layout_layer_get_orientation(struct ivi_layout_layer *ivilayer) |
| 2169 | { |
| 2170 | if (ivilayer == NULL) { |
| 2171 | weston_log("ivi_layout_layer_get_orientation: invalid argument\n"); |
| 2172 | return 0; |
| 2173 | } |
| 2174 | |
| 2175 | return ivilayer->prop.orientation; |
| 2176 | } |
| 2177 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2178 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2179 | ivi_layout_layer_set_render_order(struct ivi_layout_layer *ivilayer, |
| 2180 | struct ivi_layout_surface **pSurface, |
| 2181 | int32_t number) |
| 2182 | { |
| 2183 | struct ivi_layout *layout = get_instance(); |
| 2184 | struct ivi_layout_surface *ivisurf = NULL; |
| 2185 | struct ivi_layout_surface *next = NULL; |
| 2186 | uint32_t *id_surface = NULL; |
| 2187 | int32_t i = 0; |
| 2188 | |
| 2189 | if (ivilayer == NULL) { |
| 2190 | weston_log("ivi_layout_layer_set_render_order: invalid argument\n"); |
| 2191 | return IVI_FAILED; |
| 2192 | } |
| 2193 | |
| 2194 | if (pSurface == NULL) { |
| 2195 | wl_list_for_each_safe(ivisurf, next, &ivilayer->pending.surface_list, pending.link) { |
| 2196 | if (!wl_list_empty(&ivisurf->pending.link)) { |
| 2197 | wl_list_remove(&ivisurf->pending.link); |
| 2198 | } |
| 2199 | |
| 2200 | wl_list_init(&ivisurf->pending.link); |
| 2201 | } |
| 2202 | ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE; |
| 2203 | return IVI_SUCCEEDED; |
| 2204 | } |
| 2205 | |
| 2206 | for (i = 0; i < number; i++) { |
| 2207 | id_surface = &pSurface[i]->id_surface; |
| 2208 | |
| 2209 | wl_list_for_each_safe(ivisurf, next, &layout->surface_list, link) { |
| 2210 | if (*id_surface != ivisurf->id_surface) { |
| 2211 | continue; |
| 2212 | } |
| 2213 | |
| 2214 | if (!wl_list_empty(&ivisurf->pending.link)) { |
| 2215 | wl_list_remove(&ivisurf->pending.link); |
| 2216 | } |
| 2217 | wl_list_init(&ivisurf->pending.link); |
| 2218 | wl_list_insert(&ivilayer->pending.surface_list, |
| 2219 | &ivisurf->pending.link); |
| 2220 | break; |
| 2221 | } |
| 2222 | } |
| 2223 | |
| 2224 | ivilayer->event_mask |= IVI_NOTIFICATION_ADD; |
| 2225 | |
| 2226 | return IVI_SUCCEEDED; |
| 2227 | } |
| 2228 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2229 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2230 | ivi_layout_surface_set_visibility(struct ivi_layout_surface *ivisurf, |
| 2231 | bool newVisibility) |
| 2232 | { |
| 2233 | struct ivi_layout_surface_properties *prop = NULL; |
| 2234 | |
| 2235 | if (ivisurf == NULL) { |
| 2236 | weston_log("ivi_layout_surface_set_visibility: invalid argument\n"); |
| 2237 | return IVI_FAILED; |
| 2238 | } |
| 2239 | |
| 2240 | prop = &ivisurf->pending.prop; |
| 2241 | prop->visibility = newVisibility; |
| 2242 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 2243 | if (ivisurf->prop.visibility != newVisibility) |
| 2244 | ivisurf->event_mask |= IVI_NOTIFICATION_VISIBILITY; |
| 2245 | else |
| 2246 | ivisurf->event_mask &= ~IVI_NOTIFICATION_VISIBILITY; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2247 | |
| 2248 | return IVI_SUCCEEDED; |
| 2249 | } |
| 2250 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2251 | bool |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2252 | ivi_layout_surface_get_visibility(struct ivi_layout_surface *ivisurf) |
| 2253 | { |
| 2254 | if (ivisurf == NULL) { |
| 2255 | weston_log("ivi_layout_surface_get_visibility: invalid argument\n"); |
| 2256 | return false; |
| 2257 | } |
| 2258 | |
| 2259 | return ivisurf->prop.visibility; |
| 2260 | } |
| 2261 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2262 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2263 | ivi_layout_surface_set_opacity(struct ivi_layout_surface *ivisurf, |
| 2264 | wl_fixed_t opacity) |
| 2265 | { |
| 2266 | struct ivi_layout_surface_properties *prop = NULL; |
| 2267 | |
Nobuhiko Tanibata | a86226c | 2015-06-22 15:29:20 +0900 | [diff] [blame] | 2268 | if (ivisurf == NULL || |
| 2269 | opacity < wl_fixed_from_double(0.0) || |
| 2270 | wl_fixed_from_double(1.0) < opacity) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2271 | weston_log("ivi_layout_surface_set_opacity: invalid argument\n"); |
| 2272 | return IVI_FAILED; |
| 2273 | } |
| 2274 | |
| 2275 | prop = &ivisurf->pending.prop; |
| 2276 | prop->opacity = opacity; |
| 2277 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 2278 | if (ivisurf->prop.opacity != opacity) |
| 2279 | ivisurf->event_mask |= IVI_NOTIFICATION_OPACITY; |
| 2280 | else |
| 2281 | ivisurf->event_mask &= ~IVI_NOTIFICATION_OPACITY; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2282 | |
| 2283 | return IVI_SUCCEEDED; |
| 2284 | } |
| 2285 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2286 | wl_fixed_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2287 | ivi_layout_surface_get_opacity(struct ivi_layout_surface *ivisurf) |
| 2288 | { |
| 2289 | if (ivisurf == NULL) { |
| 2290 | weston_log("ivi_layout_surface_get_opacity: invalid argument\n"); |
| 2291 | return wl_fixed_from_double(0.0); |
| 2292 | } |
| 2293 | |
| 2294 | return ivisurf->prop.opacity; |
| 2295 | } |
| 2296 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2297 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2298 | ivi_layout_surface_set_destination_rectangle(struct ivi_layout_surface *ivisurf, |
| 2299 | int32_t x, int32_t y, |
| 2300 | int32_t width, int32_t height) |
| 2301 | { |
| 2302 | struct ivi_layout_surface_properties *prop = NULL; |
| 2303 | |
| 2304 | if (ivisurf == NULL) { |
| 2305 | weston_log("ivi_layout_surface_set_destination_rectangle: invalid argument\n"); |
| 2306 | return IVI_FAILED; |
| 2307 | } |
| 2308 | |
| 2309 | prop = &ivisurf->pending.prop; |
| 2310 | prop->start_x = prop->dest_x; |
| 2311 | prop->start_y = prop->dest_y; |
| 2312 | prop->dest_x = x; |
| 2313 | prop->dest_y = y; |
| 2314 | prop->start_width = prop->dest_width; |
| 2315 | prop->start_height = prop->dest_height; |
| 2316 | prop->dest_width = width; |
| 2317 | prop->dest_height = height; |
| 2318 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 2319 | if (ivisurf->prop.dest_x != x || ivisurf->prop.dest_y != y || |
| 2320 | ivisurf->prop.dest_width != width || |
| 2321 | ivisurf->prop.dest_height != height) |
| 2322 | ivisurf->event_mask |= IVI_NOTIFICATION_DEST_RECT; |
| 2323 | else |
| 2324 | ivisurf->event_mask &= ~IVI_NOTIFICATION_DEST_RECT; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2325 | |
| 2326 | return IVI_SUCCEEDED; |
| 2327 | } |
| 2328 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2329 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2330 | ivi_layout_surface_set_dimension(struct ivi_layout_surface *ivisurf, |
| 2331 | int32_t dest_width, int32_t dest_height) |
| 2332 | { |
| 2333 | struct ivi_layout_surface_properties *prop = NULL; |
| 2334 | |
| 2335 | if (ivisurf == NULL) { |
| 2336 | weston_log("ivi_layout_surface_set_dimension: invalid argument\n"); |
| 2337 | return IVI_FAILED; |
| 2338 | } |
| 2339 | |
| 2340 | prop = &ivisurf->pending.prop; |
| 2341 | prop->dest_width = dest_width; |
| 2342 | prop->dest_height = dest_height; |
| 2343 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 2344 | if (ivisurf->prop.dest_width != dest_width || |
| 2345 | ivisurf->prop.dest_height != dest_height) |
| 2346 | ivisurf->event_mask |= IVI_NOTIFICATION_DIMENSION; |
| 2347 | else |
| 2348 | ivisurf->event_mask &= ~IVI_NOTIFICATION_DIMENSION; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2349 | |
| 2350 | return IVI_SUCCEEDED; |
| 2351 | } |
| 2352 | |
| 2353 | int32_t |
| 2354 | ivi_layout_surface_get_dimension(struct ivi_layout_surface *ivisurf, |
| 2355 | int32_t *dest_width, int32_t *dest_height) |
| 2356 | { |
| 2357 | if (ivisurf == NULL || dest_width == NULL || dest_height == NULL) { |
| 2358 | weston_log("ivi_layout_surface_get_dimension: invalid argument\n"); |
| 2359 | return IVI_FAILED; |
| 2360 | } |
| 2361 | |
| 2362 | *dest_width = ivisurf->prop.dest_width; |
| 2363 | *dest_height = ivisurf->prop.dest_height; |
| 2364 | |
| 2365 | return IVI_SUCCEEDED; |
| 2366 | } |
| 2367 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2368 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2369 | ivi_layout_surface_set_position(struct ivi_layout_surface *ivisurf, |
| 2370 | int32_t dest_x, int32_t dest_y) |
| 2371 | { |
| 2372 | struct ivi_layout_surface_properties *prop = NULL; |
| 2373 | |
| 2374 | if (ivisurf == NULL) { |
| 2375 | weston_log("ivi_layout_surface_set_position: invalid argument\n"); |
| 2376 | return IVI_FAILED; |
| 2377 | } |
| 2378 | |
| 2379 | prop = &ivisurf->pending.prop; |
| 2380 | prop->dest_x = dest_x; |
| 2381 | prop->dest_y = dest_y; |
| 2382 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 2383 | if (ivisurf->prop.dest_x != dest_x || ivisurf->prop.dest_y != dest_y) |
| 2384 | ivisurf->event_mask |= IVI_NOTIFICATION_POSITION; |
| 2385 | else |
| 2386 | ivisurf->event_mask &= ~IVI_NOTIFICATION_POSITION; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2387 | |
| 2388 | return IVI_SUCCEEDED; |
| 2389 | } |
| 2390 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2391 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2392 | ivi_layout_surface_get_position(struct ivi_layout_surface *ivisurf, |
| 2393 | int32_t *dest_x, int32_t *dest_y) |
| 2394 | { |
| 2395 | if (ivisurf == NULL || dest_x == NULL || dest_y == NULL) { |
| 2396 | weston_log("ivi_layout_surface_get_position: invalid argument\n"); |
| 2397 | return IVI_FAILED; |
| 2398 | } |
| 2399 | |
| 2400 | *dest_x = ivisurf->prop.dest_x; |
| 2401 | *dest_y = ivisurf->prop.dest_y; |
| 2402 | |
| 2403 | return IVI_SUCCEEDED; |
| 2404 | } |
| 2405 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2406 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2407 | ivi_layout_surface_set_orientation(struct ivi_layout_surface *ivisurf, |
| 2408 | enum wl_output_transform orientation) |
| 2409 | { |
| 2410 | struct ivi_layout_surface_properties *prop = NULL; |
| 2411 | |
| 2412 | if (ivisurf == NULL) { |
| 2413 | weston_log("ivi_layout_surface_set_orientation: invalid argument\n"); |
| 2414 | return IVI_FAILED; |
| 2415 | } |
| 2416 | |
| 2417 | prop = &ivisurf->pending.prop; |
| 2418 | prop->orientation = orientation; |
| 2419 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 2420 | if (ivisurf->prop.orientation != orientation) |
| 2421 | ivisurf->event_mask |= IVI_NOTIFICATION_ORIENTATION; |
| 2422 | else |
| 2423 | ivisurf->event_mask &= ~IVI_NOTIFICATION_ORIENTATION; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2424 | |
| 2425 | return IVI_SUCCEEDED; |
| 2426 | } |
| 2427 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2428 | static enum wl_output_transform |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2429 | ivi_layout_surface_get_orientation(struct ivi_layout_surface *ivisurf) |
| 2430 | { |
| 2431 | if (ivisurf == NULL) { |
| 2432 | weston_log("ivi_layout_surface_get_orientation: invalid argument\n"); |
| 2433 | return 0; |
| 2434 | } |
| 2435 | |
| 2436 | return ivisurf->prop.orientation; |
| 2437 | } |
| 2438 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2439 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2440 | ivi_layout_screen_add_layer(struct ivi_layout_screen *iviscrn, |
| 2441 | struct ivi_layout_layer *addlayer) |
| 2442 | { |
| 2443 | struct ivi_layout *layout = get_instance(); |
| 2444 | struct ivi_layout_layer *ivilayer = NULL; |
| 2445 | struct ivi_layout_layer *next = NULL; |
| 2446 | int is_layer_in_scrn = 0; |
| 2447 | |
| 2448 | if (iviscrn == NULL || addlayer == NULL) { |
| 2449 | weston_log("ivi_layout_screen_add_layer: invalid argument\n"); |
| 2450 | return IVI_FAILED; |
| 2451 | } |
| 2452 | |
| 2453 | is_layer_in_scrn = is_layer_in_screen(addlayer, iviscrn); |
| 2454 | if (is_layer_in_scrn == 1) { |
| 2455 | weston_log("ivi_layout_screen_add_layer: addlayer is already available\n"); |
| 2456 | return IVI_SUCCEEDED; |
| 2457 | } |
| 2458 | |
| 2459 | wl_list_for_each_safe(ivilayer, next, &layout->layer_list, link) { |
| 2460 | if (ivilayer->id_layer == addlayer->id_layer) { |
| 2461 | if (!wl_list_empty(&ivilayer->pending.link)) { |
| 2462 | wl_list_remove(&ivilayer->pending.link); |
| 2463 | } |
| 2464 | wl_list_init(&ivilayer->pending.link); |
| 2465 | wl_list_insert(&iviscrn->pending.layer_list, |
| 2466 | &ivilayer->pending.link); |
| 2467 | break; |
| 2468 | } |
| 2469 | } |
| 2470 | |
| 2471 | iviscrn->event_mask |= IVI_NOTIFICATION_ADD; |
| 2472 | |
| 2473 | return IVI_SUCCEEDED; |
| 2474 | } |
| 2475 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2476 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2477 | ivi_layout_screen_set_render_order(struct ivi_layout_screen *iviscrn, |
| 2478 | struct ivi_layout_layer **pLayer, |
| 2479 | const int32_t number) |
| 2480 | { |
| 2481 | struct ivi_layout *layout = get_instance(); |
| 2482 | struct ivi_layout_layer *ivilayer = NULL; |
| 2483 | struct ivi_layout_layer *next = NULL; |
| 2484 | uint32_t *id_layer = NULL; |
| 2485 | int32_t i = 0; |
| 2486 | |
| 2487 | if (iviscrn == NULL) { |
| 2488 | weston_log("ivi_layout_screen_set_render_order: invalid argument\n"); |
| 2489 | return IVI_FAILED; |
| 2490 | } |
| 2491 | |
| 2492 | wl_list_for_each_safe(ivilayer, next, |
| 2493 | &iviscrn->pending.layer_list, pending.link) { |
| 2494 | wl_list_init(&ivilayer->pending.link); |
| 2495 | } |
| 2496 | |
| 2497 | wl_list_init(&iviscrn->pending.layer_list); |
| 2498 | |
| 2499 | if (pLayer == NULL) { |
| 2500 | wl_list_for_each_safe(ivilayer, next, &iviscrn->pending.layer_list, pending.link) { |
| 2501 | if (!wl_list_empty(&ivilayer->pending.link)) { |
| 2502 | wl_list_remove(&ivilayer->pending.link); |
| 2503 | } |
| 2504 | |
| 2505 | wl_list_init(&ivilayer->pending.link); |
| 2506 | } |
| 2507 | |
| 2508 | iviscrn->event_mask |= IVI_NOTIFICATION_REMOVE; |
| 2509 | return IVI_SUCCEEDED; |
| 2510 | } |
| 2511 | |
| 2512 | for (i = 0; i < number; i++) { |
| 2513 | id_layer = &pLayer[i]->id_layer; |
| 2514 | wl_list_for_each(ivilayer, &layout->layer_list, link) { |
| 2515 | if (*id_layer != ivilayer->id_layer) { |
| 2516 | continue; |
| 2517 | } |
| 2518 | |
| 2519 | if (!wl_list_empty(&ivilayer->pending.link)) { |
| 2520 | wl_list_remove(&ivilayer->pending.link); |
| 2521 | } |
| 2522 | wl_list_init(&ivilayer->pending.link); |
| 2523 | wl_list_insert(&iviscrn->pending.layer_list, |
| 2524 | &ivilayer->pending.link); |
| 2525 | break; |
| 2526 | } |
| 2527 | } |
| 2528 | |
| 2529 | iviscrn->event_mask |= IVI_NOTIFICATION_ADD; |
| 2530 | |
| 2531 | return IVI_SUCCEEDED; |
| 2532 | } |
| 2533 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2534 | static struct weston_output * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2535 | ivi_layout_screen_get_output(struct ivi_layout_screen *iviscrn) |
| 2536 | { |
| 2537 | return iviscrn->output; |
| 2538 | } |
| 2539 | |
| 2540 | /** |
| 2541 | * This function is used by the additional ivi-module because of dumping ivi_surface sceenshot. |
| 2542 | * The ivi-module, e.g. ivi-controller.so, is in wayland-ivi-extension of Genivi's Layer Management. |
| 2543 | * This function is used to get the result of drawing by clients. |
| 2544 | */ |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2545 | static struct weston_surface * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2546 | ivi_layout_surface_get_weston_surface(struct ivi_layout_surface *ivisurf) |
| 2547 | { |
| 2548 | return ivisurf != NULL ? ivisurf->surface : NULL; |
| 2549 | } |
| 2550 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2551 | static int32_t |
Nobuhiko Tanibata | c3fd624 | 2015-04-21 02:13:15 +0900 | [diff] [blame] | 2552 | ivi_layout_surface_get_size(struct ivi_layout_surface *ivisurf, |
| 2553 | int32_t *width, int32_t *height, |
| 2554 | int32_t *stride) |
| 2555 | { |
| 2556 | int32_t w; |
| 2557 | int32_t h; |
| 2558 | const size_t bytespp = 4; /* PIXMAN_a8b8g8r8 */ |
| 2559 | |
| 2560 | if (ivisurf == NULL || ivisurf->surface == NULL) { |
| 2561 | weston_log("%s: invalid argument\n", __func__); |
| 2562 | return IVI_FAILED; |
| 2563 | } |
| 2564 | |
| 2565 | weston_surface_get_content_size(ivisurf->surface, &w, &h); |
| 2566 | |
| 2567 | if (width != NULL) |
| 2568 | *width = w; |
| 2569 | |
| 2570 | if (height != NULL) |
| 2571 | *height = h; |
| 2572 | |
| 2573 | if (stride != NULL) |
| 2574 | *stride = w * bytespp; |
| 2575 | |
| 2576 | return IVI_SUCCEEDED; |
| 2577 | } |
| 2578 | |
| 2579 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2580 | ivi_layout_layer_add_notification(struct ivi_layout_layer *ivilayer, |
| 2581 | layer_property_notification_func callback, |
| 2582 | void *userdata) |
| 2583 | { |
| 2584 | struct ivi_layout_notification_callback *prop_callback = NULL; |
| 2585 | |
| 2586 | if (ivilayer == NULL || callback == NULL) { |
| 2587 | weston_log("ivi_layout_layer_add_notification: invalid argument\n"); |
| 2588 | return IVI_FAILED; |
| 2589 | } |
| 2590 | |
| 2591 | prop_callback = malloc(sizeof *prop_callback); |
| 2592 | if (prop_callback == NULL) { |
| 2593 | weston_log("fails to allocate memory\n"); |
| 2594 | return IVI_FAILED; |
| 2595 | } |
| 2596 | |
| 2597 | prop_callback->callback = callback; |
| 2598 | prop_callback->data = userdata; |
| 2599 | |
| 2600 | return add_notification(&ivilayer->property_changed, |
| 2601 | layer_prop_changed, |
| 2602 | prop_callback); |
| 2603 | } |
| 2604 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2605 | static const struct ivi_layout_surface_properties * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2606 | ivi_layout_get_properties_of_surface(struct ivi_layout_surface *ivisurf) |
| 2607 | { |
| 2608 | if (ivisurf == NULL) { |
| 2609 | weston_log("ivi_layout_get_properties_of_surface: invalid argument\n"); |
| 2610 | return NULL; |
| 2611 | } |
| 2612 | |
| 2613 | return &ivisurf->prop; |
| 2614 | } |
| 2615 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2616 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2617 | ivi_layout_layer_add_surface(struct ivi_layout_layer *ivilayer, |
| 2618 | struct ivi_layout_surface *addsurf) |
| 2619 | { |
| 2620 | struct ivi_layout *layout = get_instance(); |
| 2621 | struct ivi_layout_surface *ivisurf = NULL; |
| 2622 | struct ivi_layout_surface *next = NULL; |
| 2623 | int is_surf_in_layer = 0; |
| 2624 | |
| 2625 | if (ivilayer == NULL || addsurf == NULL) { |
| 2626 | weston_log("ivi_layout_layer_add_surface: invalid argument\n"); |
| 2627 | return IVI_FAILED; |
| 2628 | } |
| 2629 | |
| 2630 | is_surf_in_layer = is_surface_in_layer(addsurf, ivilayer); |
| 2631 | if (is_surf_in_layer == 1) { |
| 2632 | weston_log("ivi_layout_layer_add_surface: addsurf is already available\n"); |
| 2633 | return IVI_SUCCEEDED; |
| 2634 | } |
| 2635 | |
| 2636 | wl_list_for_each_safe(ivisurf, next, &layout->surface_list, link) { |
| 2637 | if (ivisurf->id_surface == addsurf->id_surface) { |
| 2638 | if (!wl_list_empty(&ivisurf->pending.link)) { |
| 2639 | wl_list_remove(&ivisurf->pending.link); |
| 2640 | } |
| 2641 | wl_list_init(&ivisurf->pending.link); |
| 2642 | wl_list_insert(&ivilayer->pending.surface_list, |
| 2643 | &ivisurf->pending.link); |
| 2644 | break; |
| 2645 | } |
| 2646 | } |
| 2647 | |
| 2648 | ivilayer->event_mask |= IVI_NOTIFICATION_ADD; |
| 2649 | |
| 2650 | return IVI_SUCCEEDED; |
| 2651 | } |
| 2652 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2653 | static void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2654 | ivi_layout_layer_remove_surface(struct ivi_layout_layer *ivilayer, |
| 2655 | struct ivi_layout_surface *remsurf) |
| 2656 | { |
| 2657 | struct ivi_layout_surface *ivisurf = NULL; |
| 2658 | struct ivi_layout_surface *next = NULL; |
| 2659 | |
| 2660 | if (ivilayer == NULL || remsurf == NULL) { |
| 2661 | weston_log("ivi_layout_layer_remove_surface: invalid argument\n"); |
| 2662 | return; |
| 2663 | } |
| 2664 | |
| 2665 | wl_list_for_each_safe(ivisurf, next, |
| 2666 | &ivilayer->pending.surface_list, pending.link) { |
| 2667 | if (ivisurf->id_surface == remsurf->id_surface) { |
| 2668 | if (!wl_list_empty(&ivisurf->pending.link)) { |
| 2669 | wl_list_remove(&ivisurf->pending.link); |
| 2670 | } |
| 2671 | wl_list_init(&ivisurf->pending.link); |
| 2672 | break; |
| 2673 | } |
| 2674 | } |
| 2675 | |
| 2676 | remsurf->event_mask |= IVI_NOTIFICATION_REMOVE; |
| 2677 | } |
| 2678 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2679 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2680 | ivi_layout_surface_set_source_rectangle(struct ivi_layout_surface *ivisurf, |
| 2681 | int32_t x, int32_t y, |
| 2682 | int32_t width, int32_t height) |
| 2683 | { |
| 2684 | struct ivi_layout_surface_properties *prop = NULL; |
| 2685 | |
| 2686 | if (ivisurf == NULL) { |
| 2687 | weston_log("ivi_layout_surface_set_source_rectangle: invalid argument\n"); |
| 2688 | return IVI_FAILED; |
| 2689 | } |
| 2690 | |
| 2691 | prop = &ivisurf->pending.prop; |
| 2692 | prop->source_x = x; |
| 2693 | prop->source_y = y; |
| 2694 | prop->source_width = width; |
| 2695 | prop->source_height = height; |
| 2696 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame] | 2697 | if (ivisurf->prop.source_x != x || ivisurf->prop.source_y != y || |
| 2698 | ivisurf->prop.source_width != width || |
| 2699 | ivisurf->prop.source_height != height) |
| 2700 | ivisurf->event_mask |= IVI_NOTIFICATION_SOURCE_RECT; |
| 2701 | else |
| 2702 | ivisurf->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2703 | |
| 2704 | return IVI_SUCCEEDED; |
| 2705 | } |
| 2706 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2707 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2708 | ivi_layout_commit_changes(void) |
| 2709 | { |
| 2710 | struct ivi_layout *layout = get_instance(); |
| 2711 | |
| 2712 | commit_surface_list(layout); |
| 2713 | commit_layer_list(layout); |
| 2714 | commit_screen_list(layout); |
| 2715 | |
| 2716 | commit_transition(layout); |
| 2717 | |
| 2718 | commit_changes(layout); |
| 2719 | send_prop(layout); |
| 2720 | weston_compositor_schedule_repaint(layout->compositor); |
| 2721 | |
| 2722 | return IVI_SUCCEEDED; |
| 2723 | } |
| 2724 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2725 | static int32_t |
Nobuhiko Tanibata | 3c6796f | 2014-12-15 13:20:58 +0900 | [diff] [blame] | 2726 | ivi_layout_layer_set_transition(struct ivi_layout_layer *ivilayer, |
| 2727 | enum ivi_layout_transition_type type, |
| 2728 | uint32_t duration) |
| 2729 | { |
| 2730 | if (ivilayer == NULL) { |
| 2731 | weston_log("%s: invalid argument\n", __func__); |
| 2732 | return -1; |
| 2733 | } |
| 2734 | |
| 2735 | ivilayer->pending.prop.transition_type = type; |
| 2736 | ivilayer->pending.prop.transition_duration = duration; |
| 2737 | |
| 2738 | return 0; |
| 2739 | } |
| 2740 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2741 | static int32_t |
Nobuhiko Tanibata | 3c6796f | 2014-12-15 13:20:58 +0900 | [diff] [blame] | 2742 | ivi_layout_layer_set_fade_info(struct ivi_layout_layer* ivilayer, |
| 2743 | uint32_t is_fade_in, |
| 2744 | double start_alpha, double end_alpha) |
| 2745 | { |
| 2746 | if (ivilayer == NULL) { |
| 2747 | weston_log("%s: invalid argument\n", __func__); |
| 2748 | return -1; |
| 2749 | } |
| 2750 | |
| 2751 | ivilayer->pending.prop.is_fade_in = is_fade_in; |
| 2752 | ivilayer->pending.prop.start_alpha = start_alpha; |
| 2753 | ivilayer->pending.prop.end_alpha = end_alpha; |
| 2754 | |
| 2755 | return 0; |
| 2756 | } |
| 2757 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2758 | static int32_t |
Nobuhiko Tanibata | 3c6796f | 2014-12-15 13:20:58 +0900 | [diff] [blame] | 2759 | ivi_layout_surface_set_transition_duration(struct ivi_layout_surface *ivisurf, |
| 2760 | uint32_t duration) |
| 2761 | { |
| 2762 | struct ivi_layout_surface_properties *prop; |
| 2763 | |
| 2764 | if (ivisurf == NULL) { |
| 2765 | weston_log("%s: invalid argument\n", __func__); |
| 2766 | return -1; |
| 2767 | } |
| 2768 | |
| 2769 | prop = &ivisurf->pending.prop; |
| 2770 | prop->transition_duration = duration*10; |
| 2771 | return 0; |
| 2772 | } |
| 2773 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2774 | static int32_t |
Nobuhiko Tanibata | 3c6796f | 2014-12-15 13:20:58 +0900 | [diff] [blame] | 2775 | ivi_layout_surface_set_transition(struct ivi_layout_surface *ivisurf, |
| 2776 | enum ivi_layout_transition_type type, |
| 2777 | uint32_t duration) |
| 2778 | { |
| 2779 | struct ivi_layout_surface_properties *prop; |
| 2780 | |
| 2781 | if (ivisurf == NULL) { |
| 2782 | weston_log("%s: invalid argument\n", __func__); |
| 2783 | return -1; |
| 2784 | } |
| 2785 | |
| 2786 | prop = &ivisurf->pending.prop; |
| 2787 | prop->transition_type = type; |
| 2788 | prop->transition_duration = duration; |
| 2789 | return 0; |
| 2790 | } |
| 2791 | |
Nobuhiko Tanibata | c3fd624 | 2015-04-21 02:13:15 +0900 | [diff] [blame] | 2792 | static int32_t |
| 2793 | ivi_layout_surface_dump(struct weston_surface *surface, |
| 2794 | void *target, size_t size,int32_t x, int32_t y, |
| 2795 | int32_t width, int32_t height) |
| 2796 | { |
| 2797 | int result = 0; |
| 2798 | |
| 2799 | if (surface == NULL) { |
| 2800 | weston_log("%s: invalid argument\n", __func__); |
| 2801 | return IVI_FAILED; |
| 2802 | } |
| 2803 | |
| 2804 | result = weston_surface_copy_content( |
| 2805 | surface, target, size, |
| 2806 | x, y, width, height); |
| 2807 | |
| 2808 | return result == 0 ? IVI_SUCCEEDED : IVI_FAILED; |
| 2809 | } |
| 2810 | |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 2811 | /** |
| 2812 | * methods of interaction between ivi-shell with ivi-layout |
| 2813 | */ |
| 2814 | struct weston_view * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2815 | ivi_layout_get_weston_view(struct ivi_layout_surface *surface) |
| 2816 | { |
| 2817 | struct weston_view *tmpview = NULL; |
| 2818 | |
| 2819 | if(surface == NULL) |
| 2820 | return NULL; |
| 2821 | |
| 2822 | wl_list_for_each(tmpview, &surface->surface->views, surface_link) |
| 2823 | { |
| 2824 | if (tmpview != NULL) { |
| 2825 | break; |
| 2826 | } |
| 2827 | } |
| 2828 | return tmpview; |
| 2829 | } |
| 2830 | |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 2831 | void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2832 | ivi_layout_surface_configure(struct ivi_layout_surface *ivisurf, |
| 2833 | int32_t width, int32_t height) |
| 2834 | { |
| 2835 | struct ivi_layout *layout = get_instance(); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2836 | |
Nobuhiko Tanibata | e6cc997 | 2015-04-27 16:54:01 +0900 | [diff] [blame] | 2837 | /* emit callback which is set by ivi-layout api user */ |
| 2838 | wl_signal_emit(&layout->surface_notification.configure_changed, |
| 2839 | ivisurf); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2840 | } |
| 2841 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2842 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2843 | ivi_layout_surface_set_content_observer(struct ivi_layout_surface *ivisurf, |
| 2844 | ivi_controller_surface_content_callback callback, |
| 2845 | void* userdata) |
| 2846 | { |
| 2847 | int32_t ret = IVI_FAILED; |
| 2848 | |
| 2849 | if (ivisurf != NULL) { |
| 2850 | ivisurf->content_observer.callback = callback; |
| 2851 | ivisurf->content_observer.userdata = userdata; |
| 2852 | ret = IVI_SUCCEEDED; |
| 2853 | } |
| 2854 | return ret; |
| 2855 | } |
| 2856 | |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 2857 | struct ivi_layout_surface* |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2858 | ivi_layout_surface_create(struct weston_surface *wl_surface, |
| 2859 | uint32_t id_surface) |
| 2860 | { |
| 2861 | struct ivi_layout *layout = get_instance(); |
| 2862 | struct ivi_layout_surface *ivisurf = NULL; |
| 2863 | struct weston_view *tmpview = NULL; |
| 2864 | |
| 2865 | if (wl_surface == NULL) { |
| 2866 | weston_log("ivi_layout_surface_create: invalid argument\n"); |
| 2867 | return NULL; |
| 2868 | } |
| 2869 | |
| 2870 | ivisurf = get_surface(&layout->surface_list, id_surface); |
| 2871 | if (ivisurf != NULL) { |
| 2872 | if (ivisurf->surface != NULL) { |
| 2873 | weston_log("id_surface(%d) is already created\n", id_surface); |
| 2874 | return NULL; |
| 2875 | } |
| 2876 | } |
| 2877 | |
| 2878 | ivisurf = calloc(1, sizeof *ivisurf); |
| 2879 | if (ivisurf == NULL) { |
| 2880 | weston_log("fails to allocate memory\n"); |
| 2881 | return NULL; |
| 2882 | } |
| 2883 | |
| 2884 | wl_list_init(&ivisurf->link); |
| 2885 | wl_signal_init(&ivisurf->property_changed); |
| 2886 | wl_signal_init(&ivisurf->configured); |
| 2887 | wl_list_init(&ivisurf->layer_list); |
| 2888 | ivisurf->id_surface = id_surface; |
| 2889 | ivisurf->layout = layout; |
| 2890 | |
| 2891 | ivisurf->surface = wl_surface; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2892 | |
| 2893 | tmpview = weston_view_create(wl_surface); |
| 2894 | if (tmpview == NULL) { |
| 2895 | weston_log("fails to allocate memory\n"); |
| 2896 | } |
| 2897 | |
| 2898 | ivisurf->surface->width_from_buffer = 0; |
| 2899 | ivisurf->surface->height_from_buffer = 0; |
| 2900 | |
| 2901 | weston_matrix_init(&ivisurf->surface_rotation.matrix); |
| 2902 | weston_matrix_init(&ivisurf->layer_rotation.matrix); |
| 2903 | weston_matrix_init(&ivisurf->surface_pos.matrix); |
| 2904 | weston_matrix_init(&ivisurf->layer_pos.matrix); |
| 2905 | weston_matrix_init(&ivisurf->scaling.matrix); |
| 2906 | |
| 2907 | wl_list_init(&ivisurf->surface_rotation.link); |
| 2908 | wl_list_init(&ivisurf->layer_rotation.link); |
| 2909 | wl_list_init(&ivisurf->surface_pos.link); |
| 2910 | wl_list_init(&ivisurf->layer_pos.link); |
| 2911 | wl_list_init(&ivisurf->scaling.link); |
| 2912 | |
| 2913 | init_surface_properties(&ivisurf->prop); |
| 2914 | ivisurf->event_mask = 0; |
| 2915 | |
| 2916 | ivisurf->pending.prop = ivisurf->prop; |
| 2917 | wl_list_init(&ivisurf->pending.link); |
| 2918 | |
| 2919 | wl_list_init(&ivisurf->order.link); |
| 2920 | wl_list_init(&ivisurf->order.layer_list); |
| 2921 | |
| 2922 | wl_list_insert(&layout->surface_list, &ivisurf->link); |
| 2923 | |
| 2924 | wl_signal_emit(&layout->surface_notification.created, ivisurf); |
| 2925 | |
| 2926 | return ivisurf; |
| 2927 | } |
| 2928 | |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 2929 | void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2930 | ivi_layout_init_with_compositor(struct weston_compositor *ec) |
| 2931 | { |
| 2932 | struct ivi_layout *layout = get_instance(); |
| 2933 | |
| 2934 | layout->compositor = ec; |
| 2935 | |
| 2936 | wl_list_init(&layout->surface_list); |
| 2937 | wl_list_init(&layout->layer_list); |
| 2938 | wl_list_init(&layout->screen_list); |
| 2939 | |
| 2940 | wl_signal_init(&layout->layer_notification.created); |
| 2941 | wl_signal_init(&layout->layer_notification.removed); |
| 2942 | |
| 2943 | wl_signal_init(&layout->surface_notification.created); |
| 2944 | wl_signal_init(&layout->surface_notification.removed); |
| 2945 | wl_signal_init(&layout->surface_notification.configure_changed); |
| 2946 | |
| 2947 | /* Add layout_layer at the last of weston_compositor.layer_list */ |
| 2948 | weston_layer_init(&layout->layout_layer, ec->layer_list.prev); |
| 2949 | |
| 2950 | create_screen(ec); |
| 2951 | |
| 2952 | layout->transitions = ivi_layout_transition_set_create(ec); |
| 2953 | wl_list_init(&layout->pending_transition_list); |
| 2954 | } |
| 2955 | |
| 2956 | |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 2957 | void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2958 | ivi_layout_surface_add_configured_listener(struct ivi_layout_surface* ivisurf, |
| 2959 | struct wl_listener* listener) |
| 2960 | { |
| 2961 | wl_signal_add(&ivisurf->configured, listener); |
| 2962 | } |
| 2963 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2964 | static struct ivi_controller_interface ivi_controller_interface = { |
| 2965 | /** |
| 2966 | * commit all changes |
| 2967 | */ |
| 2968 | .commit_changes = ivi_layout_commit_changes, |
| 2969 | |
| 2970 | /** |
| 2971 | * surface controller interfaces |
| 2972 | */ |
| 2973 | .add_notification_create_surface = ivi_layout_add_notification_create_surface, |
| 2974 | .remove_notification_create_surface = ivi_layout_remove_notification_create_surface, |
| 2975 | .add_notification_remove_surface = ivi_layout_add_notification_remove_surface, |
| 2976 | .remove_notification_remove_surface = ivi_layout_remove_notification_remove_surface, |
| 2977 | .add_notification_configure_surface = ivi_layout_add_notification_configure_surface, |
| 2978 | .remove_notification_configure_surface = ivi_layout_remove_notification_configure_surface, |
| 2979 | .get_surfaces = ivi_layout_get_surfaces, |
| 2980 | .get_id_of_surface = ivi_layout_get_id_of_surface, |
| 2981 | .get_surface_from_id = ivi_layout_get_surface_from_id, |
| 2982 | .get_properties_of_surface = ivi_layout_get_properties_of_surface, |
| 2983 | .get_surfaces_on_layer = ivi_layout_get_surfaces_on_layer, |
| 2984 | .surface_set_visibility = ivi_layout_surface_set_visibility, |
| 2985 | .surface_get_visibility = ivi_layout_surface_get_visibility, |
| 2986 | .surface_set_opacity = ivi_layout_surface_set_opacity, |
| 2987 | .surface_get_opacity = ivi_layout_surface_get_opacity, |
| 2988 | .surface_set_source_rectangle = ivi_layout_surface_set_source_rectangle, |
| 2989 | .surface_set_destination_rectangle = ivi_layout_surface_set_destination_rectangle, |
| 2990 | .surface_set_position = ivi_layout_surface_set_position, |
| 2991 | .surface_get_position = ivi_layout_surface_get_position, |
| 2992 | .surface_set_dimension = ivi_layout_surface_set_dimension, |
| 2993 | .surface_get_dimension = ivi_layout_surface_get_dimension, |
| 2994 | .surface_set_orientation = ivi_layout_surface_set_orientation, |
| 2995 | .surface_get_orientation = ivi_layout_surface_get_orientation, |
| 2996 | .surface_set_content_observer = ivi_layout_surface_set_content_observer, |
| 2997 | .surface_add_notification = ivi_layout_surface_add_notification, |
| 2998 | .surface_remove_notification = ivi_layout_surface_remove_notification, |
| 2999 | .surface_get_weston_surface = ivi_layout_surface_get_weston_surface, |
| 3000 | .surface_set_transition = ivi_layout_surface_set_transition, |
| 3001 | .surface_set_transition_duration = ivi_layout_surface_set_transition_duration, |
| 3002 | |
| 3003 | /** |
| 3004 | * layer controller interfaces |
| 3005 | */ |
| 3006 | .add_notification_create_layer = ivi_layout_add_notification_create_layer, |
| 3007 | .remove_notification_create_layer = ivi_layout_remove_notification_create_layer, |
| 3008 | .add_notification_remove_layer = ivi_layout_add_notification_remove_layer, |
| 3009 | .remove_notification_remove_layer = ivi_layout_remove_notification_remove_layer, |
| 3010 | .layer_create_with_dimension = ivi_layout_layer_create_with_dimension, |
Nobuhiko Tanibata | 3aa8aed | 2015-06-22 15:32:23 +0900 | [diff] [blame] | 3011 | .layer_destroy = ivi_layout_layer_destroy, |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 3012 | .get_layers = ivi_layout_get_layers, |
| 3013 | .get_id_of_layer = ivi_layout_get_id_of_layer, |
| 3014 | .get_layer_from_id = ivi_layout_get_layer_from_id, |
| 3015 | .get_properties_of_layer = ivi_layout_get_properties_of_layer, |
| 3016 | .get_layers_under_surface = ivi_layout_get_layers_under_surface, |
| 3017 | .get_layers_on_screen = ivi_layout_get_layers_on_screen, |
| 3018 | .layer_set_visibility = ivi_layout_layer_set_visibility, |
| 3019 | .layer_get_visibility = ivi_layout_layer_get_visibility, |
| 3020 | .layer_set_opacity = ivi_layout_layer_set_opacity, |
| 3021 | .layer_get_opacity = ivi_layout_layer_get_opacity, |
| 3022 | .layer_set_source_rectangle = ivi_layout_layer_set_source_rectangle, |
| 3023 | .layer_set_destination_rectangle = ivi_layout_layer_set_destination_rectangle, |
| 3024 | .layer_set_position = ivi_layout_layer_set_position, |
| 3025 | .layer_get_position = ivi_layout_layer_get_position, |
| 3026 | .layer_set_dimension = ivi_layout_layer_set_dimension, |
| 3027 | .layer_get_dimension = ivi_layout_layer_get_dimension, |
| 3028 | .layer_set_orientation = ivi_layout_layer_set_orientation, |
| 3029 | .layer_get_orientation = ivi_layout_layer_get_orientation, |
| 3030 | .layer_add_surface = ivi_layout_layer_add_surface, |
| 3031 | .layer_remove_surface = ivi_layout_layer_remove_surface, |
| 3032 | .layer_set_render_order = ivi_layout_layer_set_render_order, |
| 3033 | .layer_add_notification = ivi_layout_layer_add_notification, |
| 3034 | .layer_remove_notification = ivi_layout_layer_remove_notification, |
| 3035 | .layer_set_transition = ivi_layout_layer_set_transition, |
| 3036 | |
| 3037 | /** |
Nobuhiko Tanibata | 4d0116e | 2015-06-22 15:31:57 +0900 | [diff] [blame] | 3038 | * screen controller interfaces part1 |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 3039 | */ |
| 3040 | .get_screen_from_id = ivi_layout_get_screen_from_id, |
| 3041 | .get_screen_resolution = ivi_layout_get_screen_resolution, |
| 3042 | .get_screens = ivi_layout_get_screens, |
| 3043 | .get_screens_under_layer = ivi_layout_get_screens_under_layer, |
| 3044 | .screen_add_layer = ivi_layout_screen_add_layer, |
| 3045 | .screen_set_render_order = ivi_layout_screen_set_render_order, |
| 3046 | .screen_get_output = ivi_layout_screen_get_output, |
| 3047 | |
| 3048 | /** |
| 3049 | * animation |
| 3050 | */ |
| 3051 | .transition_move_layer_cancel = ivi_layout_transition_move_layer_cancel, |
Nobuhiko Tanibata | c3fd624 | 2015-04-21 02:13:15 +0900 | [diff] [blame] | 3052 | .layer_set_fade_info = ivi_layout_layer_set_fade_info, |
| 3053 | |
| 3054 | /** |
| 3055 | * surface content dumping for debugging |
| 3056 | */ |
| 3057 | .surface_get_size = ivi_layout_surface_get_size, |
| 3058 | .surface_dump = ivi_layout_surface_dump, |
Nobuhiko Tanibata | 8205170 | 2015-06-22 15:31:26 +0900 | [diff] [blame] | 3059 | |
| 3060 | /** |
Nobuhiko Tanibata | db8efd1 | 2015-06-22 15:31:39 +0900 | [diff] [blame] | 3061 | * remove notification by callback on property changes of ivi_surface/layer |
Nobuhiko Tanibata | 8205170 | 2015-06-22 15:31:26 +0900 | [diff] [blame] | 3062 | */ |
Nobuhiko Tanibata | db8efd1 | 2015-06-22 15:31:39 +0900 | [diff] [blame] | 3063 | .surface_remove_notification_by_callback = ivi_layout_surface_remove_notification_by_callback, |
Nobuhiko Tanibata | 4d0116e | 2015-06-22 15:31:57 +0900 | [diff] [blame] | 3064 | .layer_remove_notification_by_callback = ivi_layout_layer_remove_notification_by_callback, |
| 3065 | |
| 3066 | /** |
| 3067 | * screen controller interfaces part2 |
| 3068 | */ |
| 3069 | .get_id_of_screen = ivi_layout_get_id_of_screen |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 3070 | }; |
| 3071 | |
| 3072 | int |
| 3073 | load_controller_modules(struct weston_compositor *compositor, const char *modules, |
| 3074 | int *argc, char *argv[]) |
| 3075 | { |
| 3076 | const char *p, *end; |
| 3077 | char buffer[256]; |
| 3078 | int (*controller_module_init)(struct weston_compositor *compositor, |
| 3079 | int *argc, char *argv[], |
| 3080 | const struct ivi_controller_interface *interface, |
| 3081 | size_t interface_version); |
| 3082 | |
| 3083 | if (modules == NULL) |
| 3084 | return 0; |
| 3085 | |
| 3086 | p = modules; |
| 3087 | while (*p) { |
| 3088 | end = strchrnul(p, ','); |
| 3089 | snprintf(buffer, sizeof buffer, "%.*s", (int)(end - p), p); |
| 3090 | |
| 3091 | controller_module_init = weston_load_module(buffer, "controller_module_init"); |
Pekka Paalanen | 97246c0 | 2015-03-26 15:47:29 +0200 | [diff] [blame] | 3092 | if (!controller_module_init) |
| 3093 | return -1; |
| 3094 | |
| 3095 | if (controller_module_init(compositor, argc, argv, |
| 3096 | &ivi_controller_interface, |
| 3097 | sizeof(struct ivi_controller_interface)) != 0) { |
| 3098 | weston_log("ivi-shell: Initialization of controller module fails"); |
| 3099 | return -1; |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 3100 | } |
| 3101 | |
| 3102 | p = end; |
| 3103 | while (*p == ',') |
| 3104 | p++; |
| 3105 | } |
| 3106 | |
| 3107 | return 0; |
| 3108 | } |