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