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