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