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