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 | { |
| 759 | if (ivilayer->event_mask | ivisurf->event_mask) { |
| 760 | struct weston_view *tmpview; |
| 761 | update_opacity(ivilayer, ivisurf); |
| 762 | update_layer_orientation(ivilayer, ivisurf); |
| 763 | update_layer_position(ivilayer, ivisurf); |
| 764 | update_surface_position(ivisurf); |
| 765 | update_surface_orientation(ivilayer, ivisurf); |
| 766 | update_scale(ivilayer, ivisurf); |
| 767 | |
| 768 | ivisurf->update_count++; |
| 769 | |
| 770 | wl_list_for_each(tmpview, &ivisurf->surface->views, surface_link) { |
| 771 | if (tmpview != NULL) { |
| 772 | break; |
| 773 | } |
| 774 | } |
| 775 | |
| 776 | if (tmpview != NULL) { |
| 777 | weston_view_geometry_dirty(tmpview); |
| 778 | } |
| 779 | |
| 780 | if (ivisurf->surface != NULL) { |
| 781 | weston_surface_damage(ivisurf->surface); |
| 782 | } |
| 783 | } |
| 784 | } |
| 785 | |
| 786 | static void |
| 787 | commit_changes(struct ivi_layout *layout) |
| 788 | { |
| 789 | struct ivi_layout_screen *iviscrn = NULL; |
| 790 | struct ivi_layout_layer *ivilayer = NULL; |
| 791 | struct ivi_layout_surface *ivisurf = NULL; |
| 792 | |
| 793 | wl_list_for_each(iviscrn, &layout->screen_list, link) { |
| 794 | wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) { |
| 795 | wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) { |
| 796 | update_prop(ivilayer, ivisurf); |
| 797 | } |
| 798 | } |
| 799 | } |
| 800 | } |
| 801 | |
| 802 | static void |
| 803 | commit_surface_list(struct ivi_layout *layout) |
| 804 | { |
| 805 | struct ivi_layout_surface *ivisurf = NULL; |
| 806 | int32_t dest_x = 0; |
| 807 | int32_t dest_y = 0; |
| 808 | int32_t dest_width = 0; |
| 809 | int32_t dest_height = 0; |
| 810 | int32_t configured = 0; |
| 811 | |
| 812 | wl_list_for_each(ivisurf, &layout->surface_list, link) { |
| 813 | if(ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEFAULT) { |
| 814 | dest_x = ivisurf->prop.dest_x; |
| 815 | dest_y = ivisurf->prop.dest_y; |
| 816 | dest_width = ivisurf->prop.dest_width; |
| 817 | dest_height = ivisurf->prop.dest_height; |
| 818 | |
| 819 | ivi_layout_transition_move_resize_view(ivisurf, |
| 820 | ivisurf->pending.prop.dest_x, |
| 821 | ivisurf->pending.prop.dest_y, |
| 822 | ivisurf->pending.prop.dest_width, |
| 823 | ivisurf->pending.prop.dest_height, |
| 824 | ivisurf->pending.prop.transition_duration); |
| 825 | |
| 826 | if(ivisurf->pending.prop.visibility) { |
| 827 | ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration); |
| 828 | } else { |
| 829 | ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration); |
| 830 | } |
| 831 | |
| 832 | ivisurf->prop = ivisurf->pending.prop; |
| 833 | ivisurf->prop.dest_x = dest_x; |
| 834 | ivisurf->prop.dest_y = dest_y; |
| 835 | ivisurf->prop.dest_width = dest_width; |
| 836 | ivisurf->prop.dest_height = dest_height; |
| 837 | ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 838 | ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 839 | |
| 840 | } else if(ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEST_RECT_ONLY){ |
| 841 | dest_x = ivisurf->prop.dest_x; |
| 842 | dest_y = ivisurf->prop.dest_y; |
| 843 | dest_width = ivisurf->prop.dest_width; |
| 844 | dest_height = ivisurf->prop.dest_height; |
| 845 | |
| 846 | ivi_layout_transition_move_resize_view(ivisurf, |
| 847 | ivisurf->pending.prop.dest_x, |
| 848 | ivisurf->pending.prop.dest_y, |
| 849 | ivisurf->pending.prop.dest_width, |
| 850 | ivisurf->pending.prop.dest_height, |
| 851 | ivisurf->pending.prop.transition_duration); |
| 852 | |
| 853 | ivisurf->prop = ivisurf->pending.prop; |
| 854 | ivisurf->prop.dest_x = dest_x; |
| 855 | ivisurf->prop.dest_y = dest_y; |
| 856 | ivisurf->prop.dest_width = dest_width; |
| 857 | ivisurf->prop.dest_height = dest_height; |
| 858 | |
| 859 | ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 860 | ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 861 | |
| 862 | } else if(ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY){ |
| 863 | configured = 0; |
| 864 | if(ivisurf->pending.prop.visibility) { |
| 865 | ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration); |
| 866 | } else { |
| 867 | ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration); |
| 868 | } |
| 869 | |
| 870 | if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width || |
| 871 | ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) { |
| 872 | configured = 1; |
| 873 | } |
| 874 | |
| 875 | ivisurf->prop = ivisurf->pending.prop; |
| 876 | ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 877 | ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 878 | |
| 879 | if (configured && !is_surface_transition(ivisurf)) |
| 880 | wl_signal_emit(&ivisurf->configured, ivisurf); |
| 881 | } else { |
| 882 | configured = 0; |
| 883 | if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width || |
| 884 | ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) { |
| 885 | configured = 1; |
| 886 | } |
| 887 | |
| 888 | ivisurf->prop = ivisurf->pending.prop; |
| 889 | ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 890 | ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 891 | |
| 892 | if (configured && !is_surface_transition(ivisurf)) |
| 893 | wl_signal_emit(&ivisurf->configured, ivisurf); |
| 894 | } |
| 895 | } |
| 896 | } |
| 897 | |
| 898 | static void |
| 899 | commit_layer_list(struct ivi_layout *layout) |
| 900 | { |
| 901 | struct ivi_layout_layer *ivilayer = NULL; |
| 902 | struct ivi_layout_surface *ivisurf = NULL; |
| 903 | struct ivi_layout_surface *next = NULL; |
| 904 | |
| 905 | wl_list_for_each(ivilayer, &layout->layer_list, link) { |
| 906 | if(ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_MOVE) { |
| 907 | ivi_layout_transition_move_layer(ivilayer, ivilayer->pending.prop.dest_x, ivilayer->pending.prop.dest_y, ivilayer->pending.prop.transition_duration); |
| 908 | } else if(ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_FADE) { |
| 909 | ivi_layout_transition_fade_layer(ivilayer,ivilayer->pending.prop.is_fade_in, |
| 910 | ivilayer->pending.prop.start_alpha,ivilayer->pending.prop.end_alpha, |
| 911 | NULL, NULL, |
| 912 | ivilayer->pending.prop.transition_duration); |
| 913 | } |
| 914 | ivilayer->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE; |
| 915 | |
| 916 | ivilayer->prop = ivilayer->pending.prop; |
| 917 | |
| 918 | if (!(ivilayer->event_mask & |
| 919 | (IVI_NOTIFICATION_ADD | IVI_NOTIFICATION_REMOVE)) ) { |
| 920 | continue; |
| 921 | } |
| 922 | |
| 923 | if (ivilayer->event_mask & IVI_NOTIFICATION_REMOVE) { |
| 924 | wl_list_for_each_safe(ivisurf, next, |
| 925 | &ivilayer->order.surface_list, order.link) { |
| 926 | remove_ordersurface_from_layer(ivisurf); |
| 927 | |
| 928 | if (!wl_list_empty(&ivisurf->order.link)) { |
| 929 | wl_list_remove(&ivisurf->order.link); |
| 930 | } |
| 931 | |
| 932 | wl_list_init(&ivisurf->order.link); |
| 933 | ivisurf->event_mask |= IVI_NOTIFICATION_REMOVE; |
| 934 | } |
| 935 | |
| 936 | wl_list_init(&ivilayer->order.surface_list); |
| 937 | } |
| 938 | |
| 939 | if (ivilayer->event_mask & IVI_NOTIFICATION_ADD) { |
| 940 | wl_list_for_each_safe(ivisurf, next, |
| 941 | &ivilayer->order.surface_list, order.link) { |
| 942 | remove_ordersurface_from_layer(ivisurf); |
| 943 | |
| 944 | if (!wl_list_empty(&ivisurf->order.link)) { |
| 945 | wl_list_remove(&ivisurf->order.link); |
| 946 | } |
| 947 | |
| 948 | wl_list_init(&ivisurf->order.link); |
| 949 | } |
| 950 | |
| 951 | wl_list_init(&ivilayer->order.surface_list); |
| 952 | wl_list_for_each(ivisurf, &ivilayer->pending.surface_list, |
| 953 | pending.link) { |
| 954 | if(!wl_list_empty(&ivisurf->order.link)){ |
| 955 | wl_list_remove(&ivisurf->order.link); |
| 956 | wl_list_init(&ivisurf->order.link); |
| 957 | } |
| 958 | |
| 959 | wl_list_insert(&ivilayer->order.surface_list, |
| 960 | &ivisurf->order.link); |
| 961 | add_ordersurface_to_layer(ivisurf, ivilayer); |
| 962 | ivisurf->event_mask |= IVI_NOTIFICATION_ADD; |
| 963 | } |
| 964 | } |
| 965 | } |
| 966 | } |
| 967 | |
| 968 | static void |
| 969 | commit_screen_list(struct ivi_layout *layout) |
| 970 | { |
| 971 | struct ivi_layout_screen *iviscrn = NULL; |
| 972 | struct ivi_layout_layer *ivilayer = NULL; |
| 973 | struct ivi_layout_layer *next = NULL; |
| 974 | struct ivi_layout_surface *ivisurf = NULL; |
| 975 | |
| 976 | wl_list_for_each(iviscrn, &layout->screen_list, link) { |
| 977 | if (iviscrn->event_mask & IVI_NOTIFICATION_REMOVE) { |
| 978 | wl_list_for_each_safe(ivilayer, next, |
| 979 | &iviscrn->order.layer_list, order.link) { |
| 980 | remove_orderlayer_from_screen(ivilayer); |
| 981 | |
| 982 | if (!wl_list_empty(&ivilayer->order.link)) { |
| 983 | wl_list_remove(&ivilayer->order.link); |
| 984 | } |
| 985 | |
| 986 | wl_list_init(&ivilayer->order.link); |
| 987 | ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE; |
| 988 | } |
| 989 | } |
| 990 | |
| 991 | if (iviscrn->event_mask & IVI_NOTIFICATION_ADD) { |
| 992 | wl_list_for_each_safe(ivilayer, next, |
| 993 | &iviscrn->order.layer_list, order.link) { |
| 994 | remove_orderlayer_from_screen(ivilayer); |
| 995 | |
| 996 | if (!wl_list_empty(&ivilayer->order.link)) { |
| 997 | wl_list_remove(&ivilayer->order.link); |
| 998 | } |
| 999 | |
| 1000 | wl_list_init(&ivilayer->order.link); |
| 1001 | } |
| 1002 | |
| 1003 | wl_list_init(&iviscrn->order.layer_list); |
| 1004 | wl_list_for_each(ivilayer, &iviscrn->pending.layer_list, |
| 1005 | pending.link) { |
| 1006 | wl_list_insert(&iviscrn->order.layer_list, |
| 1007 | &ivilayer->order.link); |
| 1008 | add_orderlayer_to_screen(ivilayer, iviscrn); |
| 1009 | ivilayer->event_mask |= IVI_NOTIFICATION_ADD; |
| 1010 | } |
| 1011 | } |
| 1012 | |
| 1013 | iviscrn->event_mask = 0; |
| 1014 | |
| 1015 | /* Clear view list of layout ivi_layer */ |
| 1016 | wl_list_init(&layout->layout_layer.view_list.link); |
| 1017 | |
| 1018 | wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) { |
| 1019 | if (ivilayer->prop.visibility == false) |
| 1020 | continue; |
| 1021 | |
| 1022 | wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) { |
| 1023 | struct weston_view *tmpview = NULL; |
| 1024 | wl_list_for_each(tmpview, &ivisurf->surface->views, surface_link) { |
| 1025 | if (tmpview != NULL) { |
| 1026 | break; |
| 1027 | } |
| 1028 | } |
| 1029 | |
| 1030 | if (ivisurf->prop.visibility == false) |
| 1031 | continue; |
| 1032 | if (ivisurf->surface == NULL || tmpview == NULL) |
| 1033 | continue; |
| 1034 | |
| 1035 | weston_layer_entry_insert(&layout->layout_layer.view_list, |
| 1036 | &tmpview->layer_link); |
| 1037 | |
| 1038 | ivisurf->surface->output = iviscrn->output; |
| 1039 | } |
| 1040 | } |
| 1041 | |
| 1042 | break; |
| 1043 | } |
| 1044 | } |
| 1045 | |
| 1046 | static void |
| 1047 | commit_transition(struct ivi_layout* layout) |
| 1048 | { |
| 1049 | if(wl_list_empty(&layout->pending_transition_list)){ |
| 1050 | return; |
| 1051 | } |
| 1052 | |
| 1053 | wl_list_insert_list(&layout->transitions->transition_list, |
| 1054 | &layout->pending_transition_list); |
| 1055 | |
| 1056 | wl_list_init(&layout->pending_transition_list); |
| 1057 | |
| 1058 | wl_event_source_timer_update(layout->transitions->event_source, 1); |
| 1059 | } |
| 1060 | |
| 1061 | static void |
| 1062 | send_surface_prop(struct ivi_layout_surface *ivisurf) |
| 1063 | { |
| 1064 | wl_signal_emit(&ivisurf->property_changed, ivisurf); |
| 1065 | ivisurf->event_mask = 0; |
| 1066 | } |
| 1067 | |
| 1068 | static void |
| 1069 | send_layer_prop(struct ivi_layout_layer *ivilayer) |
| 1070 | { |
| 1071 | wl_signal_emit(&ivilayer->property_changed, ivilayer); |
| 1072 | ivilayer->event_mask = 0; |
| 1073 | } |
| 1074 | |
| 1075 | static void |
| 1076 | send_prop(struct ivi_layout *layout) |
| 1077 | { |
| 1078 | struct ivi_layout_layer *ivilayer = NULL; |
| 1079 | struct ivi_layout_surface *ivisurf = NULL; |
| 1080 | |
| 1081 | wl_list_for_each_reverse(ivilayer, &layout->layer_list, link) { |
Nobuhiko Tanibata | 6ce3ef8 | 2015-06-22 15:32:06 +0900 | [diff] [blame] | 1082 | if (ivilayer->event_mask) |
| 1083 | send_layer_prop(ivilayer); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1084 | } |
| 1085 | |
| 1086 | wl_list_for_each_reverse(ivisurf, &layout->surface_list, link) { |
Nobuhiko Tanibata | 6ce3ef8 | 2015-06-22 15:32:06 +0900 | [diff] [blame] | 1087 | if (ivisurf->event_mask) |
| 1088 | send_surface_prop(ivisurf); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1089 | } |
| 1090 | } |
| 1091 | |
| 1092 | static void |
| 1093 | clear_surface_pending_list(struct ivi_layout_layer *ivilayer) |
| 1094 | { |
| 1095 | struct ivi_layout_surface *surface_link = NULL; |
| 1096 | struct ivi_layout_surface *surface_next = NULL; |
| 1097 | |
| 1098 | wl_list_for_each_safe(surface_link, surface_next, |
| 1099 | &ivilayer->pending.surface_list, pending.link) { |
| 1100 | if (!wl_list_empty(&surface_link->pending.link)) { |
| 1101 | wl_list_remove(&surface_link->pending.link); |
| 1102 | } |
| 1103 | |
| 1104 | wl_list_init(&surface_link->pending.link); |
| 1105 | } |
| 1106 | |
| 1107 | ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE; |
| 1108 | } |
| 1109 | |
| 1110 | static void |
| 1111 | clear_surface_order_list(struct ivi_layout_layer *ivilayer) |
| 1112 | { |
| 1113 | struct ivi_layout_surface *surface_link = NULL; |
| 1114 | struct ivi_layout_surface *surface_next = NULL; |
| 1115 | |
| 1116 | wl_list_for_each_safe(surface_link, surface_next, |
| 1117 | &ivilayer->order.surface_list, order.link) { |
| 1118 | if (!wl_list_empty(&surface_link->order.link)) { |
| 1119 | wl_list_remove(&surface_link->order.link); |
| 1120 | } |
| 1121 | |
| 1122 | wl_list_init(&surface_link->order.link); |
| 1123 | } |
| 1124 | |
| 1125 | ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE; |
| 1126 | } |
| 1127 | |
| 1128 | static void |
| 1129 | layer_created(struct wl_listener *listener, void *data) |
| 1130 | { |
| 1131 | struct ivi_layout_layer *ivilayer = data; |
| 1132 | |
| 1133 | struct listener_layout_notification *notification = |
| 1134 | container_of(listener, |
| 1135 | struct listener_layout_notification, |
| 1136 | listener); |
| 1137 | |
| 1138 | struct ivi_layout_notification_callback *created_callback = |
| 1139 | notification->userdata; |
| 1140 | |
| 1141 | ((layer_create_notification_func)created_callback->callback) |
| 1142 | (ivilayer, created_callback->data); |
| 1143 | } |
| 1144 | |
| 1145 | static void |
| 1146 | layer_removed(struct wl_listener *listener, void *data) |
| 1147 | { |
| 1148 | struct ivi_layout_layer *ivilayer = data; |
| 1149 | |
| 1150 | struct listener_layout_notification *notification = |
| 1151 | container_of(listener, |
| 1152 | struct listener_layout_notification, |
| 1153 | listener); |
| 1154 | |
| 1155 | struct ivi_layout_notification_callback *removed_callback = |
| 1156 | notification->userdata; |
| 1157 | |
| 1158 | ((layer_remove_notification_func)removed_callback->callback) |
| 1159 | (ivilayer, removed_callback->data); |
| 1160 | } |
| 1161 | |
| 1162 | static void |
| 1163 | layer_prop_changed(struct wl_listener *listener, void *data) |
| 1164 | { |
| 1165 | struct ivi_layout_layer *ivilayer = data; |
| 1166 | |
| 1167 | struct listener_layout_notification *layout_listener = |
| 1168 | container_of(listener, |
| 1169 | struct listener_layout_notification, |
| 1170 | listener); |
| 1171 | |
| 1172 | struct ivi_layout_notification_callback *prop_callback = |
| 1173 | layout_listener->userdata; |
| 1174 | |
| 1175 | ((layer_property_notification_func)prop_callback->callback) |
| 1176 | (ivilayer, &ivilayer->prop, ivilayer->event_mask, prop_callback->data); |
| 1177 | } |
| 1178 | |
| 1179 | static void |
| 1180 | surface_created(struct wl_listener *listener, void *data) |
| 1181 | { |
| 1182 | struct ivi_layout_surface *ivisurface = data; |
| 1183 | |
| 1184 | struct listener_layout_notification *notification = |
| 1185 | container_of(listener, |
| 1186 | struct listener_layout_notification, |
| 1187 | listener); |
| 1188 | |
| 1189 | struct ivi_layout_notification_callback *created_callback = |
| 1190 | notification->userdata; |
| 1191 | |
| 1192 | ((surface_create_notification_func)created_callback->callback) |
| 1193 | (ivisurface, created_callback->data); |
| 1194 | } |
| 1195 | |
| 1196 | static void |
| 1197 | surface_removed(struct wl_listener *listener, void *data) |
| 1198 | { |
| 1199 | struct ivi_layout_surface *ivisurface = data; |
| 1200 | |
| 1201 | struct listener_layout_notification *notification = |
| 1202 | container_of(listener, |
| 1203 | struct listener_layout_notification, |
| 1204 | listener); |
| 1205 | |
| 1206 | struct ivi_layout_notification_callback *removed_callback = |
| 1207 | notification->userdata; |
| 1208 | |
| 1209 | ((surface_remove_notification_func)removed_callback->callback) |
| 1210 | (ivisurface, removed_callback->data); |
| 1211 | } |
| 1212 | |
| 1213 | static void |
| 1214 | surface_prop_changed(struct wl_listener *listener, void *data) |
| 1215 | { |
| 1216 | struct ivi_layout_surface *ivisurf = data; |
| 1217 | |
| 1218 | struct listener_layout_notification *layout_listener = |
| 1219 | container_of(listener, |
| 1220 | struct listener_layout_notification, |
| 1221 | listener); |
| 1222 | |
| 1223 | struct ivi_layout_notification_callback *prop_callback = |
| 1224 | layout_listener->userdata; |
| 1225 | |
| 1226 | ((surface_property_notification_func)prop_callback->callback) |
| 1227 | (ivisurf, &ivisurf->prop, ivisurf->event_mask, prop_callback->data); |
| 1228 | |
| 1229 | ivisurf->event_mask = 0; |
| 1230 | } |
| 1231 | |
| 1232 | static void |
| 1233 | surface_configure_changed(struct wl_listener *listener, |
| 1234 | void *data) |
| 1235 | { |
| 1236 | struct ivi_layout_surface *ivisurface = data; |
| 1237 | |
| 1238 | struct listener_layout_notification *notification = |
| 1239 | container_of(listener, |
| 1240 | struct listener_layout_notification, |
| 1241 | listener); |
| 1242 | |
| 1243 | struct ivi_layout_notification_callback *configure_changed_callback = |
| 1244 | notification->userdata; |
| 1245 | |
| 1246 | ((surface_configure_notification_func)configure_changed_callback->callback) |
| 1247 | (ivisurface, configure_changed_callback->data); |
| 1248 | } |
| 1249 | |
| 1250 | static int32_t |
| 1251 | add_notification(struct wl_signal *signal, |
| 1252 | wl_notify_func_t callback, |
| 1253 | void *userdata) |
| 1254 | { |
| 1255 | struct listener_layout_notification *notification = NULL; |
| 1256 | |
| 1257 | notification = malloc(sizeof *notification); |
| 1258 | if (notification == NULL) { |
| 1259 | weston_log("fails to allocate memory\n"); |
| 1260 | free(userdata); |
| 1261 | return IVI_FAILED; |
| 1262 | } |
| 1263 | |
| 1264 | notification->listener.notify = callback; |
| 1265 | notification->userdata = userdata; |
| 1266 | |
| 1267 | wl_signal_add(signal, ¬ification->listener); |
| 1268 | |
| 1269 | return IVI_SUCCEEDED; |
| 1270 | } |
| 1271 | |
| 1272 | static void |
| 1273 | remove_notification(struct wl_list *listener_list, void *callback, void *userdata) |
| 1274 | { |
| 1275 | struct wl_listener *listener = NULL; |
| 1276 | struct wl_listener *next = NULL; |
| 1277 | |
| 1278 | wl_list_for_each_safe(listener, next, listener_list, link) { |
| 1279 | struct listener_layout_notification *notification = |
| 1280 | container_of(listener, |
| 1281 | struct listener_layout_notification, |
| 1282 | listener); |
| 1283 | |
| 1284 | struct ivi_layout_notification_callback *notification_callback = |
| 1285 | notification->userdata; |
| 1286 | |
| 1287 | if ((notification_callback->callback != callback) || |
| 1288 | (notification_callback->data != userdata)) { |
| 1289 | continue; |
| 1290 | } |
| 1291 | |
| 1292 | if (!wl_list_empty(&listener->link)) { |
| 1293 | wl_list_remove(&listener->link); |
| 1294 | } |
| 1295 | |
| 1296 | free(notification->userdata); |
| 1297 | free(notification); |
| 1298 | } |
| 1299 | } |
| 1300 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1301 | /** |
| 1302 | * Exported APIs of ivi-layout library are implemented from here. |
| 1303 | * Brief of APIs is described in ivi-layout-export.h. |
| 1304 | */ |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1305 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1306 | ivi_layout_add_notification_create_layer(layer_create_notification_func callback, |
| 1307 | void *userdata) |
| 1308 | { |
| 1309 | struct ivi_layout *layout = get_instance(); |
| 1310 | struct ivi_layout_notification_callback *created_callback = NULL; |
| 1311 | |
| 1312 | if (callback == NULL) { |
| 1313 | weston_log("ivi_layout_add_notification_create_layer: invalid argument\n"); |
| 1314 | return IVI_FAILED; |
| 1315 | } |
| 1316 | |
| 1317 | created_callback = malloc(sizeof *created_callback); |
| 1318 | if (created_callback == NULL) { |
| 1319 | weston_log("fails to allocate memory\n"); |
| 1320 | return IVI_FAILED; |
| 1321 | } |
| 1322 | |
| 1323 | created_callback->callback = callback; |
| 1324 | created_callback->data = userdata; |
| 1325 | |
| 1326 | return add_notification(&layout->layer_notification.created, |
| 1327 | layer_created, |
| 1328 | created_callback); |
| 1329 | } |
| 1330 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1331 | static void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1332 | ivi_layout_remove_notification_create_layer(layer_create_notification_func callback, |
| 1333 | void *userdata) |
| 1334 | { |
| 1335 | struct ivi_layout *layout = get_instance(); |
| 1336 | remove_notification(&layout->layer_notification.created.listener_list, callback, userdata); |
| 1337 | } |
| 1338 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1339 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1340 | ivi_layout_add_notification_remove_layer(layer_remove_notification_func callback, |
| 1341 | void *userdata) |
| 1342 | { |
| 1343 | struct ivi_layout *layout = get_instance(); |
| 1344 | struct ivi_layout_notification_callback *removed_callback = NULL; |
| 1345 | |
| 1346 | if (callback == NULL) { |
| 1347 | weston_log("ivi_layout_add_notification_remove_layer: invalid argument\n"); |
| 1348 | return IVI_FAILED; |
| 1349 | } |
| 1350 | |
| 1351 | removed_callback = malloc(sizeof *removed_callback); |
| 1352 | if (removed_callback == NULL) { |
| 1353 | weston_log("fails to allocate memory\n"); |
| 1354 | return IVI_FAILED; |
| 1355 | } |
| 1356 | |
| 1357 | removed_callback->callback = callback; |
| 1358 | removed_callback->data = userdata; |
| 1359 | return add_notification(&layout->layer_notification.removed, |
| 1360 | layer_removed, |
| 1361 | removed_callback); |
| 1362 | } |
| 1363 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1364 | static void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1365 | ivi_layout_remove_notification_remove_layer(layer_remove_notification_func callback, |
| 1366 | void *userdata) |
| 1367 | { |
| 1368 | struct ivi_layout *layout = get_instance(); |
| 1369 | remove_notification(&layout->layer_notification.removed.listener_list, callback, userdata); |
| 1370 | } |
| 1371 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1372 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1373 | ivi_layout_add_notification_create_surface(surface_create_notification_func callback, |
| 1374 | void *userdata) |
| 1375 | { |
| 1376 | struct ivi_layout *layout = get_instance(); |
| 1377 | struct ivi_layout_notification_callback *created_callback = NULL; |
| 1378 | |
| 1379 | if (callback == NULL) { |
| 1380 | weston_log("ivi_layout_add_notification_create_surface: invalid argument\n"); |
| 1381 | return IVI_FAILED; |
| 1382 | } |
| 1383 | |
| 1384 | created_callback = malloc(sizeof *created_callback); |
| 1385 | if (created_callback == NULL) { |
| 1386 | weston_log("fails to allocate memory\n"); |
| 1387 | return IVI_FAILED; |
| 1388 | } |
| 1389 | |
| 1390 | created_callback->callback = callback; |
| 1391 | created_callback->data = userdata; |
| 1392 | |
| 1393 | return add_notification(&layout->surface_notification.created, |
| 1394 | surface_created, |
| 1395 | created_callback); |
| 1396 | } |
| 1397 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1398 | static void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1399 | ivi_layout_remove_notification_create_surface(surface_create_notification_func callback, |
| 1400 | void *userdata) |
| 1401 | { |
| 1402 | struct ivi_layout *layout = get_instance(); |
| 1403 | remove_notification(&layout->surface_notification.created.listener_list, callback, userdata); |
| 1404 | } |
| 1405 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1406 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1407 | ivi_layout_add_notification_remove_surface(surface_remove_notification_func callback, |
| 1408 | void *userdata) |
| 1409 | { |
| 1410 | struct ivi_layout *layout = get_instance(); |
| 1411 | struct ivi_layout_notification_callback *removed_callback = NULL; |
| 1412 | |
| 1413 | if (callback == NULL) { |
| 1414 | weston_log("ivi_layout_add_notification_remove_surface: invalid argument\n"); |
| 1415 | return IVI_FAILED; |
| 1416 | } |
| 1417 | |
| 1418 | removed_callback = malloc(sizeof *removed_callback); |
| 1419 | if (removed_callback == NULL) { |
| 1420 | weston_log("fails to allocate memory\n"); |
| 1421 | return IVI_FAILED; |
| 1422 | } |
| 1423 | |
| 1424 | removed_callback->callback = callback; |
| 1425 | removed_callback->data = userdata; |
| 1426 | |
| 1427 | return add_notification(&layout->surface_notification.removed, |
| 1428 | surface_removed, |
| 1429 | removed_callback); |
| 1430 | } |
| 1431 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1432 | static void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1433 | ivi_layout_remove_notification_remove_surface(surface_remove_notification_func callback, |
| 1434 | void *userdata) |
| 1435 | { |
| 1436 | struct ivi_layout *layout = get_instance(); |
| 1437 | remove_notification(&layout->surface_notification.removed.listener_list, callback, userdata); |
| 1438 | } |
| 1439 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1440 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1441 | ivi_layout_add_notification_configure_surface(surface_configure_notification_func callback, |
| 1442 | void *userdata) |
| 1443 | { |
| 1444 | struct ivi_layout *layout = get_instance(); |
| 1445 | struct ivi_layout_notification_callback *configure_changed_callback = NULL; |
| 1446 | if (callback == NULL) { |
| 1447 | weston_log("ivi_layout_add_notification_configure_surface: invalid argument\n"); |
| 1448 | return IVI_FAILED; |
| 1449 | } |
| 1450 | |
| 1451 | configure_changed_callback = malloc(sizeof *configure_changed_callback); |
| 1452 | if (configure_changed_callback == NULL) { |
| 1453 | weston_log("fails to allocate memory\n"); |
| 1454 | return IVI_FAILED; |
| 1455 | } |
| 1456 | |
| 1457 | configure_changed_callback->callback = callback; |
| 1458 | configure_changed_callback->data = userdata; |
| 1459 | |
| 1460 | return add_notification(&layout->surface_notification.configure_changed, |
| 1461 | surface_configure_changed, |
| 1462 | configure_changed_callback); |
| 1463 | } |
| 1464 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1465 | static void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1466 | ivi_layout_remove_notification_configure_surface(surface_configure_notification_func callback, |
| 1467 | void *userdata) |
| 1468 | { |
| 1469 | struct ivi_layout *layout = get_instance(); |
| 1470 | remove_notification(&layout->surface_notification.configure_changed.listener_list, callback, userdata); |
| 1471 | } |
| 1472 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1473 | uint32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1474 | ivi_layout_get_id_of_surface(struct ivi_layout_surface *ivisurf) |
| 1475 | { |
| 1476 | return ivisurf->id_surface; |
| 1477 | } |
| 1478 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1479 | static uint32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1480 | ivi_layout_get_id_of_layer(struct ivi_layout_layer *ivilayer) |
| 1481 | { |
| 1482 | return ivilayer->id_layer; |
| 1483 | } |
| 1484 | |
Nobuhiko Tanibata | 4d0116e | 2015-06-22 15:31:57 +0900 | [diff] [blame] | 1485 | static uint32_t |
| 1486 | ivi_layout_get_id_of_screen(struct ivi_layout_screen *iviscrn) |
| 1487 | { |
| 1488 | return iviscrn->id_screen; |
| 1489 | } |
| 1490 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1491 | static struct ivi_layout_layer * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1492 | ivi_layout_get_layer_from_id(uint32_t id_layer) |
| 1493 | { |
| 1494 | struct ivi_layout *layout = get_instance(); |
| 1495 | struct ivi_layout_layer *ivilayer = NULL; |
| 1496 | |
| 1497 | wl_list_for_each(ivilayer, &layout->layer_list, link) { |
| 1498 | if (ivilayer->id_layer == id_layer) { |
| 1499 | return ivilayer; |
| 1500 | } |
| 1501 | } |
| 1502 | |
| 1503 | return NULL; |
| 1504 | } |
| 1505 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1506 | struct ivi_layout_surface * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1507 | ivi_layout_get_surface_from_id(uint32_t id_surface) |
| 1508 | { |
| 1509 | struct ivi_layout *layout = get_instance(); |
| 1510 | struct ivi_layout_surface *ivisurf = NULL; |
| 1511 | |
| 1512 | wl_list_for_each(ivisurf, &layout->surface_list, link) { |
| 1513 | if (ivisurf->id_surface == id_surface) { |
| 1514 | return ivisurf; |
| 1515 | } |
| 1516 | } |
| 1517 | |
| 1518 | return NULL; |
| 1519 | } |
| 1520 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1521 | static struct ivi_layout_screen * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1522 | ivi_layout_get_screen_from_id(uint32_t id_screen) |
| 1523 | { |
| 1524 | struct ivi_layout *layout = get_instance(); |
| 1525 | struct ivi_layout_screen *iviscrn = NULL; |
| 1526 | |
| 1527 | wl_list_for_each(iviscrn, &layout->screen_list, link) { |
| 1528 | /* FIXME : select iviscrn from screen_list by id_screen */ |
| 1529 | return iviscrn; |
| 1530 | break; |
| 1531 | } |
| 1532 | |
| 1533 | return NULL; |
| 1534 | } |
| 1535 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1536 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1537 | ivi_layout_get_screen_resolution(struct ivi_layout_screen *iviscrn, |
| 1538 | int32_t *pWidth, int32_t *pHeight) |
| 1539 | { |
| 1540 | struct weston_output *output = NULL; |
| 1541 | |
Nobuhiko Tanibata | 0c217cb | 2015-06-22 15:30:32 +0900 | [diff] [blame] | 1542 | if (iviscrn == NULL || pWidth == NULL || pHeight == NULL) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1543 | weston_log("ivi_layout_get_screen_resolution: invalid argument\n"); |
| 1544 | return IVI_FAILED; |
| 1545 | } |
| 1546 | |
| 1547 | output = iviscrn->output; |
| 1548 | *pWidth = output->current_mode->width; |
| 1549 | *pHeight = output->current_mode->height; |
| 1550 | |
| 1551 | return IVI_SUCCEEDED; |
| 1552 | } |
| 1553 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1554 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1555 | ivi_layout_surface_add_notification(struct ivi_layout_surface *ivisurf, |
| 1556 | surface_property_notification_func callback, |
| 1557 | void *userdata) |
| 1558 | { |
| 1559 | struct listener_layout_notification* notification = NULL; |
| 1560 | struct ivi_layout_notification_callback *prop_callback = NULL; |
| 1561 | |
| 1562 | if (ivisurf == NULL || callback == NULL) { |
| 1563 | weston_log("ivi_layout_surface_add_notification: invalid argument\n"); |
| 1564 | return IVI_FAILED; |
| 1565 | } |
| 1566 | |
| 1567 | notification = malloc(sizeof *notification); |
| 1568 | if (notification == NULL) { |
| 1569 | weston_log("fails to allocate memory\n"); |
| 1570 | return IVI_FAILED; |
| 1571 | } |
| 1572 | |
| 1573 | prop_callback = malloc(sizeof *prop_callback); |
| 1574 | if (prop_callback == NULL) { |
| 1575 | weston_log("fails to allocate memory\n"); |
| 1576 | return IVI_FAILED; |
| 1577 | } |
| 1578 | |
| 1579 | prop_callback->callback = callback; |
| 1580 | prop_callback->data = userdata; |
| 1581 | |
| 1582 | notification->listener.notify = surface_prop_changed; |
| 1583 | notification->userdata = prop_callback; |
| 1584 | |
| 1585 | wl_signal_add(&ivisurf->property_changed, ¬ification->listener); |
| 1586 | |
| 1587 | return IVI_SUCCEEDED; |
| 1588 | } |
| 1589 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1590 | static const struct ivi_layout_layer_properties * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1591 | ivi_layout_get_properties_of_layer(struct ivi_layout_layer *ivilayer) |
| 1592 | { |
| 1593 | if (ivilayer == NULL) { |
| 1594 | weston_log("ivi_layout_get_properties_of_layer: invalid argument\n"); |
| 1595 | return NULL; |
| 1596 | } |
| 1597 | |
| 1598 | return &ivilayer->prop; |
| 1599 | } |
| 1600 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1601 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1602 | ivi_layout_get_screens(int32_t *pLength, struct ivi_layout_screen ***ppArray) |
| 1603 | { |
| 1604 | struct ivi_layout *layout = get_instance(); |
| 1605 | struct ivi_layout_screen *iviscrn = NULL; |
| 1606 | int32_t length = 0; |
| 1607 | int32_t n = 0; |
| 1608 | |
| 1609 | if (pLength == NULL || ppArray == NULL) { |
| 1610 | weston_log("ivi_layout_get_screens: invalid argument\n"); |
| 1611 | return IVI_FAILED; |
| 1612 | } |
| 1613 | |
| 1614 | length = wl_list_length(&layout->screen_list); |
| 1615 | |
| 1616 | if (length != 0){ |
| 1617 | /* the Array must be free by module which called this function */ |
| 1618 | *ppArray = calloc(length, sizeof(struct ivi_layout_screen *)); |
| 1619 | if (*ppArray == NULL) { |
| 1620 | weston_log("fails to allocate memory\n"); |
| 1621 | return IVI_FAILED; |
| 1622 | } |
| 1623 | |
| 1624 | wl_list_for_each(iviscrn, &layout->screen_list, link) { |
| 1625 | (*ppArray)[n++] = iviscrn; |
| 1626 | } |
| 1627 | } |
| 1628 | |
| 1629 | *pLength = length; |
| 1630 | |
| 1631 | return IVI_SUCCEEDED; |
| 1632 | } |
| 1633 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1634 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1635 | ivi_layout_get_screens_under_layer(struct ivi_layout_layer *ivilayer, |
| 1636 | int32_t *pLength, |
| 1637 | struct ivi_layout_screen ***ppArray) |
| 1638 | { |
| 1639 | struct link_screen *link_scrn = NULL; |
| 1640 | int32_t length = 0; |
| 1641 | int32_t n = 0; |
| 1642 | |
| 1643 | if (ivilayer == NULL || pLength == NULL || ppArray == NULL) { |
| 1644 | weston_log("ivi_layout_get_screens_under_layer: invalid argument\n"); |
| 1645 | return IVI_FAILED; |
| 1646 | } |
| 1647 | |
| 1648 | length = wl_list_length(&ivilayer->screen_list); |
| 1649 | |
| 1650 | if (length != 0){ |
| 1651 | /* the Array must be free by module which called this function */ |
| 1652 | *ppArray = calloc(length, sizeof(struct ivi_layout_screen *)); |
| 1653 | if (*ppArray == NULL) { |
| 1654 | weston_log("fails to allocate memory\n"); |
| 1655 | return IVI_FAILED; |
| 1656 | } |
| 1657 | |
| 1658 | wl_list_for_each(link_scrn, &ivilayer->screen_list, link) { |
| 1659 | (*ppArray)[n++] = link_scrn->iviscrn; |
| 1660 | } |
| 1661 | } |
| 1662 | |
| 1663 | *pLength = length; |
| 1664 | |
| 1665 | return IVI_SUCCEEDED; |
| 1666 | } |
| 1667 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1668 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1669 | ivi_layout_get_layers(int32_t *pLength, struct ivi_layout_layer ***ppArray) |
| 1670 | { |
| 1671 | struct ivi_layout *layout = get_instance(); |
| 1672 | struct ivi_layout_layer *ivilayer = NULL; |
| 1673 | int32_t length = 0; |
| 1674 | int32_t n = 0; |
| 1675 | |
| 1676 | if (pLength == NULL || ppArray == NULL) { |
| 1677 | weston_log("ivi_layout_get_layers: invalid argument\n"); |
| 1678 | return IVI_FAILED; |
| 1679 | } |
| 1680 | |
| 1681 | length = wl_list_length(&layout->layer_list); |
| 1682 | |
| 1683 | if (length != 0){ |
| 1684 | /* the Array must be free by module which called this function */ |
| 1685 | *ppArray = calloc(length, sizeof(struct ivi_layout_layer *)); |
| 1686 | if (*ppArray == NULL) { |
| 1687 | weston_log("fails to allocate memory\n"); |
| 1688 | return IVI_FAILED; |
| 1689 | } |
| 1690 | |
| 1691 | wl_list_for_each(ivilayer, &layout->layer_list, link) { |
| 1692 | (*ppArray)[n++] = ivilayer; |
| 1693 | } |
| 1694 | } |
| 1695 | |
| 1696 | *pLength = length; |
| 1697 | |
| 1698 | return IVI_SUCCEEDED; |
| 1699 | } |
| 1700 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1701 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1702 | ivi_layout_get_layers_on_screen(struct ivi_layout_screen *iviscrn, |
| 1703 | int32_t *pLength, |
| 1704 | struct ivi_layout_layer ***ppArray) |
| 1705 | { |
| 1706 | struct ivi_layout_layer *ivilayer = NULL; |
| 1707 | int32_t length = 0; |
| 1708 | int32_t n = 0; |
| 1709 | |
| 1710 | if (iviscrn == NULL || pLength == NULL || ppArray == NULL) { |
| 1711 | weston_log("ivi_layout_get_layers_on_screen: invalid argument\n"); |
| 1712 | return IVI_FAILED; |
| 1713 | } |
| 1714 | |
| 1715 | length = wl_list_length(&iviscrn->order.layer_list); |
| 1716 | |
| 1717 | if (length != 0){ |
| 1718 | /* the Array must be free by module which called this function */ |
| 1719 | *ppArray = calloc(length, sizeof(struct ivi_layout_layer *)); |
| 1720 | if (*ppArray == NULL) { |
| 1721 | weston_log("fails to allocate memory\n"); |
| 1722 | return IVI_FAILED; |
| 1723 | } |
| 1724 | |
Nobuhiko Tanibata | e2b8214 | 2015-06-22 15:30:19 +0900 | [diff] [blame] | 1725 | wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1726 | (*ppArray)[n++] = ivilayer; |
| 1727 | } |
| 1728 | } |
| 1729 | |
| 1730 | *pLength = length; |
| 1731 | |
| 1732 | return IVI_SUCCEEDED; |
| 1733 | } |
| 1734 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1735 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1736 | ivi_layout_get_layers_under_surface(struct ivi_layout_surface *ivisurf, |
| 1737 | int32_t *pLength, |
| 1738 | struct ivi_layout_layer ***ppArray) |
| 1739 | { |
| 1740 | struct link_layer *link_layer = NULL; |
| 1741 | int32_t length = 0; |
| 1742 | int32_t n = 0; |
| 1743 | |
| 1744 | if (ivisurf == NULL || pLength == NULL || ppArray == NULL) { |
| 1745 | weston_log("ivi_layout_getLayers: invalid argument\n"); |
| 1746 | return IVI_FAILED; |
| 1747 | } |
| 1748 | |
| 1749 | length = wl_list_length(&ivisurf->layer_list); |
| 1750 | |
| 1751 | if (length != 0){ |
| 1752 | /* the Array must be free by module which called this function */ |
| 1753 | *ppArray = calloc(length, sizeof(struct ivi_layout_layer *)); |
| 1754 | if (*ppArray == NULL) { |
| 1755 | weston_log("fails to allocate memory\n"); |
| 1756 | return IVI_FAILED; |
| 1757 | } |
| 1758 | |
| 1759 | wl_list_for_each(link_layer, &ivisurf->layer_list, link) { |
| 1760 | (*ppArray)[n++] = link_layer->ivilayer; |
| 1761 | } |
| 1762 | } |
| 1763 | |
| 1764 | *pLength = length; |
| 1765 | |
| 1766 | return IVI_SUCCEEDED; |
| 1767 | } |
| 1768 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1769 | static |
| 1770 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1771 | ivi_layout_get_surfaces(int32_t *pLength, struct ivi_layout_surface ***ppArray) |
| 1772 | { |
| 1773 | struct ivi_layout *layout = get_instance(); |
| 1774 | struct ivi_layout_surface *ivisurf = NULL; |
| 1775 | int32_t length = 0; |
| 1776 | int32_t n = 0; |
| 1777 | |
| 1778 | if (pLength == NULL || ppArray == NULL) { |
| 1779 | weston_log("ivi_layout_get_surfaces: invalid argument\n"); |
| 1780 | return IVI_FAILED; |
| 1781 | } |
| 1782 | |
| 1783 | length = wl_list_length(&layout->surface_list); |
| 1784 | |
| 1785 | if (length != 0){ |
| 1786 | /* the Array must be free by module which called this function */ |
| 1787 | *ppArray = calloc(length, sizeof(struct ivi_layout_surface *)); |
| 1788 | if (*ppArray == NULL) { |
| 1789 | weston_log("fails to allocate memory\n"); |
| 1790 | return IVI_FAILED; |
| 1791 | } |
| 1792 | |
| 1793 | wl_list_for_each(ivisurf, &layout->surface_list, link) { |
| 1794 | (*ppArray)[n++] = ivisurf; |
| 1795 | } |
| 1796 | } |
| 1797 | |
| 1798 | *pLength = length; |
| 1799 | |
| 1800 | return IVI_SUCCEEDED; |
| 1801 | } |
| 1802 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1803 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1804 | ivi_layout_get_surfaces_on_layer(struct ivi_layout_layer *ivilayer, |
| 1805 | int32_t *pLength, |
| 1806 | struct ivi_layout_surface ***ppArray) |
| 1807 | { |
| 1808 | struct ivi_layout_surface *ivisurf = NULL; |
| 1809 | int32_t length = 0; |
| 1810 | int32_t n = 0; |
| 1811 | |
| 1812 | if (ivilayer == NULL || pLength == NULL || ppArray == NULL) { |
| 1813 | weston_log("ivi_layout_getSurfaceIDsOnLayer: invalid argument\n"); |
| 1814 | return IVI_FAILED; |
| 1815 | } |
| 1816 | |
| 1817 | length = wl_list_length(&ivilayer->order.surface_list); |
| 1818 | |
| 1819 | if (length != 0) { |
| 1820 | /* the Array must be free by module which called this function */ |
| 1821 | *ppArray = calloc(length, sizeof(struct ivi_layout_surface *)); |
| 1822 | if (*ppArray == NULL) { |
| 1823 | weston_log("fails to allocate memory\n"); |
| 1824 | return IVI_FAILED; |
| 1825 | } |
| 1826 | |
| 1827 | wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) { |
| 1828 | (*ppArray)[n++] = ivisurf; |
| 1829 | } |
| 1830 | } |
| 1831 | |
| 1832 | *pLength = length; |
| 1833 | |
| 1834 | return IVI_SUCCEEDED; |
| 1835 | } |
| 1836 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1837 | static struct ivi_layout_layer * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1838 | ivi_layout_layer_create_with_dimension(uint32_t id_layer, |
| 1839 | int32_t width, int32_t height) |
| 1840 | { |
| 1841 | struct ivi_layout *layout = get_instance(); |
| 1842 | struct ivi_layout_layer *ivilayer = NULL; |
| 1843 | |
| 1844 | ivilayer = get_layer(&layout->layer_list, id_layer); |
| 1845 | if (ivilayer != NULL) { |
| 1846 | weston_log("id_layer is already created\n"); |
Nobuhiko Tanibata | 4b601e1 | 2015-06-22 15:31:16 +0900 | [diff] [blame] | 1847 | ++ivilayer->ref_count; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1848 | return ivilayer; |
| 1849 | } |
| 1850 | |
| 1851 | ivilayer = calloc(1, sizeof *ivilayer); |
| 1852 | if (ivilayer == NULL) { |
| 1853 | weston_log("fails to allocate memory\n"); |
| 1854 | return NULL; |
| 1855 | } |
| 1856 | |
Nobuhiko Tanibata | 4b601e1 | 2015-06-22 15:31:16 +0900 | [diff] [blame] | 1857 | ivilayer->ref_count = 1; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1858 | wl_list_init(&ivilayer->link); |
| 1859 | wl_signal_init(&ivilayer->property_changed); |
| 1860 | wl_list_init(&ivilayer->screen_list); |
| 1861 | wl_list_init(&ivilayer->link_to_surface); |
| 1862 | ivilayer->layout = layout; |
| 1863 | ivilayer->id_layer = id_layer; |
| 1864 | |
| 1865 | init_layer_properties(&ivilayer->prop, width, height); |
| 1866 | ivilayer->event_mask = 0; |
| 1867 | |
| 1868 | wl_list_init(&ivilayer->pending.surface_list); |
| 1869 | wl_list_init(&ivilayer->pending.link); |
| 1870 | ivilayer->pending.prop = ivilayer->prop; |
| 1871 | |
| 1872 | wl_list_init(&ivilayer->order.surface_list); |
| 1873 | wl_list_init(&ivilayer->order.link); |
| 1874 | |
| 1875 | wl_list_insert(&layout->layer_list, &ivilayer->link); |
| 1876 | |
| 1877 | wl_signal_emit(&layout->layer_notification.created, ivilayer); |
| 1878 | |
| 1879 | return ivilayer; |
| 1880 | } |
| 1881 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1882 | static void |
Nobuhiko Tanibata | ef6c786 | 2014-12-15 13:20:44 +0900 | [diff] [blame] | 1883 | ivi_layout_layer_remove_notification(struct ivi_layout_layer *ivilayer) |
| 1884 | { |
| 1885 | if (ivilayer == NULL) { |
| 1886 | weston_log("ivi_layout_layer_remove_notification: invalid argument\n"); |
| 1887 | return; |
| 1888 | } |
| 1889 | |
| 1890 | remove_all_notification(&ivilayer->property_changed.listener_list); |
| 1891 | } |
| 1892 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1893 | static void |
Nobuhiko Tanibata | db8efd1 | 2015-06-22 15:31:39 +0900 | [diff] [blame] | 1894 | ivi_layout_layer_remove_notification_by_callback(struct ivi_layout_layer *ivilayer, |
| 1895 | layer_property_notification_func callback, |
| 1896 | void *userdata) |
| 1897 | { |
| 1898 | if (ivilayer == NULL) { |
| 1899 | weston_log("ivi_layout_layer_remove_notification_by_callback: invalid argument\n"); |
| 1900 | return; |
| 1901 | } |
| 1902 | |
| 1903 | remove_notification(&ivilayer->property_changed.listener_list, callback, userdata); |
| 1904 | } |
| 1905 | |
| 1906 | static void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1907 | ivi_layout_layer_remove(struct ivi_layout_layer *ivilayer) |
| 1908 | { |
| 1909 | struct ivi_layout *layout = get_instance(); |
| 1910 | |
| 1911 | if (ivilayer == NULL) { |
| 1912 | weston_log("ivi_layout_layer_remove: invalid argument\n"); |
| 1913 | return; |
| 1914 | } |
| 1915 | |
Nobuhiko Tanibata | 4b601e1 | 2015-06-22 15:31:16 +0900 | [diff] [blame] | 1916 | if (--ivilayer->ref_count > 0) |
| 1917 | return; |
| 1918 | |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1919 | wl_signal_emit(&layout->layer_notification.removed, ivilayer); |
| 1920 | |
| 1921 | clear_surface_pending_list(ivilayer); |
| 1922 | clear_surface_order_list(ivilayer); |
| 1923 | |
| 1924 | if (!wl_list_empty(&ivilayer->pending.link)) { |
| 1925 | wl_list_remove(&ivilayer->pending.link); |
| 1926 | } |
| 1927 | if (!wl_list_empty(&ivilayer->order.link)) { |
| 1928 | wl_list_remove(&ivilayer->order.link); |
| 1929 | } |
| 1930 | if (!wl_list_empty(&ivilayer->link)) { |
| 1931 | wl_list_remove(&ivilayer->link); |
| 1932 | } |
| 1933 | remove_orderlayer_from_screen(ivilayer); |
| 1934 | remove_link_to_surface(ivilayer); |
| 1935 | ivi_layout_layer_remove_notification(ivilayer); |
| 1936 | |
| 1937 | free(ivilayer); |
| 1938 | } |
| 1939 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1940 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1941 | ivi_layout_layer_set_visibility(struct ivi_layout_layer *ivilayer, |
| 1942 | bool newVisibility) |
| 1943 | { |
| 1944 | struct ivi_layout_layer_properties *prop = NULL; |
| 1945 | |
| 1946 | if (ivilayer == NULL) { |
| 1947 | weston_log("ivi_layout_layer_set_visibility: invalid argument\n"); |
| 1948 | return IVI_FAILED; |
| 1949 | } |
| 1950 | |
| 1951 | prop = &ivilayer->pending.prop; |
| 1952 | prop->visibility = newVisibility; |
| 1953 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame^] | 1954 | if (ivilayer->prop.visibility != newVisibility) |
| 1955 | ivilayer->event_mask |= IVI_NOTIFICATION_VISIBILITY; |
| 1956 | else |
| 1957 | ivilayer->event_mask &= ~IVI_NOTIFICATION_VISIBILITY; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1958 | |
| 1959 | return IVI_SUCCEEDED; |
| 1960 | } |
| 1961 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1962 | static bool |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1963 | ivi_layout_layer_get_visibility(struct ivi_layout_layer *ivilayer) |
| 1964 | { |
| 1965 | if (ivilayer == NULL) { |
| 1966 | weston_log("ivi_layout_layer_get_visibility: invalid argument\n"); |
| 1967 | return false; |
| 1968 | } |
| 1969 | |
| 1970 | return ivilayer->prop.visibility; |
| 1971 | } |
| 1972 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1973 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1974 | ivi_layout_layer_set_opacity(struct ivi_layout_layer *ivilayer, |
| 1975 | wl_fixed_t opacity) |
| 1976 | { |
| 1977 | struct ivi_layout_layer_properties *prop = NULL; |
| 1978 | |
Nobuhiko Tanibata | 7bbacc6 | 2015-06-22 15:30:09 +0900 | [diff] [blame] | 1979 | if (ivilayer == NULL || |
| 1980 | opacity < wl_fixed_from_double(0.0) || |
| 1981 | wl_fixed_from_double(1.0) < opacity) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1982 | weston_log("ivi_layout_layer_set_opacity: invalid argument\n"); |
| 1983 | return IVI_FAILED; |
| 1984 | } |
| 1985 | |
| 1986 | prop = &ivilayer->pending.prop; |
| 1987 | prop->opacity = opacity; |
| 1988 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame^] | 1989 | if (ivilayer->prop.opacity != opacity) |
| 1990 | ivilayer->event_mask |= IVI_NOTIFICATION_OPACITY; |
| 1991 | else |
| 1992 | ivilayer->event_mask &= ~IVI_NOTIFICATION_OPACITY; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1993 | |
| 1994 | return IVI_SUCCEEDED; |
| 1995 | } |
| 1996 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 1997 | wl_fixed_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 1998 | ivi_layout_layer_get_opacity(struct ivi_layout_layer *ivilayer) |
| 1999 | { |
| 2000 | if (ivilayer == NULL) { |
| 2001 | weston_log("ivi_layout_layer_get_opacity: invalid argument\n"); |
| 2002 | return wl_fixed_from_double(0.0); |
| 2003 | } |
| 2004 | |
| 2005 | return ivilayer->prop.opacity; |
| 2006 | } |
| 2007 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2008 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2009 | ivi_layout_layer_set_source_rectangle(struct ivi_layout_layer *ivilayer, |
| 2010 | int32_t x, int32_t y, |
| 2011 | int32_t width, int32_t height) |
| 2012 | { |
| 2013 | struct ivi_layout_layer_properties *prop = NULL; |
| 2014 | |
| 2015 | if (ivilayer == NULL) { |
| 2016 | weston_log("ivi_layout_layer_set_source_rectangle: invalid argument\n"); |
| 2017 | return IVI_FAILED; |
| 2018 | } |
| 2019 | |
| 2020 | prop = &ivilayer->pending.prop; |
| 2021 | prop->source_x = x; |
| 2022 | prop->source_y = y; |
| 2023 | prop->source_width = width; |
| 2024 | prop->source_height = height; |
| 2025 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame^] | 2026 | if (ivilayer->prop.source_x != x || ivilayer->prop.source_y != y || |
| 2027 | ivilayer->prop.source_width != width || |
| 2028 | ivilayer->prop.source_height != height) |
| 2029 | ivilayer->event_mask |= IVI_NOTIFICATION_SOURCE_RECT; |
| 2030 | else |
| 2031 | ivilayer->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2032 | |
| 2033 | return IVI_SUCCEEDED; |
| 2034 | } |
| 2035 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2036 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2037 | ivi_layout_layer_set_destination_rectangle(struct ivi_layout_layer *ivilayer, |
| 2038 | int32_t x, int32_t y, |
| 2039 | int32_t width, int32_t height) |
| 2040 | { |
| 2041 | struct ivi_layout_layer_properties *prop = NULL; |
| 2042 | |
| 2043 | if (ivilayer == NULL) { |
| 2044 | weston_log("ivi_layout_layer_set_destination_rectangle: invalid argument\n"); |
| 2045 | return IVI_FAILED; |
| 2046 | } |
| 2047 | |
| 2048 | prop = &ivilayer->pending.prop; |
| 2049 | prop->dest_x = x; |
| 2050 | prop->dest_y = y; |
| 2051 | prop->dest_width = width; |
| 2052 | prop->dest_height = height; |
| 2053 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame^] | 2054 | if (ivilayer->prop.dest_x != x || ivilayer->prop.dest_y != y || |
| 2055 | ivilayer->prop.dest_width != width || |
| 2056 | ivilayer->prop.dest_height != height) |
| 2057 | ivilayer->event_mask |= IVI_NOTIFICATION_DEST_RECT; |
| 2058 | else |
| 2059 | ivilayer->event_mask &= ~IVI_NOTIFICATION_DEST_RECT; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2060 | |
| 2061 | return IVI_SUCCEEDED; |
| 2062 | } |
| 2063 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2064 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2065 | ivi_layout_layer_get_dimension(struct ivi_layout_layer *ivilayer, |
| 2066 | int32_t *dest_width, int32_t *dest_height) |
| 2067 | { |
| 2068 | if (ivilayer == NULL || dest_width == NULL || dest_height == NULL) { |
| 2069 | weston_log("ivi_layout_layer_get_dimension: invalid argument\n"); |
| 2070 | return IVI_FAILED; |
| 2071 | } |
| 2072 | |
| 2073 | *dest_width = ivilayer->prop.dest_width; |
| 2074 | *dest_height = ivilayer->prop.dest_height; |
| 2075 | |
| 2076 | return IVI_SUCCEEDED; |
| 2077 | } |
| 2078 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2079 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2080 | ivi_layout_layer_set_dimension(struct ivi_layout_layer *ivilayer, |
| 2081 | int32_t dest_width, int32_t dest_height) |
| 2082 | { |
| 2083 | struct ivi_layout_layer_properties *prop = NULL; |
| 2084 | |
| 2085 | if (ivilayer == NULL) { |
| 2086 | weston_log("ivi_layout_layer_set_dimension: invalid argument\n"); |
| 2087 | return IVI_FAILED; |
| 2088 | } |
| 2089 | |
| 2090 | prop = &ivilayer->pending.prop; |
| 2091 | |
| 2092 | prop->dest_width = dest_width; |
| 2093 | prop->dest_height = dest_height; |
| 2094 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame^] | 2095 | if (ivilayer->prop.dest_width != dest_width || |
| 2096 | ivilayer->prop.dest_height != dest_height) |
| 2097 | ivilayer->event_mask |= IVI_NOTIFICATION_DIMENSION; |
| 2098 | else |
| 2099 | ivilayer->event_mask &= ~IVI_NOTIFICATION_DIMENSION; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2100 | |
| 2101 | return IVI_SUCCEEDED; |
| 2102 | } |
| 2103 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2104 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2105 | ivi_layout_layer_get_position(struct ivi_layout_layer *ivilayer, |
| 2106 | int32_t *dest_x, int32_t *dest_y) |
| 2107 | { |
| 2108 | if (ivilayer == NULL || dest_x == NULL || dest_y == NULL) { |
| 2109 | weston_log("ivi_layout_layer_get_position: invalid argument\n"); |
| 2110 | return IVI_FAILED; |
| 2111 | } |
| 2112 | |
| 2113 | *dest_x = ivilayer->prop.dest_x; |
| 2114 | *dest_y = ivilayer->prop.dest_y; |
| 2115 | |
| 2116 | return IVI_SUCCEEDED; |
| 2117 | } |
| 2118 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2119 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2120 | ivi_layout_layer_set_position(struct ivi_layout_layer *ivilayer, |
| 2121 | int32_t dest_x, int32_t dest_y) |
| 2122 | { |
| 2123 | struct ivi_layout_layer_properties *prop = NULL; |
| 2124 | |
| 2125 | if (ivilayer == NULL) { |
| 2126 | weston_log("ivi_layout_layer_set_position: invalid argument\n"); |
| 2127 | return IVI_FAILED; |
| 2128 | } |
| 2129 | |
| 2130 | prop = &ivilayer->pending.prop; |
| 2131 | prop->dest_x = dest_x; |
| 2132 | prop->dest_y = dest_y; |
| 2133 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame^] | 2134 | if (ivilayer->prop.dest_x != dest_x || ivilayer->prop.dest_y != dest_y) |
| 2135 | ivilayer->event_mask |= IVI_NOTIFICATION_POSITION; |
| 2136 | else |
| 2137 | ivilayer->event_mask &= ~IVI_NOTIFICATION_POSITION; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2138 | |
| 2139 | return IVI_SUCCEEDED; |
| 2140 | } |
| 2141 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2142 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2143 | ivi_layout_layer_set_orientation(struct ivi_layout_layer *ivilayer, |
| 2144 | enum wl_output_transform orientation) |
| 2145 | { |
| 2146 | struct ivi_layout_layer_properties *prop = NULL; |
| 2147 | |
| 2148 | if (ivilayer == NULL) { |
| 2149 | weston_log("ivi_layout_layer_set_orientation: invalid argument\n"); |
| 2150 | return IVI_FAILED; |
| 2151 | } |
| 2152 | |
| 2153 | prop = &ivilayer->pending.prop; |
| 2154 | prop->orientation = orientation; |
| 2155 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame^] | 2156 | if (ivilayer->prop.orientation != orientation) |
| 2157 | ivilayer->event_mask |= IVI_NOTIFICATION_ORIENTATION; |
| 2158 | else |
| 2159 | ivilayer->event_mask &= ~IVI_NOTIFICATION_ORIENTATION; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2160 | |
| 2161 | return IVI_SUCCEEDED; |
| 2162 | } |
| 2163 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2164 | static enum wl_output_transform |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2165 | ivi_layout_layer_get_orientation(struct ivi_layout_layer *ivilayer) |
| 2166 | { |
| 2167 | if (ivilayer == NULL) { |
| 2168 | weston_log("ivi_layout_layer_get_orientation: invalid argument\n"); |
| 2169 | return 0; |
| 2170 | } |
| 2171 | |
| 2172 | return ivilayer->prop.orientation; |
| 2173 | } |
| 2174 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2175 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2176 | ivi_layout_layer_set_render_order(struct ivi_layout_layer *ivilayer, |
| 2177 | struct ivi_layout_surface **pSurface, |
| 2178 | int32_t number) |
| 2179 | { |
| 2180 | struct ivi_layout *layout = get_instance(); |
| 2181 | struct ivi_layout_surface *ivisurf = NULL; |
| 2182 | struct ivi_layout_surface *next = NULL; |
| 2183 | uint32_t *id_surface = NULL; |
| 2184 | int32_t i = 0; |
| 2185 | |
| 2186 | if (ivilayer == NULL) { |
| 2187 | weston_log("ivi_layout_layer_set_render_order: invalid argument\n"); |
| 2188 | return IVI_FAILED; |
| 2189 | } |
| 2190 | |
| 2191 | if (pSurface == NULL) { |
| 2192 | wl_list_for_each_safe(ivisurf, next, &ivilayer->pending.surface_list, pending.link) { |
| 2193 | if (!wl_list_empty(&ivisurf->pending.link)) { |
| 2194 | wl_list_remove(&ivisurf->pending.link); |
| 2195 | } |
| 2196 | |
| 2197 | wl_list_init(&ivisurf->pending.link); |
| 2198 | } |
| 2199 | ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE; |
| 2200 | return IVI_SUCCEEDED; |
| 2201 | } |
| 2202 | |
| 2203 | for (i = 0; i < number; i++) { |
| 2204 | id_surface = &pSurface[i]->id_surface; |
| 2205 | |
| 2206 | wl_list_for_each_safe(ivisurf, next, &layout->surface_list, link) { |
| 2207 | if (*id_surface != ivisurf->id_surface) { |
| 2208 | continue; |
| 2209 | } |
| 2210 | |
| 2211 | if (!wl_list_empty(&ivisurf->pending.link)) { |
| 2212 | wl_list_remove(&ivisurf->pending.link); |
| 2213 | } |
| 2214 | wl_list_init(&ivisurf->pending.link); |
| 2215 | wl_list_insert(&ivilayer->pending.surface_list, |
| 2216 | &ivisurf->pending.link); |
| 2217 | break; |
| 2218 | } |
| 2219 | } |
| 2220 | |
| 2221 | ivilayer->event_mask |= IVI_NOTIFICATION_ADD; |
| 2222 | |
| 2223 | return IVI_SUCCEEDED; |
| 2224 | } |
| 2225 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2226 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2227 | ivi_layout_surface_set_visibility(struct ivi_layout_surface *ivisurf, |
| 2228 | bool newVisibility) |
| 2229 | { |
| 2230 | struct ivi_layout_surface_properties *prop = NULL; |
| 2231 | |
| 2232 | if (ivisurf == NULL) { |
| 2233 | weston_log("ivi_layout_surface_set_visibility: invalid argument\n"); |
| 2234 | return IVI_FAILED; |
| 2235 | } |
| 2236 | |
| 2237 | prop = &ivisurf->pending.prop; |
| 2238 | prop->visibility = newVisibility; |
| 2239 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame^] | 2240 | if (ivisurf->prop.visibility != newVisibility) |
| 2241 | ivisurf->event_mask |= IVI_NOTIFICATION_VISIBILITY; |
| 2242 | else |
| 2243 | ivisurf->event_mask &= ~IVI_NOTIFICATION_VISIBILITY; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2244 | |
| 2245 | return IVI_SUCCEEDED; |
| 2246 | } |
| 2247 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2248 | bool |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2249 | ivi_layout_surface_get_visibility(struct ivi_layout_surface *ivisurf) |
| 2250 | { |
| 2251 | if (ivisurf == NULL) { |
| 2252 | weston_log("ivi_layout_surface_get_visibility: invalid argument\n"); |
| 2253 | return false; |
| 2254 | } |
| 2255 | |
| 2256 | return ivisurf->prop.visibility; |
| 2257 | } |
| 2258 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2259 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2260 | ivi_layout_surface_set_opacity(struct ivi_layout_surface *ivisurf, |
| 2261 | wl_fixed_t opacity) |
| 2262 | { |
| 2263 | struct ivi_layout_surface_properties *prop = NULL; |
| 2264 | |
Nobuhiko Tanibata | a86226c | 2015-06-22 15:29:20 +0900 | [diff] [blame] | 2265 | if (ivisurf == NULL || |
| 2266 | opacity < wl_fixed_from_double(0.0) || |
| 2267 | wl_fixed_from_double(1.0) < opacity) { |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2268 | weston_log("ivi_layout_surface_set_opacity: invalid argument\n"); |
| 2269 | return IVI_FAILED; |
| 2270 | } |
| 2271 | |
| 2272 | prop = &ivisurf->pending.prop; |
| 2273 | prop->opacity = opacity; |
| 2274 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame^] | 2275 | if (ivisurf->prop.opacity != opacity) |
| 2276 | ivisurf->event_mask |= IVI_NOTIFICATION_OPACITY; |
| 2277 | else |
| 2278 | ivisurf->event_mask &= ~IVI_NOTIFICATION_OPACITY; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2279 | |
| 2280 | return IVI_SUCCEEDED; |
| 2281 | } |
| 2282 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2283 | wl_fixed_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2284 | ivi_layout_surface_get_opacity(struct ivi_layout_surface *ivisurf) |
| 2285 | { |
| 2286 | if (ivisurf == NULL) { |
| 2287 | weston_log("ivi_layout_surface_get_opacity: invalid argument\n"); |
| 2288 | return wl_fixed_from_double(0.0); |
| 2289 | } |
| 2290 | |
| 2291 | return ivisurf->prop.opacity; |
| 2292 | } |
| 2293 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2294 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2295 | ivi_layout_surface_set_destination_rectangle(struct ivi_layout_surface *ivisurf, |
| 2296 | int32_t x, int32_t y, |
| 2297 | int32_t width, int32_t height) |
| 2298 | { |
| 2299 | struct ivi_layout_surface_properties *prop = NULL; |
| 2300 | |
| 2301 | if (ivisurf == NULL) { |
| 2302 | weston_log("ivi_layout_surface_set_destination_rectangle: invalid argument\n"); |
| 2303 | return IVI_FAILED; |
| 2304 | } |
| 2305 | |
| 2306 | prop = &ivisurf->pending.prop; |
| 2307 | prop->start_x = prop->dest_x; |
| 2308 | prop->start_y = prop->dest_y; |
| 2309 | prop->dest_x = x; |
| 2310 | prop->dest_y = y; |
| 2311 | prop->start_width = prop->dest_width; |
| 2312 | prop->start_height = prop->dest_height; |
| 2313 | prop->dest_width = width; |
| 2314 | prop->dest_height = height; |
| 2315 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame^] | 2316 | if (ivisurf->prop.dest_x != x || ivisurf->prop.dest_y != y || |
| 2317 | ivisurf->prop.dest_width != width || |
| 2318 | ivisurf->prop.dest_height != height) |
| 2319 | ivisurf->event_mask |= IVI_NOTIFICATION_DEST_RECT; |
| 2320 | else |
| 2321 | ivisurf->event_mask &= ~IVI_NOTIFICATION_DEST_RECT; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2322 | |
| 2323 | return IVI_SUCCEEDED; |
| 2324 | } |
| 2325 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2326 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2327 | ivi_layout_surface_set_dimension(struct ivi_layout_surface *ivisurf, |
| 2328 | int32_t dest_width, int32_t dest_height) |
| 2329 | { |
| 2330 | struct ivi_layout_surface_properties *prop = NULL; |
| 2331 | |
| 2332 | if (ivisurf == NULL) { |
| 2333 | weston_log("ivi_layout_surface_set_dimension: invalid argument\n"); |
| 2334 | return IVI_FAILED; |
| 2335 | } |
| 2336 | |
| 2337 | prop = &ivisurf->pending.prop; |
| 2338 | prop->dest_width = dest_width; |
| 2339 | prop->dest_height = dest_height; |
| 2340 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame^] | 2341 | if (ivisurf->prop.dest_width != dest_width || |
| 2342 | ivisurf->prop.dest_height != dest_height) |
| 2343 | ivisurf->event_mask |= IVI_NOTIFICATION_DIMENSION; |
| 2344 | else |
| 2345 | ivisurf->event_mask &= ~IVI_NOTIFICATION_DIMENSION; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2346 | |
| 2347 | return IVI_SUCCEEDED; |
| 2348 | } |
| 2349 | |
| 2350 | int32_t |
| 2351 | ivi_layout_surface_get_dimension(struct ivi_layout_surface *ivisurf, |
| 2352 | int32_t *dest_width, int32_t *dest_height) |
| 2353 | { |
| 2354 | if (ivisurf == NULL || dest_width == NULL || dest_height == NULL) { |
| 2355 | weston_log("ivi_layout_surface_get_dimension: invalid argument\n"); |
| 2356 | return IVI_FAILED; |
| 2357 | } |
| 2358 | |
| 2359 | *dest_width = ivisurf->prop.dest_width; |
| 2360 | *dest_height = ivisurf->prop.dest_height; |
| 2361 | |
| 2362 | return IVI_SUCCEEDED; |
| 2363 | } |
| 2364 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2365 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2366 | ivi_layout_surface_set_position(struct ivi_layout_surface *ivisurf, |
| 2367 | int32_t dest_x, int32_t dest_y) |
| 2368 | { |
| 2369 | struct ivi_layout_surface_properties *prop = NULL; |
| 2370 | |
| 2371 | if (ivisurf == NULL) { |
| 2372 | weston_log("ivi_layout_surface_set_position: invalid argument\n"); |
| 2373 | return IVI_FAILED; |
| 2374 | } |
| 2375 | |
| 2376 | prop = &ivisurf->pending.prop; |
| 2377 | prop->dest_x = dest_x; |
| 2378 | prop->dest_y = dest_y; |
| 2379 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame^] | 2380 | if (ivisurf->prop.dest_x != dest_x || ivisurf->prop.dest_y != dest_y) |
| 2381 | ivisurf->event_mask |= IVI_NOTIFICATION_POSITION; |
| 2382 | else |
| 2383 | ivisurf->event_mask &= ~IVI_NOTIFICATION_POSITION; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2384 | |
| 2385 | return IVI_SUCCEEDED; |
| 2386 | } |
| 2387 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2388 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2389 | ivi_layout_surface_get_position(struct ivi_layout_surface *ivisurf, |
| 2390 | int32_t *dest_x, int32_t *dest_y) |
| 2391 | { |
| 2392 | if (ivisurf == NULL || dest_x == NULL || dest_y == NULL) { |
| 2393 | weston_log("ivi_layout_surface_get_position: invalid argument\n"); |
| 2394 | return IVI_FAILED; |
| 2395 | } |
| 2396 | |
| 2397 | *dest_x = ivisurf->prop.dest_x; |
| 2398 | *dest_y = ivisurf->prop.dest_y; |
| 2399 | |
| 2400 | return IVI_SUCCEEDED; |
| 2401 | } |
| 2402 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2403 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2404 | ivi_layout_surface_set_orientation(struct ivi_layout_surface *ivisurf, |
| 2405 | enum wl_output_transform orientation) |
| 2406 | { |
| 2407 | struct ivi_layout_surface_properties *prop = NULL; |
| 2408 | |
| 2409 | if (ivisurf == NULL) { |
| 2410 | weston_log("ivi_layout_surface_set_orientation: invalid argument\n"); |
| 2411 | return IVI_FAILED; |
| 2412 | } |
| 2413 | |
| 2414 | prop = &ivisurf->pending.prop; |
| 2415 | prop->orientation = orientation; |
| 2416 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame^] | 2417 | if (ivisurf->prop.orientation != orientation) |
| 2418 | ivisurf->event_mask |= IVI_NOTIFICATION_ORIENTATION; |
| 2419 | else |
| 2420 | ivisurf->event_mask &= ~IVI_NOTIFICATION_ORIENTATION; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2421 | |
| 2422 | return IVI_SUCCEEDED; |
| 2423 | } |
| 2424 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2425 | static enum wl_output_transform |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2426 | ivi_layout_surface_get_orientation(struct ivi_layout_surface *ivisurf) |
| 2427 | { |
| 2428 | if (ivisurf == NULL) { |
| 2429 | weston_log("ivi_layout_surface_get_orientation: invalid argument\n"); |
| 2430 | return 0; |
| 2431 | } |
| 2432 | |
| 2433 | return ivisurf->prop.orientation; |
| 2434 | } |
| 2435 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2436 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2437 | ivi_layout_screen_add_layer(struct ivi_layout_screen *iviscrn, |
| 2438 | struct ivi_layout_layer *addlayer) |
| 2439 | { |
| 2440 | struct ivi_layout *layout = get_instance(); |
| 2441 | struct ivi_layout_layer *ivilayer = NULL; |
| 2442 | struct ivi_layout_layer *next = NULL; |
| 2443 | int is_layer_in_scrn = 0; |
| 2444 | |
| 2445 | if (iviscrn == NULL || addlayer == NULL) { |
| 2446 | weston_log("ivi_layout_screen_add_layer: invalid argument\n"); |
| 2447 | return IVI_FAILED; |
| 2448 | } |
| 2449 | |
| 2450 | is_layer_in_scrn = is_layer_in_screen(addlayer, iviscrn); |
| 2451 | if (is_layer_in_scrn == 1) { |
| 2452 | weston_log("ivi_layout_screen_add_layer: addlayer is already available\n"); |
| 2453 | return IVI_SUCCEEDED; |
| 2454 | } |
| 2455 | |
| 2456 | wl_list_for_each_safe(ivilayer, next, &layout->layer_list, link) { |
| 2457 | if (ivilayer->id_layer == addlayer->id_layer) { |
| 2458 | if (!wl_list_empty(&ivilayer->pending.link)) { |
| 2459 | wl_list_remove(&ivilayer->pending.link); |
| 2460 | } |
| 2461 | wl_list_init(&ivilayer->pending.link); |
| 2462 | wl_list_insert(&iviscrn->pending.layer_list, |
| 2463 | &ivilayer->pending.link); |
| 2464 | break; |
| 2465 | } |
| 2466 | } |
| 2467 | |
| 2468 | iviscrn->event_mask |= IVI_NOTIFICATION_ADD; |
| 2469 | |
| 2470 | return IVI_SUCCEEDED; |
| 2471 | } |
| 2472 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2473 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2474 | ivi_layout_screen_set_render_order(struct ivi_layout_screen *iviscrn, |
| 2475 | struct ivi_layout_layer **pLayer, |
| 2476 | const int32_t number) |
| 2477 | { |
| 2478 | struct ivi_layout *layout = get_instance(); |
| 2479 | struct ivi_layout_layer *ivilayer = NULL; |
| 2480 | struct ivi_layout_layer *next = NULL; |
| 2481 | uint32_t *id_layer = NULL; |
| 2482 | int32_t i = 0; |
| 2483 | |
| 2484 | if (iviscrn == NULL) { |
| 2485 | weston_log("ivi_layout_screen_set_render_order: invalid argument\n"); |
| 2486 | return IVI_FAILED; |
| 2487 | } |
| 2488 | |
| 2489 | wl_list_for_each_safe(ivilayer, next, |
| 2490 | &iviscrn->pending.layer_list, pending.link) { |
| 2491 | wl_list_init(&ivilayer->pending.link); |
| 2492 | } |
| 2493 | |
| 2494 | wl_list_init(&iviscrn->pending.layer_list); |
| 2495 | |
| 2496 | if (pLayer == NULL) { |
| 2497 | wl_list_for_each_safe(ivilayer, next, &iviscrn->pending.layer_list, pending.link) { |
| 2498 | if (!wl_list_empty(&ivilayer->pending.link)) { |
| 2499 | wl_list_remove(&ivilayer->pending.link); |
| 2500 | } |
| 2501 | |
| 2502 | wl_list_init(&ivilayer->pending.link); |
| 2503 | } |
| 2504 | |
| 2505 | iviscrn->event_mask |= IVI_NOTIFICATION_REMOVE; |
| 2506 | return IVI_SUCCEEDED; |
| 2507 | } |
| 2508 | |
| 2509 | for (i = 0; i < number; i++) { |
| 2510 | id_layer = &pLayer[i]->id_layer; |
| 2511 | wl_list_for_each(ivilayer, &layout->layer_list, link) { |
| 2512 | if (*id_layer != ivilayer->id_layer) { |
| 2513 | continue; |
| 2514 | } |
| 2515 | |
| 2516 | if (!wl_list_empty(&ivilayer->pending.link)) { |
| 2517 | wl_list_remove(&ivilayer->pending.link); |
| 2518 | } |
| 2519 | wl_list_init(&ivilayer->pending.link); |
| 2520 | wl_list_insert(&iviscrn->pending.layer_list, |
| 2521 | &ivilayer->pending.link); |
| 2522 | break; |
| 2523 | } |
| 2524 | } |
| 2525 | |
| 2526 | iviscrn->event_mask |= IVI_NOTIFICATION_ADD; |
| 2527 | |
| 2528 | return IVI_SUCCEEDED; |
| 2529 | } |
| 2530 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2531 | static struct weston_output * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2532 | ivi_layout_screen_get_output(struct ivi_layout_screen *iviscrn) |
| 2533 | { |
| 2534 | return iviscrn->output; |
| 2535 | } |
| 2536 | |
| 2537 | /** |
| 2538 | * This function is used by the additional ivi-module because of dumping ivi_surface sceenshot. |
| 2539 | * The ivi-module, e.g. ivi-controller.so, is in wayland-ivi-extension of Genivi's Layer Management. |
| 2540 | * This function is used to get the result of drawing by clients. |
| 2541 | */ |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2542 | static struct weston_surface * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2543 | ivi_layout_surface_get_weston_surface(struct ivi_layout_surface *ivisurf) |
| 2544 | { |
| 2545 | return ivisurf != NULL ? ivisurf->surface : NULL; |
| 2546 | } |
| 2547 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2548 | static int32_t |
Nobuhiko Tanibata | c3fd624 | 2015-04-21 02:13:15 +0900 | [diff] [blame] | 2549 | ivi_layout_surface_get_size(struct ivi_layout_surface *ivisurf, |
| 2550 | int32_t *width, int32_t *height, |
| 2551 | int32_t *stride) |
| 2552 | { |
| 2553 | int32_t w; |
| 2554 | int32_t h; |
| 2555 | const size_t bytespp = 4; /* PIXMAN_a8b8g8r8 */ |
| 2556 | |
| 2557 | if (ivisurf == NULL || ivisurf->surface == NULL) { |
| 2558 | weston_log("%s: invalid argument\n", __func__); |
| 2559 | return IVI_FAILED; |
| 2560 | } |
| 2561 | |
| 2562 | weston_surface_get_content_size(ivisurf->surface, &w, &h); |
| 2563 | |
| 2564 | if (width != NULL) |
| 2565 | *width = w; |
| 2566 | |
| 2567 | if (height != NULL) |
| 2568 | *height = h; |
| 2569 | |
| 2570 | if (stride != NULL) |
| 2571 | *stride = w * bytespp; |
| 2572 | |
| 2573 | return IVI_SUCCEEDED; |
| 2574 | } |
| 2575 | |
| 2576 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2577 | ivi_layout_layer_add_notification(struct ivi_layout_layer *ivilayer, |
| 2578 | layer_property_notification_func callback, |
| 2579 | void *userdata) |
| 2580 | { |
| 2581 | struct ivi_layout_notification_callback *prop_callback = NULL; |
| 2582 | |
| 2583 | if (ivilayer == NULL || callback == NULL) { |
| 2584 | weston_log("ivi_layout_layer_add_notification: invalid argument\n"); |
| 2585 | return IVI_FAILED; |
| 2586 | } |
| 2587 | |
| 2588 | prop_callback = malloc(sizeof *prop_callback); |
| 2589 | if (prop_callback == NULL) { |
| 2590 | weston_log("fails to allocate memory\n"); |
| 2591 | return IVI_FAILED; |
| 2592 | } |
| 2593 | |
| 2594 | prop_callback->callback = callback; |
| 2595 | prop_callback->data = userdata; |
| 2596 | |
| 2597 | return add_notification(&ivilayer->property_changed, |
| 2598 | layer_prop_changed, |
| 2599 | prop_callback); |
| 2600 | } |
| 2601 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2602 | static const struct ivi_layout_surface_properties * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2603 | ivi_layout_get_properties_of_surface(struct ivi_layout_surface *ivisurf) |
| 2604 | { |
| 2605 | if (ivisurf == NULL) { |
| 2606 | weston_log("ivi_layout_get_properties_of_surface: invalid argument\n"); |
| 2607 | return NULL; |
| 2608 | } |
| 2609 | |
| 2610 | return &ivisurf->prop; |
| 2611 | } |
| 2612 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2613 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2614 | ivi_layout_layer_add_surface(struct ivi_layout_layer *ivilayer, |
| 2615 | struct ivi_layout_surface *addsurf) |
| 2616 | { |
| 2617 | struct ivi_layout *layout = get_instance(); |
| 2618 | struct ivi_layout_surface *ivisurf = NULL; |
| 2619 | struct ivi_layout_surface *next = NULL; |
| 2620 | int is_surf_in_layer = 0; |
| 2621 | |
| 2622 | if (ivilayer == NULL || addsurf == NULL) { |
| 2623 | weston_log("ivi_layout_layer_add_surface: invalid argument\n"); |
| 2624 | return IVI_FAILED; |
| 2625 | } |
| 2626 | |
| 2627 | is_surf_in_layer = is_surface_in_layer(addsurf, ivilayer); |
| 2628 | if (is_surf_in_layer == 1) { |
| 2629 | weston_log("ivi_layout_layer_add_surface: addsurf is already available\n"); |
| 2630 | return IVI_SUCCEEDED; |
| 2631 | } |
| 2632 | |
| 2633 | wl_list_for_each_safe(ivisurf, next, &layout->surface_list, link) { |
| 2634 | if (ivisurf->id_surface == addsurf->id_surface) { |
| 2635 | if (!wl_list_empty(&ivisurf->pending.link)) { |
| 2636 | wl_list_remove(&ivisurf->pending.link); |
| 2637 | } |
| 2638 | wl_list_init(&ivisurf->pending.link); |
| 2639 | wl_list_insert(&ivilayer->pending.surface_list, |
| 2640 | &ivisurf->pending.link); |
| 2641 | break; |
| 2642 | } |
| 2643 | } |
| 2644 | |
| 2645 | ivilayer->event_mask |= IVI_NOTIFICATION_ADD; |
| 2646 | |
| 2647 | return IVI_SUCCEEDED; |
| 2648 | } |
| 2649 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2650 | static void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2651 | ivi_layout_layer_remove_surface(struct ivi_layout_layer *ivilayer, |
| 2652 | struct ivi_layout_surface *remsurf) |
| 2653 | { |
| 2654 | struct ivi_layout_surface *ivisurf = NULL; |
| 2655 | struct ivi_layout_surface *next = NULL; |
| 2656 | |
| 2657 | if (ivilayer == NULL || remsurf == NULL) { |
| 2658 | weston_log("ivi_layout_layer_remove_surface: invalid argument\n"); |
| 2659 | return; |
| 2660 | } |
| 2661 | |
| 2662 | wl_list_for_each_safe(ivisurf, next, |
| 2663 | &ivilayer->pending.surface_list, pending.link) { |
| 2664 | if (ivisurf->id_surface == remsurf->id_surface) { |
| 2665 | if (!wl_list_empty(&ivisurf->pending.link)) { |
| 2666 | wl_list_remove(&ivisurf->pending.link); |
| 2667 | } |
| 2668 | wl_list_init(&ivisurf->pending.link); |
| 2669 | break; |
| 2670 | } |
| 2671 | } |
| 2672 | |
| 2673 | remsurf->event_mask |= IVI_NOTIFICATION_REMOVE; |
| 2674 | } |
| 2675 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2676 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2677 | ivi_layout_surface_set_source_rectangle(struct ivi_layout_surface *ivisurf, |
| 2678 | int32_t x, int32_t y, |
| 2679 | int32_t width, int32_t height) |
| 2680 | { |
| 2681 | struct ivi_layout_surface_properties *prop = NULL; |
| 2682 | |
| 2683 | if (ivisurf == NULL) { |
| 2684 | weston_log("ivi_layout_surface_set_source_rectangle: invalid argument\n"); |
| 2685 | return IVI_FAILED; |
| 2686 | } |
| 2687 | |
| 2688 | prop = &ivisurf->pending.prop; |
| 2689 | prop->source_x = x; |
| 2690 | prop->source_y = y; |
| 2691 | prop->source_width = width; |
| 2692 | prop->source_height = height; |
| 2693 | |
Nobuhiko Tanibata | 5d4a323 | 2015-06-22 15:32:14 +0900 | [diff] [blame^] | 2694 | if (ivisurf->prop.source_x != x || ivisurf->prop.source_y != y || |
| 2695 | ivisurf->prop.source_width != width || |
| 2696 | ivisurf->prop.source_height != height) |
| 2697 | ivisurf->event_mask |= IVI_NOTIFICATION_SOURCE_RECT; |
| 2698 | else |
| 2699 | ivisurf->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2700 | |
| 2701 | return IVI_SUCCEEDED; |
| 2702 | } |
| 2703 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2704 | int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2705 | ivi_layout_commit_changes(void) |
| 2706 | { |
| 2707 | struct ivi_layout *layout = get_instance(); |
| 2708 | |
| 2709 | commit_surface_list(layout); |
| 2710 | commit_layer_list(layout); |
| 2711 | commit_screen_list(layout); |
| 2712 | |
| 2713 | commit_transition(layout); |
| 2714 | |
| 2715 | commit_changes(layout); |
| 2716 | send_prop(layout); |
| 2717 | weston_compositor_schedule_repaint(layout->compositor); |
| 2718 | |
| 2719 | return IVI_SUCCEEDED; |
| 2720 | } |
| 2721 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2722 | static int32_t |
Nobuhiko Tanibata | 3c6796f | 2014-12-15 13:20:58 +0900 | [diff] [blame] | 2723 | ivi_layout_layer_set_transition(struct ivi_layout_layer *ivilayer, |
| 2724 | enum ivi_layout_transition_type type, |
| 2725 | uint32_t duration) |
| 2726 | { |
| 2727 | if (ivilayer == NULL) { |
| 2728 | weston_log("%s: invalid argument\n", __func__); |
| 2729 | return -1; |
| 2730 | } |
| 2731 | |
| 2732 | ivilayer->pending.prop.transition_type = type; |
| 2733 | ivilayer->pending.prop.transition_duration = duration; |
| 2734 | |
| 2735 | return 0; |
| 2736 | } |
| 2737 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2738 | static int32_t |
Nobuhiko Tanibata | 3c6796f | 2014-12-15 13:20:58 +0900 | [diff] [blame] | 2739 | ivi_layout_layer_set_fade_info(struct ivi_layout_layer* ivilayer, |
| 2740 | uint32_t is_fade_in, |
| 2741 | double start_alpha, double end_alpha) |
| 2742 | { |
| 2743 | if (ivilayer == NULL) { |
| 2744 | weston_log("%s: invalid argument\n", __func__); |
| 2745 | return -1; |
| 2746 | } |
| 2747 | |
| 2748 | ivilayer->pending.prop.is_fade_in = is_fade_in; |
| 2749 | ivilayer->pending.prop.start_alpha = start_alpha; |
| 2750 | ivilayer->pending.prop.end_alpha = end_alpha; |
| 2751 | |
| 2752 | return 0; |
| 2753 | } |
| 2754 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2755 | static int32_t |
Nobuhiko Tanibata | 3c6796f | 2014-12-15 13:20:58 +0900 | [diff] [blame] | 2756 | ivi_layout_surface_set_transition_duration(struct ivi_layout_surface *ivisurf, |
| 2757 | uint32_t duration) |
| 2758 | { |
| 2759 | struct ivi_layout_surface_properties *prop; |
| 2760 | |
| 2761 | if (ivisurf == NULL) { |
| 2762 | weston_log("%s: invalid argument\n", __func__); |
| 2763 | return -1; |
| 2764 | } |
| 2765 | |
| 2766 | prop = &ivisurf->pending.prop; |
| 2767 | prop->transition_duration = duration*10; |
| 2768 | return 0; |
| 2769 | } |
| 2770 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2771 | static int32_t |
Nobuhiko Tanibata | 3c6796f | 2014-12-15 13:20:58 +0900 | [diff] [blame] | 2772 | ivi_layout_surface_set_transition(struct ivi_layout_surface *ivisurf, |
| 2773 | enum ivi_layout_transition_type type, |
| 2774 | uint32_t duration) |
| 2775 | { |
| 2776 | struct ivi_layout_surface_properties *prop; |
| 2777 | |
| 2778 | if (ivisurf == NULL) { |
| 2779 | weston_log("%s: invalid argument\n", __func__); |
| 2780 | return -1; |
| 2781 | } |
| 2782 | |
| 2783 | prop = &ivisurf->pending.prop; |
| 2784 | prop->transition_type = type; |
| 2785 | prop->transition_duration = duration; |
| 2786 | return 0; |
| 2787 | } |
| 2788 | |
Nobuhiko Tanibata | c3fd624 | 2015-04-21 02:13:15 +0900 | [diff] [blame] | 2789 | static int32_t |
| 2790 | ivi_layout_surface_dump(struct weston_surface *surface, |
| 2791 | void *target, size_t size,int32_t x, int32_t y, |
| 2792 | int32_t width, int32_t height) |
| 2793 | { |
| 2794 | int result = 0; |
| 2795 | |
| 2796 | if (surface == NULL) { |
| 2797 | weston_log("%s: invalid argument\n", __func__); |
| 2798 | return IVI_FAILED; |
| 2799 | } |
| 2800 | |
| 2801 | result = weston_surface_copy_content( |
| 2802 | surface, target, size, |
| 2803 | x, y, width, height); |
| 2804 | |
| 2805 | return result == 0 ? IVI_SUCCEEDED : IVI_FAILED; |
| 2806 | } |
| 2807 | |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 2808 | /** |
| 2809 | * methods of interaction between ivi-shell with ivi-layout |
| 2810 | */ |
| 2811 | struct weston_view * |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2812 | ivi_layout_get_weston_view(struct ivi_layout_surface *surface) |
| 2813 | { |
| 2814 | struct weston_view *tmpview = NULL; |
| 2815 | |
| 2816 | if(surface == NULL) |
| 2817 | return NULL; |
| 2818 | |
| 2819 | wl_list_for_each(tmpview, &surface->surface->views, surface_link) |
| 2820 | { |
| 2821 | if (tmpview != NULL) { |
| 2822 | break; |
| 2823 | } |
| 2824 | } |
| 2825 | return tmpview; |
| 2826 | } |
| 2827 | |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 2828 | void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2829 | ivi_layout_surface_configure(struct ivi_layout_surface *ivisurf, |
| 2830 | int32_t width, int32_t height) |
| 2831 | { |
| 2832 | struct ivi_layout *layout = get_instance(); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2833 | |
Nobuhiko Tanibata | e6cc997 | 2015-04-27 16:54:01 +0900 | [diff] [blame] | 2834 | /* emit callback which is set by ivi-layout api user */ |
| 2835 | wl_signal_emit(&layout->surface_notification.configure_changed, |
| 2836 | ivisurf); |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2837 | } |
| 2838 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2839 | static int32_t |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2840 | ivi_layout_surface_set_content_observer(struct ivi_layout_surface *ivisurf, |
| 2841 | ivi_controller_surface_content_callback callback, |
| 2842 | void* userdata) |
| 2843 | { |
| 2844 | int32_t ret = IVI_FAILED; |
| 2845 | |
| 2846 | if (ivisurf != NULL) { |
| 2847 | ivisurf->content_observer.callback = callback; |
| 2848 | ivisurf->content_observer.userdata = userdata; |
| 2849 | ret = IVI_SUCCEEDED; |
| 2850 | } |
| 2851 | return ret; |
| 2852 | } |
| 2853 | |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 2854 | struct ivi_layout_surface* |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2855 | ivi_layout_surface_create(struct weston_surface *wl_surface, |
| 2856 | uint32_t id_surface) |
| 2857 | { |
| 2858 | struct ivi_layout *layout = get_instance(); |
| 2859 | struct ivi_layout_surface *ivisurf = NULL; |
| 2860 | struct weston_view *tmpview = NULL; |
| 2861 | |
| 2862 | if (wl_surface == NULL) { |
| 2863 | weston_log("ivi_layout_surface_create: invalid argument\n"); |
| 2864 | return NULL; |
| 2865 | } |
| 2866 | |
| 2867 | ivisurf = get_surface(&layout->surface_list, id_surface); |
| 2868 | if (ivisurf != NULL) { |
| 2869 | if (ivisurf->surface != NULL) { |
| 2870 | weston_log("id_surface(%d) is already created\n", id_surface); |
| 2871 | return NULL; |
| 2872 | } |
| 2873 | } |
| 2874 | |
| 2875 | ivisurf = calloc(1, sizeof *ivisurf); |
| 2876 | if (ivisurf == NULL) { |
| 2877 | weston_log("fails to allocate memory\n"); |
| 2878 | return NULL; |
| 2879 | } |
| 2880 | |
| 2881 | wl_list_init(&ivisurf->link); |
| 2882 | wl_signal_init(&ivisurf->property_changed); |
| 2883 | wl_signal_init(&ivisurf->configured); |
| 2884 | wl_list_init(&ivisurf->layer_list); |
| 2885 | ivisurf->id_surface = id_surface; |
| 2886 | ivisurf->layout = layout; |
| 2887 | |
| 2888 | ivisurf->surface = wl_surface; |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2889 | |
| 2890 | tmpview = weston_view_create(wl_surface); |
| 2891 | if (tmpview == NULL) { |
| 2892 | weston_log("fails to allocate memory\n"); |
| 2893 | } |
| 2894 | |
| 2895 | ivisurf->surface->width_from_buffer = 0; |
| 2896 | ivisurf->surface->height_from_buffer = 0; |
| 2897 | |
| 2898 | weston_matrix_init(&ivisurf->surface_rotation.matrix); |
| 2899 | weston_matrix_init(&ivisurf->layer_rotation.matrix); |
| 2900 | weston_matrix_init(&ivisurf->surface_pos.matrix); |
| 2901 | weston_matrix_init(&ivisurf->layer_pos.matrix); |
| 2902 | weston_matrix_init(&ivisurf->scaling.matrix); |
| 2903 | |
| 2904 | wl_list_init(&ivisurf->surface_rotation.link); |
| 2905 | wl_list_init(&ivisurf->layer_rotation.link); |
| 2906 | wl_list_init(&ivisurf->surface_pos.link); |
| 2907 | wl_list_init(&ivisurf->layer_pos.link); |
| 2908 | wl_list_init(&ivisurf->scaling.link); |
| 2909 | |
| 2910 | init_surface_properties(&ivisurf->prop); |
| 2911 | ivisurf->event_mask = 0; |
| 2912 | |
| 2913 | ivisurf->pending.prop = ivisurf->prop; |
| 2914 | wl_list_init(&ivisurf->pending.link); |
| 2915 | |
| 2916 | wl_list_init(&ivisurf->order.link); |
| 2917 | wl_list_init(&ivisurf->order.layer_list); |
| 2918 | |
| 2919 | wl_list_insert(&layout->surface_list, &ivisurf->link); |
| 2920 | |
| 2921 | wl_signal_emit(&layout->surface_notification.created, ivisurf); |
| 2922 | |
| 2923 | return ivisurf; |
| 2924 | } |
| 2925 | |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 2926 | void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2927 | ivi_layout_init_with_compositor(struct weston_compositor *ec) |
| 2928 | { |
| 2929 | struct ivi_layout *layout = get_instance(); |
| 2930 | |
| 2931 | layout->compositor = ec; |
| 2932 | |
| 2933 | wl_list_init(&layout->surface_list); |
| 2934 | wl_list_init(&layout->layer_list); |
| 2935 | wl_list_init(&layout->screen_list); |
| 2936 | |
| 2937 | wl_signal_init(&layout->layer_notification.created); |
| 2938 | wl_signal_init(&layout->layer_notification.removed); |
| 2939 | |
| 2940 | wl_signal_init(&layout->surface_notification.created); |
| 2941 | wl_signal_init(&layout->surface_notification.removed); |
| 2942 | wl_signal_init(&layout->surface_notification.configure_changed); |
| 2943 | |
| 2944 | /* Add layout_layer at the last of weston_compositor.layer_list */ |
| 2945 | weston_layer_init(&layout->layout_layer, ec->layer_list.prev); |
| 2946 | |
| 2947 | create_screen(ec); |
| 2948 | |
| 2949 | layout->transitions = ivi_layout_transition_set_create(ec); |
| 2950 | wl_list_init(&layout->pending_transition_list); |
| 2951 | } |
| 2952 | |
| 2953 | |
Nobuhiko Tanibata | 28dc18c | 2014-12-15 13:22:31 +0900 | [diff] [blame] | 2954 | void |
Nobuhiko Tanibata | 6f9df65 | 2014-11-27 13:22:00 +0900 | [diff] [blame] | 2955 | ivi_layout_surface_add_configured_listener(struct ivi_layout_surface* ivisurf, |
| 2956 | struct wl_listener* listener) |
| 2957 | { |
| 2958 | wl_signal_add(&ivisurf->configured, listener); |
| 2959 | } |
| 2960 | |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 2961 | static struct ivi_controller_interface ivi_controller_interface = { |
| 2962 | /** |
| 2963 | * commit all changes |
| 2964 | */ |
| 2965 | .commit_changes = ivi_layout_commit_changes, |
| 2966 | |
| 2967 | /** |
| 2968 | * surface controller interfaces |
| 2969 | */ |
| 2970 | .add_notification_create_surface = ivi_layout_add_notification_create_surface, |
| 2971 | .remove_notification_create_surface = ivi_layout_remove_notification_create_surface, |
| 2972 | .add_notification_remove_surface = ivi_layout_add_notification_remove_surface, |
| 2973 | .remove_notification_remove_surface = ivi_layout_remove_notification_remove_surface, |
| 2974 | .add_notification_configure_surface = ivi_layout_add_notification_configure_surface, |
| 2975 | .remove_notification_configure_surface = ivi_layout_remove_notification_configure_surface, |
| 2976 | .get_surfaces = ivi_layout_get_surfaces, |
| 2977 | .get_id_of_surface = ivi_layout_get_id_of_surface, |
| 2978 | .get_surface_from_id = ivi_layout_get_surface_from_id, |
| 2979 | .get_properties_of_surface = ivi_layout_get_properties_of_surface, |
| 2980 | .get_surfaces_on_layer = ivi_layout_get_surfaces_on_layer, |
| 2981 | .surface_set_visibility = ivi_layout_surface_set_visibility, |
| 2982 | .surface_get_visibility = ivi_layout_surface_get_visibility, |
| 2983 | .surface_set_opacity = ivi_layout_surface_set_opacity, |
| 2984 | .surface_get_opacity = ivi_layout_surface_get_opacity, |
| 2985 | .surface_set_source_rectangle = ivi_layout_surface_set_source_rectangle, |
| 2986 | .surface_set_destination_rectangle = ivi_layout_surface_set_destination_rectangle, |
| 2987 | .surface_set_position = ivi_layout_surface_set_position, |
| 2988 | .surface_get_position = ivi_layout_surface_get_position, |
| 2989 | .surface_set_dimension = ivi_layout_surface_set_dimension, |
| 2990 | .surface_get_dimension = ivi_layout_surface_get_dimension, |
| 2991 | .surface_set_orientation = ivi_layout_surface_set_orientation, |
| 2992 | .surface_get_orientation = ivi_layout_surface_get_orientation, |
| 2993 | .surface_set_content_observer = ivi_layout_surface_set_content_observer, |
| 2994 | .surface_add_notification = ivi_layout_surface_add_notification, |
| 2995 | .surface_remove_notification = ivi_layout_surface_remove_notification, |
| 2996 | .surface_get_weston_surface = ivi_layout_surface_get_weston_surface, |
| 2997 | .surface_set_transition = ivi_layout_surface_set_transition, |
| 2998 | .surface_set_transition_duration = ivi_layout_surface_set_transition_duration, |
| 2999 | |
| 3000 | /** |
| 3001 | * layer controller interfaces |
| 3002 | */ |
| 3003 | .add_notification_create_layer = ivi_layout_add_notification_create_layer, |
| 3004 | .remove_notification_create_layer = ivi_layout_remove_notification_create_layer, |
| 3005 | .add_notification_remove_layer = ivi_layout_add_notification_remove_layer, |
| 3006 | .remove_notification_remove_layer = ivi_layout_remove_notification_remove_layer, |
| 3007 | .layer_create_with_dimension = ivi_layout_layer_create_with_dimension, |
| 3008 | .layer_remove = ivi_layout_layer_remove, |
| 3009 | .get_layers = ivi_layout_get_layers, |
| 3010 | .get_id_of_layer = ivi_layout_get_id_of_layer, |
| 3011 | .get_layer_from_id = ivi_layout_get_layer_from_id, |
| 3012 | .get_properties_of_layer = ivi_layout_get_properties_of_layer, |
| 3013 | .get_layers_under_surface = ivi_layout_get_layers_under_surface, |
| 3014 | .get_layers_on_screen = ivi_layout_get_layers_on_screen, |
| 3015 | .layer_set_visibility = ivi_layout_layer_set_visibility, |
| 3016 | .layer_get_visibility = ivi_layout_layer_get_visibility, |
| 3017 | .layer_set_opacity = ivi_layout_layer_set_opacity, |
| 3018 | .layer_get_opacity = ivi_layout_layer_get_opacity, |
| 3019 | .layer_set_source_rectangle = ivi_layout_layer_set_source_rectangle, |
| 3020 | .layer_set_destination_rectangle = ivi_layout_layer_set_destination_rectangle, |
| 3021 | .layer_set_position = ivi_layout_layer_set_position, |
| 3022 | .layer_get_position = ivi_layout_layer_get_position, |
| 3023 | .layer_set_dimension = ivi_layout_layer_set_dimension, |
| 3024 | .layer_get_dimension = ivi_layout_layer_get_dimension, |
| 3025 | .layer_set_orientation = ivi_layout_layer_set_orientation, |
| 3026 | .layer_get_orientation = ivi_layout_layer_get_orientation, |
| 3027 | .layer_add_surface = ivi_layout_layer_add_surface, |
| 3028 | .layer_remove_surface = ivi_layout_layer_remove_surface, |
| 3029 | .layer_set_render_order = ivi_layout_layer_set_render_order, |
| 3030 | .layer_add_notification = ivi_layout_layer_add_notification, |
| 3031 | .layer_remove_notification = ivi_layout_layer_remove_notification, |
| 3032 | .layer_set_transition = ivi_layout_layer_set_transition, |
| 3033 | |
| 3034 | /** |
Nobuhiko Tanibata | 4d0116e | 2015-06-22 15:31:57 +0900 | [diff] [blame] | 3035 | * screen controller interfaces part1 |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 3036 | */ |
| 3037 | .get_screen_from_id = ivi_layout_get_screen_from_id, |
| 3038 | .get_screen_resolution = ivi_layout_get_screen_resolution, |
| 3039 | .get_screens = ivi_layout_get_screens, |
| 3040 | .get_screens_under_layer = ivi_layout_get_screens_under_layer, |
| 3041 | .screen_add_layer = ivi_layout_screen_add_layer, |
| 3042 | .screen_set_render_order = ivi_layout_screen_set_render_order, |
| 3043 | .screen_get_output = ivi_layout_screen_get_output, |
| 3044 | |
| 3045 | /** |
| 3046 | * animation |
| 3047 | */ |
| 3048 | .transition_move_layer_cancel = ivi_layout_transition_move_layer_cancel, |
Nobuhiko Tanibata | c3fd624 | 2015-04-21 02:13:15 +0900 | [diff] [blame] | 3049 | .layer_set_fade_info = ivi_layout_layer_set_fade_info, |
| 3050 | |
| 3051 | /** |
| 3052 | * surface content dumping for debugging |
| 3053 | */ |
| 3054 | .surface_get_size = ivi_layout_surface_get_size, |
| 3055 | .surface_dump = ivi_layout_surface_dump, |
Nobuhiko Tanibata | 8205170 | 2015-06-22 15:31:26 +0900 | [diff] [blame] | 3056 | |
| 3057 | /** |
Nobuhiko Tanibata | db8efd1 | 2015-06-22 15:31:39 +0900 | [diff] [blame] | 3058 | * remove notification by callback on property changes of ivi_surface/layer |
Nobuhiko Tanibata | 8205170 | 2015-06-22 15:31:26 +0900 | [diff] [blame] | 3059 | */ |
Nobuhiko Tanibata | db8efd1 | 2015-06-22 15:31:39 +0900 | [diff] [blame] | 3060 | .surface_remove_notification_by_callback = ivi_layout_surface_remove_notification_by_callback, |
Nobuhiko Tanibata | 4d0116e | 2015-06-22 15:31:57 +0900 | [diff] [blame] | 3061 | .layer_remove_notification_by_callback = ivi_layout_layer_remove_notification_by_callback, |
| 3062 | |
| 3063 | /** |
| 3064 | * screen controller interfaces part2 |
| 3065 | */ |
| 3066 | .get_id_of_screen = ivi_layout_get_id_of_screen |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 3067 | }; |
| 3068 | |
| 3069 | int |
| 3070 | load_controller_modules(struct weston_compositor *compositor, const char *modules, |
| 3071 | int *argc, char *argv[]) |
| 3072 | { |
| 3073 | const char *p, *end; |
| 3074 | char buffer[256]; |
| 3075 | int (*controller_module_init)(struct weston_compositor *compositor, |
| 3076 | int *argc, char *argv[], |
| 3077 | const struct ivi_controller_interface *interface, |
| 3078 | size_t interface_version); |
| 3079 | |
| 3080 | if (modules == NULL) |
| 3081 | return 0; |
| 3082 | |
| 3083 | p = modules; |
| 3084 | while (*p) { |
| 3085 | end = strchrnul(p, ','); |
| 3086 | snprintf(buffer, sizeof buffer, "%.*s", (int)(end - p), p); |
| 3087 | |
| 3088 | controller_module_init = weston_load_module(buffer, "controller_module_init"); |
Pekka Paalanen | 97246c0 | 2015-03-26 15:47:29 +0200 | [diff] [blame] | 3089 | if (!controller_module_init) |
| 3090 | return -1; |
| 3091 | |
| 3092 | if (controller_module_init(compositor, argc, argv, |
| 3093 | &ivi_controller_interface, |
| 3094 | sizeof(struct ivi_controller_interface)) != 0) { |
| 3095 | weston_log("ivi-shell: Initialization of controller module fails"); |
| 3096 | return -1; |
Nobuhiko Tanibata | ee8e583 | 2014-12-15 13:25:39 +0900 | [diff] [blame] | 3097 | } |
| 3098 | |
| 3099 | p = end; |
| 3100 | while (*p == ',') |
| 3101 | p++; |
| 3102 | } |
| 3103 | |
| 3104 | return 0; |
| 3105 | } |