blob: ada7a7c6c3f8a1d66498c7e593a6d3e0ba514304 [file] [log] [blame]
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001/*
2 * Copyright (C) 2013 DENSO CORPORATION
3 *
Bryce Harringtonaf637c22015-06-11 12:55:55 -07004 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090011 *
Bryce Harringtonaf637c22015-06-11 12:55:55 -070012 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial
14 * portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090024 */
25
26/**
27 * Implementation of ivi-layout library. The actual view on ivi_screen is
Bryce Harringtone6da35d2016-05-19 17:35:02 -070028 * not updated until ivi_layout_commit_changes is called. An overview from
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090029 * calling API for updating properties of ivi_surface/ivi_layer to asking
30 * compositor to compose them by using weston_compositor_schedule_repaint,
31 * 0/ initialize this library by ivi_layout_init_with_compositor
32 * with (struct weston_compositor *ec) from ivi-shell.
Bryce Harringtone6da35d2016-05-19 17:35:02 -070033 * 1/ When an API for updating properties of ivi_surface/ivi_layer, it updates
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090034 * pending prop of ivi_surface/ivi_layer/ivi_screen which are structure to
35 * store properties.
Bryce Harringtone6da35d2016-05-19 17:35:02 -070036 * 2/ Before calling commitChanges, in case of calling an API to get a property,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090037 * return current property, not pending property.
38 * 3/ At the timing of calling ivi_layout_commitChanges, pending properties
39 * are applied to properties.
40 *
41 * *) ivi_layout_commitChanges is also called by transition animation
42 * per each frame. See ivi-layout-transition.c in details. Transition
43 * animation interpolates frames between previous properties of ivi_surface
44 * and new ones.
Bryce Harringtone6da35d2016-05-19 17:35:02 -070045 * For example, when a property of ivi_surface is changed from invisibile
46 * to visibile, it behaves like fade-in. When ivi_layout_commitChange is
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090047 * called during transition animation, it cancels the transition and
48 * re-start transition to new properties from current properties of final
Bryce Harringtone6da35d2016-05-19 17:35:02 -070049 * frame just before the cancellation.
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090050 *
51 * 4/ According properties, set transformation by using weston_matrix and
52 * weston_view per ivi_surfaces and ivi_layers in while loop.
53 * 5/ Set damage and trigger transform by using weston_view_geometry_dirty.
54 * 6/ Notify update of properties.
55 * 7/ Trigger composition by weston_compositor_schedule_repaint.
56 *
57 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +090058#include "config.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090059
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090060#include <string.h>
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +000061#include <assert.h>
Jussi Kukkonen649bbce2016-07-19 14:16:27 +030062#include <stdint.h>
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090063
Pekka Paalanen58f98c92016-06-03 16:45:21 +030064#include "compositor/weston.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090065#include "compositor.h"
Pekka Paalanen1f821932016-03-15 16:57:51 +020066#include "ivi-shell.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090067#include "ivi-layout-export.h"
68#include "ivi-layout-private.h"
Pekka Paalanen32ca7912016-03-15 17:21:00 +020069#include "ivi-layout-shell.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090070
Jon Cruz867d50e2015-06-15 15:37:10 -070071#include "shared/helpers.h"
Jon Cruz4678bab2015-06-15 15:37:07 -070072#include "shared/os-compatibility.h"
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +090073
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +090074#define max(a, b) ((a) > (b) ? (a) : (b))
75
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090076struct ivi_layout;
77
78struct ivi_layout_screen {
Ucan, Emre (ADITG/SW1)7da38232016-07-01 09:34:50 +000079 struct wl_list link; /* ivi_layout::screen_list */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090080
81 struct ivi_layout *layout;
82 struct weston_output *output;
83
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090084 struct {
Ucan, Emre (ADITG/SW1)7da38232016-07-01 09:34:50 +000085 struct wl_list layer_list; /* ivi_layout_layer::pending.link */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090086 } pending;
87
88 struct {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +000089 int dirty;
Ucan, Emre (ADITG/SW1)7da38232016-07-01 09:34:50 +000090 struct wl_list layer_list; /* ivi_layout_layer::order.link */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090091 } order;
92};
93
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +090094struct ivi_rectangle
95{
96 int32_t x;
97 int32_t y;
98 int32_t width;
99 int32_t height;
100};
101
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900102static struct ivi_layout ivilayout = {0};
103
104struct ivi_layout *
105get_instance(void)
106{
107 return &ivilayout;
108}
109
110/**
Bryce Harringtone6da35d2016-05-19 17:35:02 -0700111 * Internal API to add/remove an ivi_layer to/from ivi_screen.
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900112 */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900113static struct ivi_layout_surface *
114get_surface(struct wl_list *surf_list, uint32_t id_surface)
115{
116 struct ivi_layout_surface *ivisurf;
117
118 wl_list_for_each(ivisurf, surf_list, link) {
119 if (ivisurf->id_surface == id_surface) {
120 return ivisurf;
121 }
122 }
123
124 return NULL;
125}
126
127static struct ivi_layout_layer *
128get_layer(struct wl_list *layer_list, uint32_t id_layer)
129{
130 struct ivi_layout_layer *ivilayer;
131
132 wl_list_for_each(ivilayer, layer_list, link) {
133 if (ivilayer->id_layer == id_layer) {
134 return ivilayer;
135 }
136 }
137
138 return NULL;
139}
140
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000141static bool
142ivi_view_is_rendered(struct ivi_layout_view *view)
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000143{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000144 return !wl_list_empty(&view->order_link);
145}
146
147static void
148ivi_view_destroy(struct ivi_layout_view *ivi_view)
149{
150 wl_list_remove(&ivi_view->transform.link);
151 wl_list_remove(&ivi_view->link);
152 wl_list_remove(&ivi_view->surf_link);
153 wl_list_remove(&ivi_view->pending_link);
154 wl_list_remove(&ivi_view->order_link);
155
156 weston_view_destroy(ivi_view->view);
157
158 free(ivi_view);
159}
160
161static struct ivi_layout_view*
162ivi_view_create(struct ivi_layout_layer *ivilayer,
163 struct ivi_layout_surface *ivisurf)
164{
165 struct ivi_layout_view *ivi_view;
166
167 ivi_view = calloc(1, sizeof *ivi_view);
168 if (ivi_view == NULL) {
169 weston_log("fails to allocate memory\n");
170 return NULL;
171 }
172
173 ivi_view->view = weston_view_create(ivisurf->surface);
174 if (ivi_view->view == NULL) {
175 weston_log("fails to allocate memory\n");
176 return NULL;
177 }
178
179 weston_matrix_init(&ivi_view->transform.matrix);
180 wl_list_init(&ivi_view->transform.link);
181
182 ivi_view->ivisurf = ivisurf;
183 ivi_view->on_layer = ivilayer;
184 wl_list_insert(&ivilayer->layout->view_list,
185 &ivi_view->link);
186 wl_list_insert(&ivisurf->view_list,
187 &ivi_view->surf_link);
188
189 wl_list_init(&ivi_view->pending_link);
190 wl_list_init(&ivi_view->order_link);
191
192 return ivi_view;
193}
194
195static struct ivi_layout_view *
196get_ivi_view(struct ivi_layout_layer *ivilayer,
197 struct ivi_layout_surface *ivisurf)
198{
199 struct ivi_layout_view *ivi_view;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000200
201 assert(ivisurf->surface != NULL);
202
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000203 wl_list_for_each(ivi_view, &ivisurf->view_list, surf_link) {
204 if (ivi_view->on_layer == ivilayer)
205 return ivi_view;
206 }
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000207
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000208 return NULL;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000209}
210
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +0000211static struct ivi_layout_screen *
212get_screen_from_output(struct weston_output *output)
213{
214 struct ivi_layout *layout = get_instance();
215 struct ivi_layout_screen *iviscrn = NULL;
216
217 wl_list_for_each(iviscrn, &layout->screen_list, link) {
218 if (iviscrn->output == output)
219 return iviscrn;
220 }
221
222 return NULL;
223}
224
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900225/**
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900226 * Called at destruction of wl_surface/ivi_surface
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900227 */
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900228void
229ivi_layout_surface_destroy(struct ivi_layout_surface *ivisurf)
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900230{
231 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000232 struct ivi_layout_view *ivi_view ,*next;
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900233
234 if (ivisurf == NULL) {
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900235 weston_log("%s: invalid argument\n", __func__);
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900236 return;
237 }
238
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900239 wl_list_remove(&ivisurf->link);
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900240
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000241 wl_list_for_each_safe(ivi_view, next, &ivisurf->view_list, surf_link) {
242 ivi_view_destroy(ivi_view);
243 }
244
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900245 wl_signal_emit(&layout->surface_notification.removed, ivisurf);
246
Mateusz Polroladada6e32016-03-09 09:13:26 +0000247 ivi_layout_remove_all_surface_transitions(ivisurf);
248
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900249 free(ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900250}
251
252/**
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900253 * Internal API to initialize ivi_screens found from output_list of weston_compositor.
254 * Called by ivi_layout_init_with_compositor.
255 */
256static void
257create_screen(struct weston_compositor *ec)
258{
259 struct ivi_layout *layout = get_instance();
260 struct ivi_layout_screen *iviscrn = NULL;
261 struct weston_output *output = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900262
263 wl_list_for_each(output, &ec->output_list, link) {
264 iviscrn = calloc(1, sizeof *iviscrn);
265 if (iviscrn == NULL) {
266 weston_log("fails to allocate memory\n");
267 continue;
268 }
269
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900270 iviscrn->layout = layout;
271
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900272 iviscrn->output = output;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900273
274 wl_list_init(&iviscrn->pending.layer_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900275
276 wl_list_init(&iviscrn->order.layer_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900277
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900278 wl_list_insert(&layout->screen_list, &iviscrn->link);
279 }
280}
281
282/**
283 * Internal APIs to initialize properties of ivi_surface/ivi_layer when they are created.
284 */
285static void
286init_layer_properties(struct ivi_layout_layer_properties *prop,
287 int32_t width, int32_t height)
288{
289 memset(prop, 0, sizeof *prop);
290 prop->opacity = wl_fixed_from_double(1.0);
291 prop->source_width = width;
292 prop->source_height = height;
293 prop->dest_width = width;
294 prop->dest_height = height;
295}
296
297static void
298init_surface_properties(struct ivi_layout_surface_properties *prop)
299{
300 memset(prop, 0, sizeof *prop);
301 prop->opacity = wl_fixed_from_double(1.0);
Nobuhiko Tanibatae259a7a2015-04-27 17:02:54 +0900302 /*
Bryce Harringtone6da35d2016-05-19 17:35:02 -0700303 * FIXME: this shall be fixed by ivi-layout-transition.
Nobuhiko Tanibatae259a7a2015-04-27 17:02:54 +0900304 */
305 prop->dest_width = 1;
306 prop->dest_height = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900307}
308
309/**
310 * Internal APIs to be called from ivi_layout_commit_changes.
311 */
312static void
313update_opacity(struct ivi_layout_layer *ivilayer,
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000314 struct ivi_layout_surface *ivisurf,
315 struct weston_view *view)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900316{
317 double layer_alpha = wl_fixed_to_double(ivilayer->prop.opacity);
318 double surf_alpha = wl_fixed_to_double(ivisurf->prop.opacity);
319
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000320 view->alpha = layer_alpha * surf_alpha;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900321}
322
323static void
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900324get_rotate_values(enum wl_output_transform orientation,
325 float *v_sin,
326 float *v_cos)
327{
328 switch (orientation) {
329 case WL_OUTPUT_TRANSFORM_90:
330 *v_sin = 1.0f;
331 *v_cos = 0.0f;
332 break;
333 case WL_OUTPUT_TRANSFORM_180:
334 *v_sin = 0.0f;
335 *v_cos = -1.0f;
336 break;
337 case WL_OUTPUT_TRANSFORM_270:
338 *v_sin = -1.0f;
339 *v_cos = 0.0f;
340 break;
341 case WL_OUTPUT_TRANSFORM_NORMAL:
342 default:
343 *v_sin = 0.0f;
344 *v_cos = 1.0f;
345 break;
346 }
347}
348
349static void
350get_scale(enum wl_output_transform orientation,
351 float dest_width,
352 float dest_height,
353 float source_width,
354 float source_height,
355 float *scale_x,
356 float *scale_y)
357{
358 switch (orientation) {
359 case WL_OUTPUT_TRANSFORM_90:
360 *scale_x = dest_width / source_height;
361 *scale_y = dest_height / source_width;
362 break;
363 case WL_OUTPUT_TRANSFORM_180:
364 *scale_x = dest_width / source_width;
365 *scale_y = dest_height / source_height;
366 break;
367 case WL_OUTPUT_TRANSFORM_270:
368 *scale_x = dest_width / source_height;
369 *scale_y = dest_height / source_width;
370 break;
371 case WL_OUTPUT_TRANSFORM_NORMAL:
372 default:
373 *scale_x = dest_width / source_width;
374 *scale_y = dest_height / source_height;
375 break;
376 }
377}
378
379static void
380calc_transformation_matrix(struct ivi_rectangle *source_rect,
381 struct ivi_rectangle *dest_rect,
382 enum wl_output_transform orientation,
383 struct weston_matrix *m)
384{
385 float source_center_x;
386 float source_center_y;
387 float vsin;
388 float vcos;
389 float scale_x;
390 float scale_y;
391 float translate_x;
392 float translate_y;
393
394 source_center_x = source_rect->x + source_rect->width * 0.5f;
395 source_center_y = source_rect->y + source_rect->height * 0.5f;
396 weston_matrix_translate(m, -source_center_x, -source_center_y, 0.0f);
397
398 get_rotate_values(orientation, &vsin, &vcos);
399 weston_matrix_rotate_xy(m, vcos, vsin);
400
401 get_scale(orientation,
402 dest_rect->width,
403 dest_rect->height,
404 source_rect->width,
405 source_rect->height,
406 &scale_x,
407 &scale_y);
408 weston_matrix_scale(m, scale_x, scale_y, 1.0f);
409
410 translate_x = dest_rect->width * 0.5f + dest_rect->x;
411 translate_y = dest_rect->height * 0.5f + dest_rect->y;
412 weston_matrix_translate(m, translate_x, translate_y, 0.0f);
413}
414
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900415/*
416 * This computes intersected rect_output from two ivi_rectangles
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900417 */
418static void
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900419ivi_rectangle_intersect(const struct ivi_rectangle *rect1,
420 const struct ivi_rectangle *rect2,
421 struct ivi_rectangle *rect_output)
422{
423 int32_t rect1_right = rect1->x + rect1->width;
424 int32_t rect1_bottom = rect1->y + rect1->height;
425 int32_t rect2_right = rect2->x + rect2->width;
426 int32_t rect2_bottom = rect2->y + rect2->height;
427
428 rect_output->x = max(rect1->x, rect2->x);
429 rect_output->y = max(rect1->y, rect2->y);
430 rect_output->width = rect1_right < rect2_right ?
431 rect1_right - rect_output->x :
432 rect2_right - rect_output->x;
433 rect_output->height = rect1_bottom < rect2_bottom ?
434 rect1_bottom - rect_output->y :
435 rect2_bottom - rect_output->y;
436
437 if (rect_output->width < 0 || rect_output->height < 0) {
438 rect_output->width = 0;
439 rect_output->height = 0;
440 }
441}
442
443/*
444 * Transform rect_input by the inverse of matrix, intersect with boundingbox,
445 * and store the result in rect_output.
446 * The boundingbox must be given in the same coordinate space as rect_output.
447 * Additionally, there are the following restrictions on the matrix:
448 * - no projective transformations
449 * - no skew
450 * - only multiples of 90-degree rotations supported
451 *
452 * In failure case of weston_matrix_invert, rect_output is set to boundingbox
453 * as a fail-safe with log.
454 */
455static void
456calc_inverse_matrix_transform(const struct weston_matrix *matrix,
457 const struct ivi_rectangle *rect_input,
458 const struct ivi_rectangle *boundingbox,
459 struct ivi_rectangle *rect_output)
460{
461 struct weston_matrix m;
462 struct weston_vector top_left;
463 struct weston_vector bottom_right;
464
465 assert(boundingbox != rect_output);
466
467 if (weston_matrix_invert(&m, matrix) < 0) {
468 weston_log("ivi-shell: calc_inverse_matrix_transform fails to invert a matrix.\n");
469 weston_log("ivi-shell: boundingbox is set to the rect_output.\n");
470 rect_output->x = boundingbox->x;
471 rect_output->y = boundingbox->y;
472 rect_output->width = boundingbox->width;
473 rect_output->height = boundingbox->height;
474 }
475
476 /* The vectors and matrices involved will always produce f[3] == 1.0. */
477 top_left.f[0] = rect_input->x;
478 top_left.f[1] = rect_input->y;
479 top_left.f[2] = 0.0f;
480 top_left.f[3] = 1.0f;
481
482 bottom_right.f[0] = rect_input->x + rect_input->width;
483 bottom_right.f[1] = rect_input->y + rect_input->height;
484 bottom_right.f[2] = 0.0f;
485 bottom_right.f[3] = 1.0f;
486
487 weston_matrix_transform(&m, &top_left);
488 weston_matrix_transform(&m, &bottom_right);
489
490 if (top_left.f[0] < bottom_right.f[0]) {
491 rect_output->x = top_left.f[0];
492 rect_output->width = bottom_right.f[0] - rect_output->x;
493 } else {
494 rect_output->x = bottom_right.f[0];
495 rect_output->width = top_left.f[0] - rect_output->x;
496 }
497
498 if (top_left.f[1] < bottom_right.f[1]) {
499 rect_output->y = top_left.f[1];
500 rect_output->height = bottom_right.f[1] - rect_output->y;
501 } else {
502 rect_output->y = bottom_right.f[1];
503 rect_output->height = top_left.f[1] - rect_output->y;
504 }
505
506 ivi_rectangle_intersect(rect_output, boundingbox, rect_output);
507}
508
509/**
510 * This computes the whole transformation matrix:m from surface-local
Yong Bakose0698712016-04-28 11:59:08 -0500511 * coordinates to multi-screen coordinates, which are global coordinates.
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900512 * It is assumed that weston_view::geometry.{x,y} are zero.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900513 *
Bryce Harringtone6da35d2016-05-19 17:35:02 -0700514 * Additionally, this computes the mask on surface-local coordinates as an
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900515 * ivi_rectangle. This can be set to weston_view_set_mask.
516 *
517 * The mask is computed by following steps
Yong Bakose0698712016-04-28 11:59:08 -0500518 * - destination rectangle of layer is transformed to multi-screen coordinates,
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900519 * global coordinates. This is done by adding weston_output.{x,y} in simple
520 * because there is no scaled and rotated transformation.
Yong Bakose0698712016-04-28 11:59:08 -0500521 * - destination rectangle of layer in multi-screen coordinates needs to be
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900522 * intersected inside of a screen the layer is assigned to. This is because
523 * overlapped region of weston surface in another screen shall not be
524 * displayed according to ivi use case.
525 * - destination rectangle of layer
Yong Bakose0698712016-04-28 11:59:08 -0500526 * - in multi-screen coordinates,
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900527 * - and intersected inside of an assigned screen,
Yong Bakose0698712016-04-28 11:59:08 -0500528 * is inversed to surface-local coordinates by inversed matrix:m.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900529 * - the area is intersected by intersected area between weston_surface and
530 * source rectangle of ivi_surface.
531 */
532static void
533calc_surface_to_global_matrix_and_mask_to_weston_surface(
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900534 struct ivi_layout_screen *iviscrn,
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900535 struct ivi_layout_layer *ivilayer,
536 struct ivi_layout_surface *ivisurf,
537 struct weston_matrix *m,
538 struct ivi_rectangle *result)
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900539{
540 const struct ivi_layout_surface_properties *sp = &ivisurf->prop;
541 const struct ivi_layout_layer_properties *lp = &ivilayer->prop;
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900542 struct weston_output *output = iviscrn->output;
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900543 struct ivi_rectangle weston_surface_rect = { 0,
544 0,
545 ivisurf->surface->width,
546 ivisurf->surface->height };
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900547 struct ivi_rectangle surface_source_rect = { sp->source_x,
548 sp->source_y,
549 sp->source_width,
550 sp->source_height };
551 struct ivi_rectangle surface_dest_rect = { sp->dest_x,
552 sp->dest_y,
553 sp->dest_width,
554 sp->dest_height };
555 struct ivi_rectangle layer_source_rect = { lp->source_x,
556 lp->source_y,
557 lp->source_width,
558 lp->source_height };
559 struct ivi_rectangle layer_dest_rect = { lp->dest_x,
560 lp->dest_y,
561 lp->dest_width,
562 lp->dest_height };
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900563 struct ivi_rectangle screen_dest_rect = { output->x,
564 output->y,
565 output->width,
566 output->height };
567 struct ivi_rectangle layer_dest_rect_in_global =
568 { lp->dest_x + output->x,
569 lp->dest_y + output->y,
570 lp->dest_width,
571 lp->dest_height };
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900572 struct ivi_rectangle surface_result;
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900573 struct ivi_rectangle layer_dest_rect_in_global_intersected;
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900574
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900575 /*
576 * the whole transformation matrix:m from surface-local
577 * coordinates to global coordinates, which is computed by
578 * two steps,
579 * - surface-local coordinates to layer-local coordinates
Yong Bakose0698712016-04-28 11:59:08 -0500580 * - layer-local coordinates to single screen-local coordinates
581 * - single screen-local coordinates to multi-screen coordinates,
582 * which are global coordinates.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900583 */
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900584 calc_transformation_matrix(&surface_source_rect,
585 &surface_dest_rect,
586 sp->orientation, m);
587
588 calc_transformation_matrix(&layer_source_rect,
589 &layer_dest_rect,
590 lp->orientation, m);
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900591
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900592 weston_matrix_translate(m, output->x, output->y, 0.0f);
593
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900594 /* this intersected ivi_rectangle would be used for masking
595 * weston_surface
596 */
597 ivi_rectangle_intersect(&surface_source_rect, &weston_surface_rect,
598 &surface_result);
599
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900600 /*
601 * destination rectangle of layer in multi screens coordinate
602 * is intersected to avoid displaying outside of an assigned screen.
603 */
604 ivi_rectangle_intersect(&layer_dest_rect_in_global, &screen_dest_rect,
605 &layer_dest_rect_in_global_intersected);
606
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900607 /* calc masking area of weston_surface from m */
608 calc_inverse_matrix_transform(m,
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900609 &layer_dest_rect_in_global_intersected,
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900610 &surface_result,
611 result);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900612}
613
614static void
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900615update_prop(struct ivi_layout_screen *iviscrn,
616 struct ivi_layout_layer *ivilayer,
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000617 struct ivi_layout_view *ivi_view)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900618{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000619 struct ivi_layout_surface *ivisurf;
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900620 struct ivi_rectangle r;
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900621 bool can_calc = true;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900622
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000623 assert(ivi_view->on_layer == ivilayer);
624
625 ivisurf = ivi_view->ivisurf;
626
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900627 /*In case of no prop change, this just returns*/
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000628 if (!ivilayer->prop.event_mask && !ivisurf->prop.event_mask)
Nobuhiko Tanibata4c1dbf72015-07-15 13:55:50 +0900629 return;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900630
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000631 update_opacity(ivilayer, ivisurf, ivi_view->view);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900632
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900633 if (ivisurf->prop.source_width == 0 || ivisurf->prop.source_height == 0) {
634 weston_log("ivi-shell: source rectangle is not yet set by ivi_layout_surface_set_source_rectangle\n");
635 can_calc = false;
636 }
637
638 if (ivisurf->prop.dest_width == 0 || ivisurf->prop.dest_height == 0) {
639 weston_log("ivi-shell: destination rectangle is not yet set by ivi_layout_surface_set_destination_rectangle\n");
640 can_calc = false;
641 }
642
643 if (can_calc) {
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000644 wl_list_remove(&ivi_view->transform.link);
645 weston_matrix_init(&ivi_view->transform.matrix);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900646
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900647 calc_surface_to_global_matrix_and_mask_to_weston_surface(
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000648 iviscrn, ivilayer, ivisurf, &ivi_view->transform.matrix, &r);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900649
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000650 weston_view_set_mask(ivi_view->view, r.x, r.y, r.width, r.height);
651 wl_list_insert(&ivi_view->view->geometry.transformation_list,
652 &ivi_view->transform.link);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900653
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000654 weston_view_set_transform_parent(ivi_view->view, NULL);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900655 }
656
657 ivisurf->update_count++;
658
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000659 weston_view_geometry_dirty(ivi_view->view);
Nobuhiko Tanibata4c1dbf72015-07-15 13:55:50 +0900660
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000661 weston_surface_damage(ivisurf->surface);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900662}
663
664static void
665commit_changes(struct ivi_layout *layout)
666{
667 struct ivi_layout_screen *iviscrn = NULL;
668 struct ivi_layout_layer *ivilayer = NULL;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000669 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900670
671 wl_list_for_each(iviscrn, &layout->screen_list, link) {
672 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900673 /*
674 * If ivilayer is invisible, weston_view of ivisurf doesn't
675 * need to be modified.
676 */
677 if (ivilayer->prop.visibility == false)
678 continue;
679
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000680 wl_list_for_each(ivi_view, &ivilayer->order.view_list, order_link) {
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900681 /*
682 * If ivilayer is invisible, weston_view of ivisurf doesn't
683 * need to be modified.
684 */
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000685 if (ivi_view->ivisurf->prop.visibility == false)
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900686 continue;
687
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000688 update_prop(iviscrn, ivilayer, ivi_view);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900689 }
690 }
691 }
692}
693
694static void
695commit_surface_list(struct ivi_layout *layout)
696{
697 struct ivi_layout_surface *ivisurf = NULL;
698 int32_t dest_x = 0;
699 int32_t dest_y = 0;
700 int32_t dest_width = 0;
701 int32_t dest_height = 0;
702 int32_t configured = 0;
703
704 wl_list_for_each(ivisurf, &layout->surface_list, link) {
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300705 if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEFAULT) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900706 dest_x = ivisurf->prop.dest_x;
707 dest_y = ivisurf->prop.dest_y;
708 dest_width = ivisurf->prop.dest_width;
709 dest_height = ivisurf->prop.dest_height;
710
711 ivi_layout_transition_move_resize_view(ivisurf,
712 ivisurf->pending.prop.dest_x,
713 ivisurf->pending.prop.dest_y,
714 ivisurf->pending.prop.dest_width,
715 ivisurf->pending.prop.dest_height,
716 ivisurf->pending.prop.transition_duration);
717
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300718 if (ivisurf->pending.prop.visibility) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900719 ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration);
720 } else {
721 ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration);
722 }
723
724 ivisurf->prop = ivisurf->pending.prop;
725 ivisurf->prop.dest_x = dest_x;
726 ivisurf->prop.dest_y = dest_y;
727 ivisurf->prop.dest_width = dest_width;
728 ivisurf->prop.dest_height = dest_height;
729 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
730 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
731
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300732 } else if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEST_RECT_ONLY) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900733 dest_x = ivisurf->prop.dest_x;
734 dest_y = ivisurf->prop.dest_y;
735 dest_width = ivisurf->prop.dest_width;
736 dest_height = ivisurf->prop.dest_height;
737
738 ivi_layout_transition_move_resize_view(ivisurf,
739 ivisurf->pending.prop.dest_x,
740 ivisurf->pending.prop.dest_y,
741 ivisurf->pending.prop.dest_width,
742 ivisurf->pending.prop.dest_height,
743 ivisurf->pending.prop.transition_duration);
744
745 ivisurf->prop = ivisurf->pending.prop;
746 ivisurf->prop.dest_x = dest_x;
747 ivisurf->prop.dest_y = dest_y;
748 ivisurf->prop.dest_width = dest_width;
749 ivisurf->prop.dest_height = dest_height;
750
751 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
752 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
753
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300754 } else if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900755 configured = 0;
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300756 if (ivisurf->pending.prop.visibility) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900757 ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration);
758 } else {
759 ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration);
760 }
761
762 if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width ||
763 ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) {
764 configured = 1;
765 }
766
767 ivisurf->prop = ivisurf->pending.prop;
768 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
769 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
770
Pekka Paalanen1f821932016-03-15 16:57:51 +0200771 if (configured && !is_surface_transition(ivisurf)) {
Pekka Paalanen1f821932016-03-15 16:57:51 +0200772 shell_surface_send_configure(ivisurf->surface,
773 ivisurf->prop.dest_width,
774 ivisurf->prop.dest_height);
775 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900776 } else {
777 configured = 0;
778 if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width ||
779 ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) {
780 configured = 1;
781 }
782
783 ivisurf->prop = ivisurf->pending.prop;
784 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
785 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
786
Pekka Paalanen1f821932016-03-15 16:57:51 +0200787 if (configured && !is_surface_transition(ivisurf)) {
Pekka Paalanen1f821932016-03-15 16:57:51 +0200788 shell_surface_send_configure(ivisurf->surface,
789 ivisurf->prop.dest_width,
790 ivisurf->prop.dest_height);
791 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900792 }
793 }
794}
795
796static void
797commit_layer_list(struct ivi_layout *layout)
798{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000799 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900800 struct ivi_layout_layer *ivilayer = NULL;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000801 struct ivi_layout_view *next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900802
803 wl_list_for_each(ivilayer, &layout->layer_list, link) {
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300804 if (ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_MOVE) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900805 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 -0300806 } else if (ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_FADE) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900807 ivi_layout_transition_fade_layer(ivilayer,ivilayer->pending.prop.is_fade_in,
808 ivilayer->pending.prop.start_alpha,ivilayer->pending.prop.end_alpha,
809 NULL, NULL,
810 ivilayer->pending.prop.transition_duration);
811 }
812 ivilayer->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
813
814 ivilayer->prop = ivilayer->pending.prop;
815
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +0000816 if (!ivilayer->order.dirty) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900817 continue;
818 }
819
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000820 wl_list_for_each_safe(ivi_view, next, &ivilayer->order.view_list,
821 order_link) {
822 wl_list_remove(&ivi_view->order_link);
823 wl_list_init(&ivi_view->order_link);
824 ivi_view->ivisurf->prop.event_mask |= IVI_NOTIFICATION_REMOVE;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900825 }
826
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000827 assert(wl_list_empty(&ivilayer->order.view_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900828
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000829 wl_list_for_each(ivi_view, &ivilayer->pending.view_list,
830 pending_link) {
831 wl_list_remove(&ivi_view->order_link);
832 wl_list_insert(&ivilayer->order.view_list, &ivi_view->order_link);
833 ivi_view->ivisurf->prop.event_mask |= IVI_NOTIFICATION_ADD;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900834 }
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +0000835
836 ivilayer->order.dirty = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900837 }
838}
839
840static void
841commit_screen_list(struct ivi_layout *layout)
842{
843 struct ivi_layout_screen *iviscrn = NULL;
844 struct ivi_layout_layer *ivilayer = NULL;
845 struct ivi_layout_layer *next = NULL;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000846 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900847
Nobuhiko Tanibatafbfa8f22015-11-25 23:36:57 +0900848 /* Clear view list of layout ivi_layer */
849 wl_list_init(&layout->layout_layer.view_list.link);
850
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900851 wl_list_for_each(iviscrn, &layout->screen_list, link) {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000852 if (iviscrn->order.dirty) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900853 wl_list_for_each_safe(ivilayer, next,
854 &iviscrn->order.layer_list, order.link) {
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +0000855 ivilayer->on_screen = NULL;
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000856 wl_list_remove(&ivilayer->order.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900857 wl_list_init(&ivilayer->order.link);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000858 ivilayer->prop.event_mask |= IVI_NOTIFICATION_REMOVE;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900859 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900860
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000861 assert(wl_list_empty(&iviscrn->order.layer_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900862
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900863 wl_list_for_each(ivilayer, &iviscrn->pending.layer_list,
864 pending.link) {
Nobuhiko Tanibata77b0ee12015-11-25 23:36:46 +0900865 /* FIXME: avoid to insert order.link to multiple screens */
866 wl_list_remove(&ivilayer->order.link);
867
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900868 wl_list_insert(&iviscrn->order.layer_list,
869 &ivilayer->order.link);
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +0000870 ivilayer->on_screen = iviscrn;
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000871 ivilayer->prop.event_mask |= IVI_NOTIFICATION_ADD;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900872 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900873
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000874 iviscrn->order.dirty = 0;
875 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900876
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900877 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
878 if (ivilayer->prop.visibility == false)
879 continue;
880
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000881 wl_list_for_each(ivi_view, &ivilayer->order.view_list, order_link) {
882 if (ivi_view->ivisurf->prop.visibility == false)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900883 continue;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000884
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900885 weston_layer_entry_insert(&layout->layout_layer.view_list,
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000886 &ivi_view->view->layer_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900887
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000888 ivi_view->view->output = iviscrn->output;
Armin Krezović50ff4bf2016-06-30 06:04:31 +0200889 ivi_view->ivisurf->surface->is_mapped = true;
890 ivi_view->view->is_mapped = true;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900891 }
892 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900893 }
894}
895
896static void
897commit_transition(struct ivi_layout* layout)
898{
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300899 if (wl_list_empty(&layout->pending_transition_list)) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900900 return;
901 }
902
903 wl_list_insert_list(&layout->transitions->transition_list,
904 &layout->pending_transition_list);
905
906 wl_list_init(&layout->pending_transition_list);
907
908 wl_event_source_timer_update(layout->transitions->event_source, 1);
909}
910
911static void
912send_surface_prop(struct ivi_layout_surface *ivisurf)
913{
914 wl_signal_emit(&ivisurf->property_changed, ivisurf);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000915 ivisurf->pending.prop.event_mask = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900916}
917
918static void
919send_layer_prop(struct ivi_layout_layer *ivilayer)
920{
921 wl_signal_emit(&ivilayer->property_changed, ivilayer);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000922 ivilayer->pending.prop.event_mask = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900923}
924
925static void
926send_prop(struct ivi_layout *layout)
927{
928 struct ivi_layout_layer *ivilayer = NULL;
929 struct ivi_layout_surface *ivisurf = NULL;
930
931 wl_list_for_each_reverse(ivilayer, &layout->layer_list, link) {
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000932 if (ivilayer->prop.event_mask)
Nobuhiko Tanibata6ce3ef82015-06-22 15:32:06 +0900933 send_layer_prop(ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900934 }
935
936 wl_list_for_each_reverse(ivisurf, &layout->surface_list, link) {
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000937 if (ivisurf->prop.event_mask)
Nobuhiko Tanibata6ce3ef82015-06-22 15:32:06 +0900938 send_surface_prop(ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900939 }
940}
941
942static void
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000943clear_view_pending_list(struct ivi_layout_layer *ivilayer)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900944{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000945 struct ivi_layout_view *view_link = NULL;
946 struct ivi_layout_view *view_next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900947
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000948 wl_list_for_each_safe(view_link, view_next,
949 &ivilayer->pending.view_list, pending_link) {
950 wl_list_remove(&view_link->pending_link);
951 wl_list_init(&view_link->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900952 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900953}
954
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900955/**
956 * Exported APIs of ivi-layout library are implemented from here.
957 * Brief of APIs is described in ivi-layout-export.h.
958 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900959static int32_t
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000960ivi_layout_add_listener_create_layer(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900961{
962 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900963
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000964 if (listener == NULL) {
965 weston_log("ivi_layout_add_listener_create_layer: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900966 return IVI_FAILED;
967 }
968
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000969 wl_signal_add(&layout->layer_notification.created, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900970
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000971 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900972}
973
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900974static int32_t
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000975ivi_layout_add_listener_remove_layer(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900976{
977 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900978
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000979 if (listener == NULL) {
980 weston_log("ivi_layout_add_listener_remove_layer: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900981 return IVI_FAILED;
982 }
983
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000984 wl_signal_add(&layout->layer_notification.removed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900985
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000986 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900987}
988
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900989static int32_t
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000990ivi_layout_add_listener_create_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900991{
992 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900993
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000994 if (listener == NULL) {
995 weston_log("ivi_layout_add_listener_create_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900996 return IVI_FAILED;
997 }
998
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000999 wl_signal_add(&layout->surface_notification.created, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001000
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00001001 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001002}
1003
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001004static int32_t
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001005ivi_layout_add_listener_remove_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001006{
1007 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001008
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001009 if (listener == NULL) {
1010 weston_log("ivi_layout_add_listener_remove_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001011 return IVI_FAILED;
1012 }
1013
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001014 wl_signal_add(&layout->surface_notification.removed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001015
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001016 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001017}
1018
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001019static int32_t
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001020ivi_layout_add_listener_configure_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001021{
1022 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001023
1024 if (listener == NULL) {
1025 weston_log("ivi_layout_add_listener_configure_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001026 return IVI_FAILED;
1027 }
1028
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001029 wl_signal_add(&layout->surface_notification.configure_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001030
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001031 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001032}
1033
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001034uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001035ivi_layout_get_id_of_surface(struct ivi_layout_surface *ivisurf)
1036{
1037 return ivisurf->id_surface;
1038}
1039
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001040static uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001041ivi_layout_get_id_of_layer(struct ivi_layout_layer *ivilayer)
1042{
1043 return ivilayer->id_layer;
1044}
1045
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001046static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001047ivi_layout_get_layer_from_id(uint32_t id_layer)
1048{
1049 struct ivi_layout *layout = get_instance();
1050 struct ivi_layout_layer *ivilayer = NULL;
1051
1052 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1053 if (ivilayer->id_layer == id_layer) {
1054 return ivilayer;
1055 }
1056 }
1057
1058 return NULL;
1059}
1060
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001061struct ivi_layout_surface *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001062ivi_layout_get_surface_from_id(uint32_t id_surface)
1063{
1064 struct ivi_layout *layout = get_instance();
1065 struct ivi_layout_surface *ivisurf = NULL;
1066
1067 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1068 if (ivisurf->id_surface == id_surface) {
1069 return ivisurf;
1070 }
1071 }
1072
1073 return NULL;
1074}
1075
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001076static int32_t
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001077ivi_layout_surface_add_listener(struct ivi_layout_surface *ivisurf,
1078 struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001079{
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001080 if (ivisurf == NULL || listener == NULL) {
1081 weston_log("ivi_layout_surface_add_listener: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001082 return IVI_FAILED;
1083 }
1084
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001085 wl_signal_add(&ivisurf->property_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001086
1087 return IVI_SUCCEEDED;
1088}
1089
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001090static const struct ivi_layout_layer_properties *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001091ivi_layout_get_properties_of_layer(struct ivi_layout_layer *ivilayer)
1092{
1093 if (ivilayer == NULL) {
1094 weston_log("ivi_layout_get_properties_of_layer: invalid argument\n");
1095 return NULL;
1096 }
1097
1098 return &ivilayer->prop;
1099}
1100
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001101static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001102ivi_layout_get_screens_under_layer(struct ivi_layout_layer *ivilayer,
1103 int32_t *pLength,
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001104 struct weston_output ***ppArray)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001105{
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001106 int32_t length = 0;
1107 int32_t n = 0;
1108
1109 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1110 weston_log("ivi_layout_get_screens_under_layer: invalid argument\n");
1111 return IVI_FAILED;
1112 }
1113
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +00001114 if (ivilayer->on_screen != NULL)
1115 length = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001116
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001117 if (length != 0) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001118 /* the Array must be free by module which called this function */
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001119 *ppArray = calloc(length, sizeof(struct weston_output *));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001120 if (*ppArray == NULL) {
1121 weston_log("fails to allocate memory\n");
1122 return IVI_FAILED;
1123 }
1124
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001125 (*ppArray)[n++] = ivilayer->on_screen->output;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001126 }
1127
1128 *pLength = length;
1129
1130 return IVI_SUCCEEDED;
1131}
1132
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001133static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001134ivi_layout_get_layers(int32_t *pLength, struct ivi_layout_layer ***ppArray)
1135{
1136 struct ivi_layout *layout = get_instance();
1137 struct ivi_layout_layer *ivilayer = NULL;
1138 int32_t length = 0;
1139 int32_t n = 0;
1140
1141 if (pLength == NULL || ppArray == NULL) {
1142 weston_log("ivi_layout_get_layers: invalid argument\n");
1143 return IVI_FAILED;
1144 }
1145
1146 length = wl_list_length(&layout->layer_list);
1147
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001148 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001149 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001150 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1151 if (*ppArray == NULL) {
1152 weston_log("fails to allocate memory\n");
1153 return IVI_FAILED;
1154 }
1155
1156 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1157 (*ppArray)[n++] = ivilayer;
1158 }
1159 }
1160
1161 *pLength = length;
1162
1163 return IVI_SUCCEEDED;
1164}
1165
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001166static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001167ivi_layout_get_layers_on_screen(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001168 int32_t *pLength,
1169 struct ivi_layout_layer ***ppArray)
1170{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001171 struct ivi_layout_screen *iviscrn = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001172 struct ivi_layout_layer *ivilayer = NULL;
1173 int32_t length = 0;
1174 int32_t n = 0;
1175
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001176 if (output == NULL || pLength == NULL || ppArray == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001177 weston_log("ivi_layout_get_layers_on_screen: invalid argument\n");
1178 return IVI_FAILED;
1179 }
1180
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001181 iviscrn = get_screen_from_output(output);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001182 length = wl_list_length(&iviscrn->order.layer_list);
1183
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001184 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001185 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001186 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1187 if (*ppArray == NULL) {
1188 weston_log("fails to allocate memory\n");
1189 return IVI_FAILED;
1190 }
1191
Nobuhiko Tanibatae2b82142015-06-22 15:30:19 +09001192 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001193 (*ppArray)[n++] = ivilayer;
1194 }
1195 }
1196
1197 *pLength = length;
1198
1199 return IVI_SUCCEEDED;
1200}
1201
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001202static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001203ivi_layout_get_layers_under_surface(struct ivi_layout_surface *ivisurf,
1204 int32_t *pLength,
1205 struct ivi_layout_layer ***ppArray)
1206{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001207 struct ivi_layout_view *ivi_view;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001208 int32_t length = 0;
1209 int32_t n = 0;
1210
1211 if (ivisurf == NULL || pLength == NULL || ppArray == NULL) {
1212 weston_log("ivi_layout_getLayers: invalid argument\n");
1213 return IVI_FAILED;
1214 }
1215
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001216 if (!wl_list_empty(&ivisurf->view_list)) {
1217 /* the Array must be free by module which called this function */
1218 length = wl_list_length(&ivisurf->view_list);
1219 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001220 if (*ppArray == NULL) {
1221 weston_log("fails to allocate memory\n");
1222 return IVI_FAILED;
1223 }
1224
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001225 wl_list_for_each_reverse(ivi_view, &ivisurf->view_list, surf_link) {
1226 if (ivi_view_is_rendered(ivi_view))
1227 (*ppArray)[n++] = ivi_view->on_layer;
1228 else
1229 length--;
1230 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001231 }
1232
1233 *pLength = length;
1234
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001235 if (!length) {
1236 free(*ppArray);
1237 *ppArray = NULL;
1238 }
1239
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001240 return IVI_SUCCEEDED;
1241}
1242
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001243static
1244int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001245ivi_layout_get_surfaces(int32_t *pLength, struct ivi_layout_surface ***ppArray)
1246{
1247 struct ivi_layout *layout = get_instance();
1248 struct ivi_layout_surface *ivisurf = NULL;
1249 int32_t length = 0;
1250 int32_t n = 0;
1251
1252 if (pLength == NULL || ppArray == NULL) {
1253 weston_log("ivi_layout_get_surfaces: invalid argument\n");
1254 return IVI_FAILED;
1255 }
1256
1257 length = wl_list_length(&layout->surface_list);
1258
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001259 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001260 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001261 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1262 if (*ppArray == NULL) {
1263 weston_log("fails to allocate memory\n");
1264 return IVI_FAILED;
1265 }
1266
1267 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1268 (*ppArray)[n++] = ivisurf;
1269 }
1270 }
1271
1272 *pLength = length;
1273
1274 return IVI_SUCCEEDED;
1275}
1276
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001277static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001278ivi_layout_get_surfaces_on_layer(struct ivi_layout_layer *ivilayer,
1279 int32_t *pLength,
1280 struct ivi_layout_surface ***ppArray)
1281{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001282 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001283 int32_t length = 0;
1284 int32_t n = 0;
1285
1286 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1287 weston_log("ivi_layout_getSurfaceIDsOnLayer: invalid argument\n");
1288 return IVI_FAILED;
1289 }
1290
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001291 length = wl_list_length(&ivilayer->order.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001292
1293 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001294 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001295 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1296 if (*ppArray == NULL) {
1297 weston_log("fails to allocate memory\n");
1298 return IVI_FAILED;
1299 }
1300
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001301 wl_list_for_each(ivi_view, &ivilayer->order.view_list, order_link) {
1302 (*ppArray)[n++] = ivi_view->ivisurf;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001303 }
1304 }
1305
1306 *pLength = length;
1307
1308 return IVI_SUCCEEDED;
1309}
1310
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001311static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001312ivi_layout_layer_create_with_dimension(uint32_t id_layer,
1313 int32_t width, int32_t height)
1314{
1315 struct ivi_layout *layout = get_instance();
1316 struct ivi_layout_layer *ivilayer = NULL;
1317
1318 ivilayer = get_layer(&layout->layer_list, id_layer);
1319 if (ivilayer != NULL) {
1320 weston_log("id_layer is already created\n");
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001321 ++ivilayer->ref_count;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001322 return ivilayer;
1323 }
1324
1325 ivilayer = calloc(1, sizeof *ivilayer);
1326 if (ivilayer == NULL) {
1327 weston_log("fails to allocate memory\n");
1328 return NULL;
1329 }
1330
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001331 ivilayer->ref_count = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001332 wl_signal_init(&ivilayer->property_changed);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001333 ivilayer->layout = layout;
1334 ivilayer->id_layer = id_layer;
1335
1336 init_layer_properties(&ivilayer->prop, width, height);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001337
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001338 wl_list_init(&ivilayer->pending.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001339 wl_list_init(&ivilayer->pending.link);
1340 ivilayer->pending.prop = ivilayer->prop;
1341
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001342 wl_list_init(&ivilayer->order.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001343 wl_list_init(&ivilayer->order.link);
1344
1345 wl_list_insert(&layout->layer_list, &ivilayer->link);
1346
1347 wl_signal_emit(&layout->layer_notification.created, ivilayer);
1348
1349 return ivilayer;
1350}
1351
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001352static void
Nobuhiko Tanibata3aa8aed2015-06-22 15:32:23 +09001353ivi_layout_layer_destroy(struct ivi_layout_layer *ivilayer)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001354{
1355 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001356 struct ivi_layout_view *ivi_view, *next;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001357
1358 if (ivilayer == NULL) {
1359 weston_log("ivi_layout_layer_remove: invalid argument\n");
1360 return;
1361 }
1362
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001363 if (--ivilayer->ref_count > 0)
1364 return;
1365
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001366 /*Destroy all ivi_views*/
1367 wl_list_for_each_safe(ivi_view, next, &layout->view_list, link) {
1368 if (ivi_view->on_layer == ivilayer)
1369 ivi_view_destroy(ivi_view);
1370 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001371
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001372 wl_signal_emit(&layout->layer_notification.removed, ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001373
Ucan, Emre (ADITG/SW1)cf34dc22015-08-20 14:13:33 +00001374 wl_list_remove(&ivilayer->pending.link);
1375 wl_list_remove(&ivilayer->order.link);
1376 wl_list_remove(&ivilayer->link);
1377
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001378 free(ivilayer);
1379}
1380
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001381int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001382ivi_layout_layer_set_visibility(struct ivi_layout_layer *ivilayer,
1383 bool newVisibility)
1384{
1385 struct ivi_layout_layer_properties *prop = NULL;
1386
1387 if (ivilayer == NULL) {
1388 weston_log("ivi_layout_layer_set_visibility: invalid argument\n");
1389 return IVI_FAILED;
1390 }
1391
1392 prop = &ivilayer->pending.prop;
1393 prop->visibility = newVisibility;
1394
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001395 if (ivilayer->prop.visibility != newVisibility)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001396 prop->event_mask |= IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001397 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001398 prop->event_mask &= ~IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001399
1400 return IVI_SUCCEEDED;
1401}
1402
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001403int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001404ivi_layout_layer_set_opacity(struct ivi_layout_layer *ivilayer,
1405 wl_fixed_t opacity)
1406{
1407 struct ivi_layout_layer_properties *prop = NULL;
1408
Nobuhiko Tanibata7bbacc62015-06-22 15:30:09 +09001409 if (ivilayer == NULL ||
1410 opacity < wl_fixed_from_double(0.0) ||
1411 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001412 weston_log("ivi_layout_layer_set_opacity: invalid argument\n");
1413 return IVI_FAILED;
1414 }
1415
1416 prop = &ivilayer->pending.prop;
1417 prop->opacity = opacity;
1418
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001419 if (ivilayer->prop.opacity != opacity)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001420 prop->event_mask |= IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001421 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001422 prop->event_mask &= ~IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001423
1424 return IVI_SUCCEEDED;
1425}
1426
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001427static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001428ivi_layout_layer_set_source_rectangle(struct ivi_layout_layer *ivilayer,
1429 int32_t x, int32_t y,
1430 int32_t width, int32_t height)
1431{
1432 struct ivi_layout_layer_properties *prop = NULL;
1433
1434 if (ivilayer == NULL) {
1435 weston_log("ivi_layout_layer_set_source_rectangle: invalid argument\n");
1436 return IVI_FAILED;
1437 }
1438
1439 prop = &ivilayer->pending.prop;
1440 prop->source_x = x;
1441 prop->source_y = y;
1442 prop->source_width = width;
1443 prop->source_height = height;
1444
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001445 if (ivilayer->prop.source_x != x || ivilayer->prop.source_y != y ||
1446 ivilayer->prop.source_width != width ||
1447 ivilayer->prop.source_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001448 prop->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001449 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001450 prop->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001451
1452 return IVI_SUCCEEDED;
1453}
1454
Ucan, Emre \(ADITG/SW1\)e62bfd82016-03-04 12:50:46 +00001455int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001456ivi_layout_layer_set_destination_rectangle(struct ivi_layout_layer *ivilayer,
1457 int32_t x, int32_t y,
1458 int32_t width, int32_t height)
1459{
1460 struct ivi_layout_layer_properties *prop = NULL;
1461
1462 if (ivilayer == NULL) {
1463 weston_log("ivi_layout_layer_set_destination_rectangle: invalid argument\n");
1464 return IVI_FAILED;
1465 }
1466
1467 prop = &ivilayer->pending.prop;
1468 prop->dest_x = x;
1469 prop->dest_y = y;
1470 prop->dest_width = width;
1471 prop->dest_height = height;
1472
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001473 if (ivilayer->prop.dest_x != x || ivilayer->prop.dest_y != y ||
1474 ivilayer->prop.dest_width != width ||
1475 ivilayer->prop.dest_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001476 prop->event_mask |= IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001477 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001478 prop->event_mask &= ~IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001479
1480 return IVI_SUCCEEDED;
1481}
1482
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001483static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001484ivi_layout_layer_set_orientation(struct ivi_layout_layer *ivilayer,
1485 enum wl_output_transform orientation)
1486{
1487 struct ivi_layout_layer_properties *prop = NULL;
1488
1489 if (ivilayer == NULL) {
1490 weston_log("ivi_layout_layer_set_orientation: invalid argument\n");
1491 return IVI_FAILED;
1492 }
1493
1494 prop = &ivilayer->pending.prop;
1495 prop->orientation = orientation;
1496
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001497 if (ivilayer->prop.orientation != orientation)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001498 prop->event_mask |= IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001499 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001500 prop->event_mask &= ~IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001501
1502 return IVI_SUCCEEDED;
1503}
1504
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001505int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001506ivi_layout_layer_set_render_order(struct ivi_layout_layer *ivilayer,
1507 struct ivi_layout_surface **pSurface,
1508 int32_t number)
1509{
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001510 int32_t i = 0;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001511 struct ivi_layout_view * ivi_view;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001512
1513 if (ivilayer == NULL) {
1514 weston_log("ivi_layout_layer_set_render_order: invalid argument\n");
1515 return IVI_FAILED;
1516 }
1517
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001518 clear_view_pending_list(ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001519
1520 for (i = 0; i < number; i++) {
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001521 ivi_view = get_ivi_view(ivilayer, pSurface[i]);
1522 if (!ivi_view)
1523 ivi_view = ivi_view_create(ivilayer, pSurface[i]);
1524
1525 assert(ivi_view != NULL);
1526
1527 wl_list_remove(&ivi_view->pending_link);
1528 wl_list_insert(&ivilayer->pending.view_list, &ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001529 }
1530
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +00001531 ivilayer->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001532
1533 return IVI_SUCCEEDED;
1534}
1535
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001536int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001537ivi_layout_surface_set_visibility(struct ivi_layout_surface *ivisurf,
1538 bool newVisibility)
1539{
1540 struct ivi_layout_surface_properties *prop = NULL;
1541
1542 if (ivisurf == NULL) {
1543 weston_log("ivi_layout_surface_set_visibility: invalid argument\n");
1544 return IVI_FAILED;
1545 }
1546
1547 prop = &ivisurf->pending.prop;
1548 prop->visibility = newVisibility;
1549
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001550 if (ivisurf->prop.visibility != newVisibility)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001551 prop->event_mask |= IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001552 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001553 prop->event_mask &= ~IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001554
1555 return IVI_SUCCEEDED;
1556}
1557
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001558int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001559ivi_layout_surface_set_opacity(struct ivi_layout_surface *ivisurf,
1560 wl_fixed_t opacity)
1561{
1562 struct ivi_layout_surface_properties *prop = NULL;
1563
Nobuhiko Tanibataa86226c2015-06-22 15:29:20 +09001564 if (ivisurf == NULL ||
1565 opacity < wl_fixed_from_double(0.0) ||
1566 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001567 weston_log("ivi_layout_surface_set_opacity: invalid argument\n");
1568 return IVI_FAILED;
1569 }
1570
1571 prop = &ivisurf->pending.prop;
1572 prop->opacity = opacity;
1573
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001574 if (ivisurf->prop.opacity != opacity)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001575 prop->event_mask |= IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001576 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001577 prop->event_mask &= ~IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001578
1579 return IVI_SUCCEEDED;
1580}
1581
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001582int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001583ivi_layout_surface_set_destination_rectangle(struct ivi_layout_surface *ivisurf,
1584 int32_t x, int32_t y,
1585 int32_t width, int32_t height)
1586{
1587 struct ivi_layout_surface_properties *prop = NULL;
1588
1589 if (ivisurf == NULL) {
1590 weston_log("ivi_layout_surface_set_destination_rectangle: invalid argument\n");
1591 return IVI_FAILED;
1592 }
1593
1594 prop = &ivisurf->pending.prop;
1595 prop->start_x = prop->dest_x;
1596 prop->start_y = prop->dest_y;
1597 prop->dest_x = x;
1598 prop->dest_y = y;
1599 prop->start_width = prop->dest_width;
1600 prop->start_height = prop->dest_height;
1601 prop->dest_width = width;
1602 prop->dest_height = height;
1603
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001604 if (ivisurf->prop.dest_x != x || ivisurf->prop.dest_y != y ||
1605 ivisurf->prop.dest_width != width ||
1606 ivisurf->prop.dest_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001607 prop->event_mask |= IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001608 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001609 prop->event_mask &= ~IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001610
1611 return IVI_SUCCEEDED;
1612}
1613
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001614static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001615ivi_layout_surface_set_orientation(struct ivi_layout_surface *ivisurf,
1616 enum wl_output_transform orientation)
1617{
1618 struct ivi_layout_surface_properties *prop = NULL;
1619
1620 if (ivisurf == NULL) {
1621 weston_log("ivi_layout_surface_set_orientation: invalid argument\n");
1622 return IVI_FAILED;
1623 }
1624
1625 prop = &ivisurf->pending.prop;
1626 prop->orientation = orientation;
1627
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001628 if (ivisurf->prop.orientation != orientation)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001629 prop->event_mask |= IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001630 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001631 prop->event_mask &= ~IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001632
1633 return IVI_SUCCEEDED;
1634}
1635
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001636static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001637ivi_layout_screen_add_layer(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001638 struct ivi_layout_layer *addlayer)
1639{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001640 struct ivi_layout_screen *iviscrn;
1641
1642 if (output == NULL || addlayer == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001643 weston_log("ivi_layout_screen_add_layer: invalid argument\n");
1644 return IVI_FAILED;
1645 }
1646
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001647 iviscrn = get_screen_from_output(output);
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001648
Ucan, Emre (ADITG/SW1)bb4ec0a2015-08-28 12:59:01 +00001649 if (addlayer->on_screen == iviscrn) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001650 weston_log("ivi_layout_screen_add_layer: addlayer is already available\n");
1651 return IVI_SUCCEEDED;
1652 }
1653
Ucan, Emre (ADITG/SW1)f46306f2016-03-16 13:37:07 +00001654 wl_list_remove(&addlayer->pending.link);
1655 wl_list_insert(&iviscrn->pending.layer_list, &addlayer->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001656
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001657 iviscrn->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001658
1659 return IVI_SUCCEEDED;
1660}
1661
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001662static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001663ivi_layout_screen_set_render_order(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001664 struct ivi_layout_layer **pLayer,
1665 const int32_t number)
1666{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001667 struct ivi_layout_screen *iviscrn;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001668 struct ivi_layout_layer *ivilayer = NULL;
1669 struct ivi_layout_layer *next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001670 int32_t i = 0;
1671
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001672 if (output == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001673 weston_log("ivi_layout_screen_set_render_order: invalid argument\n");
1674 return IVI_FAILED;
1675 }
1676
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001677 iviscrn = get_screen_from_output(output);
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001678
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001679 wl_list_for_each_safe(ivilayer, next,
1680 &iviscrn->pending.layer_list, pending.link) {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001681 wl_list_remove(&ivilayer->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001682 wl_list_init(&ivilayer->pending.link);
1683 }
1684
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001685 assert(wl_list_empty(&iviscrn->pending.layer_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001686
1687 for (i = 0; i < number; i++) {
Ucan, Emre (ADITG/SW1)4e221f02016-03-16 13:37:08 +00001688 wl_list_remove(&pLayer[i]->pending.link);
1689 wl_list_insert(&iviscrn->pending.layer_list,
1690 &pLayer[i]->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001691 }
1692
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001693 iviscrn->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001694
1695 return IVI_SUCCEEDED;
1696}
1697
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001698/**
1699 * This function is used by the additional ivi-module because of dumping ivi_surface sceenshot.
1700 * The ivi-module, e.g. ivi-controller.so, is in wayland-ivi-extension of Genivi's Layer Management.
1701 * This function is used to get the result of drawing by clients.
1702 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001703static struct weston_surface *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001704ivi_layout_surface_get_weston_surface(struct ivi_layout_surface *ivisurf)
1705{
1706 return ivisurf != NULL ? ivisurf->surface : NULL;
1707}
1708
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001709static int32_t
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09001710ivi_layout_surface_get_size(struct ivi_layout_surface *ivisurf,
1711 int32_t *width, int32_t *height,
1712 int32_t *stride)
1713{
1714 int32_t w;
1715 int32_t h;
1716 const size_t bytespp = 4; /* PIXMAN_a8b8g8r8 */
1717
1718 if (ivisurf == NULL || ivisurf->surface == NULL) {
1719 weston_log("%s: invalid argument\n", __func__);
1720 return IVI_FAILED;
1721 }
1722
1723 weston_surface_get_content_size(ivisurf->surface, &w, &h);
1724
1725 if (width != NULL)
1726 *width = w;
1727
1728 if (height != NULL)
1729 *height = h;
1730
1731 if (stride != NULL)
1732 *stride = w * bytespp;
1733
1734 return IVI_SUCCEEDED;
1735}
1736
1737static int32_t
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001738ivi_layout_layer_add_listener(struct ivi_layout_layer *ivilayer,
1739 struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001740{
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001741 if (ivilayer == NULL || listener == NULL) {
1742 weston_log("ivi_layout_layer_add_listener: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001743 return IVI_FAILED;
1744 }
1745
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001746 wl_signal_add(&ivilayer->property_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001747
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001748 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001749}
1750
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001751static const struct ivi_layout_surface_properties *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001752ivi_layout_get_properties_of_surface(struct ivi_layout_surface *ivisurf)
1753{
1754 if (ivisurf == NULL) {
1755 weston_log("ivi_layout_get_properties_of_surface: invalid argument\n");
1756 return NULL;
1757 }
1758
1759 return &ivisurf->prop;
1760}
1761
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001762static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001763ivi_layout_layer_add_surface(struct ivi_layout_layer *ivilayer,
1764 struct ivi_layout_surface *addsurf)
1765{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001766 struct ivi_layout_view *ivi_view;
1767
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001768 if (ivilayer == NULL || addsurf == NULL) {
1769 weston_log("ivi_layout_layer_add_surface: invalid argument\n");
1770 return IVI_FAILED;
1771 }
1772
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001773 ivi_view = get_ivi_view(ivilayer, addsurf);
1774 if (!ivi_view)
1775 ivi_view = ivi_view_create(ivilayer, addsurf);
1776 else if (ivi_view_is_rendered(ivi_view))
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001777 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001778
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001779 wl_list_remove(&ivi_view->pending_link);
1780 wl_list_insert(&ivilayer->pending.view_list, &ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001781
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +00001782 ivilayer->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001783
1784 return IVI_SUCCEEDED;
1785}
1786
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001787static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001788ivi_layout_layer_remove_surface(struct ivi_layout_layer *ivilayer,
1789 struct ivi_layout_surface *remsurf)
1790{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001791 struct ivi_layout_view *ivi_view;
1792
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001793 if (ivilayer == NULL || remsurf == NULL) {
1794 weston_log("ivi_layout_layer_remove_surface: invalid argument\n");
1795 return;
1796 }
1797
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001798 ivi_view = get_ivi_view(ivilayer, remsurf);
1799 if (ivi_view) {
1800 wl_list_remove(&ivi_view->pending_link);
1801 wl_list_init(&ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001802
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001803 ivilayer->order.dirty = 1;
1804 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001805}
1806
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001807static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001808ivi_layout_surface_set_source_rectangle(struct ivi_layout_surface *ivisurf,
1809 int32_t x, int32_t y,
1810 int32_t width, int32_t height)
1811{
1812 struct ivi_layout_surface_properties *prop = NULL;
1813
1814 if (ivisurf == NULL) {
1815 weston_log("ivi_layout_surface_set_source_rectangle: invalid argument\n");
1816 return IVI_FAILED;
1817 }
1818
1819 prop = &ivisurf->pending.prop;
1820 prop->source_x = x;
1821 prop->source_y = y;
1822 prop->source_width = width;
1823 prop->source_height = height;
1824
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001825 if (ivisurf->prop.source_x != x || ivisurf->prop.source_y != y ||
1826 ivisurf->prop.source_width != width ||
1827 ivisurf->prop.source_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001828 prop->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001829 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001830 prop->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001831
1832 return IVI_SUCCEEDED;
1833}
1834
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001835int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001836ivi_layout_commit_changes(void)
1837{
1838 struct ivi_layout *layout = get_instance();
1839
1840 commit_surface_list(layout);
1841 commit_layer_list(layout);
1842 commit_screen_list(layout);
1843
1844 commit_transition(layout);
1845
1846 commit_changes(layout);
1847 send_prop(layout);
1848 weston_compositor_schedule_repaint(layout->compositor);
1849
1850 return IVI_SUCCEEDED;
1851}
1852
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001853static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001854ivi_layout_layer_set_transition(struct ivi_layout_layer *ivilayer,
1855 enum ivi_layout_transition_type type,
1856 uint32_t duration)
1857{
1858 if (ivilayer == NULL) {
1859 weston_log("%s: invalid argument\n", __func__);
1860 return -1;
1861 }
1862
1863 ivilayer->pending.prop.transition_type = type;
1864 ivilayer->pending.prop.transition_duration = duration;
1865
1866 return 0;
1867}
1868
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001869static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001870ivi_layout_layer_set_fade_info(struct ivi_layout_layer* ivilayer,
1871 uint32_t is_fade_in,
1872 double start_alpha, double end_alpha)
1873{
1874 if (ivilayer == NULL) {
1875 weston_log("%s: invalid argument\n", __func__);
1876 return -1;
1877 }
1878
1879 ivilayer->pending.prop.is_fade_in = is_fade_in;
1880 ivilayer->pending.prop.start_alpha = start_alpha;
1881 ivilayer->pending.prop.end_alpha = end_alpha;
1882
1883 return 0;
1884}
1885
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001886static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001887ivi_layout_surface_set_transition_duration(struct ivi_layout_surface *ivisurf,
1888 uint32_t duration)
1889{
1890 struct ivi_layout_surface_properties *prop;
1891
1892 if (ivisurf == NULL) {
1893 weston_log("%s: invalid argument\n", __func__);
1894 return -1;
1895 }
1896
1897 prop = &ivisurf->pending.prop;
1898 prop->transition_duration = duration*10;
1899 return 0;
1900}
1901
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001902static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001903ivi_layout_surface_set_transition(struct ivi_layout_surface *ivisurf,
1904 enum ivi_layout_transition_type type,
1905 uint32_t duration)
1906{
1907 struct ivi_layout_surface_properties *prop;
1908
1909 if (ivisurf == NULL) {
1910 weston_log("%s: invalid argument\n", __func__);
1911 return -1;
1912 }
1913
1914 prop = &ivisurf->pending.prop;
1915 prop->transition_type = type;
1916 prop->transition_duration = duration;
1917 return 0;
1918}
1919
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09001920static int32_t
1921ivi_layout_surface_dump(struct weston_surface *surface,
1922 void *target, size_t size,int32_t x, int32_t y,
1923 int32_t width, int32_t height)
1924{
1925 int result = 0;
1926
1927 if (surface == NULL) {
1928 weston_log("%s: invalid argument\n", __func__);
1929 return IVI_FAILED;
1930 }
1931
1932 result = weston_surface_copy_content(
1933 surface, target, size,
1934 x, y, width, height);
1935
1936 return result == 0 ? IVI_SUCCEEDED : IVI_FAILED;
1937}
1938
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001939/**
1940 * methods of interaction between ivi-shell with ivi-layout
1941 */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001942
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001943void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001944ivi_layout_surface_configure(struct ivi_layout_surface *ivisurf,
1945 int32_t width, int32_t height)
1946{
1947 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001948
Nobuhiko Tanibatae6cc9972015-04-27 16:54:01 +09001949 /* emit callback which is set by ivi-layout api user */
1950 wl_signal_emit(&layout->surface_notification.configure_changed,
1951 ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001952}
1953
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001954struct ivi_layout_surface*
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001955ivi_layout_surface_create(struct weston_surface *wl_surface,
1956 uint32_t id_surface)
1957{
1958 struct ivi_layout *layout = get_instance();
1959 struct ivi_layout_surface *ivisurf = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001960
1961 if (wl_surface == NULL) {
1962 weston_log("ivi_layout_surface_create: invalid argument\n");
1963 return NULL;
1964 }
1965
1966 ivisurf = get_surface(&layout->surface_list, id_surface);
1967 if (ivisurf != NULL) {
1968 if (ivisurf->surface != NULL) {
1969 weston_log("id_surface(%d) is already created\n", id_surface);
1970 return NULL;
1971 }
1972 }
1973
1974 ivisurf = calloc(1, sizeof *ivisurf);
1975 if (ivisurf == NULL) {
1976 weston_log("fails to allocate memory\n");
1977 return NULL;
1978 }
1979
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001980 wl_signal_init(&ivisurf->property_changed);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001981 ivisurf->id_surface = id_surface;
1982 ivisurf->layout = layout;
1983
1984 ivisurf->surface = wl_surface;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001985
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001986 ivisurf->surface->width_from_buffer = 0;
1987 ivisurf->surface->height_from_buffer = 0;
1988
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001989 init_surface_properties(&ivisurf->prop);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001990
1991 ivisurf->pending.prop = ivisurf->prop;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001992
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001993 wl_list_init(&ivisurf->view_list);
1994
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001995 wl_list_insert(&layout->surface_list, &ivisurf->link);
1996
1997 wl_signal_emit(&layout->surface_notification.created, ivisurf);
1998
1999 return ivisurf;
2000}
2001
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002002void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002003ivi_layout_init_with_compositor(struct weston_compositor *ec)
2004{
2005 struct ivi_layout *layout = get_instance();
2006
2007 layout->compositor = ec;
2008
2009 wl_list_init(&layout->surface_list);
2010 wl_list_init(&layout->layer_list);
2011 wl_list_init(&layout->screen_list);
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00002012 wl_list_init(&layout->view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002013
2014 wl_signal_init(&layout->layer_notification.created);
2015 wl_signal_init(&layout->layer_notification.removed);
2016
2017 wl_signal_init(&layout->surface_notification.created);
2018 wl_signal_init(&layout->surface_notification.removed);
2019 wl_signal_init(&layout->surface_notification.configure_changed);
2020
2021 /* Add layout_layer at the last of weston_compositor.layer_list */
Quentin Glidic82681572016-12-17 13:40:51 +01002022 weston_layer_init(&layout->layout_layer, ec);
2023 weston_layer_set_position(&layout->layout_layer,
2024 WESTON_LAYER_POSITION_NORMAL);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002025
2026 create_screen(ec);
2027
2028 layout->transitions = ivi_layout_transition_set_create(ec);
2029 wl_list_init(&layout->pending_transition_list);
2030}
2031
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002032static struct ivi_layout_interface ivi_layout_interface = {
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002033 /**
2034 * commit all changes
2035 */
2036 .commit_changes = ivi_layout_commit_changes,
2037
2038 /**
2039 * surface controller interfaces
2040 */
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00002041 .add_listener_create_surface = ivi_layout_add_listener_create_surface,
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00002042 .add_listener_remove_surface = ivi_layout_add_listener_remove_surface,
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00002043 .add_listener_configure_surface = ivi_layout_add_listener_configure_surface,
Pekka Paalaneneaa43fc2016-04-12 16:06:58 +03002044 .get_surface = shell_get_ivi_layout_surface,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002045 .get_surfaces = ivi_layout_get_surfaces,
2046 .get_id_of_surface = ivi_layout_get_id_of_surface,
2047 .get_surface_from_id = ivi_layout_get_surface_from_id,
2048 .get_properties_of_surface = ivi_layout_get_properties_of_surface,
2049 .get_surfaces_on_layer = ivi_layout_get_surfaces_on_layer,
2050 .surface_set_visibility = ivi_layout_surface_set_visibility,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002051 .surface_set_opacity = ivi_layout_surface_set_opacity,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002052 .surface_set_source_rectangle = ivi_layout_surface_set_source_rectangle,
2053 .surface_set_destination_rectangle = ivi_layout_surface_set_destination_rectangle,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002054 .surface_set_orientation = ivi_layout_surface_set_orientation,
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00002055 .surface_add_listener = ivi_layout_surface_add_listener,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002056 .surface_get_weston_surface = ivi_layout_surface_get_weston_surface,
2057 .surface_set_transition = ivi_layout_surface_set_transition,
2058 .surface_set_transition_duration = ivi_layout_surface_set_transition_duration,
2059
2060 /**
2061 * layer controller interfaces
2062 */
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +00002063 .add_listener_create_layer = ivi_layout_add_listener_create_layer,
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +00002064 .add_listener_remove_layer = ivi_layout_add_listener_remove_layer,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002065 .layer_create_with_dimension = ivi_layout_layer_create_with_dimension,
Nobuhiko Tanibata3aa8aed2015-06-22 15:32:23 +09002066 .layer_destroy = ivi_layout_layer_destroy,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002067 .get_layers = ivi_layout_get_layers,
2068 .get_id_of_layer = ivi_layout_get_id_of_layer,
2069 .get_layer_from_id = ivi_layout_get_layer_from_id,
2070 .get_properties_of_layer = ivi_layout_get_properties_of_layer,
2071 .get_layers_under_surface = ivi_layout_get_layers_under_surface,
2072 .get_layers_on_screen = ivi_layout_get_layers_on_screen,
2073 .layer_set_visibility = ivi_layout_layer_set_visibility,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002074 .layer_set_opacity = ivi_layout_layer_set_opacity,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002075 .layer_set_source_rectangle = ivi_layout_layer_set_source_rectangle,
2076 .layer_set_destination_rectangle = ivi_layout_layer_set_destination_rectangle,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002077 .layer_set_orientation = ivi_layout_layer_set_orientation,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002078 .layer_add_surface = ivi_layout_layer_add_surface,
2079 .layer_remove_surface = ivi_layout_layer_remove_surface,
2080 .layer_set_render_order = ivi_layout_layer_set_render_order,
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00002081 .layer_add_listener = ivi_layout_layer_add_listener,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002082 .layer_set_transition = ivi_layout_layer_set_transition,
2083
2084 /**
Ucan, Emre (ADITG/SW1)6d89b1c2016-03-17 15:30:49 +00002085 * screen controller interfaces
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002086 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002087 .get_screens_under_layer = ivi_layout_get_screens_under_layer,
2088 .screen_add_layer = ivi_layout_screen_add_layer,
2089 .screen_set_render_order = ivi_layout_screen_set_render_order,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002090
2091 /**
2092 * animation
2093 */
2094 .transition_move_layer_cancel = ivi_layout_transition_move_layer_cancel,
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09002095 .layer_set_fade_info = ivi_layout_layer_set_fade_info,
2096
2097 /**
2098 * surface content dumping for debugging
2099 */
2100 .surface_get_size = ivi_layout_surface_get_size,
2101 .surface_dump = ivi_layout_surface_dump,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002102};
2103
2104int
2105load_controller_modules(struct weston_compositor *compositor, const char *modules,
2106 int *argc, char *argv[])
2107{
2108 const char *p, *end;
2109 char buffer[256];
2110 int (*controller_module_init)(struct weston_compositor *compositor,
2111 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002112 const struct ivi_layout_interface *interface,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002113 size_t interface_version);
2114
2115 if (modules == NULL)
2116 return 0;
2117
2118 p = modules;
2119 while (*p) {
2120 end = strchrnul(p, ',');
2121 snprintf(buffer, sizeof buffer, "%.*s", (int)(end - p), p);
2122
Giulio Camuffo179fcda2016-06-02 21:48:14 +03002123 controller_module_init = wet_load_module(buffer, "controller_module_init");
Pekka Paalanen97246c02015-03-26 15:47:29 +02002124 if (!controller_module_init)
2125 return -1;
2126
2127 if (controller_module_init(compositor, argc, argv,
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002128 &ivi_layout_interface,
2129 sizeof(struct ivi_layout_interface)) != 0) {
Pekka Paalanen97246c02015-03-26 15:47:29 +02002130 weston_log("ivi-shell: Initialization of controller module fails");
2131 return -1;
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002132 }
2133
2134 p = end;
2135 while (*p == ',')
2136 p++;
2137 }
2138
2139 return 0;
2140}