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