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