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