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