blob: 64e4ead8e0387efade9bfd5d35144256d33e7468 [file] [log] [blame]
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001/*
2 * Copyright (C) 2013 DENSO CORPORATION
3 *
Bryce Harringtonaf637c22015-06-11 12:55:55 -07004 * 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 Tanibata6f9df652014-11-27 13:22:00 +090011 *
Bryce Harringtonaf637c22015-06-11 12:55:55 -070012 * 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 Tanibata6f9df652014-11-27 13:22:00 +090024 */
25
26/**
27 * Implementation of ivi-layout library. The actual view on ivi_screen is
Bryce Harringtone6da35d2016-05-19 17:35:02 -070028 * not updated until ivi_layout_commit_changes is called. An overview from
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090029 * 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 Harringtone6da35d2016-05-19 17:35:02 -070033 * 1/ When an API for updating properties of ivi_surface/ivi_layer, it updates
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090034 * pending prop of ivi_surface/ivi_layer/ivi_screen which are structure to
35 * store properties.
Bryce Harringtone6da35d2016-05-19 17:35:02 -070036 * 2/ Before calling commitChanges, in case of calling an API to get a property,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090037 * 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 Harringtone6da35d2016-05-19 17:35:02 -070045 * 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 Tanibata6f9df652014-11-27 13:22:00 +090047 * called during transition animation, it cancels the transition and
48 * re-start transition to new properties from current properties of final
Bryce Harringtone6da35d2016-05-19 17:35:02 -070049 * frame just before the cancellation.
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090050 *
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 Tanibataee8e5832014-12-15 13:25:39 +090058#include "config.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090059
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090060#include <string.h>
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +000061#include <assert.h>
Jussi Kukkonen649bbce2016-07-19 14:16:27 +030062#include <stdint.h>
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090063
Pekka Paalanen58f98c92016-06-03 16:45:21 +030064#include "compositor/weston.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090065#include "compositor.h"
Pekka Paalanen1f821932016-03-15 16:57:51 +020066#include "ivi-shell.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090067#include "ivi-layout-export.h"
68#include "ivi-layout-private.h"
Pekka Paalanen32ca7912016-03-15 17:21:00 +020069#include "ivi-layout-shell.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090070
Jon Cruz867d50e2015-06-15 15:37:10 -070071#include "shared/helpers.h"
Jon Cruz4678bab2015-06-15 15:37:07 -070072#include "shared/os-compatibility.h"
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +090073
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +090074#define max(a, b) ((a) > (b) ? (a) : (b))
75
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090076struct ivi_layout;
77
78struct ivi_layout_screen {
Ucan, Emre (ADITG/SW1)7da38232016-07-01 09:34:50 +000079 struct wl_list link; /* ivi_layout::screen_list */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090080
81 struct ivi_layout *layout;
82 struct weston_output *output;
83
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090084 struct {
Ucan, Emre (ADITG/SW1)7da38232016-07-01 09:34:50 +000085 struct wl_list layer_list; /* ivi_layout_layer::pending.link */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090086 } pending;
87
88 struct {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +000089 int dirty;
Ucan, Emre (ADITG/SW1)7da38232016-07-01 09:34:50 +000090 struct wl_list layer_list; /* ivi_layout_layer::order.link */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090091 } order;
92};
93
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +090094struct ivi_rectangle
95{
96 int32_t x;
97 int32_t y;
98 int32_t width;
99 int32_t height;
100};
101
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900102static struct ivi_layout ivilayout = {0};
103
104struct ivi_layout *
105get_instance(void)
106{
107 return &ivilayout;
108}
109
110/**
Bryce Harringtone6da35d2016-05-19 17:35:02 -0700111 * Internal API to add/remove an ivi_layer to/from ivi_screen.
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900112 */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900113static struct ivi_layout_surface *
114get_surface(struct wl_list *surf_list, uint32_t id_surface)
115{
116 struct ivi_layout_surface *ivisurf;
117
118 wl_list_for_each(ivisurf, surf_list, link) {
119 if (ivisurf->id_surface == id_surface) {
120 return ivisurf;
121 }
122 }
123
124 return NULL;
125}
126
127static struct ivi_layout_layer *
128get_layer(struct wl_list *layer_list, uint32_t id_layer)
129{
130 struct ivi_layout_layer *ivilayer;
131
132 wl_list_for_each(ivilayer, layer_list, link) {
133 if (ivilayer->id_layer == id_layer) {
134 return ivilayer;
135 }
136 }
137
138 return NULL;
139}
140
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000141static bool
142ivi_view_is_rendered(struct ivi_layout_view *view)
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000143{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000144 return !wl_list_empty(&view->order_link);
145}
146
147static void
148ivi_view_destroy(struct ivi_layout_view *ivi_view)
149{
150 wl_list_remove(&ivi_view->transform.link);
151 wl_list_remove(&ivi_view->link);
152 wl_list_remove(&ivi_view->surf_link);
153 wl_list_remove(&ivi_view->pending_link);
154 wl_list_remove(&ivi_view->order_link);
155
156 weston_view_destroy(ivi_view->view);
157
158 free(ivi_view);
159}
160
161static struct ivi_layout_view*
162ivi_view_create(struct ivi_layout_layer *ivilayer,
163 struct ivi_layout_surface *ivisurf)
164{
165 struct ivi_layout_view *ivi_view;
166
167 ivi_view = calloc(1, sizeof *ivi_view);
168 if (ivi_view == NULL) {
169 weston_log("fails to allocate memory\n");
170 return NULL;
171 }
172
173 ivi_view->view = weston_view_create(ivisurf->surface);
174 if (ivi_view->view == NULL) {
175 weston_log("fails to allocate memory\n");
176 return NULL;
177 }
178
179 weston_matrix_init(&ivi_view->transform.matrix);
180 wl_list_init(&ivi_view->transform.link);
181
182 ivi_view->ivisurf = ivisurf;
183 ivi_view->on_layer = ivilayer;
184 wl_list_insert(&ivilayer->layout->view_list,
185 &ivi_view->link);
186 wl_list_insert(&ivisurf->view_list,
187 &ivi_view->surf_link);
188
189 wl_list_init(&ivi_view->pending_link);
190 wl_list_init(&ivi_view->order_link);
191
192 return ivi_view;
193}
194
195static struct ivi_layout_view *
196get_ivi_view(struct ivi_layout_layer *ivilayer,
197 struct ivi_layout_surface *ivisurf)
198{
199 struct ivi_layout_view *ivi_view;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000200
201 assert(ivisurf->surface != NULL);
202
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000203 wl_list_for_each(ivi_view, &ivisurf->view_list, surf_link) {
204 if (ivi_view->on_layer == ivilayer)
205 return ivi_view;
206 }
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000207
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000208 return NULL;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000209}
210
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +0000211static struct ivi_layout_screen *
212get_screen_from_output(struct weston_output *output)
213{
214 struct ivi_layout *layout = get_instance();
215 struct ivi_layout_screen *iviscrn = NULL;
216
217 wl_list_for_each(iviscrn, &layout->screen_list, link) {
218 if (iviscrn->output == output)
219 return iviscrn;
220 }
221
222 return NULL;
223}
224
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900225/**
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900226 * Called at destruction of wl_surface/ivi_surface
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900227 */
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900228void
229ivi_layout_surface_destroy(struct ivi_layout_surface *ivisurf)
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900230{
231 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000232 struct ivi_layout_view *ivi_view ,*next;
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900233
234 if (ivisurf == NULL) {
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900235 weston_log("%s: invalid argument\n", __func__);
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900236 return;
237 }
238
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900239 wl_list_remove(&ivisurf->link);
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900240
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000241 wl_list_for_each_safe(ivi_view, next, &ivisurf->view_list, surf_link) {
242 ivi_view_destroy(ivi_view);
243 }
244
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900245 wl_signal_emit(&layout->surface_notification.removed, ivisurf);
246
Mateusz Polroladada6e32016-03-09 09:13:26 +0000247 ivi_layout_remove_all_surface_transitions(ivisurf);
248
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900249 free(ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900250}
251
252/**
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900253 * Internal API to initialize ivi_screens found from output_list of weston_compositor.
254 * Called by ivi_layout_init_with_compositor.
255 */
256static void
257create_screen(struct weston_compositor *ec)
258{
259 struct ivi_layout *layout = get_instance();
260 struct ivi_layout_screen *iviscrn = NULL;
261 struct weston_output *output = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900262
263 wl_list_for_each(output, &ec->output_list, link) {
264 iviscrn = calloc(1, sizeof *iviscrn);
265 if (iviscrn == NULL) {
266 weston_log("fails to allocate memory\n");
267 continue;
268 }
269
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900270 iviscrn->layout = layout;
271
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900272 iviscrn->output = output;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900273
274 wl_list_init(&iviscrn->pending.layer_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900275
276 wl_list_init(&iviscrn->order.layer_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900277
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900278 wl_list_insert(&layout->screen_list, &iviscrn->link);
279 }
280}
281
282/**
283 * Internal APIs to initialize properties of ivi_surface/ivi_layer when they are created.
284 */
285static void
286init_layer_properties(struct ivi_layout_layer_properties *prop,
287 int32_t width, int32_t height)
288{
289 memset(prop, 0, sizeof *prop);
290 prop->opacity = wl_fixed_from_double(1.0);
291 prop->source_width = width;
292 prop->source_height = height;
293 prop->dest_width = width;
294 prop->dest_height = height;
295}
296
297static void
298init_surface_properties(struct ivi_layout_surface_properties *prop)
299{
300 memset(prop, 0, sizeof *prop);
301 prop->opacity = wl_fixed_from_double(1.0);
Nobuhiko Tanibatae259a7a2015-04-27 17:02:54 +0900302 /*
Bryce Harringtone6da35d2016-05-19 17:35:02 -0700303 * FIXME: this shall be fixed by ivi-layout-transition.
Nobuhiko Tanibatae259a7a2015-04-27 17:02:54 +0900304 */
305 prop->dest_width = 1;
306 prop->dest_height = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900307}
308
309/**
310 * Internal APIs to be called from ivi_layout_commit_changes.
311 */
312static void
313update_opacity(struct ivi_layout_layer *ivilayer,
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000314 struct ivi_layout_surface *ivisurf,
315 struct weston_view *view)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900316{
317 double layer_alpha = wl_fixed_to_double(ivilayer->prop.opacity);
318 double surf_alpha = wl_fixed_to_double(ivisurf->prop.opacity);
319
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000320 view->alpha = layer_alpha * surf_alpha;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900321}
322
323static void
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900324get_rotate_values(enum wl_output_transform orientation,
325 float *v_sin,
326 float *v_cos)
327{
328 switch (orientation) {
329 case WL_OUTPUT_TRANSFORM_90:
330 *v_sin = 1.0f;
331 *v_cos = 0.0f;
332 break;
333 case WL_OUTPUT_TRANSFORM_180:
334 *v_sin = 0.0f;
335 *v_cos = -1.0f;
336 break;
337 case WL_OUTPUT_TRANSFORM_270:
338 *v_sin = -1.0f;
339 *v_cos = 0.0f;
340 break;
341 case WL_OUTPUT_TRANSFORM_NORMAL:
342 default:
343 *v_sin = 0.0f;
344 *v_cos = 1.0f;
345 break;
346 }
347}
348
349static void
350get_scale(enum wl_output_transform orientation,
351 float dest_width,
352 float dest_height,
353 float source_width,
354 float source_height,
355 float *scale_x,
356 float *scale_y)
357{
358 switch (orientation) {
359 case WL_OUTPUT_TRANSFORM_90:
360 *scale_x = dest_width / source_height;
361 *scale_y = dest_height / source_width;
362 break;
363 case WL_OUTPUT_TRANSFORM_180:
364 *scale_x = dest_width / source_width;
365 *scale_y = dest_height / source_height;
366 break;
367 case WL_OUTPUT_TRANSFORM_270:
368 *scale_x = dest_width / source_height;
369 *scale_y = dest_height / source_width;
370 break;
371 case WL_OUTPUT_TRANSFORM_NORMAL:
372 default:
373 *scale_x = dest_width / source_width;
374 *scale_y = dest_height / source_height;
375 break;
376 }
377}
378
379static void
380calc_transformation_matrix(struct ivi_rectangle *source_rect,
381 struct ivi_rectangle *dest_rect,
382 enum wl_output_transform orientation,
383 struct weston_matrix *m)
384{
385 float source_center_x;
386 float source_center_y;
387 float vsin;
388 float vcos;
389 float scale_x;
390 float scale_y;
391 float translate_x;
392 float translate_y;
393
394 source_center_x = source_rect->x + source_rect->width * 0.5f;
395 source_center_y = source_rect->y + source_rect->height * 0.5f;
396 weston_matrix_translate(m, -source_center_x, -source_center_y, 0.0f);
397
398 get_rotate_values(orientation, &vsin, &vcos);
399 weston_matrix_rotate_xy(m, vcos, vsin);
400
401 get_scale(orientation,
402 dest_rect->width,
403 dest_rect->height,
404 source_rect->width,
405 source_rect->height,
406 &scale_x,
407 &scale_y);
408 weston_matrix_scale(m, scale_x, scale_y, 1.0f);
409
410 translate_x = dest_rect->width * 0.5f + dest_rect->x;
411 translate_y = dest_rect->height * 0.5f + dest_rect->y;
412 weston_matrix_translate(m, translate_x, translate_y, 0.0f);
413}
414
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900415/*
416 * This computes intersected rect_output from two ivi_rectangles
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900417 */
418static void
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900419ivi_rectangle_intersect(const struct ivi_rectangle *rect1,
420 const struct ivi_rectangle *rect2,
421 struct ivi_rectangle *rect_output)
422{
423 int32_t rect1_right = rect1->x + rect1->width;
424 int32_t rect1_bottom = rect1->y + rect1->height;
425 int32_t rect2_right = rect2->x + rect2->width;
426 int32_t rect2_bottom = rect2->y + rect2->height;
427
428 rect_output->x = max(rect1->x, rect2->x);
429 rect_output->y = max(rect1->y, rect2->y);
430 rect_output->width = rect1_right < rect2_right ?
431 rect1_right - rect_output->x :
432 rect2_right - rect_output->x;
433 rect_output->height = rect1_bottom < rect2_bottom ?
434 rect1_bottom - rect_output->y :
435 rect2_bottom - rect_output->y;
436
437 if (rect_output->width < 0 || rect_output->height < 0) {
438 rect_output->width = 0;
439 rect_output->height = 0;
440 }
441}
442
443/*
444 * Transform rect_input by the inverse of matrix, intersect with boundingbox,
445 * and store the result in rect_output.
446 * The boundingbox must be given in the same coordinate space as rect_output.
447 * Additionally, there are the following restrictions on the matrix:
448 * - no projective transformations
449 * - no skew
450 * - only multiples of 90-degree rotations supported
451 *
452 * In failure case of weston_matrix_invert, rect_output is set to boundingbox
453 * as a fail-safe with log.
454 */
455static void
456calc_inverse_matrix_transform(const struct weston_matrix *matrix,
457 const struct ivi_rectangle *rect_input,
458 const struct ivi_rectangle *boundingbox,
459 struct ivi_rectangle *rect_output)
460{
461 struct weston_matrix m;
462 struct weston_vector top_left;
463 struct weston_vector bottom_right;
464
465 assert(boundingbox != rect_output);
466
467 if (weston_matrix_invert(&m, matrix) < 0) {
468 weston_log("ivi-shell: calc_inverse_matrix_transform fails to invert a matrix.\n");
469 weston_log("ivi-shell: boundingbox is set to the rect_output.\n");
470 rect_output->x = boundingbox->x;
471 rect_output->y = boundingbox->y;
472 rect_output->width = boundingbox->width;
473 rect_output->height = boundingbox->height;
474 }
475
476 /* The vectors and matrices involved will always produce f[3] == 1.0. */
477 top_left.f[0] = rect_input->x;
478 top_left.f[1] = rect_input->y;
479 top_left.f[2] = 0.0f;
480 top_left.f[3] = 1.0f;
481
482 bottom_right.f[0] = rect_input->x + rect_input->width;
483 bottom_right.f[1] = rect_input->y + rect_input->height;
484 bottom_right.f[2] = 0.0f;
485 bottom_right.f[3] = 1.0f;
486
487 weston_matrix_transform(&m, &top_left);
488 weston_matrix_transform(&m, &bottom_right);
489
490 if (top_left.f[0] < bottom_right.f[0]) {
491 rect_output->x = top_left.f[0];
492 rect_output->width = bottom_right.f[0] - rect_output->x;
493 } else {
494 rect_output->x = bottom_right.f[0];
495 rect_output->width = top_left.f[0] - rect_output->x;
496 }
497
498 if (top_left.f[1] < bottom_right.f[1]) {
499 rect_output->y = top_left.f[1];
500 rect_output->height = bottom_right.f[1] - rect_output->y;
501 } else {
502 rect_output->y = bottom_right.f[1];
503 rect_output->height = top_left.f[1] - rect_output->y;
504 }
505
506 ivi_rectangle_intersect(rect_output, boundingbox, rect_output);
507}
508
509/**
510 * This computes the whole transformation matrix:m from surface-local
Yong Bakose0698712016-04-28 11:59:08 -0500511 * coordinates to multi-screen coordinates, which are global coordinates.
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900512 * It is assumed that weston_view::geometry.{x,y} are zero.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900513 *
Bryce Harringtone6da35d2016-05-19 17:35:02 -0700514 * Additionally, this computes the mask on surface-local coordinates as an
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900515 * ivi_rectangle. This can be set to weston_view_set_mask.
516 *
517 * The mask is computed by following steps
Yong Bakose0698712016-04-28 11:59:08 -0500518 * - destination rectangle of layer is transformed to multi-screen coordinates,
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900519 * global coordinates. This is done by adding weston_output.{x,y} in simple
520 * because there is no scaled and rotated transformation.
Yong Bakose0698712016-04-28 11:59:08 -0500521 * - destination rectangle of layer in multi-screen coordinates needs to be
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900522 * intersected inside of a screen the layer is assigned to. This is because
523 * overlapped region of weston surface in another screen shall not be
524 * displayed according to ivi use case.
525 * - destination rectangle of layer
Yong Bakose0698712016-04-28 11:59:08 -0500526 * - in multi-screen coordinates,
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900527 * - and intersected inside of an assigned screen,
Yong Bakose0698712016-04-28 11:59:08 -0500528 * is inversed to surface-local coordinates by inversed matrix:m.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900529 * - the area is intersected by intersected area between weston_surface and
530 * source rectangle of ivi_surface.
531 */
532static void
533calc_surface_to_global_matrix_and_mask_to_weston_surface(
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900534 struct ivi_layout_screen *iviscrn,
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900535 struct ivi_layout_layer *ivilayer,
536 struct ivi_layout_surface *ivisurf,
537 struct weston_matrix *m,
538 struct ivi_rectangle *result)
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900539{
540 const struct ivi_layout_surface_properties *sp = &ivisurf->prop;
541 const struct ivi_layout_layer_properties *lp = &ivilayer->prop;
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900542 struct weston_output *output = iviscrn->output;
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900543 struct ivi_rectangle weston_surface_rect = { 0,
544 0,
545 ivisurf->surface->width,
546 ivisurf->surface->height };
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900547 struct ivi_rectangle surface_source_rect = { sp->source_x,
548 sp->source_y,
549 sp->source_width,
550 sp->source_height };
551 struct ivi_rectangle surface_dest_rect = { sp->dest_x,
552 sp->dest_y,
553 sp->dest_width,
554 sp->dest_height };
555 struct ivi_rectangle layer_source_rect = { lp->source_x,
556 lp->source_y,
557 lp->source_width,
558 lp->source_height };
559 struct ivi_rectangle layer_dest_rect = { lp->dest_x,
560 lp->dest_y,
561 lp->dest_width,
562 lp->dest_height };
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900563 struct ivi_rectangle screen_dest_rect = { output->x,
564 output->y,
565 output->width,
566 output->height };
567 struct ivi_rectangle layer_dest_rect_in_global =
568 { lp->dest_x + output->x,
569 lp->dest_y + output->y,
570 lp->dest_width,
571 lp->dest_height };
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900572 struct ivi_rectangle surface_result;
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900573 struct ivi_rectangle layer_dest_rect_in_global_intersected;
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900574
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900575 /*
576 * the whole transformation matrix:m from surface-local
577 * coordinates to global coordinates, which is computed by
578 * two steps,
579 * - surface-local coordinates to layer-local coordinates
Yong Bakose0698712016-04-28 11:59:08 -0500580 * - layer-local coordinates to single screen-local coordinates
581 * - single screen-local coordinates to multi-screen coordinates,
582 * which are global coordinates.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900583 */
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900584 calc_transformation_matrix(&surface_source_rect,
585 &surface_dest_rect,
586 sp->orientation, m);
587
588 calc_transformation_matrix(&layer_source_rect,
589 &layer_dest_rect,
590 lp->orientation, m);
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900591
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900592 weston_matrix_translate(m, output->x, output->y, 0.0f);
593
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900594 /* this intersected ivi_rectangle would be used for masking
595 * weston_surface
596 */
597 ivi_rectangle_intersect(&surface_source_rect, &weston_surface_rect,
598 &surface_result);
599
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900600 /*
601 * destination rectangle of layer in multi screens coordinate
602 * is intersected to avoid displaying outside of an assigned screen.
603 */
604 ivi_rectangle_intersect(&layer_dest_rect_in_global, &screen_dest_rect,
605 &layer_dest_rect_in_global_intersected);
606
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900607 /* calc masking area of weston_surface from m */
608 calc_inverse_matrix_transform(m,
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900609 &layer_dest_rect_in_global_intersected,
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900610 &surface_result,
611 result);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900612}
613
614static void
Ucan, Emre (ADITG/SW1)1b92ba22017-01-30 13:36:05 +0000615update_prop(struct ivi_layout_view *ivi_view)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900616{
Ucan, Emre (ADITG/SW1)1b92ba22017-01-30 13:36:05 +0000617 struct ivi_layout_surface *ivisurf = ivi_view->ivisurf;
618 struct ivi_layout_layer *ivilayer = ivi_view->on_layer;
619 struct ivi_layout_screen *iviscrn = ivilayer->on_screen;
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900620 struct ivi_rectangle r;
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900621 bool can_calc = true;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900622
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900623 /*In case of no prop change, this just returns*/
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000624 if (!ivilayer->prop.event_mask && !ivisurf->prop.event_mask)
Nobuhiko Tanibata4c1dbf72015-07-15 13:55:50 +0900625 return;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900626
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000627 update_opacity(ivilayer, ivisurf, ivi_view->view);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900628
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900629 if (ivisurf->prop.source_width == 0 || ivisurf->prop.source_height == 0) {
630 weston_log("ivi-shell: source rectangle is not yet set by ivi_layout_surface_set_source_rectangle\n");
631 can_calc = false;
632 }
633
634 if (ivisurf->prop.dest_width == 0 || ivisurf->prop.dest_height == 0) {
635 weston_log("ivi-shell: destination rectangle is not yet set by ivi_layout_surface_set_destination_rectangle\n");
636 can_calc = false;
637 }
638
639 if (can_calc) {
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000640 wl_list_remove(&ivi_view->transform.link);
641 weston_matrix_init(&ivi_view->transform.matrix);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900642
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900643 calc_surface_to_global_matrix_and_mask_to_weston_surface(
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000644 iviscrn, ivilayer, ivisurf, &ivi_view->transform.matrix, &r);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900645
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000646 weston_view_set_mask(ivi_view->view, r.x, r.y, r.width, r.height);
647 wl_list_insert(&ivi_view->view->geometry.transformation_list,
648 &ivi_view->transform.link);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900649
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000650 weston_view_set_transform_parent(ivi_view->view, NULL);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900651 }
652
653 ivisurf->update_count++;
654
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000655 weston_view_geometry_dirty(ivi_view->view);
Nobuhiko Tanibata4c1dbf72015-07-15 13:55:50 +0900656
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000657 weston_surface_damage(ivisurf->surface);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900658}
659
660static void
661commit_changes(struct ivi_layout *layout)
662{
Ucan, Emre (ADITG/SW1)27799352017-01-30 13:36:07 +0000663 struct ivi_layout_screen *iviscrn = NULL;
664 struct ivi_layout_layer *ivilayer = NULL;
665 struct ivi_layout_surface *ivisurf = NULL;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000666 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900667
Ucan, Emre (ADITG/SW1)27799352017-01-30 13:36:07 +0000668 wl_list_for_each(ivi_view, &layout->view_list, link) {
669 ivisurf = ivi_view->ivisurf;
670 ivilayer = ivi_view->on_layer;
671 iviscrn = ivilayer->on_screen;
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900672
Ucan, Emre (ADITG/SW1)27799352017-01-30 13:36:07 +0000673 /*
674 * If the view is not on the currently rendered scenegraph,
675 * we do not need to update its properties.
676 */
677 if (wl_list_empty(&ivi_view->order_link) || !iviscrn)
678 continue;
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900679
Ucan, Emre (ADITG/SW1)27799352017-01-30 13:36:07 +0000680 /*
681 * If the view's layer or surface is invisible, we do not need
682 * to update its properties.
683 */
Ucan, Emre (ADITG/SW1)7fe0bb22017-02-07 12:55:59 +0000684 if (!ivilayer->prop.visibility || !ivisurf->prop.visibility) {
685 /*
686 * If ivilayer or ivisurf of ivi_view is made invisible
687 * in this commit_changes call, we have to damage
688 * the weston_view below this ivi_view. Otherwise content
689 * of this ivi_view will stay visible.
690 */
691 if ((ivilayer->prop.event_mask | ivisurf->prop.event_mask) &&
692 IVI_NOTIFICATION_VISIBILITY)
693 weston_view_damage_below(ivi_view->view);
694
Ucan, Emre (ADITG/SW1)27799352017-01-30 13:36:07 +0000695 continue;
Ucan, Emre (ADITG/SW1)7fe0bb22017-02-07 12:55:59 +0000696 }
Ucan, Emre (ADITG/SW1)27799352017-01-30 13:36:07 +0000697
698 update_prop(ivi_view);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900699 }
700}
701
702static void
703commit_surface_list(struct ivi_layout *layout)
704{
705 struct ivi_layout_surface *ivisurf = NULL;
706 int32_t dest_x = 0;
707 int32_t dest_y = 0;
708 int32_t dest_width = 0;
709 int32_t dest_height = 0;
710 int32_t configured = 0;
711
712 wl_list_for_each(ivisurf, &layout->surface_list, link) {
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300713 if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEFAULT) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900714 dest_x = ivisurf->prop.dest_x;
715 dest_y = ivisurf->prop.dest_y;
716 dest_width = ivisurf->prop.dest_width;
717 dest_height = ivisurf->prop.dest_height;
718
719 ivi_layout_transition_move_resize_view(ivisurf,
720 ivisurf->pending.prop.dest_x,
721 ivisurf->pending.prop.dest_y,
722 ivisurf->pending.prop.dest_width,
723 ivisurf->pending.prop.dest_height,
724 ivisurf->pending.prop.transition_duration);
725
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300726 if (ivisurf->pending.prop.visibility) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900727 ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration);
728 } else {
729 ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration);
730 }
731
732 ivisurf->prop = ivisurf->pending.prop;
733 ivisurf->prop.dest_x = dest_x;
734 ivisurf->prop.dest_y = dest_y;
735 ivisurf->prop.dest_width = dest_width;
736 ivisurf->prop.dest_height = dest_height;
737 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
738 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
739
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300740 } else if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEST_RECT_ONLY) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900741 dest_x = ivisurf->prop.dest_x;
742 dest_y = ivisurf->prop.dest_y;
743 dest_width = ivisurf->prop.dest_width;
744 dest_height = ivisurf->prop.dest_height;
745
746 ivi_layout_transition_move_resize_view(ivisurf,
747 ivisurf->pending.prop.dest_x,
748 ivisurf->pending.prop.dest_y,
749 ivisurf->pending.prop.dest_width,
750 ivisurf->pending.prop.dest_height,
751 ivisurf->pending.prop.transition_duration);
752
753 ivisurf->prop = ivisurf->pending.prop;
754 ivisurf->prop.dest_x = dest_x;
755 ivisurf->prop.dest_y = dest_y;
756 ivisurf->prop.dest_width = dest_width;
757 ivisurf->prop.dest_height = dest_height;
758
759 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
760 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
761
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300762 } else if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900763 configured = 0;
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300764 if (ivisurf->pending.prop.visibility) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900765 ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration);
766 } else {
767 ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration);
768 }
769
770 if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width ||
771 ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) {
772 configured = 1;
773 }
774
775 ivisurf->prop = ivisurf->pending.prop;
776 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
777 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
778
Pekka Paalanen1f821932016-03-15 16:57:51 +0200779 if (configured && !is_surface_transition(ivisurf)) {
Pekka Paalanen1f821932016-03-15 16:57:51 +0200780 shell_surface_send_configure(ivisurf->surface,
781 ivisurf->prop.dest_width,
782 ivisurf->prop.dest_height);
783 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900784 } else {
785 configured = 0;
786 if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width ||
787 ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) {
788 configured = 1;
789 }
790
791 ivisurf->prop = ivisurf->pending.prop;
792 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
793 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
794
Pekka Paalanen1f821932016-03-15 16:57:51 +0200795 if (configured && !is_surface_transition(ivisurf)) {
Pekka Paalanen1f821932016-03-15 16:57:51 +0200796 shell_surface_send_configure(ivisurf->surface,
797 ivisurf->prop.dest_width,
798 ivisurf->prop.dest_height);
799 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900800 }
801 }
802}
803
804static void
805commit_layer_list(struct ivi_layout *layout)
806{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000807 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900808 struct ivi_layout_layer *ivilayer = NULL;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000809 struct ivi_layout_view *next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900810
811 wl_list_for_each(ivilayer, &layout->layer_list, link) {
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300812 if (ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_MOVE) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900813 ivi_layout_transition_move_layer(ivilayer, ivilayer->pending.prop.dest_x, ivilayer->pending.prop.dest_y, ivilayer->pending.prop.transition_duration);
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300814 } else if (ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_FADE) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900815 ivi_layout_transition_fade_layer(ivilayer,ivilayer->pending.prop.is_fade_in,
816 ivilayer->pending.prop.start_alpha,ivilayer->pending.prop.end_alpha,
817 NULL, NULL,
818 ivilayer->pending.prop.transition_duration);
819 }
820 ivilayer->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
821
822 ivilayer->prop = ivilayer->pending.prop;
823
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +0000824 if (!ivilayer->order.dirty) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900825 continue;
826 }
827
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000828 wl_list_for_each_safe(ivi_view, next, &ivilayer->order.view_list,
829 order_link) {
830 wl_list_remove(&ivi_view->order_link);
831 wl_list_init(&ivi_view->order_link);
832 ivi_view->ivisurf->prop.event_mask |= IVI_NOTIFICATION_REMOVE;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900833 }
834
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000835 assert(wl_list_empty(&ivilayer->order.view_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900836
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000837 wl_list_for_each(ivi_view, &ivilayer->pending.view_list,
838 pending_link) {
839 wl_list_remove(&ivi_view->order_link);
840 wl_list_insert(&ivilayer->order.view_list, &ivi_view->order_link);
841 ivi_view->ivisurf->prop.event_mask |= IVI_NOTIFICATION_ADD;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900842 }
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +0000843
844 ivilayer->order.dirty = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900845 }
846}
847
848static void
849commit_screen_list(struct ivi_layout *layout)
850{
851 struct ivi_layout_screen *iviscrn = NULL;
852 struct ivi_layout_layer *ivilayer = NULL;
853 struct ivi_layout_layer *next = NULL;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000854 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900855
Nobuhiko Tanibatafbfa8f22015-11-25 23:36:57 +0900856 /* Clear view list of layout ivi_layer */
857 wl_list_init(&layout->layout_layer.view_list.link);
858
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900859 wl_list_for_each(iviscrn, &layout->screen_list, link) {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000860 if (iviscrn->order.dirty) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900861 wl_list_for_each_safe(ivilayer, next,
862 &iviscrn->order.layer_list, order.link) {
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +0000863 ivilayer->on_screen = NULL;
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000864 wl_list_remove(&ivilayer->order.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900865 wl_list_init(&ivilayer->order.link);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000866 ivilayer->prop.event_mask |= IVI_NOTIFICATION_REMOVE;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900867 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900868
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000869 assert(wl_list_empty(&iviscrn->order.layer_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900870
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900871 wl_list_for_each(ivilayer, &iviscrn->pending.layer_list,
872 pending.link) {
Nobuhiko Tanibata77b0ee12015-11-25 23:36:46 +0900873 /* FIXME: avoid to insert order.link to multiple screens */
874 wl_list_remove(&ivilayer->order.link);
875
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900876 wl_list_insert(&iviscrn->order.layer_list,
877 &ivilayer->order.link);
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +0000878 ivilayer->on_screen = iviscrn;
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000879 ivilayer->prop.event_mask |= IVI_NOTIFICATION_ADD;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900880 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900881
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000882 iviscrn->order.dirty = 0;
883 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900884
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900885 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
886 if (ivilayer->prop.visibility == false)
887 continue;
888
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000889 wl_list_for_each(ivi_view, &ivilayer->order.view_list, order_link) {
890 if (ivi_view->ivisurf->prop.visibility == false)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900891 continue;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000892
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900893 weston_layer_entry_insert(&layout->layout_layer.view_list,
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000894 &ivi_view->view->layer_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900895
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000896 ivi_view->view->output = iviscrn->output;
Armin Krezović50ff4bf2016-06-30 06:04:31 +0200897 ivi_view->ivisurf->surface->is_mapped = true;
898 ivi_view->view->is_mapped = true;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900899 }
900 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900901 }
902}
903
904static void
905commit_transition(struct ivi_layout* layout)
906{
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300907 if (wl_list_empty(&layout->pending_transition_list)) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900908 return;
909 }
910
911 wl_list_insert_list(&layout->transitions->transition_list,
912 &layout->pending_transition_list);
913
914 wl_list_init(&layout->pending_transition_list);
915
916 wl_event_source_timer_update(layout->transitions->event_source, 1);
917}
918
919static void
920send_surface_prop(struct ivi_layout_surface *ivisurf)
921{
922 wl_signal_emit(&ivisurf->property_changed, ivisurf);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000923 ivisurf->pending.prop.event_mask = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900924}
925
926static void
927send_layer_prop(struct ivi_layout_layer *ivilayer)
928{
929 wl_signal_emit(&ivilayer->property_changed, ivilayer);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000930 ivilayer->pending.prop.event_mask = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900931}
932
933static void
934send_prop(struct ivi_layout *layout)
935{
936 struct ivi_layout_layer *ivilayer = NULL;
937 struct ivi_layout_surface *ivisurf = NULL;
938
939 wl_list_for_each_reverse(ivilayer, &layout->layer_list, link) {
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000940 if (ivilayer->prop.event_mask)
Nobuhiko Tanibata6ce3ef82015-06-22 15:32:06 +0900941 send_layer_prop(ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900942 }
943
944 wl_list_for_each_reverse(ivisurf, &layout->surface_list, link) {
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000945 if (ivisurf->prop.event_mask)
Nobuhiko Tanibata6ce3ef82015-06-22 15:32:06 +0900946 send_surface_prop(ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900947 }
948}
949
950static void
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000951clear_view_pending_list(struct ivi_layout_layer *ivilayer)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900952{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000953 struct ivi_layout_view *view_link = NULL;
954 struct ivi_layout_view *view_next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900955
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000956 wl_list_for_each_safe(view_link, view_next,
957 &ivilayer->pending.view_list, pending_link) {
958 wl_list_remove(&view_link->pending_link);
959 wl_list_init(&view_link->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900960 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900961}
962
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900963/**
964 * Exported APIs of ivi-layout library are implemented from here.
965 * Brief of APIs is described in ivi-layout-export.h.
966 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900967static int32_t
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000968ivi_layout_add_listener_create_layer(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900969{
970 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900971
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000972 if (listener == NULL) {
973 weston_log("ivi_layout_add_listener_create_layer: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900974 return IVI_FAILED;
975 }
976
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000977 wl_signal_add(&layout->layer_notification.created, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900978
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000979 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900980}
981
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900982static int32_t
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000983ivi_layout_add_listener_remove_layer(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900984{
985 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900986
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000987 if (listener == NULL) {
988 weston_log("ivi_layout_add_listener_remove_layer: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900989 return IVI_FAILED;
990 }
991
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000992 wl_signal_add(&layout->layer_notification.removed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900993
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000994 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900995}
996
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900997static int32_t
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000998ivi_layout_add_listener_create_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900999{
1000 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001001
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00001002 if (listener == NULL) {
1003 weston_log("ivi_layout_add_listener_create_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001004 return IVI_FAILED;
1005 }
1006
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00001007 wl_signal_add(&layout->surface_notification.created, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001008
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00001009 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001010}
1011
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001012static int32_t
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001013ivi_layout_add_listener_remove_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001014{
1015 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001016
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001017 if (listener == NULL) {
1018 weston_log("ivi_layout_add_listener_remove_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001019 return IVI_FAILED;
1020 }
1021
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001022 wl_signal_add(&layout->surface_notification.removed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001023
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001024 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001025}
1026
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001027static int32_t
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001028ivi_layout_add_listener_configure_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001029{
1030 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001031
1032 if (listener == NULL) {
1033 weston_log("ivi_layout_add_listener_configure_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001034 return IVI_FAILED;
1035 }
1036
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001037 wl_signal_add(&layout->surface_notification.configure_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001038
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001039 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001040}
1041
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001042uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001043ivi_layout_get_id_of_surface(struct ivi_layout_surface *ivisurf)
1044{
1045 return ivisurf->id_surface;
1046}
1047
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001048static uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001049ivi_layout_get_id_of_layer(struct ivi_layout_layer *ivilayer)
1050{
1051 return ivilayer->id_layer;
1052}
1053
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001054static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001055ivi_layout_get_layer_from_id(uint32_t id_layer)
1056{
1057 struct ivi_layout *layout = get_instance();
1058 struct ivi_layout_layer *ivilayer = NULL;
1059
1060 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1061 if (ivilayer->id_layer == id_layer) {
1062 return ivilayer;
1063 }
1064 }
1065
1066 return NULL;
1067}
1068
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001069struct ivi_layout_surface *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001070ivi_layout_get_surface_from_id(uint32_t id_surface)
1071{
1072 struct ivi_layout *layout = get_instance();
1073 struct ivi_layout_surface *ivisurf = NULL;
1074
1075 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1076 if (ivisurf->id_surface == id_surface) {
1077 return ivisurf;
1078 }
1079 }
1080
1081 return NULL;
1082}
1083
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001084static int32_t
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001085ivi_layout_surface_add_listener(struct ivi_layout_surface *ivisurf,
1086 struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001087{
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001088 if (ivisurf == NULL || listener == NULL) {
1089 weston_log("ivi_layout_surface_add_listener: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001090 return IVI_FAILED;
1091 }
1092
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001093 wl_signal_add(&ivisurf->property_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001094
1095 return IVI_SUCCEEDED;
1096}
1097
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001098static const struct ivi_layout_layer_properties *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001099ivi_layout_get_properties_of_layer(struct ivi_layout_layer *ivilayer)
1100{
1101 if (ivilayer == NULL) {
1102 weston_log("ivi_layout_get_properties_of_layer: invalid argument\n");
1103 return NULL;
1104 }
1105
1106 return &ivilayer->prop;
1107}
1108
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001109static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001110ivi_layout_get_screens_under_layer(struct ivi_layout_layer *ivilayer,
1111 int32_t *pLength,
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001112 struct weston_output ***ppArray)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001113{
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001114 int32_t length = 0;
1115 int32_t n = 0;
1116
1117 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1118 weston_log("ivi_layout_get_screens_under_layer: invalid argument\n");
1119 return IVI_FAILED;
1120 }
1121
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +00001122 if (ivilayer->on_screen != NULL)
1123 length = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001124
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001125 if (length != 0) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001126 /* the Array must be free by module which called this function */
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001127 *ppArray = calloc(length, sizeof(struct weston_output *));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001128 if (*ppArray == NULL) {
1129 weston_log("fails to allocate memory\n");
1130 return IVI_FAILED;
1131 }
1132
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001133 (*ppArray)[n++] = ivilayer->on_screen->output;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001134 }
1135
1136 *pLength = length;
1137
1138 return IVI_SUCCEEDED;
1139}
1140
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001141static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001142ivi_layout_get_layers(int32_t *pLength, struct ivi_layout_layer ***ppArray)
1143{
1144 struct ivi_layout *layout = get_instance();
1145 struct ivi_layout_layer *ivilayer = NULL;
1146 int32_t length = 0;
1147 int32_t n = 0;
1148
1149 if (pLength == NULL || ppArray == NULL) {
1150 weston_log("ivi_layout_get_layers: invalid argument\n");
1151 return IVI_FAILED;
1152 }
1153
1154 length = wl_list_length(&layout->layer_list);
1155
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001156 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001157 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001158 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1159 if (*ppArray == NULL) {
1160 weston_log("fails to allocate memory\n");
1161 return IVI_FAILED;
1162 }
1163
1164 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1165 (*ppArray)[n++] = ivilayer;
1166 }
1167 }
1168
1169 *pLength = length;
1170
1171 return IVI_SUCCEEDED;
1172}
1173
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001174static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001175ivi_layout_get_layers_on_screen(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001176 int32_t *pLength,
1177 struct ivi_layout_layer ***ppArray)
1178{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001179 struct ivi_layout_screen *iviscrn = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001180 struct ivi_layout_layer *ivilayer = NULL;
1181 int32_t length = 0;
1182 int32_t n = 0;
1183
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001184 if (output == NULL || pLength == NULL || ppArray == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001185 weston_log("ivi_layout_get_layers_on_screen: invalid argument\n");
1186 return IVI_FAILED;
1187 }
1188
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001189 iviscrn = get_screen_from_output(output);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001190 length = wl_list_length(&iviscrn->order.layer_list);
1191
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001192 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001193 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001194 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1195 if (*ppArray == NULL) {
1196 weston_log("fails to allocate memory\n");
1197 return IVI_FAILED;
1198 }
1199
Nobuhiko Tanibatae2b82142015-06-22 15:30:19 +09001200 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001201 (*ppArray)[n++] = ivilayer;
1202 }
1203 }
1204
1205 *pLength = length;
1206
1207 return IVI_SUCCEEDED;
1208}
1209
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001210static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001211ivi_layout_get_layers_under_surface(struct ivi_layout_surface *ivisurf,
1212 int32_t *pLength,
1213 struct ivi_layout_layer ***ppArray)
1214{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001215 struct ivi_layout_view *ivi_view;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001216 int32_t length = 0;
1217 int32_t n = 0;
1218
1219 if (ivisurf == NULL || pLength == NULL || ppArray == NULL) {
1220 weston_log("ivi_layout_getLayers: invalid argument\n");
1221 return IVI_FAILED;
1222 }
1223
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001224 if (!wl_list_empty(&ivisurf->view_list)) {
1225 /* the Array must be free by module which called this function */
1226 length = wl_list_length(&ivisurf->view_list);
1227 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001228 if (*ppArray == NULL) {
1229 weston_log("fails to allocate memory\n");
1230 return IVI_FAILED;
1231 }
1232
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001233 wl_list_for_each_reverse(ivi_view, &ivisurf->view_list, surf_link) {
1234 if (ivi_view_is_rendered(ivi_view))
1235 (*ppArray)[n++] = ivi_view->on_layer;
1236 else
1237 length--;
1238 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001239 }
1240
1241 *pLength = length;
1242
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001243 if (!length) {
1244 free(*ppArray);
1245 *ppArray = NULL;
1246 }
1247
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001248 return IVI_SUCCEEDED;
1249}
1250
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001251static
1252int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001253ivi_layout_get_surfaces(int32_t *pLength, struct ivi_layout_surface ***ppArray)
1254{
1255 struct ivi_layout *layout = get_instance();
1256 struct ivi_layout_surface *ivisurf = NULL;
1257 int32_t length = 0;
1258 int32_t n = 0;
1259
1260 if (pLength == NULL || ppArray == NULL) {
1261 weston_log("ivi_layout_get_surfaces: invalid argument\n");
1262 return IVI_FAILED;
1263 }
1264
1265 length = wl_list_length(&layout->surface_list);
1266
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001267 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001268 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001269 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1270 if (*ppArray == NULL) {
1271 weston_log("fails to allocate memory\n");
1272 return IVI_FAILED;
1273 }
1274
1275 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1276 (*ppArray)[n++] = ivisurf;
1277 }
1278 }
1279
1280 *pLength = length;
1281
1282 return IVI_SUCCEEDED;
1283}
1284
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001285static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001286ivi_layout_get_surfaces_on_layer(struct ivi_layout_layer *ivilayer,
1287 int32_t *pLength,
1288 struct ivi_layout_surface ***ppArray)
1289{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001290 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001291 int32_t length = 0;
1292 int32_t n = 0;
1293
1294 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1295 weston_log("ivi_layout_getSurfaceIDsOnLayer: invalid argument\n");
1296 return IVI_FAILED;
1297 }
1298
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001299 length = wl_list_length(&ivilayer->order.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001300
1301 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001302 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001303 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1304 if (*ppArray == NULL) {
1305 weston_log("fails to allocate memory\n");
1306 return IVI_FAILED;
1307 }
1308
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001309 wl_list_for_each(ivi_view, &ivilayer->order.view_list, order_link) {
1310 (*ppArray)[n++] = ivi_view->ivisurf;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001311 }
1312 }
1313
1314 *pLength = length;
1315
1316 return IVI_SUCCEEDED;
1317}
1318
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001319static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001320ivi_layout_layer_create_with_dimension(uint32_t id_layer,
1321 int32_t width, int32_t height)
1322{
1323 struct ivi_layout *layout = get_instance();
1324 struct ivi_layout_layer *ivilayer = NULL;
1325
1326 ivilayer = get_layer(&layout->layer_list, id_layer);
1327 if (ivilayer != NULL) {
1328 weston_log("id_layer is already created\n");
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001329 ++ivilayer->ref_count;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001330 return ivilayer;
1331 }
1332
1333 ivilayer = calloc(1, sizeof *ivilayer);
1334 if (ivilayer == NULL) {
1335 weston_log("fails to allocate memory\n");
1336 return NULL;
1337 }
1338
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001339 ivilayer->ref_count = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001340 wl_signal_init(&ivilayer->property_changed);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001341 ivilayer->layout = layout;
1342 ivilayer->id_layer = id_layer;
1343
1344 init_layer_properties(&ivilayer->prop, width, height);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001345
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001346 wl_list_init(&ivilayer->pending.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001347 wl_list_init(&ivilayer->pending.link);
1348 ivilayer->pending.prop = ivilayer->prop;
1349
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001350 wl_list_init(&ivilayer->order.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001351 wl_list_init(&ivilayer->order.link);
1352
1353 wl_list_insert(&layout->layer_list, &ivilayer->link);
1354
1355 wl_signal_emit(&layout->layer_notification.created, ivilayer);
1356
1357 return ivilayer;
1358}
1359
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001360static void
Nobuhiko Tanibata3aa8aed2015-06-22 15:32:23 +09001361ivi_layout_layer_destroy(struct ivi_layout_layer *ivilayer)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001362{
1363 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001364 struct ivi_layout_view *ivi_view, *next;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001365
1366 if (ivilayer == NULL) {
Ucan, Emre (ADITG/SW1)66602522017-01-17 12:35:20 +00001367 weston_log("ivi_layout_layer_destroy: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001368 return;
1369 }
1370
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001371 if (--ivilayer->ref_count > 0)
1372 return;
1373
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001374 /*Destroy all ivi_views*/
1375 wl_list_for_each_safe(ivi_view, next, &layout->view_list, link) {
1376 if (ivi_view->on_layer == ivilayer)
1377 ivi_view_destroy(ivi_view);
1378 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001379
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001380 wl_signal_emit(&layout->layer_notification.removed, ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001381
Ucan, Emre (ADITG/SW1)cf34dc22015-08-20 14:13:33 +00001382 wl_list_remove(&ivilayer->pending.link);
1383 wl_list_remove(&ivilayer->order.link);
1384 wl_list_remove(&ivilayer->link);
1385
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001386 free(ivilayer);
1387}
1388
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001389int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001390ivi_layout_layer_set_visibility(struct ivi_layout_layer *ivilayer,
1391 bool newVisibility)
1392{
1393 struct ivi_layout_layer_properties *prop = NULL;
1394
1395 if (ivilayer == NULL) {
1396 weston_log("ivi_layout_layer_set_visibility: invalid argument\n");
1397 return IVI_FAILED;
1398 }
1399
1400 prop = &ivilayer->pending.prop;
1401 prop->visibility = newVisibility;
1402
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001403 if (ivilayer->prop.visibility != newVisibility)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001404 prop->event_mask |= IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001405 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001406 prop->event_mask &= ~IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001407
1408 return IVI_SUCCEEDED;
1409}
1410
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001411int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001412ivi_layout_layer_set_opacity(struct ivi_layout_layer *ivilayer,
1413 wl_fixed_t opacity)
1414{
1415 struct ivi_layout_layer_properties *prop = NULL;
1416
Nobuhiko Tanibata7bbacc62015-06-22 15:30:09 +09001417 if (ivilayer == NULL ||
1418 opacity < wl_fixed_from_double(0.0) ||
1419 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001420 weston_log("ivi_layout_layer_set_opacity: invalid argument\n");
1421 return IVI_FAILED;
1422 }
1423
1424 prop = &ivilayer->pending.prop;
1425 prop->opacity = opacity;
1426
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001427 if (ivilayer->prop.opacity != opacity)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001428 prop->event_mask |= IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001429 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001430 prop->event_mask &= ~IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001431
1432 return IVI_SUCCEEDED;
1433}
1434
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001435static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001436ivi_layout_layer_set_source_rectangle(struct ivi_layout_layer *ivilayer,
1437 int32_t x, int32_t y,
1438 int32_t width, int32_t height)
1439{
1440 struct ivi_layout_layer_properties *prop = NULL;
1441
1442 if (ivilayer == NULL) {
1443 weston_log("ivi_layout_layer_set_source_rectangle: invalid argument\n");
1444 return IVI_FAILED;
1445 }
1446
1447 prop = &ivilayer->pending.prop;
1448 prop->source_x = x;
1449 prop->source_y = y;
1450 prop->source_width = width;
1451 prop->source_height = height;
1452
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001453 if (ivilayer->prop.source_x != x || ivilayer->prop.source_y != y ||
1454 ivilayer->prop.source_width != width ||
1455 ivilayer->prop.source_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001456 prop->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001457 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001458 prop->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001459
1460 return IVI_SUCCEEDED;
1461}
1462
Ucan, Emre \(ADITG/SW1\)e62bfd82016-03-04 12:50:46 +00001463int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001464ivi_layout_layer_set_destination_rectangle(struct ivi_layout_layer *ivilayer,
1465 int32_t x, int32_t y,
1466 int32_t width, int32_t height)
1467{
1468 struct ivi_layout_layer_properties *prop = NULL;
1469
1470 if (ivilayer == NULL) {
1471 weston_log("ivi_layout_layer_set_destination_rectangle: invalid argument\n");
1472 return IVI_FAILED;
1473 }
1474
1475 prop = &ivilayer->pending.prop;
1476 prop->dest_x = x;
1477 prop->dest_y = y;
1478 prop->dest_width = width;
1479 prop->dest_height = height;
1480
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001481 if (ivilayer->prop.dest_x != x || ivilayer->prop.dest_y != y ||
1482 ivilayer->prop.dest_width != width ||
1483 ivilayer->prop.dest_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001484 prop->event_mask |= IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001485 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001486 prop->event_mask &= ~IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001487
1488 return IVI_SUCCEEDED;
1489}
1490
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001491static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001492ivi_layout_layer_set_orientation(struct ivi_layout_layer *ivilayer,
1493 enum wl_output_transform orientation)
1494{
1495 struct ivi_layout_layer_properties *prop = NULL;
1496
1497 if (ivilayer == NULL) {
1498 weston_log("ivi_layout_layer_set_orientation: invalid argument\n");
1499 return IVI_FAILED;
1500 }
1501
1502 prop = &ivilayer->pending.prop;
1503 prop->orientation = orientation;
1504
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001505 if (ivilayer->prop.orientation != orientation)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001506 prop->event_mask |= IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001507 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001508 prop->event_mask &= ~IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001509
1510 return IVI_SUCCEEDED;
1511}
1512
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001513int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001514ivi_layout_layer_set_render_order(struct ivi_layout_layer *ivilayer,
1515 struct ivi_layout_surface **pSurface,
1516 int32_t number)
1517{
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001518 int32_t i = 0;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001519 struct ivi_layout_view * ivi_view;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001520
1521 if (ivilayer == NULL) {
1522 weston_log("ivi_layout_layer_set_render_order: invalid argument\n");
1523 return IVI_FAILED;
1524 }
1525
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001526 clear_view_pending_list(ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001527
1528 for (i = 0; i < number; i++) {
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001529 ivi_view = get_ivi_view(ivilayer, pSurface[i]);
1530 if (!ivi_view)
1531 ivi_view = ivi_view_create(ivilayer, pSurface[i]);
1532
1533 assert(ivi_view != NULL);
1534
1535 wl_list_remove(&ivi_view->pending_link);
1536 wl_list_insert(&ivilayer->pending.view_list, &ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001537 }
1538
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +00001539 ivilayer->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001540
1541 return IVI_SUCCEEDED;
1542}
1543
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001544int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001545ivi_layout_surface_set_visibility(struct ivi_layout_surface *ivisurf,
1546 bool newVisibility)
1547{
1548 struct ivi_layout_surface_properties *prop = NULL;
1549
1550 if (ivisurf == NULL) {
1551 weston_log("ivi_layout_surface_set_visibility: invalid argument\n");
1552 return IVI_FAILED;
1553 }
1554
1555 prop = &ivisurf->pending.prop;
1556 prop->visibility = newVisibility;
1557
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001558 if (ivisurf->prop.visibility != newVisibility)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001559 prop->event_mask |= IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001560 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001561 prop->event_mask &= ~IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001562
1563 return IVI_SUCCEEDED;
1564}
1565
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001566int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001567ivi_layout_surface_set_opacity(struct ivi_layout_surface *ivisurf,
1568 wl_fixed_t opacity)
1569{
1570 struct ivi_layout_surface_properties *prop = NULL;
1571
Nobuhiko Tanibataa86226c2015-06-22 15:29:20 +09001572 if (ivisurf == NULL ||
1573 opacity < wl_fixed_from_double(0.0) ||
1574 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001575 weston_log("ivi_layout_surface_set_opacity: invalid argument\n");
1576 return IVI_FAILED;
1577 }
1578
1579 prop = &ivisurf->pending.prop;
1580 prop->opacity = opacity;
1581
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001582 if (ivisurf->prop.opacity != opacity)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001583 prop->event_mask |= IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001584 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001585 prop->event_mask &= ~IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001586
1587 return IVI_SUCCEEDED;
1588}
1589
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001590int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001591ivi_layout_surface_set_destination_rectangle(struct ivi_layout_surface *ivisurf,
1592 int32_t x, int32_t y,
1593 int32_t width, int32_t height)
1594{
1595 struct ivi_layout_surface_properties *prop = NULL;
1596
1597 if (ivisurf == NULL) {
1598 weston_log("ivi_layout_surface_set_destination_rectangle: invalid argument\n");
1599 return IVI_FAILED;
1600 }
1601
1602 prop = &ivisurf->pending.prop;
1603 prop->start_x = prop->dest_x;
1604 prop->start_y = prop->dest_y;
1605 prop->dest_x = x;
1606 prop->dest_y = y;
1607 prop->start_width = prop->dest_width;
1608 prop->start_height = prop->dest_height;
1609 prop->dest_width = width;
1610 prop->dest_height = height;
1611
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001612 if (ivisurf->prop.dest_x != x || ivisurf->prop.dest_y != y ||
1613 ivisurf->prop.dest_width != width ||
1614 ivisurf->prop.dest_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001615 prop->event_mask |= IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001616 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001617 prop->event_mask &= ~IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001618
1619 return IVI_SUCCEEDED;
1620}
1621
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001622static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001623ivi_layout_surface_set_orientation(struct ivi_layout_surface *ivisurf,
1624 enum wl_output_transform orientation)
1625{
1626 struct ivi_layout_surface_properties *prop = NULL;
1627
1628 if (ivisurf == NULL) {
1629 weston_log("ivi_layout_surface_set_orientation: invalid argument\n");
1630 return IVI_FAILED;
1631 }
1632
1633 prop = &ivisurf->pending.prop;
1634 prop->orientation = orientation;
1635
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001636 if (ivisurf->prop.orientation != orientation)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001637 prop->event_mask |= IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001638 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001639 prop->event_mask &= ~IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001640
1641 return IVI_SUCCEEDED;
1642}
1643
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001644static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001645ivi_layout_screen_add_layer(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001646 struct ivi_layout_layer *addlayer)
1647{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001648 struct ivi_layout_screen *iviscrn;
1649
1650 if (output == NULL || addlayer == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001651 weston_log("ivi_layout_screen_add_layer: invalid argument\n");
1652 return IVI_FAILED;
1653 }
1654
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001655 iviscrn = get_screen_from_output(output);
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001656
Ucan, Emre (ADITG/SW1)f46306f2016-03-16 13:37:07 +00001657 wl_list_remove(&addlayer->pending.link);
1658 wl_list_insert(&iviscrn->pending.layer_list, &addlayer->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001659
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001660 iviscrn->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001661
1662 return IVI_SUCCEEDED;
1663}
1664
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001665static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001666ivi_layout_screen_set_render_order(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001667 struct ivi_layout_layer **pLayer,
1668 const int32_t number)
1669{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001670 struct ivi_layout_screen *iviscrn;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001671 struct ivi_layout_layer *ivilayer = NULL;
1672 struct ivi_layout_layer *next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001673 int32_t i = 0;
1674
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001675 if (output == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001676 weston_log("ivi_layout_screen_set_render_order: invalid argument\n");
1677 return IVI_FAILED;
1678 }
1679
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001680 iviscrn = get_screen_from_output(output);
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001681
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001682 wl_list_for_each_safe(ivilayer, next,
1683 &iviscrn->pending.layer_list, pending.link) {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001684 wl_list_remove(&ivilayer->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001685 wl_list_init(&ivilayer->pending.link);
1686 }
1687
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001688 assert(wl_list_empty(&iviscrn->pending.layer_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001689
1690 for (i = 0; i < number; i++) {
Ucan, Emre (ADITG/SW1)4e221f02016-03-16 13:37:08 +00001691 wl_list_remove(&pLayer[i]->pending.link);
1692 wl_list_insert(&iviscrn->pending.layer_list,
1693 &pLayer[i]->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001694 }
1695
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001696 iviscrn->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001697
1698 return IVI_SUCCEEDED;
1699}
1700
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001701/**
1702 * This function is used by the additional ivi-module because of dumping ivi_surface sceenshot.
1703 * The ivi-module, e.g. ivi-controller.so, is in wayland-ivi-extension of Genivi's Layer Management.
1704 * This function is used to get the result of drawing by clients.
1705 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001706static struct weston_surface *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001707ivi_layout_surface_get_weston_surface(struct ivi_layout_surface *ivisurf)
1708{
1709 return ivisurf != NULL ? ivisurf->surface : NULL;
1710}
1711
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001712static int32_t
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09001713ivi_layout_surface_get_size(struct ivi_layout_surface *ivisurf,
1714 int32_t *width, int32_t *height,
1715 int32_t *stride)
1716{
1717 int32_t w;
1718 int32_t h;
1719 const size_t bytespp = 4; /* PIXMAN_a8b8g8r8 */
1720
1721 if (ivisurf == NULL || ivisurf->surface == NULL) {
1722 weston_log("%s: invalid argument\n", __func__);
1723 return IVI_FAILED;
1724 }
1725
1726 weston_surface_get_content_size(ivisurf->surface, &w, &h);
1727
1728 if (width != NULL)
1729 *width = w;
1730
1731 if (height != NULL)
1732 *height = h;
1733
1734 if (stride != NULL)
1735 *stride = w * bytespp;
1736
1737 return IVI_SUCCEEDED;
1738}
1739
1740static int32_t
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001741ivi_layout_layer_add_listener(struct ivi_layout_layer *ivilayer,
1742 struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001743{
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001744 if (ivilayer == NULL || listener == NULL) {
1745 weston_log("ivi_layout_layer_add_listener: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001746 return IVI_FAILED;
1747 }
1748
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001749 wl_signal_add(&ivilayer->property_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001750
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001751 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001752}
1753
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001754static const struct ivi_layout_surface_properties *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001755ivi_layout_get_properties_of_surface(struct ivi_layout_surface *ivisurf)
1756{
1757 if (ivisurf == NULL) {
1758 weston_log("ivi_layout_get_properties_of_surface: invalid argument\n");
1759 return NULL;
1760 }
1761
1762 return &ivisurf->prop;
1763}
1764
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001765static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001766ivi_layout_layer_add_surface(struct ivi_layout_layer *ivilayer,
1767 struct ivi_layout_surface *addsurf)
1768{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001769 struct ivi_layout_view *ivi_view;
1770
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001771 if (ivilayer == NULL || addsurf == NULL) {
1772 weston_log("ivi_layout_layer_add_surface: invalid argument\n");
1773 return IVI_FAILED;
1774 }
1775
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001776 ivi_view = get_ivi_view(ivilayer, addsurf);
1777 if (!ivi_view)
1778 ivi_view = ivi_view_create(ivilayer, addsurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001779
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001780 wl_list_remove(&ivi_view->pending_link);
1781 wl_list_insert(&ivilayer->pending.view_list, &ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001782
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +00001783 ivilayer->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001784
1785 return IVI_SUCCEEDED;
1786}
1787
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001788static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001789ivi_layout_layer_remove_surface(struct ivi_layout_layer *ivilayer,
1790 struct ivi_layout_surface *remsurf)
1791{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001792 struct ivi_layout_view *ivi_view;
1793
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001794 if (ivilayer == NULL || remsurf == NULL) {
1795 weston_log("ivi_layout_layer_remove_surface: invalid argument\n");
1796 return;
1797 }
1798
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001799 ivi_view = get_ivi_view(ivilayer, remsurf);
1800 if (ivi_view) {
1801 wl_list_remove(&ivi_view->pending_link);
1802 wl_list_init(&ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001803
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001804 ivilayer->order.dirty = 1;
1805 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001806}
1807
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001808static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001809ivi_layout_surface_set_source_rectangle(struct ivi_layout_surface *ivisurf,
1810 int32_t x, int32_t y,
1811 int32_t width, int32_t height)
1812{
1813 struct ivi_layout_surface_properties *prop = NULL;
1814
1815 if (ivisurf == NULL) {
1816 weston_log("ivi_layout_surface_set_source_rectangle: invalid argument\n");
1817 return IVI_FAILED;
1818 }
1819
1820 prop = &ivisurf->pending.prop;
1821 prop->source_x = x;
1822 prop->source_y = y;
1823 prop->source_width = width;
1824 prop->source_height = height;
1825
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001826 if (ivisurf->prop.source_x != x || ivisurf->prop.source_y != y ||
1827 ivisurf->prop.source_width != width ||
1828 ivisurf->prop.source_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001829 prop->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001830 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001831 prop->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001832
1833 return IVI_SUCCEEDED;
1834}
1835
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001836int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001837ivi_layout_commit_changes(void)
1838{
1839 struct ivi_layout *layout = get_instance();
1840
1841 commit_surface_list(layout);
1842 commit_layer_list(layout);
1843 commit_screen_list(layout);
1844
1845 commit_transition(layout);
1846
1847 commit_changes(layout);
1848 send_prop(layout);
1849 weston_compositor_schedule_repaint(layout->compositor);
1850
1851 return IVI_SUCCEEDED;
1852}
1853
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001854static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001855ivi_layout_layer_set_transition(struct ivi_layout_layer *ivilayer,
1856 enum ivi_layout_transition_type type,
1857 uint32_t duration)
1858{
1859 if (ivilayer == NULL) {
1860 weston_log("%s: invalid argument\n", __func__);
1861 return -1;
1862 }
1863
1864 ivilayer->pending.prop.transition_type = type;
1865 ivilayer->pending.prop.transition_duration = duration;
1866
1867 return 0;
1868}
1869
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001870static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001871ivi_layout_layer_set_fade_info(struct ivi_layout_layer* ivilayer,
1872 uint32_t is_fade_in,
1873 double start_alpha, double end_alpha)
1874{
1875 if (ivilayer == NULL) {
1876 weston_log("%s: invalid argument\n", __func__);
1877 return -1;
1878 }
1879
1880 ivilayer->pending.prop.is_fade_in = is_fade_in;
1881 ivilayer->pending.prop.start_alpha = start_alpha;
1882 ivilayer->pending.prop.end_alpha = end_alpha;
1883
1884 return 0;
1885}
1886
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001887static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001888ivi_layout_surface_set_transition_duration(struct ivi_layout_surface *ivisurf,
1889 uint32_t duration)
1890{
1891 struct ivi_layout_surface_properties *prop;
1892
1893 if (ivisurf == NULL) {
1894 weston_log("%s: invalid argument\n", __func__);
1895 return -1;
1896 }
1897
1898 prop = &ivisurf->pending.prop;
1899 prop->transition_duration = duration*10;
1900 return 0;
1901}
1902
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001903static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001904ivi_layout_surface_set_transition(struct ivi_layout_surface *ivisurf,
1905 enum ivi_layout_transition_type type,
1906 uint32_t duration)
1907{
1908 struct ivi_layout_surface_properties *prop;
1909
1910 if (ivisurf == NULL) {
1911 weston_log("%s: invalid argument\n", __func__);
1912 return -1;
1913 }
1914
1915 prop = &ivisurf->pending.prop;
1916 prop->transition_type = type;
1917 prop->transition_duration = duration;
1918 return 0;
1919}
1920
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09001921static int32_t
1922ivi_layout_surface_dump(struct weston_surface *surface,
1923 void *target, size_t size,int32_t x, int32_t y,
1924 int32_t width, int32_t height)
1925{
1926 int result = 0;
1927
1928 if (surface == NULL) {
1929 weston_log("%s: invalid argument\n", __func__);
1930 return IVI_FAILED;
1931 }
1932
1933 result = weston_surface_copy_content(
1934 surface, target, size,
1935 x, y, width, height);
1936
1937 return result == 0 ? IVI_SUCCEEDED : IVI_FAILED;
1938}
1939
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001940/**
1941 * methods of interaction between ivi-shell with ivi-layout
1942 */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001943
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001944void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001945ivi_layout_surface_configure(struct ivi_layout_surface *ivisurf,
1946 int32_t width, int32_t height)
1947{
1948 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001949
Nobuhiko Tanibatae6cc9972015-04-27 16:54:01 +09001950 /* emit callback which is set by ivi-layout api user */
1951 wl_signal_emit(&layout->surface_notification.configure_changed,
1952 ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001953}
1954
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001955struct ivi_layout_surface*
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001956ivi_layout_surface_create(struct weston_surface *wl_surface,
1957 uint32_t id_surface)
1958{
1959 struct ivi_layout *layout = get_instance();
1960 struct ivi_layout_surface *ivisurf = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001961
1962 if (wl_surface == NULL) {
1963 weston_log("ivi_layout_surface_create: invalid argument\n");
1964 return NULL;
1965 }
1966
1967 ivisurf = get_surface(&layout->surface_list, id_surface);
1968 if (ivisurf != NULL) {
1969 if (ivisurf->surface != NULL) {
1970 weston_log("id_surface(%d) is already created\n", id_surface);
1971 return NULL;
1972 }
1973 }
1974
1975 ivisurf = calloc(1, sizeof *ivisurf);
1976 if (ivisurf == NULL) {
1977 weston_log("fails to allocate memory\n");
1978 return NULL;
1979 }
1980
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001981 wl_signal_init(&ivisurf->property_changed);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001982 ivisurf->id_surface = id_surface;
1983 ivisurf->layout = layout;
1984
1985 ivisurf->surface = wl_surface;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001986
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001987 ivisurf->surface->width_from_buffer = 0;
1988 ivisurf->surface->height_from_buffer = 0;
1989
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001990 init_surface_properties(&ivisurf->prop);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001991
1992 ivisurf->pending.prop = ivisurf->prop;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001993
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001994 wl_list_init(&ivisurf->view_list);
1995
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001996 wl_list_insert(&layout->surface_list, &ivisurf->link);
1997
1998 wl_signal_emit(&layout->surface_notification.created, ivisurf);
1999
2000 return ivisurf;
2001}
2002
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002003void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002004ivi_layout_init_with_compositor(struct weston_compositor *ec)
2005{
2006 struct ivi_layout *layout = get_instance();
2007
2008 layout->compositor = ec;
2009
2010 wl_list_init(&layout->surface_list);
2011 wl_list_init(&layout->layer_list);
2012 wl_list_init(&layout->screen_list);
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00002013 wl_list_init(&layout->view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002014
2015 wl_signal_init(&layout->layer_notification.created);
2016 wl_signal_init(&layout->layer_notification.removed);
2017
2018 wl_signal_init(&layout->surface_notification.created);
2019 wl_signal_init(&layout->surface_notification.removed);
2020 wl_signal_init(&layout->surface_notification.configure_changed);
2021
2022 /* Add layout_layer at the last of weston_compositor.layer_list */
Quentin Glidic82681572016-12-17 13:40:51 +01002023 weston_layer_init(&layout->layout_layer, ec);
2024 weston_layer_set_position(&layout->layout_layer,
2025 WESTON_LAYER_POSITION_NORMAL);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002026
2027 create_screen(ec);
2028
2029 layout->transitions = ivi_layout_transition_set_create(ec);
2030 wl_list_init(&layout->pending_transition_list);
2031}
2032
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002033static struct ivi_layout_interface ivi_layout_interface = {
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002034 /**
2035 * commit all changes
2036 */
2037 .commit_changes = ivi_layout_commit_changes,
2038
2039 /**
2040 * surface controller interfaces
2041 */
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00002042 .add_listener_create_surface = ivi_layout_add_listener_create_surface,
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00002043 .add_listener_remove_surface = ivi_layout_add_listener_remove_surface,
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00002044 .add_listener_configure_surface = ivi_layout_add_listener_configure_surface,
Pekka Paalaneneaa43fc2016-04-12 16:06:58 +03002045 .get_surface = shell_get_ivi_layout_surface,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002046 .get_surfaces = ivi_layout_get_surfaces,
2047 .get_id_of_surface = ivi_layout_get_id_of_surface,
2048 .get_surface_from_id = ivi_layout_get_surface_from_id,
2049 .get_properties_of_surface = ivi_layout_get_properties_of_surface,
2050 .get_surfaces_on_layer = ivi_layout_get_surfaces_on_layer,
2051 .surface_set_visibility = ivi_layout_surface_set_visibility,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002052 .surface_set_opacity = ivi_layout_surface_set_opacity,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002053 .surface_set_source_rectangle = ivi_layout_surface_set_source_rectangle,
2054 .surface_set_destination_rectangle = ivi_layout_surface_set_destination_rectangle,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002055 .surface_set_orientation = ivi_layout_surface_set_orientation,
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00002056 .surface_add_listener = ivi_layout_surface_add_listener,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002057 .surface_get_weston_surface = ivi_layout_surface_get_weston_surface,
2058 .surface_set_transition = ivi_layout_surface_set_transition,
2059 .surface_set_transition_duration = ivi_layout_surface_set_transition_duration,
2060
2061 /**
2062 * layer controller interfaces
2063 */
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +00002064 .add_listener_create_layer = ivi_layout_add_listener_create_layer,
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +00002065 .add_listener_remove_layer = ivi_layout_add_listener_remove_layer,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002066 .layer_create_with_dimension = ivi_layout_layer_create_with_dimension,
Nobuhiko Tanibata3aa8aed2015-06-22 15:32:23 +09002067 .layer_destroy = ivi_layout_layer_destroy,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002068 .get_layers = ivi_layout_get_layers,
2069 .get_id_of_layer = ivi_layout_get_id_of_layer,
2070 .get_layer_from_id = ivi_layout_get_layer_from_id,
2071 .get_properties_of_layer = ivi_layout_get_properties_of_layer,
2072 .get_layers_under_surface = ivi_layout_get_layers_under_surface,
2073 .get_layers_on_screen = ivi_layout_get_layers_on_screen,
2074 .layer_set_visibility = ivi_layout_layer_set_visibility,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002075 .layer_set_opacity = ivi_layout_layer_set_opacity,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002076 .layer_set_source_rectangle = ivi_layout_layer_set_source_rectangle,
2077 .layer_set_destination_rectangle = ivi_layout_layer_set_destination_rectangle,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002078 .layer_set_orientation = ivi_layout_layer_set_orientation,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002079 .layer_add_surface = ivi_layout_layer_add_surface,
2080 .layer_remove_surface = ivi_layout_layer_remove_surface,
2081 .layer_set_render_order = ivi_layout_layer_set_render_order,
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00002082 .layer_add_listener = ivi_layout_layer_add_listener,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002083 .layer_set_transition = ivi_layout_layer_set_transition,
2084
2085 /**
Ucan, Emre (ADITG/SW1)6d89b1c2016-03-17 15:30:49 +00002086 * screen controller interfaces
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002087 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002088 .get_screens_under_layer = ivi_layout_get_screens_under_layer,
2089 .screen_add_layer = ivi_layout_screen_add_layer,
2090 .screen_set_render_order = ivi_layout_screen_set_render_order,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002091
2092 /**
2093 * animation
2094 */
2095 .transition_move_layer_cancel = ivi_layout_transition_move_layer_cancel,
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09002096 .layer_set_fade_info = ivi_layout_layer_set_fade_info,
2097
2098 /**
2099 * surface content dumping for debugging
2100 */
2101 .surface_get_size = ivi_layout_surface_get_size,
2102 .surface_dump = ivi_layout_surface_dump,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002103};
2104
2105int
2106load_controller_modules(struct weston_compositor *compositor, const char *modules,
2107 int *argc, char *argv[])
2108{
2109 const char *p, *end;
2110 char buffer[256];
2111 int (*controller_module_init)(struct weston_compositor *compositor,
2112 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002113 const struct ivi_layout_interface *interface,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002114 size_t interface_version);
2115
2116 if (modules == NULL)
2117 return 0;
2118
2119 p = modules;
2120 while (*p) {
2121 end = strchrnul(p, ',');
2122 snprintf(buffer, sizeof buffer, "%.*s", (int)(end - p), p);
2123
Quentin Glidic8af2bec2016-12-02 14:21:46 +01002124 controller_module_init =
2125 wet_load_module_entrypoint(buffer,
2126 "controller_module_init");
Pekka Paalanen97246c02015-03-26 15:47:29 +02002127 if (!controller_module_init)
2128 return -1;
2129
2130 if (controller_module_init(compositor, argc, argv,
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002131 &ivi_layout_interface,
2132 sizeof(struct ivi_layout_interface)) != 0) {
Pekka Paalanen97246c02015-03-26 15:47:29 +02002133 weston_log("ivi-shell: Initialization of controller module fails");
2134 return -1;
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002135 }
2136
2137 p = end;
2138 while (*p == ',')
2139 p++;
2140 }
2141
2142 return 0;
2143}