blob: dec493631990eb79d19759adf2e0d89d496c6d4e [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;
Armin Krezović50ff4bf2016-06-30 06:04:31 +0200894 ivi_view->ivisurf->surface->is_mapped = true;
895 ivi_view->view->is_mapped = true;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900896 }
897 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900898 }
899}
900
901static void
902commit_transition(struct ivi_layout* layout)
903{
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300904 if (wl_list_empty(&layout->pending_transition_list)) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900905 return;
906 }
907
908 wl_list_insert_list(&layout->transitions->transition_list,
909 &layout->pending_transition_list);
910
911 wl_list_init(&layout->pending_transition_list);
912
913 wl_event_source_timer_update(layout->transitions->event_source, 1);
914}
915
916static void
917send_surface_prop(struct ivi_layout_surface *ivisurf)
918{
919 wl_signal_emit(&ivisurf->property_changed, ivisurf);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000920 ivisurf->pending.prop.event_mask = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900921}
922
923static void
924send_layer_prop(struct ivi_layout_layer *ivilayer)
925{
926 wl_signal_emit(&ivilayer->property_changed, ivilayer);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000927 ivilayer->pending.prop.event_mask = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900928}
929
930static void
931send_prop(struct ivi_layout *layout)
932{
933 struct ivi_layout_layer *ivilayer = NULL;
934 struct ivi_layout_surface *ivisurf = NULL;
935
936 wl_list_for_each_reverse(ivilayer, &layout->layer_list, link) {
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000937 if (ivilayer->prop.event_mask)
Nobuhiko Tanibata6ce3ef82015-06-22 15:32:06 +0900938 send_layer_prop(ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900939 }
940
941 wl_list_for_each_reverse(ivisurf, &layout->surface_list, link) {
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000942 if (ivisurf->prop.event_mask)
Nobuhiko Tanibata6ce3ef82015-06-22 15:32:06 +0900943 send_surface_prop(ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900944 }
945}
946
947static void
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000948clear_view_pending_list(struct ivi_layout_layer *ivilayer)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900949{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000950 struct ivi_layout_view *view_link = NULL;
951 struct ivi_layout_view *view_next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900952
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000953 wl_list_for_each_safe(view_link, view_next,
954 &ivilayer->pending.view_list, pending_link) {
955 wl_list_remove(&view_link->pending_link);
956 wl_list_init(&view_link->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900957 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900958}
959
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900960/**
961 * Exported APIs of ivi-layout library are implemented from here.
962 * Brief of APIs is described in ivi-layout-export.h.
963 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900964static int32_t
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000965ivi_layout_add_listener_create_layer(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900966{
967 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900968
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000969 if (listener == NULL) {
970 weston_log("ivi_layout_add_listener_create_layer: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900971 return IVI_FAILED;
972 }
973
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000974 wl_signal_add(&layout->layer_notification.created, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900975
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000976 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900977}
978
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900979static int32_t
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000980ivi_layout_add_listener_remove_layer(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900981{
982 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900983
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000984 if (listener == NULL) {
985 weston_log("ivi_layout_add_listener_remove_layer: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900986 return IVI_FAILED;
987 }
988
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000989 wl_signal_add(&layout->layer_notification.removed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900990
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000991 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900992}
993
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900994static int32_t
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000995ivi_layout_add_listener_create_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900996{
997 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900998
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000999 if (listener == NULL) {
1000 weston_log("ivi_layout_add_listener_create_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001001 return IVI_FAILED;
1002 }
1003
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00001004 wl_signal_add(&layout->surface_notification.created, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001005
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00001006 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001007}
1008
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001009static int32_t
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001010ivi_layout_add_listener_remove_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001011{
1012 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001013
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001014 if (listener == NULL) {
1015 weston_log("ivi_layout_add_listener_remove_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001016 return IVI_FAILED;
1017 }
1018
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001019 wl_signal_add(&layout->surface_notification.removed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001020
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001021 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001022}
1023
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001024static int32_t
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001025ivi_layout_add_listener_configure_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001026{
1027 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001028
1029 if (listener == NULL) {
1030 weston_log("ivi_layout_add_listener_configure_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001031 return IVI_FAILED;
1032 }
1033
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001034 wl_signal_add(&layout->surface_notification.configure_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001035
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001036 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001037}
1038
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001039uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001040ivi_layout_get_id_of_surface(struct ivi_layout_surface *ivisurf)
1041{
1042 return ivisurf->id_surface;
1043}
1044
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001045static uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001046ivi_layout_get_id_of_layer(struct ivi_layout_layer *ivilayer)
1047{
1048 return ivilayer->id_layer;
1049}
1050
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001051static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001052ivi_layout_get_layer_from_id(uint32_t id_layer)
1053{
1054 struct ivi_layout *layout = get_instance();
1055 struct ivi_layout_layer *ivilayer = NULL;
1056
1057 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1058 if (ivilayer->id_layer == id_layer) {
1059 return ivilayer;
1060 }
1061 }
1062
1063 return NULL;
1064}
1065
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001066struct ivi_layout_surface *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001067ivi_layout_get_surface_from_id(uint32_t id_surface)
1068{
1069 struct ivi_layout *layout = get_instance();
1070 struct ivi_layout_surface *ivisurf = NULL;
1071
1072 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1073 if (ivisurf->id_surface == id_surface) {
1074 return ivisurf;
1075 }
1076 }
1077
1078 return NULL;
1079}
1080
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001081static int32_t
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001082ivi_layout_surface_add_listener(struct ivi_layout_surface *ivisurf,
1083 struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001084{
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001085 if (ivisurf == NULL || listener == NULL) {
1086 weston_log("ivi_layout_surface_add_listener: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001087 return IVI_FAILED;
1088 }
1089
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001090 wl_signal_add(&ivisurf->property_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001091
1092 return IVI_SUCCEEDED;
1093}
1094
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001095static const struct ivi_layout_layer_properties *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001096ivi_layout_get_properties_of_layer(struct ivi_layout_layer *ivilayer)
1097{
1098 if (ivilayer == NULL) {
1099 weston_log("ivi_layout_get_properties_of_layer: invalid argument\n");
1100 return NULL;
1101 }
1102
1103 return &ivilayer->prop;
1104}
1105
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001106static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001107ivi_layout_get_screens_under_layer(struct ivi_layout_layer *ivilayer,
1108 int32_t *pLength,
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001109 struct weston_output ***ppArray)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001110{
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001111 int32_t length = 0;
1112 int32_t n = 0;
1113
1114 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1115 weston_log("ivi_layout_get_screens_under_layer: invalid argument\n");
1116 return IVI_FAILED;
1117 }
1118
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +00001119 if (ivilayer->on_screen != NULL)
1120 length = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001121
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001122 if (length != 0) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001123 /* the Array must be free by module which called this function */
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001124 *ppArray = calloc(length, sizeof(struct weston_output *));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001125 if (*ppArray == NULL) {
1126 weston_log("fails to allocate memory\n");
1127 return IVI_FAILED;
1128 }
1129
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001130 (*ppArray)[n++] = ivilayer->on_screen->output;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001131 }
1132
1133 *pLength = length;
1134
1135 return IVI_SUCCEEDED;
1136}
1137
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001138static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001139ivi_layout_get_layers(int32_t *pLength, struct ivi_layout_layer ***ppArray)
1140{
1141 struct ivi_layout *layout = get_instance();
1142 struct ivi_layout_layer *ivilayer = NULL;
1143 int32_t length = 0;
1144 int32_t n = 0;
1145
1146 if (pLength == NULL || ppArray == NULL) {
1147 weston_log("ivi_layout_get_layers: invalid argument\n");
1148 return IVI_FAILED;
1149 }
1150
1151 length = wl_list_length(&layout->layer_list);
1152
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001153 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001154 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001155 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1156 if (*ppArray == NULL) {
1157 weston_log("fails to allocate memory\n");
1158 return IVI_FAILED;
1159 }
1160
1161 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1162 (*ppArray)[n++] = ivilayer;
1163 }
1164 }
1165
1166 *pLength = length;
1167
1168 return IVI_SUCCEEDED;
1169}
1170
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001171static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001172ivi_layout_get_layers_on_screen(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001173 int32_t *pLength,
1174 struct ivi_layout_layer ***ppArray)
1175{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001176 struct ivi_layout_screen *iviscrn = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001177 struct ivi_layout_layer *ivilayer = NULL;
1178 int32_t length = 0;
1179 int32_t n = 0;
1180
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001181 if (output == NULL || pLength == NULL || ppArray == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001182 weston_log("ivi_layout_get_layers_on_screen: invalid argument\n");
1183 return IVI_FAILED;
1184 }
1185
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001186 iviscrn = get_screen_from_output(output);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001187 length = wl_list_length(&iviscrn->order.layer_list);
1188
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001189 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001190 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001191 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1192 if (*ppArray == NULL) {
1193 weston_log("fails to allocate memory\n");
1194 return IVI_FAILED;
1195 }
1196
Nobuhiko Tanibatae2b82142015-06-22 15:30:19 +09001197 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001198 (*ppArray)[n++] = ivilayer;
1199 }
1200 }
1201
1202 *pLength = length;
1203
1204 return IVI_SUCCEEDED;
1205}
1206
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001207static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001208ivi_layout_get_layers_under_surface(struct ivi_layout_surface *ivisurf,
1209 int32_t *pLength,
1210 struct ivi_layout_layer ***ppArray)
1211{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001212 struct ivi_layout_view *ivi_view;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001213 int32_t length = 0;
1214 int32_t n = 0;
1215
1216 if (ivisurf == NULL || pLength == NULL || ppArray == NULL) {
1217 weston_log("ivi_layout_getLayers: invalid argument\n");
1218 return IVI_FAILED;
1219 }
1220
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001221 if (!wl_list_empty(&ivisurf->view_list)) {
1222 /* the Array must be free by module which called this function */
1223 length = wl_list_length(&ivisurf->view_list);
1224 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001225 if (*ppArray == NULL) {
1226 weston_log("fails to allocate memory\n");
1227 return IVI_FAILED;
1228 }
1229
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001230 wl_list_for_each_reverse(ivi_view, &ivisurf->view_list, surf_link) {
1231 if (ivi_view_is_rendered(ivi_view))
1232 (*ppArray)[n++] = ivi_view->on_layer;
1233 else
1234 length--;
1235 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001236 }
1237
1238 *pLength = length;
1239
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001240 if (!length) {
1241 free(*ppArray);
1242 *ppArray = NULL;
1243 }
1244
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001245 return IVI_SUCCEEDED;
1246}
1247
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001248static
1249int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001250ivi_layout_get_surfaces(int32_t *pLength, struct ivi_layout_surface ***ppArray)
1251{
1252 struct ivi_layout *layout = get_instance();
1253 struct ivi_layout_surface *ivisurf = NULL;
1254 int32_t length = 0;
1255 int32_t n = 0;
1256
1257 if (pLength == NULL || ppArray == NULL) {
1258 weston_log("ivi_layout_get_surfaces: invalid argument\n");
1259 return IVI_FAILED;
1260 }
1261
1262 length = wl_list_length(&layout->surface_list);
1263
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001264 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001265 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001266 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1267 if (*ppArray == NULL) {
1268 weston_log("fails to allocate memory\n");
1269 return IVI_FAILED;
1270 }
1271
1272 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1273 (*ppArray)[n++] = ivisurf;
1274 }
1275 }
1276
1277 *pLength = length;
1278
1279 return IVI_SUCCEEDED;
1280}
1281
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001282static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001283ivi_layout_get_surfaces_on_layer(struct ivi_layout_layer *ivilayer,
1284 int32_t *pLength,
1285 struct ivi_layout_surface ***ppArray)
1286{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001287 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001288 int32_t length = 0;
1289 int32_t n = 0;
1290
1291 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1292 weston_log("ivi_layout_getSurfaceIDsOnLayer: invalid argument\n");
1293 return IVI_FAILED;
1294 }
1295
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001296 length = wl_list_length(&ivilayer->order.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001297
1298 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001299 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001300 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1301 if (*ppArray == NULL) {
1302 weston_log("fails to allocate memory\n");
1303 return IVI_FAILED;
1304 }
1305
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001306 wl_list_for_each(ivi_view, &ivilayer->order.view_list, order_link) {
1307 (*ppArray)[n++] = ivi_view->ivisurf;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001308 }
1309 }
1310
1311 *pLength = length;
1312
1313 return IVI_SUCCEEDED;
1314}
1315
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001316static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001317ivi_layout_layer_create_with_dimension(uint32_t id_layer,
1318 int32_t width, int32_t height)
1319{
1320 struct ivi_layout *layout = get_instance();
1321 struct ivi_layout_layer *ivilayer = NULL;
1322
1323 ivilayer = get_layer(&layout->layer_list, id_layer);
1324 if (ivilayer != NULL) {
1325 weston_log("id_layer is already created\n");
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001326 ++ivilayer->ref_count;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001327 return ivilayer;
1328 }
1329
1330 ivilayer = calloc(1, sizeof *ivilayer);
1331 if (ivilayer == NULL) {
1332 weston_log("fails to allocate memory\n");
1333 return NULL;
1334 }
1335
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001336 ivilayer->ref_count = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001337 wl_signal_init(&ivilayer->property_changed);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001338 ivilayer->layout = layout;
1339 ivilayer->id_layer = id_layer;
1340
1341 init_layer_properties(&ivilayer->prop, width, height);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001342
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001343 wl_list_init(&ivilayer->pending.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001344 wl_list_init(&ivilayer->pending.link);
1345 ivilayer->pending.prop = ivilayer->prop;
1346
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001347 wl_list_init(&ivilayer->order.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001348 wl_list_init(&ivilayer->order.link);
1349
1350 wl_list_insert(&layout->layer_list, &ivilayer->link);
1351
1352 wl_signal_emit(&layout->layer_notification.created, ivilayer);
1353
1354 return ivilayer;
1355}
1356
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001357static void
Nobuhiko Tanibata3aa8aed2015-06-22 15:32:23 +09001358ivi_layout_layer_destroy(struct ivi_layout_layer *ivilayer)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001359{
1360 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001361 struct ivi_layout_view *ivi_view, *next;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001362
1363 if (ivilayer == NULL) {
1364 weston_log("ivi_layout_layer_remove: invalid argument\n");
1365 return;
1366 }
1367
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001368 if (--ivilayer->ref_count > 0)
1369 return;
1370
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001371 /*Destroy all ivi_views*/
1372 wl_list_for_each_safe(ivi_view, next, &layout->view_list, link) {
1373 if (ivi_view->on_layer == ivilayer)
1374 ivi_view_destroy(ivi_view);
1375 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001376
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001377 wl_signal_emit(&layout->layer_notification.removed, ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001378
Ucan, Emre (ADITG/SW1)cf34dc22015-08-20 14:13:33 +00001379 wl_list_remove(&ivilayer->pending.link);
1380 wl_list_remove(&ivilayer->order.link);
1381 wl_list_remove(&ivilayer->link);
1382
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001383 free(ivilayer);
1384}
1385
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001386int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001387ivi_layout_layer_set_visibility(struct ivi_layout_layer *ivilayer,
1388 bool newVisibility)
1389{
1390 struct ivi_layout_layer_properties *prop = NULL;
1391
1392 if (ivilayer == NULL) {
1393 weston_log("ivi_layout_layer_set_visibility: invalid argument\n");
1394 return IVI_FAILED;
1395 }
1396
1397 prop = &ivilayer->pending.prop;
1398 prop->visibility = newVisibility;
1399
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001400 if (ivilayer->prop.visibility != newVisibility)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001401 prop->event_mask |= IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001402 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001403 prop->event_mask &= ~IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001404
1405 return IVI_SUCCEEDED;
1406}
1407
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001408int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001409ivi_layout_layer_set_opacity(struct ivi_layout_layer *ivilayer,
1410 wl_fixed_t opacity)
1411{
1412 struct ivi_layout_layer_properties *prop = NULL;
1413
Nobuhiko Tanibata7bbacc62015-06-22 15:30:09 +09001414 if (ivilayer == NULL ||
1415 opacity < wl_fixed_from_double(0.0) ||
1416 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001417 weston_log("ivi_layout_layer_set_opacity: invalid argument\n");
1418 return IVI_FAILED;
1419 }
1420
1421 prop = &ivilayer->pending.prop;
1422 prop->opacity = opacity;
1423
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001424 if (ivilayer->prop.opacity != opacity)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001425 prop->event_mask |= IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001426 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001427 prop->event_mask &= ~IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001428
1429 return IVI_SUCCEEDED;
1430}
1431
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001432static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001433ivi_layout_layer_set_source_rectangle(struct ivi_layout_layer *ivilayer,
1434 int32_t x, int32_t y,
1435 int32_t width, int32_t height)
1436{
1437 struct ivi_layout_layer_properties *prop = NULL;
1438
1439 if (ivilayer == NULL) {
1440 weston_log("ivi_layout_layer_set_source_rectangle: invalid argument\n");
1441 return IVI_FAILED;
1442 }
1443
1444 prop = &ivilayer->pending.prop;
1445 prop->source_x = x;
1446 prop->source_y = y;
1447 prop->source_width = width;
1448 prop->source_height = height;
1449
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001450 if (ivilayer->prop.source_x != x || ivilayer->prop.source_y != y ||
1451 ivilayer->prop.source_width != width ||
1452 ivilayer->prop.source_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001453 prop->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001454 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001455 prop->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001456
1457 return IVI_SUCCEEDED;
1458}
1459
Ucan, Emre \(ADITG/SW1\)e62bfd82016-03-04 12:50:46 +00001460int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001461ivi_layout_layer_set_destination_rectangle(struct ivi_layout_layer *ivilayer,
1462 int32_t x, int32_t y,
1463 int32_t width, int32_t height)
1464{
1465 struct ivi_layout_layer_properties *prop = NULL;
1466
1467 if (ivilayer == NULL) {
1468 weston_log("ivi_layout_layer_set_destination_rectangle: invalid argument\n");
1469 return IVI_FAILED;
1470 }
1471
1472 prop = &ivilayer->pending.prop;
1473 prop->dest_x = x;
1474 prop->dest_y = y;
1475 prop->dest_width = width;
1476 prop->dest_height = height;
1477
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001478 if (ivilayer->prop.dest_x != x || ivilayer->prop.dest_y != y ||
1479 ivilayer->prop.dest_width != width ||
1480 ivilayer->prop.dest_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001481 prop->event_mask |= IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001482 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001483 prop->event_mask &= ~IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001484
1485 return IVI_SUCCEEDED;
1486}
1487
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001488static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001489ivi_layout_layer_set_orientation(struct ivi_layout_layer *ivilayer,
1490 enum wl_output_transform orientation)
1491{
1492 struct ivi_layout_layer_properties *prop = NULL;
1493
1494 if (ivilayer == NULL) {
1495 weston_log("ivi_layout_layer_set_orientation: invalid argument\n");
1496 return IVI_FAILED;
1497 }
1498
1499 prop = &ivilayer->pending.prop;
1500 prop->orientation = orientation;
1501
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001502 if (ivilayer->prop.orientation != orientation)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001503 prop->event_mask |= IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001504 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001505 prop->event_mask &= ~IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001506
1507 return IVI_SUCCEEDED;
1508}
1509
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001510int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001511ivi_layout_layer_set_render_order(struct ivi_layout_layer *ivilayer,
1512 struct ivi_layout_surface **pSurface,
1513 int32_t number)
1514{
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001515 int32_t i = 0;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001516 struct ivi_layout_view * ivi_view;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001517
1518 if (ivilayer == NULL) {
1519 weston_log("ivi_layout_layer_set_render_order: invalid argument\n");
1520 return IVI_FAILED;
1521 }
1522
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001523 clear_view_pending_list(ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001524
1525 for (i = 0; i < number; i++) {
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001526 ivi_view = get_ivi_view(ivilayer, pSurface[i]);
1527 if (!ivi_view)
1528 ivi_view = ivi_view_create(ivilayer, pSurface[i]);
1529
1530 assert(ivi_view != NULL);
1531
1532 wl_list_remove(&ivi_view->pending_link);
1533 wl_list_insert(&ivilayer->pending.view_list, &ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001534 }
1535
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +00001536 ivilayer->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001537
1538 return IVI_SUCCEEDED;
1539}
1540
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001541int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001542ivi_layout_surface_set_visibility(struct ivi_layout_surface *ivisurf,
1543 bool newVisibility)
1544{
1545 struct ivi_layout_surface_properties *prop = NULL;
1546
1547 if (ivisurf == NULL) {
1548 weston_log("ivi_layout_surface_set_visibility: invalid argument\n");
1549 return IVI_FAILED;
1550 }
1551
1552 prop = &ivisurf->pending.prop;
1553 prop->visibility = newVisibility;
1554
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001555 if (ivisurf->prop.visibility != newVisibility)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001556 prop->event_mask |= IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001557 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001558 prop->event_mask &= ~IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001559
1560 return IVI_SUCCEEDED;
1561}
1562
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001563int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001564ivi_layout_surface_set_opacity(struct ivi_layout_surface *ivisurf,
1565 wl_fixed_t opacity)
1566{
1567 struct ivi_layout_surface_properties *prop = NULL;
1568
Nobuhiko Tanibataa86226c2015-06-22 15:29:20 +09001569 if (ivisurf == NULL ||
1570 opacity < wl_fixed_from_double(0.0) ||
1571 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001572 weston_log("ivi_layout_surface_set_opacity: invalid argument\n");
1573 return IVI_FAILED;
1574 }
1575
1576 prop = &ivisurf->pending.prop;
1577 prop->opacity = opacity;
1578
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001579 if (ivisurf->prop.opacity != opacity)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001580 prop->event_mask |= IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001581 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001582 prop->event_mask &= ~IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001583
1584 return IVI_SUCCEEDED;
1585}
1586
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001587int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001588ivi_layout_surface_set_destination_rectangle(struct ivi_layout_surface *ivisurf,
1589 int32_t x, int32_t y,
1590 int32_t width, int32_t height)
1591{
1592 struct ivi_layout_surface_properties *prop = NULL;
1593
1594 if (ivisurf == NULL) {
1595 weston_log("ivi_layout_surface_set_destination_rectangle: invalid argument\n");
1596 return IVI_FAILED;
1597 }
1598
1599 prop = &ivisurf->pending.prop;
1600 prop->start_x = prop->dest_x;
1601 prop->start_y = prop->dest_y;
1602 prop->dest_x = x;
1603 prop->dest_y = y;
1604 prop->start_width = prop->dest_width;
1605 prop->start_height = prop->dest_height;
1606 prop->dest_width = width;
1607 prop->dest_height = height;
1608
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001609 if (ivisurf->prop.dest_x != x || ivisurf->prop.dest_y != y ||
1610 ivisurf->prop.dest_width != width ||
1611 ivisurf->prop.dest_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001612 prop->event_mask |= IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001613 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001614 prop->event_mask &= ~IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001615
1616 return IVI_SUCCEEDED;
1617}
1618
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001619static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001620ivi_layout_surface_set_orientation(struct ivi_layout_surface *ivisurf,
1621 enum wl_output_transform orientation)
1622{
1623 struct ivi_layout_surface_properties *prop = NULL;
1624
1625 if (ivisurf == NULL) {
1626 weston_log("ivi_layout_surface_set_orientation: invalid argument\n");
1627 return IVI_FAILED;
1628 }
1629
1630 prop = &ivisurf->pending.prop;
1631 prop->orientation = orientation;
1632
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001633 if (ivisurf->prop.orientation != orientation)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001634 prop->event_mask |= IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001635 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001636 prop->event_mask &= ~IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001637
1638 return IVI_SUCCEEDED;
1639}
1640
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001641static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001642ivi_layout_screen_add_layer(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001643 struct ivi_layout_layer *addlayer)
1644{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001645 struct ivi_layout_screen *iviscrn;
1646
1647 if (output == NULL || addlayer == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001648 weston_log("ivi_layout_screen_add_layer: invalid argument\n");
1649 return IVI_FAILED;
1650 }
1651
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001652 iviscrn = get_screen_from_output(output);
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001653
Ucan, Emre (ADITG/SW1)bb4ec0a2015-08-28 12:59:01 +00001654 if (addlayer->on_screen == iviscrn) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001655 weston_log("ivi_layout_screen_add_layer: addlayer is already available\n");
1656 return IVI_SUCCEEDED;
1657 }
1658
Ucan, Emre (ADITG/SW1)f46306f2016-03-16 13:37:07 +00001659 wl_list_remove(&addlayer->pending.link);
1660 wl_list_insert(&iviscrn->pending.layer_list, &addlayer->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001661
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001662 iviscrn->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001663
1664 return IVI_SUCCEEDED;
1665}
1666
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001667static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001668ivi_layout_screen_set_render_order(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001669 struct ivi_layout_layer **pLayer,
1670 const int32_t number)
1671{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001672 struct ivi_layout_screen *iviscrn;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001673 struct ivi_layout_layer *ivilayer = NULL;
1674 struct ivi_layout_layer *next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001675 int32_t i = 0;
1676
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001677 if (output == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001678 weston_log("ivi_layout_screen_set_render_order: invalid argument\n");
1679 return IVI_FAILED;
1680 }
1681
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001682 iviscrn = get_screen_from_output(output);
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001683
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001684 wl_list_for_each_safe(ivilayer, next,
1685 &iviscrn->pending.layer_list, pending.link) {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001686 wl_list_remove(&ivilayer->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001687 wl_list_init(&ivilayer->pending.link);
1688 }
1689
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001690 assert(wl_list_empty(&iviscrn->pending.layer_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001691
1692 for (i = 0; i < number; i++) {
Ucan, Emre (ADITG/SW1)4e221f02016-03-16 13:37:08 +00001693 wl_list_remove(&pLayer[i]->pending.link);
1694 wl_list_insert(&iviscrn->pending.layer_list,
1695 &pLayer[i]->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001696 }
1697
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001698 iviscrn->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001699
1700 return IVI_SUCCEEDED;
1701}
1702
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001703/**
1704 * This function is used by the additional ivi-module because of dumping ivi_surface sceenshot.
1705 * The ivi-module, e.g. ivi-controller.so, is in wayland-ivi-extension of Genivi's Layer Management.
1706 * This function is used to get the result of drawing by clients.
1707 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001708static struct weston_surface *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001709ivi_layout_surface_get_weston_surface(struct ivi_layout_surface *ivisurf)
1710{
1711 return ivisurf != NULL ? ivisurf->surface : NULL;
1712}
1713
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001714static int32_t
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09001715ivi_layout_surface_get_size(struct ivi_layout_surface *ivisurf,
1716 int32_t *width, int32_t *height,
1717 int32_t *stride)
1718{
1719 int32_t w;
1720 int32_t h;
1721 const size_t bytespp = 4; /* PIXMAN_a8b8g8r8 */
1722
1723 if (ivisurf == NULL || ivisurf->surface == NULL) {
1724 weston_log("%s: invalid argument\n", __func__);
1725 return IVI_FAILED;
1726 }
1727
1728 weston_surface_get_content_size(ivisurf->surface, &w, &h);
1729
1730 if (width != NULL)
1731 *width = w;
1732
1733 if (height != NULL)
1734 *height = h;
1735
1736 if (stride != NULL)
1737 *stride = w * bytespp;
1738
1739 return IVI_SUCCEEDED;
1740}
1741
1742static int32_t
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001743ivi_layout_layer_add_listener(struct ivi_layout_layer *ivilayer,
1744 struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001745{
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001746 if (ivilayer == NULL || listener == NULL) {
1747 weston_log("ivi_layout_layer_add_listener: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001748 return IVI_FAILED;
1749 }
1750
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001751 wl_signal_add(&ivilayer->property_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001752
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001753 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001754}
1755
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001756static const struct ivi_layout_surface_properties *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001757ivi_layout_get_properties_of_surface(struct ivi_layout_surface *ivisurf)
1758{
1759 if (ivisurf == NULL) {
1760 weston_log("ivi_layout_get_properties_of_surface: invalid argument\n");
1761 return NULL;
1762 }
1763
1764 return &ivisurf->prop;
1765}
1766
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001767static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001768ivi_layout_layer_add_surface(struct ivi_layout_layer *ivilayer,
1769 struct ivi_layout_surface *addsurf)
1770{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001771 struct ivi_layout_view *ivi_view;
1772
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001773 if (ivilayer == NULL || addsurf == NULL) {
1774 weston_log("ivi_layout_layer_add_surface: invalid argument\n");
1775 return IVI_FAILED;
1776 }
1777
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001778 ivi_view = get_ivi_view(ivilayer, addsurf);
1779 if (!ivi_view)
1780 ivi_view = ivi_view_create(ivilayer, addsurf);
1781 else if (ivi_view_is_rendered(ivi_view))
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001782 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001783
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001784 wl_list_remove(&ivi_view->pending_link);
1785 wl_list_insert(&ivilayer->pending.view_list, &ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001786
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +00001787 ivilayer->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001788
1789 return IVI_SUCCEEDED;
1790}
1791
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001792static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001793ivi_layout_layer_remove_surface(struct ivi_layout_layer *ivilayer,
1794 struct ivi_layout_surface *remsurf)
1795{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001796 struct ivi_layout_view *ivi_view;
1797
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001798 if (ivilayer == NULL || remsurf == NULL) {
1799 weston_log("ivi_layout_layer_remove_surface: invalid argument\n");
1800 return;
1801 }
1802
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001803 ivi_view = get_ivi_view(ivilayer, remsurf);
1804 if (ivi_view) {
1805 wl_list_remove(&ivi_view->pending_link);
1806 wl_list_init(&ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001807
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001808 ivilayer->order.dirty = 1;
1809 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001810}
1811
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001812static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001813ivi_layout_surface_set_source_rectangle(struct ivi_layout_surface *ivisurf,
1814 int32_t x, int32_t y,
1815 int32_t width, int32_t height)
1816{
1817 struct ivi_layout_surface_properties *prop = NULL;
1818
1819 if (ivisurf == NULL) {
1820 weston_log("ivi_layout_surface_set_source_rectangle: invalid argument\n");
1821 return IVI_FAILED;
1822 }
1823
1824 prop = &ivisurf->pending.prop;
1825 prop->source_x = x;
1826 prop->source_y = y;
1827 prop->source_width = width;
1828 prop->source_height = height;
1829
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001830 if (ivisurf->prop.source_x != x || ivisurf->prop.source_y != y ||
1831 ivisurf->prop.source_width != width ||
1832 ivisurf->prop.source_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001833 prop->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001834 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001835 prop->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001836
1837 return IVI_SUCCEEDED;
1838}
1839
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001840int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001841ivi_layout_commit_changes(void)
1842{
1843 struct ivi_layout *layout = get_instance();
1844
1845 commit_surface_list(layout);
1846 commit_layer_list(layout);
1847 commit_screen_list(layout);
1848
1849 commit_transition(layout);
1850
1851 commit_changes(layout);
1852 send_prop(layout);
1853 weston_compositor_schedule_repaint(layout->compositor);
1854
1855 return IVI_SUCCEEDED;
1856}
1857
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001858static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001859ivi_layout_layer_set_transition(struct ivi_layout_layer *ivilayer,
1860 enum ivi_layout_transition_type type,
1861 uint32_t duration)
1862{
1863 if (ivilayer == NULL) {
1864 weston_log("%s: invalid argument\n", __func__);
1865 return -1;
1866 }
1867
1868 ivilayer->pending.prop.transition_type = type;
1869 ivilayer->pending.prop.transition_duration = duration;
1870
1871 return 0;
1872}
1873
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001874static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001875ivi_layout_layer_set_fade_info(struct ivi_layout_layer* ivilayer,
1876 uint32_t is_fade_in,
1877 double start_alpha, double end_alpha)
1878{
1879 if (ivilayer == NULL) {
1880 weston_log("%s: invalid argument\n", __func__);
1881 return -1;
1882 }
1883
1884 ivilayer->pending.prop.is_fade_in = is_fade_in;
1885 ivilayer->pending.prop.start_alpha = start_alpha;
1886 ivilayer->pending.prop.end_alpha = end_alpha;
1887
1888 return 0;
1889}
1890
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001891static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001892ivi_layout_surface_set_transition_duration(struct ivi_layout_surface *ivisurf,
1893 uint32_t duration)
1894{
1895 struct ivi_layout_surface_properties *prop;
1896
1897 if (ivisurf == NULL) {
1898 weston_log("%s: invalid argument\n", __func__);
1899 return -1;
1900 }
1901
1902 prop = &ivisurf->pending.prop;
1903 prop->transition_duration = duration*10;
1904 return 0;
1905}
1906
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001907static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001908ivi_layout_surface_set_transition(struct ivi_layout_surface *ivisurf,
1909 enum ivi_layout_transition_type type,
1910 uint32_t duration)
1911{
1912 struct ivi_layout_surface_properties *prop;
1913
1914 if (ivisurf == NULL) {
1915 weston_log("%s: invalid argument\n", __func__);
1916 return -1;
1917 }
1918
1919 prop = &ivisurf->pending.prop;
1920 prop->transition_type = type;
1921 prop->transition_duration = duration;
1922 return 0;
1923}
1924
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09001925static int32_t
1926ivi_layout_surface_dump(struct weston_surface *surface,
1927 void *target, size_t size,int32_t x, int32_t y,
1928 int32_t width, int32_t height)
1929{
1930 int result = 0;
1931
1932 if (surface == NULL) {
1933 weston_log("%s: invalid argument\n", __func__);
1934 return IVI_FAILED;
1935 }
1936
1937 result = weston_surface_copy_content(
1938 surface, target, size,
1939 x, y, width, height);
1940
1941 return result == 0 ? IVI_SUCCEEDED : IVI_FAILED;
1942}
1943
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001944/**
1945 * methods of interaction between ivi-shell with ivi-layout
1946 */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001947
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001948void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001949ivi_layout_surface_configure(struct ivi_layout_surface *ivisurf,
1950 int32_t width, int32_t height)
1951{
1952 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001953
Nobuhiko Tanibatae6cc9972015-04-27 16:54:01 +09001954 /* emit callback which is set by ivi-layout api user */
1955 wl_signal_emit(&layout->surface_notification.configure_changed,
1956 ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001957}
1958
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001959struct ivi_layout_surface*
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001960ivi_layout_surface_create(struct weston_surface *wl_surface,
1961 uint32_t id_surface)
1962{
1963 struct ivi_layout *layout = get_instance();
1964 struct ivi_layout_surface *ivisurf = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001965
1966 if (wl_surface == NULL) {
1967 weston_log("ivi_layout_surface_create: invalid argument\n");
1968 return NULL;
1969 }
1970
1971 ivisurf = get_surface(&layout->surface_list, id_surface);
1972 if (ivisurf != NULL) {
1973 if (ivisurf->surface != NULL) {
1974 weston_log("id_surface(%d) is already created\n", id_surface);
1975 return NULL;
1976 }
1977 }
1978
1979 ivisurf = calloc(1, sizeof *ivisurf);
1980 if (ivisurf == NULL) {
1981 weston_log("fails to allocate memory\n");
1982 return NULL;
1983 }
1984
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001985 wl_signal_init(&ivisurf->property_changed);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001986 ivisurf->id_surface = id_surface;
1987 ivisurf->layout = layout;
1988
1989 ivisurf->surface = wl_surface;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001990
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001991 ivisurf->surface->width_from_buffer = 0;
1992 ivisurf->surface->height_from_buffer = 0;
1993
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001994 init_surface_properties(&ivisurf->prop);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001995
1996 ivisurf->pending.prop = ivisurf->prop;
1997 wl_list_init(&ivisurf->pending.link);
1998
1999 wl_list_init(&ivisurf->order.link);
2000 wl_list_init(&ivisurf->order.layer_list);
2001
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00002002 wl_list_init(&ivisurf->view_list);
2003
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002004 wl_list_insert(&layout->surface_list, &ivisurf->link);
2005
2006 wl_signal_emit(&layout->surface_notification.created, ivisurf);
2007
2008 return ivisurf;
2009}
2010
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002011void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002012ivi_layout_init_with_compositor(struct weston_compositor *ec)
2013{
2014 struct ivi_layout *layout = get_instance();
2015
2016 layout->compositor = ec;
2017
2018 wl_list_init(&layout->surface_list);
2019 wl_list_init(&layout->layer_list);
2020 wl_list_init(&layout->screen_list);
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00002021 wl_list_init(&layout->view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002022
2023 wl_signal_init(&layout->layer_notification.created);
2024 wl_signal_init(&layout->layer_notification.removed);
2025
2026 wl_signal_init(&layout->surface_notification.created);
2027 wl_signal_init(&layout->surface_notification.removed);
2028 wl_signal_init(&layout->surface_notification.configure_changed);
2029
2030 /* Add layout_layer at the last of weston_compositor.layer_list */
2031 weston_layer_init(&layout->layout_layer, ec->layer_list.prev);
2032
2033 create_screen(ec);
2034
2035 layout->transitions = ivi_layout_transition_set_create(ec);
2036 wl_list_init(&layout->pending_transition_list);
2037}
2038
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002039static struct ivi_layout_interface ivi_layout_interface = {
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002040 /**
2041 * commit all changes
2042 */
2043 .commit_changes = ivi_layout_commit_changes,
2044
2045 /**
2046 * surface controller interfaces
2047 */
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00002048 .add_listener_create_surface = ivi_layout_add_listener_create_surface,
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00002049 .add_listener_remove_surface = ivi_layout_add_listener_remove_surface,
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00002050 .add_listener_configure_surface = ivi_layout_add_listener_configure_surface,
Pekka Paalaneneaa43fc2016-04-12 16:06:58 +03002051 .get_surface = shell_get_ivi_layout_surface,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002052 .get_surfaces = ivi_layout_get_surfaces,
2053 .get_id_of_surface = ivi_layout_get_id_of_surface,
2054 .get_surface_from_id = ivi_layout_get_surface_from_id,
2055 .get_properties_of_surface = ivi_layout_get_properties_of_surface,
2056 .get_surfaces_on_layer = ivi_layout_get_surfaces_on_layer,
2057 .surface_set_visibility = ivi_layout_surface_set_visibility,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002058 .surface_set_opacity = ivi_layout_surface_set_opacity,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002059 .surface_set_source_rectangle = ivi_layout_surface_set_source_rectangle,
2060 .surface_set_destination_rectangle = ivi_layout_surface_set_destination_rectangle,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002061 .surface_set_orientation = ivi_layout_surface_set_orientation,
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00002062 .surface_add_listener = ivi_layout_surface_add_listener,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002063 .surface_get_weston_surface = ivi_layout_surface_get_weston_surface,
2064 .surface_set_transition = ivi_layout_surface_set_transition,
2065 .surface_set_transition_duration = ivi_layout_surface_set_transition_duration,
2066
2067 /**
2068 * layer controller interfaces
2069 */
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +00002070 .add_listener_create_layer = ivi_layout_add_listener_create_layer,
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +00002071 .add_listener_remove_layer = ivi_layout_add_listener_remove_layer,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002072 .layer_create_with_dimension = ivi_layout_layer_create_with_dimension,
Nobuhiko Tanibata3aa8aed2015-06-22 15:32:23 +09002073 .layer_destroy = ivi_layout_layer_destroy,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002074 .get_layers = ivi_layout_get_layers,
2075 .get_id_of_layer = ivi_layout_get_id_of_layer,
2076 .get_layer_from_id = ivi_layout_get_layer_from_id,
2077 .get_properties_of_layer = ivi_layout_get_properties_of_layer,
2078 .get_layers_under_surface = ivi_layout_get_layers_under_surface,
2079 .get_layers_on_screen = ivi_layout_get_layers_on_screen,
2080 .layer_set_visibility = ivi_layout_layer_set_visibility,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002081 .layer_set_opacity = ivi_layout_layer_set_opacity,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002082 .layer_set_source_rectangle = ivi_layout_layer_set_source_rectangle,
2083 .layer_set_destination_rectangle = ivi_layout_layer_set_destination_rectangle,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002084 .layer_set_orientation = ivi_layout_layer_set_orientation,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002085 .layer_add_surface = ivi_layout_layer_add_surface,
2086 .layer_remove_surface = ivi_layout_layer_remove_surface,
2087 .layer_set_render_order = ivi_layout_layer_set_render_order,
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00002088 .layer_add_listener = ivi_layout_layer_add_listener,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002089 .layer_set_transition = ivi_layout_layer_set_transition,
2090
2091 /**
Ucan, Emre (ADITG/SW1)6d89b1c2016-03-17 15:30:49 +00002092 * screen controller interfaces
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002093 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002094 .get_screens_under_layer = ivi_layout_get_screens_under_layer,
2095 .screen_add_layer = ivi_layout_screen_add_layer,
2096 .screen_set_render_order = ivi_layout_screen_set_render_order,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002097
2098 /**
2099 * animation
2100 */
2101 .transition_move_layer_cancel = ivi_layout_transition_move_layer_cancel,
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09002102 .layer_set_fade_info = ivi_layout_layer_set_fade_info,
2103
2104 /**
2105 * surface content dumping for debugging
2106 */
2107 .surface_get_size = ivi_layout_surface_get_size,
2108 .surface_dump = ivi_layout_surface_dump,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002109};
2110
2111int
2112load_controller_modules(struct weston_compositor *compositor, const char *modules,
2113 int *argc, char *argv[])
2114{
2115 const char *p, *end;
2116 char buffer[256];
2117 int (*controller_module_init)(struct weston_compositor *compositor,
2118 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002119 const struct ivi_layout_interface *interface,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002120 size_t interface_version);
2121
2122 if (modules == NULL)
2123 return 0;
2124
2125 p = modules;
2126 while (*p) {
2127 end = strchrnul(p, ',');
2128 snprintf(buffer, sizeof buffer, "%.*s", (int)(end - p), p);
2129
Giulio Camuffo179fcda2016-06-02 21:48:14 +03002130 controller_module_init = wet_load_module(buffer, "controller_module_init");
Pekka Paalanen97246c02015-03-26 15:47:29 +02002131 if (!controller_module_init)
2132 return -1;
2133
2134 if (controller_module_init(compositor, argc, argv,
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002135 &ivi_layout_interface,
2136 sizeof(struct ivi_layout_interface)) != 0) {
Pekka Paalanen97246c02015-03-26 15:47:29 +02002137 weston_log("ivi-shell: Initialization of controller module fails");
2138 return -1;
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002139 }
2140
2141 p = end;
2142 while (*p == ',')
2143 p++;
2144 }
2145
2146 return 0;
2147}