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