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