blob: 6d7e0ee191f6f513d23dfb509c00eb5eaa5bfdc8 [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>
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090062
Pekka Paalanen58f98c92016-06-03 16:45:21 +030063#include "compositor/weston.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090064#include "compositor.h"
Pekka Paalanen1f821932016-03-15 16:57:51 +020065#include "ivi-shell.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090066#include "ivi-layout-export.h"
67#include "ivi-layout-private.h"
Pekka Paalanen32ca7912016-03-15 17:21:00 +020068#include "ivi-layout-shell.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090069
Jon Cruz867d50e2015-06-15 15:37:10 -070070#include "shared/helpers.h"
Jon Cruz4678bab2015-06-15 15:37:07 -070071#include "shared/os-compatibility.h"
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +090072
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +090073#define max(a, b) ((a) > (b) ? (a) : (b))
74
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090075struct ivi_layout;
76
77struct ivi_layout_screen {
78 struct wl_list link;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090079
80 struct ivi_layout *layout;
81 struct weston_output *output;
82
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090083 struct {
84 struct wl_list layer_list;
85 struct wl_list link;
86 } pending;
87
88 struct {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +000089 int dirty;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090090 struct wl_list layer_list;
91 struct wl_list link;
92 } order;
93};
94
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +090095struct ivi_rectangle
96{
97 int32_t x;
98 int32_t y;
99 int32_t width;
100 int32_t height;
101};
102
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900103static struct ivi_layout ivilayout = {0};
104
105struct ivi_layout *
106get_instance(void)
107{
108 return &ivilayout;
109}
110
111/**
Bryce Harringtone6da35d2016-05-19 17:35:02 -0700112 * Internal API to add/remove an ivi_layer to/from ivi_screen.
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900113 */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900114static struct ivi_layout_surface *
115get_surface(struct wl_list *surf_list, uint32_t id_surface)
116{
117 struct ivi_layout_surface *ivisurf;
118
119 wl_list_for_each(ivisurf, surf_list, link) {
120 if (ivisurf->id_surface == id_surface) {
121 return ivisurf;
122 }
123 }
124
125 return NULL;
126}
127
128static struct ivi_layout_layer *
129get_layer(struct wl_list *layer_list, uint32_t id_layer)
130{
131 struct ivi_layout_layer *ivilayer;
132
133 wl_list_for_each(ivilayer, layer_list, link) {
134 if (ivilayer->id_layer == id_layer) {
135 return ivilayer;
136 }
137 }
138
139 return NULL;
140}
141
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000142static bool
143ivi_view_is_rendered(struct ivi_layout_view *view)
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000144{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000145 return !wl_list_empty(&view->order_link);
146}
147
148static void
149ivi_view_destroy(struct ivi_layout_view *ivi_view)
150{
151 wl_list_remove(&ivi_view->transform.link);
152 wl_list_remove(&ivi_view->link);
153 wl_list_remove(&ivi_view->surf_link);
154 wl_list_remove(&ivi_view->pending_link);
155 wl_list_remove(&ivi_view->order_link);
156
157 weston_view_destroy(ivi_view->view);
158
159 free(ivi_view);
160}
161
162static struct ivi_layout_view*
163ivi_view_create(struct ivi_layout_layer *ivilayer,
164 struct ivi_layout_surface *ivisurf)
165{
166 struct ivi_layout_view *ivi_view;
167
168 ivi_view = calloc(1, sizeof *ivi_view);
169 if (ivi_view == NULL) {
170 weston_log("fails to allocate memory\n");
171 return NULL;
172 }
173
174 ivi_view->view = weston_view_create(ivisurf->surface);
175 if (ivi_view->view == NULL) {
176 weston_log("fails to allocate memory\n");
177 return NULL;
178 }
179
180 weston_matrix_init(&ivi_view->transform.matrix);
181 wl_list_init(&ivi_view->transform.link);
182
183 ivi_view->ivisurf = ivisurf;
184 ivi_view->on_layer = ivilayer;
185 wl_list_insert(&ivilayer->layout->view_list,
186 &ivi_view->link);
187 wl_list_insert(&ivisurf->view_list,
188 &ivi_view->surf_link);
189
190 wl_list_init(&ivi_view->pending_link);
191 wl_list_init(&ivi_view->order_link);
192
193 return ivi_view;
194}
195
196static struct ivi_layout_view *
197get_ivi_view(struct ivi_layout_layer *ivilayer,
198 struct ivi_layout_surface *ivisurf)
199{
200 struct ivi_layout_view *ivi_view;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000201
202 assert(ivisurf->surface != NULL);
203
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000204 wl_list_for_each(ivi_view, &ivisurf->view_list, surf_link) {
205 if (ivi_view->on_layer == ivilayer)
206 return ivi_view;
207 }
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000208
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000209 return NULL;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000210}
211
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +0000212static struct ivi_layout_screen *
213get_screen_from_output(struct weston_output *output)
214{
215 struct ivi_layout *layout = get_instance();
216 struct ivi_layout_screen *iviscrn = NULL;
217
218 wl_list_for_each(iviscrn, &layout->screen_list, link) {
219 if (iviscrn->output == output)
220 return iviscrn;
221 }
222
223 return NULL;
224}
225
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900226/**
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900227 * Called at destruction of wl_surface/ivi_surface
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900228 */
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900229void
230ivi_layout_surface_destroy(struct ivi_layout_surface *ivisurf)
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900231{
232 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000233 struct ivi_layout_view *ivi_view ,*next;
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900234
235 if (ivisurf == NULL) {
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900236 weston_log("%s: invalid argument\n", __func__);
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900237 return;
238 }
239
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900240 wl_list_remove(&ivisurf->pending.link);
241 wl_list_remove(&ivisurf->order.link);
242 wl_list_remove(&ivisurf->link);
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900243
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000244 wl_list_for_each_safe(ivi_view, next, &ivisurf->view_list, surf_link) {
245 ivi_view_destroy(ivi_view);
246 }
247
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900248 wl_signal_emit(&layout->surface_notification.removed, ivisurf);
249
Mateusz Polroladada6e32016-03-09 09:13:26 +0000250 ivi_layout_remove_all_surface_transitions(ivisurf);
251
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900252 free(ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900253}
254
255/**
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900256 * Internal API to initialize ivi_screens found from output_list of weston_compositor.
257 * Called by ivi_layout_init_with_compositor.
258 */
259static void
260create_screen(struct weston_compositor *ec)
261{
262 struct ivi_layout *layout = get_instance();
263 struct ivi_layout_screen *iviscrn = NULL;
264 struct weston_output *output = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900265
266 wl_list_for_each(output, &ec->output_list, link) {
267 iviscrn = calloc(1, sizeof *iviscrn);
268 if (iviscrn == NULL) {
269 weston_log("fails to allocate memory\n");
270 continue;
271 }
272
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900273 iviscrn->layout = layout;
274
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900275 iviscrn->output = output;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900276
277 wl_list_init(&iviscrn->pending.layer_list);
278 wl_list_init(&iviscrn->pending.link);
279
280 wl_list_init(&iviscrn->order.layer_list);
281 wl_list_init(&iviscrn->order.link);
282
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900283 wl_list_insert(&layout->screen_list, &iviscrn->link);
284 }
285}
286
287/**
288 * Internal APIs to initialize properties of ivi_surface/ivi_layer when they are created.
289 */
290static void
291init_layer_properties(struct ivi_layout_layer_properties *prop,
292 int32_t width, int32_t height)
293{
294 memset(prop, 0, sizeof *prop);
295 prop->opacity = wl_fixed_from_double(1.0);
296 prop->source_width = width;
297 prop->source_height = height;
298 prop->dest_width = width;
299 prop->dest_height = height;
300}
301
302static void
303init_surface_properties(struct ivi_layout_surface_properties *prop)
304{
305 memset(prop, 0, sizeof *prop);
306 prop->opacity = wl_fixed_from_double(1.0);
Nobuhiko Tanibatae259a7a2015-04-27 17:02:54 +0900307 /*
Bryce Harringtone6da35d2016-05-19 17:35:02 -0700308 * FIXME: this shall be fixed by ivi-layout-transition.
Nobuhiko Tanibatae259a7a2015-04-27 17:02:54 +0900309 */
310 prop->dest_width = 1;
311 prop->dest_height = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900312}
313
314/**
315 * Internal APIs to be called from ivi_layout_commit_changes.
316 */
317static void
318update_opacity(struct ivi_layout_layer *ivilayer,
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000319 struct ivi_layout_surface *ivisurf,
320 struct weston_view *view)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900321{
322 double layer_alpha = wl_fixed_to_double(ivilayer->prop.opacity);
323 double surf_alpha = wl_fixed_to_double(ivisurf->prop.opacity);
324
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000325 view->alpha = layer_alpha * surf_alpha;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900326}
327
328static void
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900329get_rotate_values(enum wl_output_transform orientation,
330 float *v_sin,
331 float *v_cos)
332{
333 switch (orientation) {
334 case WL_OUTPUT_TRANSFORM_90:
335 *v_sin = 1.0f;
336 *v_cos = 0.0f;
337 break;
338 case WL_OUTPUT_TRANSFORM_180:
339 *v_sin = 0.0f;
340 *v_cos = -1.0f;
341 break;
342 case WL_OUTPUT_TRANSFORM_270:
343 *v_sin = -1.0f;
344 *v_cos = 0.0f;
345 break;
346 case WL_OUTPUT_TRANSFORM_NORMAL:
347 default:
348 *v_sin = 0.0f;
349 *v_cos = 1.0f;
350 break;
351 }
352}
353
354static void
355get_scale(enum wl_output_transform orientation,
356 float dest_width,
357 float dest_height,
358 float source_width,
359 float source_height,
360 float *scale_x,
361 float *scale_y)
362{
363 switch (orientation) {
364 case WL_OUTPUT_TRANSFORM_90:
365 *scale_x = dest_width / source_height;
366 *scale_y = dest_height / source_width;
367 break;
368 case WL_OUTPUT_TRANSFORM_180:
369 *scale_x = dest_width / source_width;
370 *scale_y = dest_height / source_height;
371 break;
372 case WL_OUTPUT_TRANSFORM_270:
373 *scale_x = dest_width / source_height;
374 *scale_y = dest_height / source_width;
375 break;
376 case WL_OUTPUT_TRANSFORM_NORMAL:
377 default:
378 *scale_x = dest_width / source_width;
379 *scale_y = dest_height / source_height;
380 break;
381 }
382}
383
384static void
385calc_transformation_matrix(struct ivi_rectangle *source_rect,
386 struct ivi_rectangle *dest_rect,
387 enum wl_output_transform orientation,
388 struct weston_matrix *m)
389{
390 float source_center_x;
391 float source_center_y;
392 float vsin;
393 float vcos;
394 float scale_x;
395 float scale_y;
396 float translate_x;
397 float translate_y;
398
399 source_center_x = source_rect->x + source_rect->width * 0.5f;
400 source_center_y = source_rect->y + source_rect->height * 0.5f;
401 weston_matrix_translate(m, -source_center_x, -source_center_y, 0.0f);
402
403 get_rotate_values(orientation, &vsin, &vcos);
404 weston_matrix_rotate_xy(m, vcos, vsin);
405
406 get_scale(orientation,
407 dest_rect->width,
408 dest_rect->height,
409 source_rect->width,
410 source_rect->height,
411 &scale_x,
412 &scale_y);
413 weston_matrix_scale(m, scale_x, scale_y, 1.0f);
414
415 translate_x = dest_rect->width * 0.5f + dest_rect->x;
416 translate_y = dest_rect->height * 0.5f + dest_rect->y;
417 weston_matrix_translate(m, translate_x, translate_y, 0.0f);
418}
419
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900420/*
421 * This computes intersected rect_output from two ivi_rectangles
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900422 */
423static void
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900424ivi_rectangle_intersect(const struct ivi_rectangle *rect1,
425 const struct ivi_rectangle *rect2,
426 struct ivi_rectangle *rect_output)
427{
428 int32_t rect1_right = rect1->x + rect1->width;
429 int32_t rect1_bottom = rect1->y + rect1->height;
430 int32_t rect2_right = rect2->x + rect2->width;
431 int32_t rect2_bottom = rect2->y + rect2->height;
432
433 rect_output->x = max(rect1->x, rect2->x);
434 rect_output->y = max(rect1->y, rect2->y);
435 rect_output->width = rect1_right < rect2_right ?
436 rect1_right - rect_output->x :
437 rect2_right - rect_output->x;
438 rect_output->height = rect1_bottom < rect2_bottom ?
439 rect1_bottom - rect_output->y :
440 rect2_bottom - rect_output->y;
441
442 if (rect_output->width < 0 || rect_output->height < 0) {
443 rect_output->width = 0;
444 rect_output->height = 0;
445 }
446}
447
448/*
449 * Transform rect_input by the inverse of matrix, intersect with boundingbox,
450 * and store the result in rect_output.
451 * The boundingbox must be given in the same coordinate space as rect_output.
452 * Additionally, there are the following restrictions on the matrix:
453 * - no projective transformations
454 * - no skew
455 * - only multiples of 90-degree rotations supported
456 *
457 * In failure case of weston_matrix_invert, rect_output is set to boundingbox
458 * as a fail-safe with log.
459 */
460static void
461calc_inverse_matrix_transform(const struct weston_matrix *matrix,
462 const struct ivi_rectangle *rect_input,
463 const struct ivi_rectangle *boundingbox,
464 struct ivi_rectangle *rect_output)
465{
466 struct weston_matrix m;
467 struct weston_vector top_left;
468 struct weston_vector bottom_right;
469
470 assert(boundingbox != rect_output);
471
472 if (weston_matrix_invert(&m, matrix) < 0) {
473 weston_log("ivi-shell: calc_inverse_matrix_transform fails to invert a matrix.\n");
474 weston_log("ivi-shell: boundingbox is set to the rect_output.\n");
475 rect_output->x = boundingbox->x;
476 rect_output->y = boundingbox->y;
477 rect_output->width = boundingbox->width;
478 rect_output->height = boundingbox->height;
479 }
480
481 /* The vectors and matrices involved will always produce f[3] == 1.0. */
482 top_left.f[0] = rect_input->x;
483 top_left.f[1] = rect_input->y;
484 top_left.f[2] = 0.0f;
485 top_left.f[3] = 1.0f;
486
487 bottom_right.f[0] = rect_input->x + rect_input->width;
488 bottom_right.f[1] = rect_input->y + rect_input->height;
489 bottom_right.f[2] = 0.0f;
490 bottom_right.f[3] = 1.0f;
491
492 weston_matrix_transform(&m, &top_left);
493 weston_matrix_transform(&m, &bottom_right);
494
495 if (top_left.f[0] < bottom_right.f[0]) {
496 rect_output->x = top_left.f[0];
497 rect_output->width = bottom_right.f[0] - rect_output->x;
498 } else {
499 rect_output->x = bottom_right.f[0];
500 rect_output->width = top_left.f[0] - rect_output->x;
501 }
502
503 if (top_left.f[1] < bottom_right.f[1]) {
504 rect_output->y = top_left.f[1];
505 rect_output->height = bottom_right.f[1] - rect_output->y;
506 } else {
507 rect_output->y = bottom_right.f[1];
508 rect_output->height = top_left.f[1] - rect_output->y;
509 }
510
511 ivi_rectangle_intersect(rect_output, boundingbox, rect_output);
512}
513
514/**
515 * This computes the whole transformation matrix:m from surface-local
Yong Bakose0698712016-04-28 11:59:08 -0500516 * coordinates to multi-screen coordinates, which are global coordinates.
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900517 * It is assumed that weston_view::geometry.{x,y} are zero.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900518 *
Bryce Harringtone6da35d2016-05-19 17:35:02 -0700519 * Additionally, this computes the mask on surface-local coordinates as an
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900520 * ivi_rectangle. This can be set to weston_view_set_mask.
521 *
522 * The mask is computed by following steps
Yong Bakose0698712016-04-28 11:59:08 -0500523 * - destination rectangle of layer is transformed to multi-screen coordinates,
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900524 * global coordinates. This is done by adding weston_output.{x,y} in simple
525 * because there is no scaled and rotated transformation.
Yong Bakose0698712016-04-28 11:59:08 -0500526 * - destination rectangle of layer in multi-screen coordinates needs to be
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900527 * intersected inside of a screen the layer is assigned to. This is because
528 * overlapped region of weston surface in another screen shall not be
529 * displayed according to ivi use case.
530 * - destination rectangle of layer
Yong Bakose0698712016-04-28 11:59:08 -0500531 * - in multi-screen coordinates,
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900532 * - and intersected inside of an assigned screen,
Yong Bakose0698712016-04-28 11:59:08 -0500533 * is inversed to surface-local coordinates by inversed matrix:m.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900534 * - the area is intersected by intersected area between weston_surface and
535 * source rectangle of ivi_surface.
536 */
537static void
538calc_surface_to_global_matrix_and_mask_to_weston_surface(
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900539 struct ivi_layout_screen *iviscrn,
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900540 struct ivi_layout_layer *ivilayer,
541 struct ivi_layout_surface *ivisurf,
542 struct weston_matrix *m,
543 struct ivi_rectangle *result)
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900544{
545 const struct ivi_layout_surface_properties *sp = &ivisurf->prop;
546 const struct ivi_layout_layer_properties *lp = &ivilayer->prop;
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900547 struct weston_output *output = iviscrn->output;
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900548 struct ivi_rectangle weston_surface_rect = { 0,
549 0,
550 ivisurf->surface->width,
551 ivisurf->surface->height };
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900552 struct ivi_rectangle surface_source_rect = { sp->source_x,
553 sp->source_y,
554 sp->source_width,
555 sp->source_height };
556 struct ivi_rectangle surface_dest_rect = { sp->dest_x,
557 sp->dest_y,
558 sp->dest_width,
559 sp->dest_height };
560 struct ivi_rectangle layer_source_rect = { lp->source_x,
561 lp->source_y,
562 lp->source_width,
563 lp->source_height };
564 struct ivi_rectangle layer_dest_rect = { lp->dest_x,
565 lp->dest_y,
566 lp->dest_width,
567 lp->dest_height };
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900568 struct ivi_rectangle screen_dest_rect = { output->x,
569 output->y,
570 output->width,
571 output->height };
572 struct ivi_rectangle layer_dest_rect_in_global =
573 { lp->dest_x + output->x,
574 lp->dest_y + output->y,
575 lp->dest_width,
576 lp->dest_height };
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900577 struct ivi_rectangle surface_result;
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900578 struct ivi_rectangle layer_dest_rect_in_global_intersected;
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900579
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900580 /*
581 * the whole transformation matrix:m from surface-local
582 * coordinates to global coordinates, which is computed by
583 * two steps,
584 * - surface-local coordinates to layer-local coordinates
Yong Bakose0698712016-04-28 11:59:08 -0500585 * - layer-local coordinates to single screen-local coordinates
586 * - single screen-local coordinates to multi-screen coordinates,
587 * which are global coordinates.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900588 */
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900589 calc_transformation_matrix(&surface_source_rect,
590 &surface_dest_rect,
591 sp->orientation, m);
592
593 calc_transformation_matrix(&layer_source_rect,
594 &layer_dest_rect,
595 lp->orientation, m);
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900596
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900597 weston_matrix_translate(m, output->x, output->y, 0.0f);
598
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900599 /* this intersected ivi_rectangle would be used for masking
600 * weston_surface
601 */
602 ivi_rectangle_intersect(&surface_source_rect, &weston_surface_rect,
603 &surface_result);
604
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900605 /*
606 * destination rectangle of layer in multi screens coordinate
607 * is intersected to avoid displaying outside of an assigned screen.
608 */
609 ivi_rectangle_intersect(&layer_dest_rect_in_global, &screen_dest_rect,
610 &layer_dest_rect_in_global_intersected);
611
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900612 /* calc masking area of weston_surface from m */
613 calc_inverse_matrix_transform(m,
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900614 &layer_dest_rect_in_global_intersected,
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900615 &surface_result,
616 result);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900617}
618
619static void
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900620update_prop(struct ivi_layout_screen *iviscrn,
621 struct ivi_layout_layer *ivilayer,
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000622 struct ivi_layout_view *ivi_view)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900623{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000624 struct ivi_layout_surface *ivisurf;
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900625 struct ivi_rectangle r;
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900626 bool can_calc = true;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900627
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000628 assert(ivi_view->on_layer == ivilayer);
629
630 ivisurf = ivi_view->ivisurf;
631
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900632 /*In case of no prop change, this just returns*/
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000633 if (!ivilayer->prop.event_mask && !ivisurf->prop.event_mask)
Nobuhiko Tanibata4c1dbf72015-07-15 13:55:50 +0900634 return;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900635
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000636 update_opacity(ivilayer, ivisurf, ivi_view->view);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900637
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900638 if (ivisurf->prop.source_width == 0 || ivisurf->prop.source_height == 0) {
639 weston_log("ivi-shell: source rectangle is not yet set by ivi_layout_surface_set_source_rectangle\n");
640 can_calc = false;
641 }
642
643 if (ivisurf->prop.dest_width == 0 || ivisurf->prop.dest_height == 0) {
644 weston_log("ivi-shell: destination rectangle is not yet set by ivi_layout_surface_set_destination_rectangle\n");
645 can_calc = false;
646 }
647
648 if (can_calc) {
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000649 wl_list_remove(&ivi_view->transform.link);
650 weston_matrix_init(&ivi_view->transform.matrix);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900651
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900652 calc_surface_to_global_matrix_and_mask_to_weston_surface(
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000653 iviscrn, ivilayer, ivisurf, &ivi_view->transform.matrix, &r);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900654
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000655 weston_view_set_mask(ivi_view->view, r.x, r.y, r.width, r.height);
656 wl_list_insert(&ivi_view->view->geometry.transformation_list,
657 &ivi_view->transform.link);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900658
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000659 weston_view_set_transform_parent(ivi_view->view, NULL);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900660 }
661
662 ivisurf->update_count++;
663
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000664 weston_view_geometry_dirty(ivi_view->view);
Nobuhiko Tanibata4c1dbf72015-07-15 13:55:50 +0900665
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000666 weston_surface_damage(ivisurf->surface);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900667}
668
669static void
670commit_changes(struct ivi_layout *layout)
671{
672 struct ivi_layout_screen *iviscrn = NULL;
673 struct ivi_layout_layer *ivilayer = NULL;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000674 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900675
676 wl_list_for_each(iviscrn, &layout->screen_list, link) {
677 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900678 /*
679 * If ivilayer is invisible, weston_view of ivisurf doesn't
680 * need to be modified.
681 */
682 if (ivilayer->prop.visibility == false)
683 continue;
684
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000685 wl_list_for_each(ivi_view, &ivilayer->order.view_list, order_link) {
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900686 /*
687 * If ivilayer is invisible, weston_view of ivisurf doesn't
688 * need to be modified.
689 */
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000690 if (ivi_view->ivisurf->prop.visibility == false)
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900691 continue;
692
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000693 update_prop(iviscrn, ivilayer, ivi_view);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900694 }
695 }
696 }
697}
698
699static void
700commit_surface_list(struct ivi_layout *layout)
701{
702 struct ivi_layout_surface *ivisurf = NULL;
703 int32_t dest_x = 0;
704 int32_t dest_y = 0;
705 int32_t dest_width = 0;
706 int32_t dest_height = 0;
707 int32_t configured = 0;
708
709 wl_list_for_each(ivisurf, &layout->surface_list, link) {
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300710 if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEFAULT) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900711 dest_x = ivisurf->prop.dest_x;
712 dest_y = ivisurf->prop.dest_y;
713 dest_width = ivisurf->prop.dest_width;
714 dest_height = ivisurf->prop.dest_height;
715
716 ivi_layout_transition_move_resize_view(ivisurf,
717 ivisurf->pending.prop.dest_x,
718 ivisurf->pending.prop.dest_y,
719 ivisurf->pending.prop.dest_width,
720 ivisurf->pending.prop.dest_height,
721 ivisurf->pending.prop.transition_duration);
722
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300723 if (ivisurf->pending.prop.visibility) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900724 ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration);
725 } else {
726 ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration);
727 }
728
729 ivisurf->prop = ivisurf->pending.prop;
730 ivisurf->prop.dest_x = dest_x;
731 ivisurf->prop.dest_y = dest_y;
732 ivisurf->prop.dest_width = dest_width;
733 ivisurf->prop.dest_height = dest_height;
734 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
735 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
736
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300737 } else if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEST_RECT_ONLY) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900738 dest_x = ivisurf->prop.dest_x;
739 dest_y = ivisurf->prop.dest_y;
740 dest_width = ivisurf->prop.dest_width;
741 dest_height = ivisurf->prop.dest_height;
742
743 ivi_layout_transition_move_resize_view(ivisurf,
744 ivisurf->pending.prop.dest_x,
745 ivisurf->pending.prop.dest_y,
746 ivisurf->pending.prop.dest_width,
747 ivisurf->pending.prop.dest_height,
748 ivisurf->pending.prop.transition_duration);
749
750 ivisurf->prop = ivisurf->pending.prop;
751 ivisurf->prop.dest_x = dest_x;
752 ivisurf->prop.dest_y = dest_y;
753 ivisurf->prop.dest_width = dest_width;
754 ivisurf->prop.dest_height = dest_height;
755
756 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
757 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
758
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300759 } else if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900760 configured = 0;
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300761 if (ivisurf->pending.prop.visibility) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900762 ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration);
763 } else {
764 ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration);
765 }
766
767 if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width ||
768 ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) {
769 configured = 1;
770 }
771
772 ivisurf->prop = ivisurf->pending.prop;
773 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
774 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
775
Pekka Paalanen1f821932016-03-15 16:57:51 +0200776 if (configured && !is_surface_transition(ivisurf)) {
Pekka Paalanen1f821932016-03-15 16:57:51 +0200777 shell_surface_send_configure(ivisurf->surface,
778 ivisurf->prop.dest_width,
779 ivisurf->prop.dest_height);
780 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900781 } else {
782 configured = 0;
783 if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width ||
784 ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) {
785 configured = 1;
786 }
787
788 ivisurf->prop = ivisurf->pending.prop;
789 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
790 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
791
Pekka Paalanen1f821932016-03-15 16:57:51 +0200792 if (configured && !is_surface_transition(ivisurf)) {
Pekka Paalanen1f821932016-03-15 16:57:51 +0200793 shell_surface_send_configure(ivisurf->surface,
794 ivisurf->prop.dest_width,
795 ivisurf->prop.dest_height);
796 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900797 }
798 }
799}
800
801static void
802commit_layer_list(struct ivi_layout *layout)
803{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000804 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900805 struct ivi_layout_layer *ivilayer = NULL;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000806 struct ivi_layout_view *next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900807
808 wl_list_for_each(ivilayer, &layout->layer_list, link) {
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300809 if (ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_MOVE) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900810 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 -0300811 } else if (ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_FADE) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900812 ivi_layout_transition_fade_layer(ivilayer,ivilayer->pending.prop.is_fade_in,
813 ivilayer->pending.prop.start_alpha,ivilayer->pending.prop.end_alpha,
814 NULL, NULL,
815 ivilayer->pending.prop.transition_duration);
816 }
817 ivilayer->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
818
819 ivilayer->prop = ivilayer->pending.prop;
820
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +0000821 if (!ivilayer->order.dirty) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900822 continue;
823 }
824
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000825 wl_list_for_each_safe(ivi_view, next, &ivilayer->order.view_list,
826 order_link) {
827 wl_list_remove(&ivi_view->order_link);
828 wl_list_init(&ivi_view->order_link);
829 ivi_view->ivisurf->prop.event_mask |= IVI_NOTIFICATION_REMOVE;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900830 }
831
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000832 assert(wl_list_empty(&ivilayer->order.view_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900833
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000834 wl_list_for_each(ivi_view, &ivilayer->pending.view_list,
835 pending_link) {
836 wl_list_remove(&ivi_view->order_link);
837 wl_list_insert(&ivilayer->order.view_list, &ivi_view->order_link);
838 ivi_view->ivisurf->prop.event_mask |= IVI_NOTIFICATION_ADD;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900839 }
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +0000840
841 ivilayer->order.dirty = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900842 }
843}
844
845static void
846commit_screen_list(struct ivi_layout *layout)
847{
848 struct ivi_layout_screen *iviscrn = NULL;
849 struct ivi_layout_layer *ivilayer = NULL;
850 struct ivi_layout_layer *next = NULL;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000851 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900852
Nobuhiko Tanibatafbfa8f22015-11-25 23:36:57 +0900853 /* Clear view list of layout ivi_layer */
854 wl_list_init(&layout->layout_layer.view_list.link);
855
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900856 wl_list_for_each(iviscrn, &layout->screen_list, link) {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000857 if (iviscrn->order.dirty) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900858 wl_list_for_each_safe(ivilayer, next,
859 &iviscrn->order.layer_list, order.link) {
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +0000860 ivilayer->on_screen = NULL;
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000861 wl_list_remove(&ivilayer->order.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900862 wl_list_init(&ivilayer->order.link);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000863 ivilayer->prop.event_mask |= IVI_NOTIFICATION_REMOVE;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900864 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900865
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000866 assert(wl_list_empty(&iviscrn->order.layer_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900867
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900868 wl_list_for_each(ivilayer, &iviscrn->pending.layer_list,
869 pending.link) {
Nobuhiko Tanibata77b0ee12015-11-25 23:36:46 +0900870 /* FIXME: avoid to insert order.link to multiple screens */
871 wl_list_remove(&ivilayer->order.link);
872
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900873 wl_list_insert(&iviscrn->order.layer_list,
874 &ivilayer->order.link);
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +0000875 ivilayer->on_screen = iviscrn;
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000876 ivilayer->prop.event_mask |= IVI_NOTIFICATION_ADD;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900877 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900878
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000879 iviscrn->order.dirty = 0;
880 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900881
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900882 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
883 if (ivilayer->prop.visibility == false)
884 continue;
885
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000886 wl_list_for_each(ivi_view, &ivilayer->order.view_list, order_link) {
887 if (ivi_view->ivisurf->prop.visibility == false)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900888 continue;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000889
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900890 weston_layer_entry_insert(&layout->layout_layer.view_list,
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000891 &ivi_view->view->layer_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900892
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000893 ivi_view->view->output = iviscrn->output;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900894 }
895 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900896 }
897}
898
899static void
900commit_transition(struct ivi_layout* layout)
901{
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300902 if (wl_list_empty(&layout->pending_transition_list)) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900903 return;
904 }
905
906 wl_list_insert_list(&layout->transitions->transition_list,
907 &layout->pending_transition_list);
908
909 wl_list_init(&layout->pending_transition_list);
910
911 wl_event_source_timer_update(layout->transitions->event_source, 1);
912}
913
914static void
915send_surface_prop(struct ivi_layout_surface *ivisurf)
916{
917 wl_signal_emit(&ivisurf->property_changed, ivisurf);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000918 ivisurf->pending.prop.event_mask = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900919}
920
921static void
922send_layer_prop(struct ivi_layout_layer *ivilayer)
923{
924 wl_signal_emit(&ivilayer->property_changed, ivilayer);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000925 ivilayer->pending.prop.event_mask = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900926}
927
928static void
929send_prop(struct ivi_layout *layout)
930{
931 struct ivi_layout_layer *ivilayer = NULL;
932 struct ivi_layout_surface *ivisurf = NULL;
933
934 wl_list_for_each_reverse(ivilayer, &layout->layer_list, link) {
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000935 if (ivilayer->prop.event_mask)
Nobuhiko Tanibata6ce3ef82015-06-22 15:32:06 +0900936 send_layer_prop(ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900937 }
938
939 wl_list_for_each_reverse(ivisurf, &layout->surface_list, link) {
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000940 if (ivisurf->prop.event_mask)
Nobuhiko Tanibata6ce3ef82015-06-22 15:32:06 +0900941 send_surface_prop(ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900942 }
943}
944
945static void
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000946clear_view_pending_list(struct ivi_layout_layer *ivilayer)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900947{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000948 struct ivi_layout_view *view_link = NULL;
949 struct ivi_layout_view *view_next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900950
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000951 wl_list_for_each_safe(view_link, view_next,
952 &ivilayer->pending.view_list, pending_link) {
953 wl_list_remove(&view_link->pending_link);
954 wl_list_init(&view_link->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900955 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900956}
957
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900958/**
959 * Exported APIs of ivi-layout library are implemented from here.
960 * Brief of APIs is described in ivi-layout-export.h.
961 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900962static int32_t
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000963ivi_layout_add_listener_create_layer(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900964{
965 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900966
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000967 if (listener == NULL) {
968 weston_log("ivi_layout_add_listener_create_layer: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900969 return IVI_FAILED;
970 }
971
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000972 wl_signal_add(&layout->layer_notification.created, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900973
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000974 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900975}
976
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900977static int32_t
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000978ivi_layout_add_listener_remove_layer(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900979{
980 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900981
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000982 if (listener == NULL) {
983 weston_log("ivi_layout_add_listener_remove_layer: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900984 return IVI_FAILED;
985 }
986
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000987 wl_signal_add(&layout->layer_notification.removed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900988
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000989 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900990}
991
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900992static int32_t
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000993ivi_layout_add_listener_create_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900994{
995 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900996
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000997 if (listener == NULL) {
998 weston_log("ivi_layout_add_listener_create_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900999 return IVI_FAILED;
1000 }
1001
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00001002 wl_signal_add(&layout->surface_notification.created, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001003
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00001004 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001005}
1006
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001007static int32_t
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001008ivi_layout_add_listener_remove_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001009{
1010 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001011
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001012 if (listener == NULL) {
1013 weston_log("ivi_layout_add_listener_remove_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001014 return IVI_FAILED;
1015 }
1016
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001017 wl_signal_add(&layout->surface_notification.removed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001018
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001019 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001020}
1021
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001022static int32_t
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001023ivi_layout_add_listener_configure_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001024{
1025 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001026
1027 if (listener == NULL) {
1028 weston_log("ivi_layout_add_listener_configure_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001029 return IVI_FAILED;
1030 }
1031
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001032 wl_signal_add(&layout->surface_notification.configure_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001033
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001034 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001035}
1036
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001037uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001038ivi_layout_get_id_of_surface(struct ivi_layout_surface *ivisurf)
1039{
1040 return ivisurf->id_surface;
1041}
1042
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001043static uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001044ivi_layout_get_id_of_layer(struct ivi_layout_layer *ivilayer)
1045{
1046 return ivilayer->id_layer;
1047}
1048
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001049static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001050ivi_layout_get_layer_from_id(uint32_t id_layer)
1051{
1052 struct ivi_layout *layout = get_instance();
1053 struct ivi_layout_layer *ivilayer = NULL;
1054
1055 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1056 if (ivilayer->id_layer == id_layer) {
1057 return ivilayer;
1058 }
1059 }
1060
1061 return NULL;
1062}
1063
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001064struct ivi_layout_surface *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001065ivi_layout_get_surface_from_id(uint32_t id_surface)
1066{
1067 struct ivi_layout *layout = get_instance();
1068 struct ivi_layout_surface *ivisurf = NULL;
1069
1070 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1071 if (ivisurf->id_surface == id_surface) {
1072 return ivisurf;
1073 }
1074 }
1075
1076 return NULL;
1077}
1078
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001079static int32_t
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001080ivi_layout_surface_add_listener(struct ivi_layout_surface *ivisurf,
1081 struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001082{
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001083 if (ivisurf == NULL || listener == NULL) {
1084 weston_log("ivi_layout_surface_add_listener: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001085 return IVI_FAILED;
1086 }
1087
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001088 wl_signal_add(&ivisurf->property_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001089
1090 return IVI_SUCCEEDED;
1091}
1092
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001093static const struct ivi_layout_layer_properties *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001094ivi_layout_get_properties_of_layer(struct ivi_layout_layer *ivilayer)
1095{
1096 if (ivilayer == NULL) {
1097 weston_log("ivi_layout_get_properties_of_layer: invalid argument\n");
1098 return NULL;
1099 }
1100
1101 return &ivilayer->prop;
1102}
1103
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001104static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001105ivi_layout_get_screens_under_layer(struct ivi_layout_layer *ivilayer,
1106 int32_t *pLength,
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001107 struct weston_output ***ppArray)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001108{
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001109 int32_t length = 0;
1110 int32_t n = 0;
1111
1112 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1113 weston_log("ivi_layout_get_screens_under_layer: invalid argument\n");
1114 return IVI_FAILED;
1115 }
1116
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +00001117 if (ivilayer->on_screen != NULL)
1118 length = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001119
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001120 if (length != 0) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001121 /* the Array must be free by module which called this function */
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001122 *ppArray = calloc(length, sizeof(struct weston_output *));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001123 if (*ppArray == NULL) {
1124 weston_log("fails to allocate memory\n");
1125 return IVI_FAILED;
1126 }
1127
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001128 (*ppArray)[n++] = ivilayer->on_screen->output;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001129 }
1130
1131 *pLength = length;
1132
1133 return IVI_SUCCEEDED;
1134}
1135
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001136static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001137ivi_layout_get_layers(int32_t *pLength, struct ivi_layout_layer ***ppArray)
1138{
1139 struct ivi_layout *layout = get_instance();
1140 struct ivi_layout_layer *ivilayer = NULL;
1141 int32_t length = 0;
1142 int32_t n = 0;
1143
1144 if (pLength == NULL || ppArray == NULL) {
1145 weston_log("ivi_layout_get_layers: invalid argument\n");
1146 return IVI_FAILED;
1147 }
1148
1149 length = wl_list_length(&layout->layer_list);
1150
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001151 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001152 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001153 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1154 if (*ppArray == NULL) {
1155 weston_log("fails to allocate memory\n");
1156 return IVI_FAILED;
1157 }
1158
1159 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1160 (*ppArray)[n++] = ivilayer;
1161 }
1162 }
1163
1164 *pLength = length;
1165
1166 return IVI_SUCCEEDED;
1167}
1168
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001169static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001170ivi_layout_get_layers_on_screen(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001171 int32_t *pLength,
1172 struct ivi_layout_layer ***ppArray)
1173{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001174 struct ivi_layout_screen *iviscrn = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001175 struct ivi_layout_layer *ivilayer = NULL;
1176 int32_t length = 0;
1177 int32_t n = 0;
1178
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001179 if (output == NULL || pLength == NULL || ppArray == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001180 weston_log("ivi_layout_get_layers_on_screen: invalid argument\n");
1181 return IVI_FAILED;
1182 }
1183
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001184 iviscrn = get_screen_from_output(output);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001185 length = wl_list_length(&iviscrn->order.layer_list);
1186
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001187 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001188 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001189 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1190 if (*ppArray == NULL) {
1191 weston_log("fails to allocate memory\n");
1192 return IVI_FAILED;
1193 }
1194
Nobuhiko Tanibatae2b82142015-06-22 15:30:19 +09001195 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001196 (*ppArray)[n++] = ivilayer;
1197 }
1198 }
1199
1200 *pLength = length;
1201
1202 return IVI_SUCCEEDED;
1203}
1204
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001205static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001206ivi_layout_get_layers_under_surface(struct ivi_layout_surface *ivisurf,
1207 int32_t *pLength,
1208 struct ivi_layout_layer ***ppArray)
1209{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001210 struct ivi_layout_view *ivi_view;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001211 int32_t length = 0;
1212 int32_t n = 0;
1213
1214 if (ivisurf == NULL || pLength == NULL || ppArray == NULL) {
1215 weston_log("ivi_layout_getLayers: invalid argument\n");
1216 return IVI_FAILED;
1217 }
1218
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001219 if (!wl_list_empty(&ivisurf->view_list)) {
1220 /* the Array must be free by module which called this function */
1221 length = wl_list_length(&ivisurf->view_list);
1222 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001223 if (*ppArray == NULL) {
1224 weston_log("fails to allocate memory\n");
1225 return IVI_FAILED;
1226 }
1227
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001228 wl_list_for_each_reverse(ivi_view, &ivisurf->view_list, surf_link) {
1229 if (ivi_view_is_rendered(ivi_view))
1230 (*ppArray)[n++] = ivi_view->on_layer;
1231 else
1232 length--;
1233 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001234 }
1235
1236 *pLength = length;
1237
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001238 if (!length) {
1239 free(*ppArray);
1240 *ppArray = NULL;
1241 }
1242
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001243 return IVI_SUCCEEDED;
1244}
1245
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001246static
1247int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001248ivi_layout_get_surfaces(int32_t *pLength, struct ivi_layout_surface ***ppArray)
1249{
1250 struct ivi_layout *layout = get_instance();
1251 struct ivi_layout_surface *ivisurf = NULL;
1252 int32_t length = 0;
1253 int32_t n = 0;
1254
1255 if (pLength == NULL || ppArray == NULL) {
1256 weston_log("ivi_layout_get_surfaces: invalid argument\n");
1257 return IVI_FAILED;
1258 }
1259
1260 length = wl_list_length(&layout->surface_list);
1261
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001262 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001263 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001264 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1265 if (*ppArray == NULL) {
1266 weston_log("fails to allocate memory\n");
1267 return IVI_FAILED;
1268 }
1269
1270 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1271 (*ppArray)[n++] = ivisurf;
1272 }
1273 }
1274
1275 *pLength = length;
1276
1277 return IVI_SUCCEEDED;
1278}
1279
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001280static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001281ivi_layout_get_surfaces_on_layer(struct ivi_layout_layer *ivilayer,
1282 int32_t *pLength,
1283 struct ivi_layout_surface ***ppArray)
1284{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001285 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001286 int32_t length = 0;
1287 int32_t n = 0;
1288
1289 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1290 weston_log("ivi_layout_getSurfaceIDsOnLayer: invalid argument\n");
1291 return IVI_FAILED;
1292 }
1293
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001294 length = wl_list_length(&ivilayer->order.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001295
1296 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001297 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001298 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1299 if (*ppArray == NULL) {
1300 weston_log("fails to allocate memory\n");
1301 return IVI_FAILED;
1302 }
1303
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001304 wl_list_for_each(ivi_view, &ivilayer->order.view_list, order_link) {
1305 (*ppArray)[n++] = ivi_view->ivisurf;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001306 }
1307 }
1308
1309 *pLength = length;
1310
1311 return IVI_SUCCEEDED;
1312}
1313
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001314static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001315ivi_layout_layer_create_with_dimension(uint32_t id_layer,
1316 int32_t width, int32_t height)
1317{
1318 struct ivi_layout *layout = get_instance();
1319 struct ivi_layout_layer *ivilayer = NULL;
1320
1321 ivilayer = get_layer(&layout->layer_list, id_layer);
1322 if (ivilayer != NULL) {
1323 weston_log("id_layer is already created\n");
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001324 ++ivilayer->ref_count;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001325 return ivilayer;
1326 }
1327
1328 ivilayer = calloc(1, sizeof *ivilayer);
1329 if (ivilayer == NULL) {
1330 weston_log("fails to allocate memory\n");
1331 return NULL;
1332 }
1333
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001334 ivilayer->ref_count = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001335 wl_signal_init(&ivilayer->property_changed);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001336 ivilayer->layout = layout;
1337 ivilayer->id_layer = id_layer;
1338
1339 init_layer_properties(&ivilayer->prop, width, height);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001340
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001341 wl_list_init(&ivilayer->pending.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001342 wl_list_init(&ivilayer->pending.link);
1343 ivilayer->pending.prop = ivilayer->prop;
1344
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001345 wl_list_init(&ivilayer->order.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001346 wl_list_init(&ivilayer->order.link);
1347
1348 wl_list_insert(&layout->layer_list, &ivilayer->link);
1349
1350 wl_signal_emit(&layout->layer_notification.created, ivilayer);
1351
1352 return ivilayer;
1353}
1354
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001355static void
Nobuhiko Tanibata3aa8aed2015-06-22 15:32:23 +09001356ivi_layout_layer_destroy(struct ivi_layout_layer *ivilayer)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001357{
1358 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001359 struct ivi_layout_view *ivi_view, *next;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001360
1361 if (ivilayer == NULL) {
1362 weston_log("ivi_layout_layer_remove: invalid argument\n");
1363 return;
1364 }
1365
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001366 if (--ivilayer->ref_count > 0)
1367 return;
1368
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001369 /*Destroy all ivi_views*/
1370 wl_list_for_each_safe(ivi_view, next, &layout->view_list, link) {
1371 if (ivi_view->on_layer == ivilayer)
1372 ivi_view_destroy(ivi_view);
1373 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001374
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001375 wl_signal_emit(&layout->layer_notification.removed, ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001376
Ucan, Emre (ADITG/SW1)cf34dc22015-08-20 14:13:33 +00001377 wl_list_remove(&ivilayer->pending.link);
1378 wl_list_remove(&ivilayer->order.link);
1379 wl_list_remove(&ivilayer->link);
1380
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001381 free(ivilayer);
1382}
1383
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001384int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001385ivi_layout_layer_set_visibility(struct ivi_layout_layer *ivilayer,
1386 bool newVisibility)
1387{
1388 struct ivi_layout_layer_properties *prop = NULL;
1389
1390 if (ivilayer == NULL) {
1391 weston_log("ivi_layout_layer_set_visibility: invalid argument\n");
1392 return IVI_FAILED;
1393 }
1394
1395 prop = &ivilayer->pending.prop;
1396 prop->visibility = newVisibility;
1397
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001398 if (ivilayer->prop.visibility != newVisibility)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001399 prop->event_mask |= IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001400 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001401 prop->event_mask &= ~IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001402
1403 return IVI_SUCCEEDED;
1404}
1405
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001406int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001407ivi_layout_layer_set_opacity(struct ivi_layout_layer *ivilayer,
1408 wl_fixed_t opacity)
1409{
1410 struct ivi_layout_layer_properties *prop = NULL;
1411
Nobuhiko Tanibata7bbacc62015-06-22 15:30:09 +09001412 if (ivilayer == NULL ||
1413 opacity < wl_fixed_from_double(0.0) ||
1414 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001415 weston_log("ivi_layout_layer_set_opacity: invalid argument\n");
1416 return IVI_FAILED;
1417 }
1418
1419 prop = &ivilayer->pending.prop;
1420 prop->opacity = opacity;
1421
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001422 if (ivilayer->prop.opacity != opacity)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001423 prop->event_mask |= IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001424 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001425 prop->event_mask &= ~IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001426
1427 return IVI_SUCCEEDED;
1428}
1429
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001430static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001431ivi_layout_layer_set_source_rectangle(struct ivi_layout_layer *ivilayer,
1432 int32_t x, int32_t y,
1433 int32_t width, int32_t height)
1434{
1435 struct ivi_layout_layer_properties *prop = NULL;
1436
1437 if (ivilayer == NULL) {
1438 weston_log("ivi_layout_layer_set_source_rectangle: invalid argument\n");
1439 return IVI_FAILED;
1440 }
1441
1442 prop = &ivilayer->pending.prop;
1443 prop->source_x = x;
1444 prop->source_y = y;
1445 prop->source_width = width;
1446 prop->source_height = height;
1447
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001448 if (ivilayer->prop.source_x != x || ivilayer->prop.source_y != y ||
1449 ivilayer->prop.source_width != width ||
1450 ivilayer->prop.source_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001451 prop->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001452 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001453 prop->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001454
1455 return IVI_SUCCEEDED;
1456}
1457
Ucan, Emre \(ADITG/SW1\)e62bfd82016-03-04 12:50:46 +00001458int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001459ivi_layout_layer_set_destination_rectangle(struct ivi_layout_layer *ivilayer,
1460 int32_t x, int32_t y,
1461 int32_t width, int32_t height)
1462{
1463 struct ivi_layout_layer_properties *prop = NULL;
1464
1465 if (ivilayer == NULL) {
1466 weston_log("ivi_layout_layer_set_destination_rectangle: invalid argument\n");
1467 return IVI_FAILED;
1468 }
1469
1470 prop = &ivilayer->pending.prop;
1471 prop->dest_x = x;
1472 prop->dest_y = y;
1473 prop->dest_width = width;
1474 prop->dest_height = height;
1475
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001476 if (ivilayer->prop.dest_x != x || ivilayer->prop.dest_y != y ||
1477 ivilayer->prop.dest_width != width ||
1478 ivilayer->prop.dest_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001479 prop->event_mask |= IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001480 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001481 prop->event_mask &= ~IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001482
1483 return IVI_SUCCEEDED;
1484}
1485
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001486static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001487ivi_layout_layer_set_orientation(struct ivi_layout_layer *ivilayer,
1488 enum wl_output_transform orientation)
1489{
1490 struct ivi_layout_layer_properties *prop = NULL;
1491
1492 if (ivilayer == NULL) {
1493 weston_log("ivi_layout_layer_set_orientation: invalid argument\n");
1494 return IVI_FAILED;
1495 }
1496
1497 prop = &ivilayer->pending.prop;
1498 prop->orientation = orientation;
1499
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001500 if (ivilayer->prop.orientation != orientation)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001501 prop->event_mask |= IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001502 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001503 prop->event_mask &= ~IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001504
1505 return IVI_SUCCEEDED;
1506}
1507
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001508int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001509ivi_layout_layer_set_render_order(struct ivi_layout_layer *ivilayer,
1510 struct ivi_layout_surface **pSurface,
1511 int32_t number)
1512{
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001513 int32_t i = 0;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001514 struct ivi_layout_view * ivi_view;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001515
1516 if (ivilayer == NULL) {
1517 weston_log("ivi_layout_layer_set_render_order: invalid argument\n");
1518 return IVI_FAILED;
1519 }
1520
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001521 clear_view_pending_list(ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001522
1523 for (i = 0; i < number; i++) {
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001524 ivi_view = get_ivi_view(ivilayer, pSurface[i]);
1525 if (!ivi_view)
1526 ivi_view = ivi_view_create(ivilayer, pSurface[i]);
1527
1528 assert(ivi_view != NULL);
1529
1530 wl_list_remove(&ivi_view->pending_link);
1531 wl_list_insert(&ivilayer->pending.view_list, &ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001532 }
1533
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +00001534 ivilayer->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001535
1536 return IVI_SUCCEEDED;
1537}
1538
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001539int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001540ivi_layout_surface_set_visibility(struct ivi_layout_surface *ivisurf,
1541 bool newVisibility)
1542{
1543 struct ivi_layout_surface_properties *prop = NULL;
1544
1545 if (ivisurf == NULL) {
1546 weston_log("ivi_layout_surface_set_visibility: invalid argument\n");
1547 return IVI_FAILED;
1548 }
1549
1550 prop = &ivisurf->pending.prop;
1551 prop->visibility = newVisibility;
1552
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001553 if (ivisurf->prop.visibility != newVisibility)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001554 prop->event_mask |= IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001555 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001556 prop->event_mask &= ~IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001557
1558 return IVI_SUCCEEDED;
1559}
1560
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001561int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001562ivi_layout_surface_set_opacity(struct ivi_layout_surface *ivisurf,
1563 wl_fixed_t opacity)
1564{
1565 struct ivi_layout_surface_properties *prop = NULL;
1566
Nobuhiko Tanibataa86226c2015-06-22 15:29:20 +09001567 if (ivisurf == NULL ||
1568 opacity < wl_fixed_from_double(0.0) ||
1569 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001570 weston_log("ivi_layout_surface_set_opacity: invalid argument\n");
1571 return IVI_FAILED;
1572 }
1573
1574 prop = &ivisurf->pending.prop;
1575 prop->opacity = opacity;
1576
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001577 if (ivisurf->prop.opacity != opacity)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001578 prop->event_mask |= IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001579 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001580 prop->event_mask &= ~IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001581
1582 return IVI_SUCCEEDED;
1583}
1584
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001585int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001586ivi_layout_surface_set_destination_rectangle(struct ivi_layout_surface *ivisurf,
1587 int32_t x, int32_t y,
1588 int32_t width, int32_t height)
1589{
1590 struct ivi_layout_surface_properties *prop = NULL;
1591
1592 if (ivisurf == NULL) {
1593 weston_log("ivi_layout_surface_set_destination_rectangle: invalid argument\n");
1594 return IVI_FAILED;
1595 }
1596
1597 prop = &ivisurf->pending.prop;
1598 prop->start_x = prop->dest_x;
1599 prop->start_y = prop->dest_y;
1600 prop->dest_x = x;
1601 prop->dest_y = y;
1602 prop->start_width = prop->dest_width;
1603 prop->start_height = prop->dest_height;
1604 prop->dest_width = width;
1605 prop->dest_height = height;
1606
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001607 if (ivisurf->prop.dest_x != x || ivisurf->prop.dest_y != y ||
1608 ivisurf->prop.dest_width != width ||
1609 ivisurf->prop.dest_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001610 prop->event_mask |= IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001611 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001612 prop->event_mask &= ~IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001613
1614 return IVI_SUCCEEDED;
1615}
1616
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001617static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001618ivi_layout_surface_set_orientation(struct ivi_layout_surface *ivisurf,
1619 enum wl_output_transform orientation)
1620{
1621 struct ivi_layout_surface_properties *prop = NULL;
1622
1623 if (ivisurf == NULL) {
1624 weston_log("ivi_layout_surface_set_orientation: invalid argument\n");
1625 return IVI_FAILED;
1626 }
1627
1628 prop = &ivisurf->pending.prop;
1629 prop->orientation = orientation;
1630
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001631 if (ivisurf->prop.orientation != orientation)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001632 prop->event_mask |= IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001633 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001634 prop->event_mask &= ~IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001635
1636 return IVI_SUCCEEDED;
1637}
1638
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001639static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001640ivi_layout_screen_add_layer(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001641 struct ivi_layout_layer *addlayer)
1642{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001643 struct ivi_layout_screen *iviscrn;
1644
1645 if (output == NULL || addlayer == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001646 weston_log("ivi_layout_screen_add_layer: invalid argument\n");
1647 return IVI_FAILED;
1648 }
1649
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001650 iviscrn = get_screen_from_output(output);
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001651
Ucan, Emre (ADITG/SW1)bb4ec0a2015-08-28 12:59:01 +00001652 if (addlayer->on_screen == iviscrn) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001653 weston_log("ivi_layout_screen_add_layer: addlayer is already available\n");
1654 return IVI_SUCCEEDED;
1655 }
1656
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);
1779 else if (ivi_view_is_rendered(ivi_view))
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001780 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001781
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001782 wl_list_remove(&ivi_view->pending_link);
1783 wl_list_insert(&ivilayer->pending.view_list, &ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001784
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +00001785 ivilayer->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001786
1787 return IVI_SUCCEEDED;
1788}
1789
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001790static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001791ivi_layout_layer_remove_surface(struct ivi_layout_layer *ivilayer,
1792 struct ivi_layout_surface *remsurf)
1793{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001794 struct ivi_layout_view *ivi_view;
1795
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001796 if (ivilayer == NULL || remsurf == NULL) {
1797 weston_log("ivi_layout_layer_remove_surface: invalid argument\n");
1798 return;
1799 }
1800
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001801 ivi_view = get_ivi_view(ivilayer, remsurf);
1802 if (ivi_view) {
1803 wl_list_remove(&ivi_view->pending_link);
1804 wl_list_init(&ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001805
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001806 ivilayer->order.dirty = 1;
1807 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001808}
1809
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001810static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001811ivi_layout_surface_set_source_rectangle(struct ivi_layout_surface *ivisurf,
1812 int32_t x, int32_t y,
1813 int32_t width, int32_t height)
1814{
1815 struct ivi_layout_surface_properties *prop = NULL;
1816
1817 if (ivisurf == NULL) {
1818 weston_log("ivi_layout_surface_set_source_rectangle: invalid argument\n");
1819 return IVI_FAILED;
1820 }
1821
1822 prop = &ivisurf->pending.prop;
1823 prop->source_x = x;
1824 prop->source_y = y;
1825 prop->source_width = width;
1826 prop->source_height = height;
1827
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001828 if (ivisurf->prop.source_x != x || ivisurf->prop.source_y != y ||
1829 ivisurf->prop.source_width != width ||
1830 ivisurf->prop.source_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001831 prop->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001832 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001833 prop->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001834
1835 return IVI_SUCCEEDED;
1836}
1837
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001838int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001839ivi_layout_commit_changes(void)
1840{
1841 struct ivi_layout *layout = get_instance();
1842
1843 commit_surface_list(layout);
1844 commit_layer_list(layout);
1845 commit_screen_list(layout);
1846
1847 commit_transition(layout);
1848
1849 commit_changes(layout);
1850 send_prop(layout);
1851 weston_compositor_schedule_repaint(layout->compositor);
1852
1853 return IVI_SUCCEEDED;
1854}
1855
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001856static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001857ivi_layout_layer_set_transition(struct ivi_layout_layer *ivilayer,
1858 enum ivi_layout_transition_type type,
1859 uint32_t duration)
1860{
1861 if (ivilayer == NULL) {
1862 weston_log("%s: invalid argument\n", __func__);
1863 return -1;
1864 }
1865
1866 ivilayer->pending.prop.transition_type = type;
1867 ivilayer->pending.prop.transition_duration = duration;
1868
1869 return 0;
1870}
1871
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001872static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001873ivi_layout_layer_set_fade_info(struct ivi_layout_layer* ivilayer,
1874 uint32_t is_fade_in,
1875 double start_alpha, double end_alpha)
1876{
1877 if (ivilayer == NULL) {
1878 weston_log("%s: invalid argument\n", __func__);
1879 return -1;
1880 }
1881
1882 ivilayer->pending.prop.is_fade_in = is_fade_in;
1883 ivilayer->pending.prop.start_alpha = start_alpha;
1884 ivilayer->pending.prop.end_alpha = end_alpha;
1885
1886 return 0;
1887}
1888
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001889static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001890ivi_layout_surface_set_transition_duration(struct ivi_layout_surface *ivisurf,
1891 uint32_t duration)
1892{
1893 struct ivi_layout_surface_properties *prop;
1894
1895 if (ivisurf == NULL) {
1896 weston_log("%s: invalid argument\n", __func__);
1897 return -1;
1898 }
1899
1900 prop = &ivisurf->pending.prop;
1901 prop->transition_duration = duration*10;
1902 return 0;
1903}
1904
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001905static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001906ivi_layout_surface_set_transition(struct ivi_layout_surface *ivisurf,
1907 enum ivi_layout_transition_type type,
1908 uint32_t duration)
1909{
1910 struct ivi_layout_surface_properties *prop;
1911
1912 if (ivisurf == NULL) {
1913 weston_log("%s: invalid argument\n", __func__);
1914 return -1;
1915 }
1916
1917 prop = &ivisurf->pending.prop;
1918 prop->transition_type = type;
1919 prop->transition_duration = duration;
1920 return 0;
1921}
1922
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09001923static int32_t
1924ivi_layout_surface_dump(struct weston_surface *surface,
1925 void *target, size_t size,int32_t x, int32_t y,
1926 int32_t width, int32_t height)
1927{
1928 int result = 0;
1929
1930 if (surface == NULL) {
1931 weston_log("%s: invalid argument\n", __func__);
1932 return IVI_FAILED;
1933 }
1934
1935 result = weston_surface_copy_content(
1936 surface, target, size,
1937 x, y, width, height);
1938
1939 return result == 0 ? IVI_SUCCEEDED : IVI_FAILED;
1940}
1941
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001942/**
1943 * methods of interaction between ivi-shell with ivi-layout
1944 */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001945
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001946void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001947ivi_layout_surface_configure(struct ivi_layout_surface *ivisurf,
1948 int32_t width, int32_t height)
1949{
1950 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001951
Nobuhiko Tanibatae6cc9972015-04-27 16:54:01 +09001952 /* emit callback which is set by ivi-layout api user */
1953 wl_signal_emit(&layout->surface_notification.configure_changed,
1954 ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001955}
1956
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001957struct ivi_layout_surface*
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001958ivi_layout_surface_create(struct weston_surface *wl_surface,
1959 uint32_t id_surface)
1960{
1961 struct ivi_layout *layout = get_instance();
1962 struct ivi_layout_surface *ivisurf = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001963
1964 if (wl_surface == NULL) {
1965 weston_log("ivi_layout_surface_create: invalid argument\n");
1966 return NULL;
1967 }
1968
1969 ivisurf = get_surface(&layout->surface_list, id_surface);
1970 if (ivisurf != NULL) {
1971 if (ivisurf->surface != NULL) {
1972 weston_log("id_surface(%d) is already created\n", id_surface);
1973 return NULL;
1974 }
1975 }
1976
1977 ivisurf = calloc(1, sizeof *ivisurf);
1978 if (ivisurf == NULL) {
1979 weston_log("fails to allocate memory\n");
1980 return NULL;
1981 }
1982
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001983 wl_signal_init(&ivisurf->property_changed);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001984 ivisurf->id_surface = id_surface;
1985 ivisurf->layout = layout;
1986
1987 ivisurf->surface = wl_surface;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001988
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001989 ivisurf->surface->width_from_buffer = 0;
1990 ivisurf->surface->height_from_buffer = 0;
1991
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001992 init_surface_properties(&ivisurf->prop);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001993
1994 ivisurf->pending.prop = ivisurf->prop;
1995 wl_list_init(&ivisurf->pending.link);
1996
1997 wl_list_init(&ivisurf->order.link);
1998 wl_list_init(&ivisurf->order.layer_list);
1999
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00002000 wl_list_init(&ivisurf->view_list);
2001
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002002 wl_list_insert(&layout->surface_list, &ivisurf->link);
2003
2004 wl_signal_emit(&layout->surface_notification.created, ivisurf);
2005
2006 return ivisurf;
2007}
2008
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002009void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002010ivi_layout_init_with_compositor(struct weston_compositor *ec)
2011{
2012 struct ivi_layout *layout = get_instance();
2013
2014 layout->compositor = ec;
2015
2016 wl_list_init(&layout->surface_list);
2017 wl_list_init(&layout->layer_list);
2018 wl_list_init(&layout->screen_list);
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00002019 wl_list_init(&layout->view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002020
2021 wl_signal_init(&layout->layer_notification.created);
2022 wl_signal_init(&layout->layer_notification.removed);
2023
2024 wl_signal_init(&layout->surface_notification.created);
2025 wl_signal_init(&layout->surface_notification.removed);
2026 wl_signal_init(&layout->surface_notification.configure_changed);
2027
2028 /* Add layout_layer at the last of weston_compositor.layer_list */
2029 weston_layer_init(&layout->layout_layer, ec->layer_list.prev);
2030
2031 create_screen(ec);
2032
2033 layout->transitions = ivi_layout_transition_set_create(ec);
2034 wl_list_init(&layout->pending_transition_list);
2035}
2036
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002037static struct ivi_layout_interface ivi_layout_interface = {
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002038 /**
2039 * commit all changes
2040 */
2041 .commit_changes = ivi_layout_commit_changes,
2042
2043 /**
2044 * surface controller interfaces
2045 */
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00002046 .add_listener_create_surface = ivi_layout_add_listener_create_surface,
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00002047 .add_listener_remove_surface = ivi_layout_add_listener_remove_surface,
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00002048 .add_listener_configure_surface = ivi_layout_add_listener_configure_surface,
Pekka Paalaneneaa43fc2016-04-12 16:06:58 +03002049 .get_surface = shell_get_ivi_layout_surface,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002050 .get_surfaces = ivi_layout_get_surfaces,
2051 .get_id_of_surface = ivi_layout_get_id_of_surface,
2052 .get_surface_from_id = ivi_layout_get_surface_from_id,
2053 .get_properties_of_surface = ivi_layout_get_properties_of_surface,
2054 .get_surfaces_on_layer = ivi_layout_get_surfaces_on_layer,
2055 .surface_set_visibility = ivi_layout_surface_set_visibility,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002056 .surface_set_opacity = ivi_layout_surface_set_opacity,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002057 .surface_set_source_rectangle = ivi_layout_surface_set_source_rectangle,
2058 .surface_set_destination_rectangle = ivi_layout_surface_set_destination_rectangle,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002059 .surface_set_orientation = ivi_layout_surface_set_orientation,
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00002060 .surface_add_listener = ivi_layout_surface_add_listener,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002061 .surface_get_weston_surface = ivi_layout_surface_get_weston_surface,
2062 .surface_set_transition = ivi_layout_surface_set_transition,
2063 .surface_set_transition_duration = ivi_layout_surface_set_transition_duration,
2064
2065 /**
2066 * layer controller interfaces
2067 */
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +00002068 .add_listener_create_layer = ivi_layout_add_listener_create_layer,
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +00002069 .add_listener_remove_layer = ivi_layout_add_listener_remove_layer,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002070 .layer_create_with_dimension = ivi_layout_layer_create_with_dimension,
Nobuhiko Tanibata3aa8aed2015-06-22 15:32:23 +09002071 .layer_destroy = ivi_layout_layer_destroy,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002072 .get_layers = ivi_layout_get_layers,
2073 .get_id_of_layer = ivi_layout_get_id_of_layer,
2074 .get_layer_from_id = ivi_layout_get_layer_from_id,
2075 .get_properties_of_layer = ivi_layout_get_properties_of_layer,
2076 .get_layers_under_surface = ivi_layout_get_layers_under_surface,
2077 .get_layers_on_screen = ivi_layout_get_layers_on_screen,
2078 .layer_set_visibility = ivi_layout_layer_set_visibility,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002079 .layer_set_opacity = ivi_layout_layer_set_opacity,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002080 .layer_set_source_rectangle = ivi_layout_layer_set_source_rectangle,
2081 .layer_set_destination_rectangle = ivi_layout_layer_set_destination_rectangle,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002082 .layer_set_orientation = ivi_layout_layer_set_orientation,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002083 .layer_add_surface = ivi_layout_layer_add_surface,
2084 .layer_remove_surface = ivi_layout_layer_remove_surface,
2085 .layer_set_render_order = ivi_layout_layer_set_render_order,
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00002086 .layer_add_listener = ivi_layout_layer_add_listener,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002087 .layer_set_transition = ivi_layout_layer_set_transition,
2088
2089 /**
Ucan, Emre (ADITG/SW1)6d89b1c2016-03-17 15:30:49 +00002090 * screen controller interfaces
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002091 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002092 .get_screens_under_layer = ivi_layout_get_screens_under_layer,
2093 .screen_add_layer = ivi_layout_screen_add_layer,
2094 .screen_set_render_order = ivi_layout_screen_set_render_order,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002095
2096 /**
2097 * animation
2098 */
2099 .transition_move_layer_cancel = ivi_layout_transition_move_layer_cancel,
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09002100 .layer_set_fade_info = ivi_layout_layer_set_fade_info,
2101
2102 /**
2103 * surface content dumping for debugging
2104 */
2105 .surface_get_size = ivi_layout_surface_get_size,
2106 .surface_dump = ivi_layout_surface_dump,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002107};
2108
2109int
2110load_controller_modules(struct weston_compositor *compositor, const char *modules,
2111 int *argc, char *argv[])
2112{
2113 const char *p, *end;
2114 char buffer[256];
2115 int (*controller_module_init)(struct weston_compositor *compositor,
2116 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002117 const struct ivi_layout_interface *interface,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002118 size_t interface_version);
2119
2120 if (modules == NULL)
2121 return 0;
2122
2123 p = modules;
2124 while (*p) {
2125 end = strchrnul(p, ',');
2126 snprintf(buffer, sizeof buffer, "%.*s", (int)(end - p), p);
2127
Giulio Camuffo179fcda2016-06-02 21:48:14 +03002128 controller_module_init = wet_load_module(buffer, "controller_module_init");
Pekka Paalanen97246c02015-03-26 15:47:29 +02002129 if (!controller_module_init)
2130 return -1;
2131
2132 if (controller_module_init(compositor, argc, argv,
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002133 &ivi_layout_interface,
2134 sizeof(struct ivi_layout_interface)) != 0) {
Pekka Paalanen97246c02015-03-26 15:47:29 +02002135 weston_log("ivi-shell: Initialization of controller module fails");
2136 return -1;
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002137 }
2138
2139 p = end;
2140 while (*p == ',')
2141 p++;
2142 }
2143
2144 return 0;
2145}