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