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