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