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