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