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