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