blob: 7c2f32d83b4a952a58430b4fd11cb212cdac61b8 [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 {
79 struct wl_list link;
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 {
85 struct wl_list layer_list;
86 struct wl_list link;
87 } pending;
88
89 struct {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +000090 int dirty;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090091 struct wl_list layer_list;
92 struct wl_list link;
93 } order;
94};
95
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +090096struct ivi_rectangle
97{
98 int32_t x;
99 int32_t y;
100 int32_t width;
101 int32_t height;
102};
103
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900104static struct ivi_layout ivilayout = {0};
105
106struct ivi_layout *
107get_instance(void)
108{
109 return &ivilayout;
110}
111
112/**
Bryce Harringtone6da35d2016-05-19 17:35:02 -0700113 * Internal API to add/remove an ivi_layer to/from ivi_screen.
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900114 */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900115static struct ivi_layout_surface *
116get_surface(struct wl_list *surf_list, uint32_t id_surface)
117{
118 struct ivi_layout_surface *ivisurf;
119
120 wl_list_for_each(ivisurf, surf_list, link) {
121 if (ivisurf->id_surface == id_surface) {
122 return ivisurf;
123 }
124 }
125
126 return NULL;
127}
128
129static struct ivi_layout_layer *
130get_layer(struct wl_list *layer_list, uint32_t id_layer)
131{
132 struct ivi_layout_layer *ivilayer;
133
134 wl_list_for_each(ivilayer, layer_list, link) {
135 if (ivilayer->id_layer == id_layer) {
136 return ivilayer;
137 }
138 }
139
140 return NULL;
141}
142
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000143static bool
144ivi_view_is_rendered(struct ivi_layout_view *view)
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000145{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000146 return !wl_list_empty(&view->order_link);
147}
148
149static void
150ivi_view_destroy(struct ivi_layout_view *ivi_view)
151{
152 wl_list_remove(&ivi_view->transform.link);
153 wl_list_remove(&ivi_view->link);
154 wl_list_remove(&ivi_view->surf_link);
155 wl_list_remove(&ivi_view->pending_link);
156 wl_list_remove(&ivi_view->order_link);
157
158 weston_view_destroy(ivi_view->view);
159
160 free(ivi_view);
161}
162
163static struct ivi_layout_view*
164ivi_view_create(struct ivi_layout_layer *ivilayer,
165 struct ivi_layout_surface *ivisurf)
166{
167 struct ivi_layout_view *ivi_view;
168
169 ivi_view = calloc(1, sizeof *ivi_view);
170 if (ivi_view == NULL) {
171 weston_log("fails to allocate memory\n");
172 return NULL;
173 }
174
175 ivi_view->view = weston_view_create(ivisurf->surface);
176 if (ivi_view->view == NULL) {
177 weston_log("fails to allocate memory\n");
178 return NULL;
179 }
180
181 weston_matrix_init(&ivi_view->transform.matrix);
182 wl_list_init(&ivi_view->transform.link);
183
184 ivi_view->ivisurf = ivisurf;
185 ivi_view->on_layer = ivilayer;
186 wl_list_insert(&ivilayer->layout->view_list,
187 &ivi_view->link);
188 wl_list_insert(&ivisurf->view_list,
189 &ivi_view->surf_link);
190
191 wl_list_init(&ivi_view->pending_link);
192 wl_list_init(&ivi_view->order_link);
193
194 return ivi_view;
195}
196
197static struct ivi_layout_view *
198get_ivi_view(struct ivi_layout_layer *ivilayer,
199 struct ivi_layout_surface *ivisurf)
200{
201 struct ivi_layout_view *ivi_view;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000202
203 assert(ivisurf->surface != NULL);
204
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000205 wl_list_for_each(ivi_view, &ivisurf->view_list, surf_link) {
206 if (ivi_view->on_layer == ivilayer)
207 return ivi_view;
208 }
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000209
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000210 return NULL;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000211}
212
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +0000213static struct ivi_layout_screen *
214get_screen_from_output(struct weston_output *output)
215{
216 struct ivi_layout *layout = get_instance();
217 struct ivi_layout_screen *iviscrn = NULL;
218
219 wl_list_for_each(iviscrn, &layout->screen_list, link) {
220 if (iviscrn->output == output)
221 return iviscrn;
222 }
223
224 return NULL;
225}
226
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900227/**
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900228 * Called at destruction of wl_surface/ivi_surface
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900229 */
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900230void
231ivi_layout_surface_destroy(struct ivi_layout_surface *ivisurf)
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900232{
233 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000234 struct ivi_layout_view *ivi_view ,*next;
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900235
236 if (ivisurf == NULL) {
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900237 weston_log("%s: invalid argument\n", __func__);
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900238 return;
239 }
240
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900241 wl_list_remove(&ivisurf->pending.link);
242 wl_list_remove(&ivisurf->order.link);
243 wl_list_remove(&ivisurf->link);
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900244
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000245 wl_list_for_each_safe(ivi_view, next, &ivisurf->view_list, surf_link) {
246 ivi_view_destroy(ivi_view);
247 }
248
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900249 wl_signal_emit(&layout->surface_notification.removed, ivisurf);
250
Mateusz Polroladada6e32016-03-09 09:13:26 +0000251 ivi_layout_remove_all_surface_transitions(ivisurf);
252
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900253 free(ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900254}
255
256/**
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900257 * Internal API to initialize ivi_screens found from output_list of weston_compositor.
258 * Called by ivi_layout_init_with_compositor.
259 */
260static void
261create_screen(struct weston_compositor *ec)
262{
263 struct ivi_layout *layout = get_instance();
264 struct ivi_layout_screen *iviscrn = NULL;
265 struct weston_output *output = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900266
267 wl_list_for_each(output, &ec->output_list, link) {
268 iviscrn = calloc(1, sizeof *iviscrn);
269 if (iviscrn == NULL) {
270 weston_log("fails to allocate memory\n");
271 continue;
272 }
273
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900274 iviscrn->layout = layout;
275
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900276 iviscrn->output = output;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900277
278 wl_list_init(&iviscrn->pending.layer_list);
279 wl_list_init(&iviscrn->pending.link);
280
281 wl_list_init(&iviscrn->order.layer_list);
282 wl_list_init(&iviscrn->order.link);
283
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900284 wl_list_insert(&layout->screen_list, &iviscrn->link);
285 }
286}
287
288/**
289 * Internal APIs to initialize properties of ivi_surface/ivi_layer when they are created.
290 */
291static void
292init_layer_properties(struct ivi_layout_layer_properties *prop,
293 int32_t width, int32_t height)
294{
295 memset(prop, 0, sizeof *prop);
296 prop->opacity = wl_fixed_from_double(1.0);
297 prop->source_width = width;
298 prop->source_height = height;
299 prop->dest_width = width;
300 prop->dest_height = height;
301}
302
303static void
304init_surface_properties(struct ivi_layout_surface_properties *prop)
305{
306 memset(prop, 0, sizeof *prop);
307 prop->opacity = wl_fixed_from_double(1.0);
Nobuhiko Tanibatae259a7a2015-04-27 17:02:54 +0900308 /*
Bryce Harringtone6da35d2016-05-19 17:35:02 -0700309 * FIXME: this shall be fixed by ivi-layout-transition.
Nobuhiko Tanibatae259a7a2015-04-27 17:02:54 +0900310 */
311 prop->dest_width = 1;
312 prop->dest_height = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900313}
314
315/**
316 * Internal APIs to be called from ivi_layout_commit_changes.
317 */
318static void
319update_opacity(struct ivi_layout_layer *ivilayer,
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000320 struct ivi_layout_surface *ivisurf,
321 struct weston_view *view)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900322{
323 double layer_alpha = wl_fixed_to_double(ivilayer->prop.opacity);
324 double surf_alpha = wl_fixed_to_double(ivisurf->prop.opacity);
325
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000326 view->alpha = layer_alpha * surf_alpha;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900327}
328
329static void
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900330get_rotate_values(enum wl_output_transform orientation,
331 float *v_sin,
332 float *v_cos)
333{
334 switch (orientation) {
335 case WL_OUTPUT_TRANSFORM_90:
336 *v_sin = 1.0f;
337 *v_cos = 0.0f;
338 break;
339 case WL_OUTPUT_TRANSFORM_180:
340 *v_sin = 0.0f;
341 *v_cos = -1.0f;
342 break;
343 case WL_OUTPUT_TRANSFORM_270:
344 *v_sin = -1.0f;
345 *v_cos = 0.0f;
346 break;
347 case WL_OUTPUT_TRANSFORM_NORMAL:
348 default:
349 *v_sin = 0.0f;
350 *v_cos = 1.0f;
351 break;
352 }
353}
354
355static void
356get_scale(enum wl_output_transform orientation,
357 float dest_width,
358 float dest_height,
359 float source_width,
360 float source_height,
361 float *scale_x,
362 float *scale_y)
363{
364 switch (orientation) {
365 case WL_OUTPUT_TRANSFORM_90:
366 *scale_x = dest_width / source_height;
367 *scale_y = dest_height / source_width;
368 break;
369 case WL_OUTPUT_TRANSFORM_180:
370 *scale_x = dest_width / source_width;
371 *scale_y = dest_height / source_height;
372 break;
373 case WL_OUTPUT_TRANSFORM_270:
374 *scale_x = dest_width / source_height;
375 *scale_y = dest_height / source_width;
376 break;
377 case WL_OUTPUT_TRANSFORM_NORMAL:
378 default:
379 *scale_x = dest_width / source_width;
380 *scale_y = dest_height / source_height;
381 break;
382 }
383}
384
385static void
386calc_transformation_matrix(struct ivi_rectangle *source_rect,
387 struct ivi_rectangle *dest_rect,
388 enum wl_output_transform orientation,
389 struct weston_matrix *m)
390{
391 float source_center_x;
392 float source_center_y;
393 float vsin;
394 float vcos;
395 float scale_x;
396 float scale_y;
397 float translate_x;
398 float translate_y;
399
400 source_center_x = source_rect->x + source_rect->width * 0.5f;
401 source_center_y = source_rect->y + source_rect->height * 0.5f;
402 weston_matrix_translate(m, -source_center_x, -source_center_y, 0.0f);
403
404 get_rotate_values(orientation, &vsin, &vcos);
405 weston_matrix_rotate_xy(m, vcos, vsin);
406
407 get_scale(orientation,
408 dest_rect->width,
409 dest_rect->height,
410 source_rect->width,
411 source_rect->height,
412 &scale_x,
413 &scale_y);
414 weston_matrix_scale(m, scale_x, scale_y, 1.0f);
415
416 translate_x = dest_rect->width * 0.5f + dest_rect->x;
417 translate_y = dest_rect->height * 0.5f + dest_rect->y;
418 weston_matrix_translate(m, translate_x, translate_y, 0.0f);
419}
420
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900421/*
422 * This computes intersected rect_output from two ivi_rectangles
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900423 */
424static void
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900425ivi_rectangle_intersect(const struct ivi_rectangle *rect1,
426 const struct ivi_rectangle *rect2,
427 struct ivi_rectangle *rect_output)
428{
429 int32_t rect1_right = rect1->x + rect1->width;
430 int32_t rect1_bottom = rect1->y + rect1->height;
431 int32_t rect2_right = rect2->x + rect2->width;
432 int32_t rect2_bottom = rect2->y + rect2->height;
433
434 rect_output->x = max(rect1->x, rect2->x);
435 rect_output->y = max(rect1->y, rect2->y);
436 rect_output->width = rect1_right < rect2_right ?
437 rect1_right - rect_output->x :
438 rect2_right - rect_output->x;
439 rect_output->height = rect1_bottom < rect2_bottom ?
440 rect1_bottom - rect_output->y :
441 rect2_bottom - rect_output->y;
442
443 if (rect_output->width < 0 || rect_output->height < 0) {
444 rect_output->width = 0;
445 rect_output->height = 0;
446 }
447}
448
449/*
450 * Transform rect_input by the inverse of matrix, intersect with boundingbox,
451 * and store the result in rect_output.
452 * The boundingbox must be given in the same coordinate space as rect_output.
453 * Additionally, there are the following restrictions on the matrix:
454 * - no projective transformations
455 * - no skew
456 * - only multiples of 90-degree rotations supported
457 *
458 * In failure case of weston_matrix_invert, rect_output is set to boundingbox
459 * as a fail-safe with log.
460 */
461static void
462calc_inverse_matrix_transform(const struct weston_matrix *matrix,
463 const struct ivi_rectangle *rect_input,
464 const struct ivi_rectangle *boundingbox,
465 struct ivi_rectangle *rect_output)
466{
467 struct weston_matrix m;
468 struct weston_vector top_left;
469 struct weston_vector bottom_right;
470
471 assert(boundingbox != rect_output);
472
473 if (weston_matrix_invert(&m, matrix) < 0) {
474 weston_log("ivi-shell: calc_inverse_matrix_transform fails to invert a matrix.\n");
475 weston_log("ivi-shell: boundingbox is set to the rect_output.\n");
476 rect_output->x = boundingbox->x;
477 rect_output->y = boundingbox->y;
478 rect_output->width = boundingbox->width;
479 rect_output->height = boundingbox->height;
480 }
481
482 /* The vectors and matrices involved will always produce f[3] == 1.0. */
483 top_left.f[0] = rect_input->x;
484 top_left.f[1] = rect_input->y;
485 top_left.f[2] = 0.0f;
486 top_left.f[3] = 1.0f;
487
488 bottom_right.f[0] = rect_input->x + rect_input->width;
489 bottom_right.f[1] = rect_input->y + rect_input->height;
490 bottom_right.f[2] = 0.0f;
491 bottom_right.f[3] = 1.0f;
492
493 weston_matrix_transform(&m, &top_left);
494 weston_matrix_transform(&m, &bottom_right);
495
496 if (top_left.f[0] < bottom_right.f[0]) {
497 rect_output->x = top_left.f[0];
498 rect_output->width = bottom_right.f[0] - rect_output->x;
499 } else {
500 rect_output->x = bottom_right.f[0];
501 rect_output->width = top_left.f[0] - rect_output->x;
502 }
503
504 if (top_left.f[1] < bottom_right.f[1]) {
505 rect_output->y = top_left.f[1];
506 rect_output->height = bottom_right.f[1] - rect_output->y;
507 } else {
508 rect_output->y = bottom_right.f[1];
509 rect_output->height = top_left.f[1] - rect_output->y;
510 }
511
512 ivi_rectangle_intersect(rect_output, boundingbox, rect_output);
513}
514
515/**
516 * This computes the whole transformation matrix:m from surface-local
Yong Bakose0698712016-04-28 11:59:08 -0500517 * coordinates to multi-screen coordinates, which are global coordinates.
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900518 * It is assumed that weston_view::geometry.{x,y} are zero.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900519 *
Bryce Harringtone6da35d2016-05-19 17:35:02 -0700520 * Additionally, this computes the mask on surface-local coordinates as an
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900521 * ivi_rectangle. This can be set to weston_view_set_mask.
522 *
523 * The mask is computed by following steps
Yong Bakose0698712016-04-28 11:59:08 -0500524 * - destination rectangle of layer is transformed to multi-screen coordinates,
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900525 * global coordinates. This is done by adding weston_output.{x,y} in simple
526 * because there is no scaled and rotated transformation.
Yong Bakose0698712016-04-28 11:59:08 -0500527 * - destination rectangle of layer in multi-screen coordinates needs to be
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900528 * intersected inside of a screen the layer is assigned to. This is because
529 * overlapped region of weston surface in another screen shall not be
530 * displayed according to ivi use case.
531 * - destination rectangle of layer
Yong Bakose0698712016-04-28 11:59:08 -0500532 * - in multi-screen coordinates,
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900533 * - and intersected inside of an assigned screen,
Yong Bakose0698712016-04-28 11:59:08 -0500534 * is inversed to surface-local coordinates by inversed matrix:m.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900535 * - the area is intersected by intersected area between weston_surface and
536 * source rectangle of ivi_surface.
537 */
538static void
539calc_surface_to_global_matrix_and_mask_to_weston_surface(
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900540 struct ivi_layout_screen *iviscrn,
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900541 struct ivi_layout_layer *ivilayer,
542 struct ivi_layout_surface *ivisurf,
543 struct weston_matrix *m,
544 struct ivi_rectangle *result)
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900545{
546 const struct ivi_layout_surface_properties *sp = &ivisurf->prop;
547 const struct ivi_layout_layer_properties *lp = &ivilayer->prop;
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900548 struct weston_output *output = iviscrn->output;
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900549 struct ivi_rectangle weston_surface_rect = { 0,
550 0,
551 ivisurf->surface->width,
552 ivisurf->surface->height };
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900553 struct ivi_rectangle surface_source_rect = { sp->source_x,
554 sp->source_y,
555 sp->source_width,
556 sp->source_height };
557 struct ivi_rectangle surface_dest_rect = { sp->dest_x,
558 sp->dest_y,
559 sp->dest_width,
560 sp->dest_height };
561 struct ivi_rectangle layer_source_rect = { lp->source_x,
562 lp->source_y,
563 lp->source_width,
564 lp->source_height };
565 struct ivi_rectangle layer_dest_rect = { lp->dest_x,
566 lp->dest_y,
567 lp->dest_width,
568 lp->dest_height };
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900569 struct ivi_rectangle screen_dest_rect = { output->x,
570 output->y,
571 output->width,
572 output->height };
573 struct ivi_rectangle layer_dest_rect_in_global =
574 { lp->dest_x + output->x,
575 lp->dest_y + output->y,
576 lp->dest_width,
577 lp->dest_height };
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900578 struct ivi_rectangle surface_result;
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900579 struct ivi_rectangle layer_dest_rect_in_global_intersected;
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900580
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900581 /*
582 * the whole transformation matrix:m from surface-local
583 * coordinates to global coordinates, which is computed by
584 * two steps,
585 * - surface-local coordinates to layer-local coordinates
Yong Bakose0698712016-04-28 11:59:08 -0500586 * - layer-local coordinates to single screen-local coordinates
587 * - single screen-local coordinates to multi-screen coordinates,
588 * which are global coordinates.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900589 */
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900590 calc_transformation_matrix(&surface_source_rect,
591 &surface_dest_rect,
592 sp->orientation, m);
593
594 calc_transformation_matrix(&layer_source_rect,
595 &layer_dest_rect,
596 lp->orientation, m);
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900597
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900598 weston_matrix_translate(m, output->x, output->y, 0.0f);
599
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900600 /* this intersected ivi_rectangle would be used for masking
601 * weston_surface
602 */
603 ivi_rectangle_intersect(&surface_source_rect, &weston_surface_rect,
604 &surface_result);
605
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900606 /*
607 * destination rectangle of layer in multi screens coordinate
608 * is intersected to avoid displaying outside of an assigned screen.
609 */
610 ivi_rectangle_intersect(&layer_dest_rect_in_global, &screen_dest_rect,
611 &layer_dest_rect_in_global_intersected);
612
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900613 /* calc masking area of weston_surface from m */
614 calc_inverse_matrix_transform(m,
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900615 &layer_dest_rect_in_global_intersected,
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900616 &surface_result,
617 result);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900618}
619
620static void
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900621update_prop(struct ivi_layout_screen *iviscrn,
622 struct ivi_layout_layer *ivilayer,
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000623 struct ivi_layout_view *ivi_view)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900624{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000625 struct ivi_layout_surface *ivisurf;
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900626 struct ivi_rectangle r;
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900627 bool can_calc = true;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900628
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000629 assert(ivi_view->on_layer == ivilayer);
630
631 ivisurf = ivi_view->ivisurf;
632
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900633 /*In case of no prop change, this just returns*/
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000634 if (!ivilayer->prop.event_mask && !ivisurf->prop.event_mask)
Nobuhiko Tanibata4c1dbf72015-07-15 13:55:50 +0900635 return;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900636
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000637 update_opacity(ivilayer, ivisurf, ivi_view->view);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900638
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900639 if (ivisurf->prop.source_width == 0 || ivisurf->prop.source_height == 0) {
640 weston_log("ivi-shell: source rectangle is not yet set by ivi_layout_surface_set_source_rectangle\n");
641 can_calc = false;
642 }
643
644 if (ivisurf->prop.dest_width == 0 || ivisurf->prop.dest_height == 0) {
645 weston_log("ivi-shell: destination rectangle is not yet set by ivi_layout_surface_set_destination_rectangle\n");
646 can_calc = false;
647 }
648
649 if (can_calc) {
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000650 wl_list_remove(&ivi_view->transform.link);
651 weston_matrix_init(&ivi_view->transform.matrix);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900652
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900653 calc_surface_to_global_matrix_and_mask_to_weston_surface(
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000654 iviscrn, ivilayer, ivisurf, &ivi_view->transform.matrix, &r);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900655
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000656 weston_view_set_mask(ivi_view->view, r.x, r.y, r.width, r.height);
657 wl_list_insert(&ivi_view->view->geometry.transformation_list,
658 &ivi_view->transform.link);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900659
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000660 weston_view_set_transform_parent(ivi_view->view, NULL);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900661 }
662
663 ivisurf->update_count++;
664
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000665 weston_view_geometry_dirty(ivi_view->view);
Nobuhiko Tanibata4c1dbf72015-07-15 13:55:50 +0900666
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000667 weston_surface_damage(ivisurf->surface);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900668}
669
670static void
671commit_changes(struct ivi_layout *layout)
672{
673 struct ivi_layout_screen *iviscrn = NULL;
674 struct ivi_layout_layer *ivilayer = NULL;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000675 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900676
677 wl_list_for_each(iviscrn, &layout->screen_list, link) {
678 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900679 /*
680 * If ivilayer is invisible, weston_view of ivisurf doesn't
681 * need to be modified.
682 */
683 if (ivilayer->prop.visibility == false)
684 continue;
685
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000686 wl_list_for_each(ivi_view, &ivilayer->order.view_list, order_link) {
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900687 /*
688 * If ivilayer is invisible, weston_view of ivisurf doesn't
689 * need to be modified.
690 */
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000691 if (ivi_view->ivisurf->prop.visibility == false)
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900692 continue;
693
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000694 update_prop(iviscrn, ivilayer, ivi_view);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900695 }
696 }
697 }
698}
699
700static void
701commit_surface_list(struct ivi_layout *layout)
702{
703 struct ivi_layout_surface *ivisurf = NULL;
704 int32_t dest_x = 0;
705 int32_t dest_y = 0;
706 int32_t dest_width = 0;
707 int32_t dest_height = 0;
708 int32_t configured = 0;
709
710 wl_list_for_each(ivisurf, &layout->surface_list, link) {
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300711 if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEFAULT) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900712 dest_x = ivisurf->prop.dest_x;
713 dest_y = ivisurf->prop.dest_y;
714 dest_width = ivisurf->prop.dest_width;
715 dest_height = ivisurf->prop.dest_height;
716
717 ivi_layout_transition_move_resize_view(ivisurf,
718 ivisurf->pending.prop.dest_x,
719 ivisurf->pending.prop.dest_y,
720 ivisurf->pending.prop.dest_width,
721 ivisurf->pending.prop.dest_height,
722 ivisurf->pending.prop.transition_duration);
723
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300724 if (ivisurf->pending.prop.visibility) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900725 ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration);
726 } else {
727 ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration);
728 }
729
730 ivisurf->prop = ivisurf->pending.prop;
731 ivisurf->prop.dest_x = dest_x;
732 ivisurf->prop.dest_y = dest_y;
733 ivisurf->prop.dest_width = dest_width;
734 ivisurf->prop.dest_height = dest_height;
735 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
736 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
737
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300738 } else if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEST_RECT_ONLY) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900739 dest_x = ivisurf->prop.dest_x;
740 dest_y = ivisurf->prop.dest_y;
741 dest_width = ivisurf->prop.dest_width;
742 dest_height = ivisurf->prop.dest_height;
743
744 ivi_layout_transition_move_resize_view(ivisurf,
745 ivisurf->pending.prop.dest_x,
746 ivisurf->pending.prop.dest_y,
747 ivisurf->pending.prop.dest_width,
748 ivisurf->pending.prop.dest_height,
749 ivisurf->pending.prop.transition_duration);
750
751 ivisurf->prop = ivisurf->pending.prop;
752 ivisurf->prop.dest_x = dest_x;
753 ivisurf->prop.dest_y = dest_y;
754 ivisurf->prop.dest_width = dest_width;
755 ivisurf->prop.dest_height = dest_height;
756
757 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
758 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
759
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300760 } else if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900761 configured = 0;
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300762 if (ivisurf->pending.prop.visibility) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900763 ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration);
764 } else {
765 ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration);
766 }
767
768 if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width ||
769 ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) {
770 configured = 1;
771 }
772
773 ivisurf->prop = ivisurf->pending.prop;
774 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
775 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
776
Pekka Paalanen1f821932016-03-15 16:57:51 +0200777 if (configured && !is_surface_transition(ivisurf)) {
Pekka Paalanen1f821932016-03-15 16:57:51 +0200778 shell_surface_send_configure(ivisurf->surface,
779 ivisurf->prop.dest_width,
780 ivisurf->prop.dest_height);
781 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900782 } else {
783 configured = 0;
784 if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width ||
785 ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) {
786 configured = 1;
787 }
788
789 ivisurf->prop = ivisurf->pending.prop;
790 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
791 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
792
Pekka Paalanen1f821932016-03-15 16:57:51 +0200793 if (configured && !is_surface_transition(ivisurf)) {
Pekka Paalanen1f821932016-03-15 16:57:51 +0200794 shell_surface_send_configure(ivisurf->surface,
795 ivisurf->prop.dest_width,
796 ivisurf->prop.dest_height);
797 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900798 }
799 }
800}
801
802static void
803commit_layer_list(struct ivi_layout *layout)
804{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000805 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900806 struct ivi_layout_layer *ivilayer = NULL;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000807 struct ivi_layout_view *next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900808
809 wl_list_for_each(ivilayer, &layout->layer_list, link) {
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300810 if (ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_MOVE) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900811 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 -0300812 } else if (ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_FADE) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900813 ivi_layout_transition_fade_layer(ivilayer,ivilayer->pending.prop.is_fade_in,
814 ivilayer->pending.prop.start_alpha,ivilayer->pending.prop.end_alpha,
815 NULL, NULL,
816 ivilayer->pending.prop.transition_duration);
817 }
818 ivilayer->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
819
820 ivilayer->prop = ivilayer->pending.prop;
821
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +0000822 if (!ivilayer->order.dirty) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900823 continue;
824 }
825
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000826 wl_list_for_each_safe(ivi_view, next, &ivilayer->order.view_list,
827 order_link) {
828 wl_list_remove(&ivi_view->order_link);
829 wl_list_init(&ivi_view->order_link);
830 ivi_view->ivisurf->prop.event_mask |= IVI_NOTIFICATION_REMOVE;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900831 }
832
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000833 assert(wl_list_empty(&ivilayer->order.view_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900834
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000835 wl_list_for_each(ivi_view, &ivilayer->pending.view_list,
836 pending_link) {
837 wl_list_remove(&ivi_view->order_link);
838 wl_list_insert(&ivilayer->order.view_list, &ivi_view->order_link);
839 ivi_view->ivisurf->prop.event_mask |= IVI_NOTIFICATION_ADD;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900840 }
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +0000841
842 ivilayer->order.dirty = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900843 }
844}
845
846static void
847commit_screen_list(struct ivi_layout *layout)
848{
849 struct ivi_layout_screen *iviscrn = NULL;
850 struct ivi_layout_layer *ivilayer = NULL;
851 struct ivi_layout_layer *next = NULL;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000852 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900853
Nobuhiko Tanibatafbfa8f22015-11-25 23:36:57 +0900854 /* Clear view list of layout ivi_layer */
855 wl_list_init(&layout->layout_layer.view_list.link);
856
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900857 wl_list_for_each(iviscrn, &layout->screen_list, link) {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000858 if (iviscrn->order.dirty) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900859 wl_list_for_each_safe(ivilayer, next,
860 &iviscrn->order.layer_list, order.link) {
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +0000861 ivilayer->on_screen = NULL;
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000862 wl_list_remove(&ivilayer->order.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900863 wl_list_init(&ivilayer->order.link);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000864 ivilayer->prop.event_mask |= IVI_NOTIFICATION_REMOVE;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900865 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900866
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000867 assert(wl_list_empty(&iviscrn->order.layer_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900868
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900869 wl_list_for_each(ivilayer, &iviscrn->pending.layer_list,
870 pending.link) {
Nobuhiko Tanibata77b0ee12015-11-25 23:36:46 +0900871 /* FIXME: avoid to insert order.link to multiple screens */
872 wl_list_remove(&ivilayer->order.link);
873
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900874 wl_list_insert(&iviscrn->order.layer_list,
875 &ivilayer->order.link);
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +0000876 ivilayer->on_screen = iviscrn;
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000877 ivilayer->prop.event_mask |= IVI_NOTIFICATION_ADD;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900878 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900879
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000880 iviscrn->order.dirty = 0;
881 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900882
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900883 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
884 if (ivilayer->prop.visibility == false)
885 continue;
886
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000887 wl_list_for_each(ivi_view, &ivilayer->order.view_list, order_link) {
888 if (ivi_view->ivisurf->prop.visibility == false)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900889 continue;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000890
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900891 weston_layer_entry_insert(&layout->layout_layer.view_list,
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000892 &ivi_view->view->layer_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900893
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000894 ivi_view->view->output = iviscrn->output;
Armin Krezović50ff4bf2016-06-30 06:04:31 +0200895 ivi_view->ivisurf->surface->is_mapped = true;
896 ivi_view->view->is_mapped = true;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900897 }
898 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900899 }
900}
901
902static void
903commit_transition(struct ivi_layout* layout)
904{
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300905 if (wl_list_empty(&layout->pending_transition_list)) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900906 return;
907 }
908
909 wl_list_insert_list(&layout->transitions->transition_list,
910 &layout->pending_transition_list);
911
912 wl_list_init(&layout->pending_transition_list);
913
914 wl_event_source_timer_update(layout->transitions->event_source, 1);
915}
916
917static void
918send_surface_prop(struct ivi_layout_surface *ivisurf)
919{
920 wl_signal_emit(&ivisurf->property_changed, ivisurf);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000921 ivisurf->pending.prop.event_mask = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900922}
923
924static void
925send_layer_prop(struct ivi_layout_layer *ivilayer)
926{
927 wl_signal_emit(&ivilayer->property_changed, ivilayer);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000928 ivilayer->pending.prop.event_mask = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900929}
930
931static void
932send_prop(struct ivi_layout *layout)
933{
934 struct ivi_layout_layer *ivilayer = NULL;
935 struct ivi_layout_surface *ivisurf = NULL;
936
937 wl_list_for_each_reverse(ivilayer, &layout->layer_list, link) {
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000938 if (ivilayer->prop.event_mask)
Nobuhiko Tanibata6ce3ef82015-06-22 15:32:06 +0900939 send_layer_prop(ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900940 }
941
942 wl_list_for_each_reverse(ivisurf, &layout->surface_list, link) {
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000943 if (ivisurf->prop.event_mask)
Nobuhiko Tanibata6ce3ef82015-06-22 15:32:06 +0900944 send_surface_prop(ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900945 }
946}
947
948static void
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000949clear_view_pending_list(struct ivi_layout_layer *ivilayer)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900950{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000951 struct ivi_layout_view *view_link = NULL;
952 struct ivi_layout_view *view_next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900953
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000954 wl_list_for_each_safe(view_link, view_next,
955 &ivilayer->pending.view_list, pending_link) {
956 wl_list_remove(&view_link->pending_link);
957 wl_list_init(&view_link->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900958 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900959}
960
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900961/**
962 * Exported APIs of ivi-layout library are implemented from here.
963 * Brief of APIs is described in ivi-layout-export.h.
964 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900965static int32_t
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000966ivi_layout_add_listener_create_layer(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900967{
968 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900969
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000970 if (listener == NULL) {
971 weston_log("ivi_layout_add_listener_create_layer: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900972 return IVI_FAILED;
973 }
974
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000975 wl_signal_add(&layout->layer_notification.created, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900976
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000977 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900978}
979
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900980static int32_t
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000981ivi_layout_add_listener_remove_layer(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900982{
983 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900984
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000985 if (listener == NULL) {
986 weston_log("ivi_layout_add_listener_remove_layer: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900987 return IVI_FAILED;
988 }
989
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000990 wl_signal_add(&layout->layer_notification.removed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900991
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000992 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900993}
994
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900995static int32_t
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000996ivi_layout_add_listener_create_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900997{
998 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900999
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00001000 if (listener == NULL) {
1001 weston_log("ivi_layout_add_listener_create_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001002 return IVI_FAILED;
1003 }
1004
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00001005 wl_signal_add(&layout->surface_notification.created, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001006
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00001007 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001008}
1009
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001010static int32_t
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001011ivi_layout_add_listener_remove_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001012{
1013 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001014
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001015 if (listener == NULL) {
1016 weston_log("ivi_layout_add_listener_remove_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001017 return IVI_FAILED;
1018 }
1019
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001020 wl_signal_add(&layout->surface_notification.removed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001021
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001022 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001023}
1024
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001025static int32_t
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001026ivi_layout_add_listener_configure_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001027{
1028 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001029
1030 if (listener == NULL) {
1031 weston_log("ivi_layout_add_listener_configure_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001032 return IVI_FAILED;
1033 }
1034
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001035 wl_signal_add(&layout->surface_notification.configure_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001036
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001037 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001038}
1039
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001040uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001041ivi_layout_get_id_of_surface(struct ivi_layout_surface *ivisurf)
1042{
1043 return ivisurf->id_surface;
1044}
1045
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001046static uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001047ivi_layout_get_id_of_layer(struct ivi_layout_layer *ivilayer)
1048{
1049 return ivilayer->id_layer;
1050}
1051
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001052static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001053ivi_layout_get_layer_from_id(uint32_t id_layer)
1054{
1055 struct ivi_layout *layout = get_instance();
1056 struct ivi_layout_layer *ivilayer = NULL;
1057
1058 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1059 if (ivilayer->id_layer == id_layer) {
1060 return ivilayer;
1061 }
1062 }
1063
1064 return NULL;
1065}
1066
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001067struct ivi_layout_surface *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001068ivi_layout_get_surface_from_id(uint32_t id_surface)
1069{
1070 struct ivi_layout *layout = get_instance();
1071 struct ivi_layout_surface *ivisurf = NULL;
1072
1073 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1074 if (ivisurf->id_surface == id_surface) {
1075 return ivisurf;
1076 }
1077 }
1078
1079 return NULL;
1080}
1081
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001082static int32_t
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001083ivi_layout_surface_add_listener(struct ivi_layout_surface *ivisurf,
1084 struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001085{
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001086 if (ivisurf == NULL || listener == NULL) {
1087 weston_log("ivi_layout_surface_add_listener: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001088 return IVI_FAILED;
1089 }
1090
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001091 wl_signal_add(&ivisurf->property_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001092
1093 return IVI_SUCCEEDED;
1094}
1095
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001096static const struct ivi_layout_layer_properties *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001097ivi_layout_get_properties_of_layer(struct ivi_layout_layer *ivilayer)
1098{
1099 if (ivilayer == NULL) {
1100 weston_log("ivi_layout_get_properties_of_layer: invalid argument\n");
1101 return NULL;
1102 }
1103
1104 return &ivilayer->prop;
1105}
1106
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001107static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001108ivi_layout_get_screens_under_layer(struct ivi_layout_layer *ivilayer,
1109 int32_t *pLength,
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001110 struct weston_output ***ppArray)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001111{
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001112 int32_t length = 0;
1113 int32_t n = 0;
1114
1115 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1116 weston_log("ivi_layout_get_screens_under_layer: invalid argument\n");
1117 return IVI_FAILED;
1118 }
1119
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +00001120 if (ivilayer->on_screen != NULL)
1121 length = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001122
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001123 if (length != 0) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001124 /* the Array must be free by module which called this function */
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001125 *ppArray = calloc(length, sizeof(struct weston_output *));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001126 if (*ppArray == NULL) {
1127 weston_log("fails to allocate memory\n");
1128 return IVI_FAILED;
1129 }
1130
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001131 (*ppArray)[n++] = ivilayer->on_screen->output;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001132 }
1133
1134 *pLength = length;
1135
1136 return IVI_SUCCEEDED;
1137}
1138
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001139static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001140ivi_layout_get_layers(int32_t *pLength, struct ivi_layout_layer ***ppArray)
1141{
1142 struct ivi_layout *layout = get_instance();
1143 struct ivi_layout_layer *ivilayer = NULL;
1144 int32_t length = 0;
1145 int32_t n = 0;
1146
1147 if (pLength == NULL || ppArray == NULL) {
1148 weston_log("ivi_layout_get_layers: invalid argument\n");
1149 return IVI_FAILED;
1150 }
1151
1152 length = wl_list_length(&layout->layer_list);
1153
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001154 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001155 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001156 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1157 if (*ppArray == NULL) {
1158 weston_log("fails to allocate memory\n");
1159 return IVI_FAILED;
1160 }
1161
1162 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1163 (*ppArray)[n++] = ivilayer;
1164 }
1165 }
1166
1167 *pLength = length;
1168
1169 return IVI_SUCCEEDED;
1170}
1171
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001172static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001173ivi_layout_get_layers_on_screen(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001174 int32_t *pLength,
1175 struct ivi_layout_layer ***ppArray)
1176{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001177 struct ivi_layout_screen *iviscrn = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001178 struct ivi_layout_layer *ivilayer = NULL;
1179 int32_t length = 0;
1180 int32_t n = 0;
1181
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001182 if (output == NULL || pLength == NULL || ppArray == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001183 weston_log("ivi_layout_get_layers_on_screen: invalid argument\n");
1184 return IVI_FAILED;
1185 }
1186
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001187 iviscrn = get_screen_from_output(output);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001188 length = wl_list_length(&iviscrn->order.layer_list);
1189
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001190 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001191 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001192 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1193 if (*ppArray == NULL) {
1194 weston_log("fails to allocate memory\n");
1195 return IVI_FAILED;
1196 }
1197
Nobuhiko Tanibatae2b82142015-06-22 15:30:19 +09001198 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001199 (*ppArray)[n++] = ivilayer;
1200 }
1201 }
1202
1203 *pLength = length;
1204
1205 return IVI_SUCCEEDED;
1206}
1207
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001208static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001209ivi_layout_get_layers_under_surface(struct ivi_layout_surface *ivisurf,
1210 int32_t *pLength,
1211 struct ivi_layout_layer ***ppArray)
1212{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001213 struct ivi_layout_view *ivi_view;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001214 int32_t length = 0;
1215 int32_t n = 0;
1216
1217 if (ivisurf == NULL || pLength == NULL || ppArray == NULL) {
1218 weston_log("ivi_layout_getLayers: invalid argument\n");
1219 return IVI_FAILED;
1220 }
1221
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001222 if (!wl_list_empty(&ivisurf->view_list)) {
1223 /* the Array must be free by module which called this function */
1224 length = wl_list_length(&ivisurf->view_list);
1225 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001226 if (*ppArray == NULL) {
1227 weston_log("fails to allocate memory\n");
1228 return IVI_FAILED;
1229 }
1230
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001231 wl_list_for_each_reverse(ivi_view, &ivisurf->view_list, surf_link) {
1232 if (ivi_view_is_rendered(ivi_view))
1233 (*ppArray)[n++] = ivi_view->on_layer;
1234 else
1235 length--;
1236 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001237 }
1238
1239 *pLength = length;
1240
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001241 if (!length) {
1242 free(*ppArray);
1243 *ppArray = NULL;
1244 }
1245
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001246 return IVI_SUCCEEDED;
1247}
1248
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001249static
1250int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001251ivi_layout_get_surfaces(int32_t *pLength, struct ivi_layout_surface ***ppArray)
1252{
1253 struct ivi_layout *layout = get_instance();
1254 struct ivi_layout_surface *ivisurf = NULL;
1255 int32_t length = 0;
1256 int32_t n = 0;
1257
1258 if (pLength == NULL || ppArray == NULL) {
1259 weston_log("ivi_layout_get_surfaces: invalid argument\n");
1260 return IVI_FAILED;
1261 }
1262
1263 length = wl_list_length(&layout->surface_list);
1264
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001265 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001266 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001267 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1268 if (*ppArray == NULL) {
1269 weston_log("fails to allocate memory\n");
1270 return IVI_FAILED;
1271 }
1272
1273 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1274 (*ppArray)[n++] = ivisurf;
1275 }
1276 }
1277
1278 *pLength = length;
1279
1280 return IVI_SUCCEEDED;
1281}
1282
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001283static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001284ivi_layout_get_surfaces_on_layer(struct ivi_layout_layer *ivilayer,
1285 int32_t *pLength,
1286 struct ivi_layout_surface ***ppArray)
1287{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001288 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001289 int32_t length = 0;
1290 int32_t n = 0;
1291
1292 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1293 weston_log("ivi_layout_getSurfaceIDsOnLayer: invalid argument\n");
1294 return IVI_FAILED;
1295 }
1296
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001297 length = wl_list_length(&ivilayer->order.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001298
1299 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001300 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001301 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1302 if (*ppArray == NULL) {
1303 weston_log("fails to allocate memory\n");
1304 return IVI_FAILED;
1305 }
1306
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001307 wl_list_for_each(ivi_view, &ivilayer->order.view_list, order_link) {
1308 (*ppArray)[n++] = ivi_view->ivisurf;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001309 }
1310 }
1311
1312 *pLength = length;
1313
1314 return IVI_SUCCEEDED;
1315}
1316
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001317static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001318ivi_layout_layer_create_with_dimension(uint32_t id_layer,
1319 int32_t width, int32_t height)
1320{
1321 struct ivi_layout *layout = get_instance();
1322 struct ivi_layout_layer *ivilayer = NULL;
1323
1324 ivilayer = get_layer(&layout->layer_list, id_layer);
1325 if (ivilayer != NULL) {
1326 weston_log("id_layer is already created\n");
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001327 ++ivilayer->ref_count;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001328 return ivilayer;
1329 }
1330
1331 ivilayer = calloc(1, sizeof *ivilayer);
1332 if (ivilayer == NULL) {
1333 weston_log("fails to allocate memory\n");
1334 return NULL;
1335 }
1336
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001337 ivilayer->ref_count = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001338 wl_signal_init(&ivilayer->property_changed);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001339 ivilayer->layout = layout;
1340 ivilayer->id_layer = id_layer;
1341
1342 init_layer_properties(&ivilayer->prop, width, height);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001343
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001344 wl_list_init(&ivilayer->pending.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001345 wl_list_init(&ivilayer->pending.link);
1346 ivilayer->pending.prop = ivilayer->prop;
1347
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001348 wl_list_init(&ivilayer->order.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001349 wl_list_init(&ivilayer->order.link);
1350
1351 wl_list_insert(&layout->layer_list, &ivilayer->link);
1352
1353 wl_signal_emit(&layout->layer_notification.created, ivilayer);
1354
1355 return ivilayer;
1356}
1357
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001358static void
Nobuhiko Tanibata3aa8aed2015-06-22 15:32:23 +09001359ivi_layout_layer_destroy(struct ivi_layout_layer *ivilayer)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001360{
1361 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001362 struct ivi_layout_view *ivi_view, *next;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001363
1364 if (ivilayer == NULL) {
1365 weston_log("ivi_layout_layer_remove: invalid argument\n");
1366 return;
1367 }
1368
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001369 if (--ivilayer->ref_count > 0)
1370 return;
1371
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001372 /*Destroy all ivi_views*/
1373 wl_list_for_each_safe(ivi_view, next, &layout->view_list, link) {
1374 if (ivi_view->on_layer == ivilayer)
1375 ivi_view_destroy(ivi_view);
1376 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001377
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001378 wl_signal_emit(&layout->layer_notification.removed, ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001379
Ucan, Emre (ADITG/SW1)cf34dc22015-08-20 14:13:33 +00001380 wl_list_remove(&ivilayer->pending.link);
1381 wl_list_remove(&ivilayer->order.link);
1382 wl_list_remove(&ivilayer->link);
1383
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001384 free(ivilayer);
1385}
1386
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001387int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001388ivi_layout_layer_set_visibility(struct ivi_layout_layer *ivilayer,
1389 bool newVisibility)
1390{
1391 struct ivi_layout_layer_properties *prop = NULL;
1392
1393 if (ivilayer == NULL) {
1394 weston_log("ivi_layout_layer_set_visibility: invalid argument\n");
1395 return IVI_FAILED;
1396 }
1397
1398 prop = &ivilayer->pending.prop;
1399 prop->visibility = newVisibility;
1400
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001401 if (ivilayer->prop.visibility != newVisibility)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001402 prop->event_mask |= IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001403 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001404 prop->event_mask &= ~IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001405
1406 return IVI_SUCCEEDED;
1407}
1408
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001409int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001410ivi_layout_layer_set_opacity(struct ivi_layout_layer *ivilayer,
1411 wl_fixed_t opacity)
1412{
1413 struct ivi_layout_layer_properties *prop = NULL;
1414
Nobuhiko Tanibata7bbacc62015-06-22 15:30:09 +09001415 if (ivilayer == NULL ||
1416 opacity < wl_fixed_from_double(0.0) ||
1417 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001418 weston_log("ivi_layout_layer_set_opacity: invalid argument\n");
1419 return IVI_FAILED;
1420 }
1421
1422 prop = &ivilayer->pending.prop;
1423 prop->opacity = opacity;
1424
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001425 if (ivilayer->prop.opacity != opacity)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001426 prop->event_mask |= IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001427 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001428 prop->event_mask &= ~IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001429
1430 return IVI_SUCCEEDED;
1431}
1432
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001433static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001434ivi_layout_layer_set_source_rectangle(struct ivi_layout_layer *ivilayer,
1435 int32_t x, int32_t y,
1436 int32_t width, int32_t height)
1437{
1438 struct ivi_layout_layer_properties *prop = NULL;
1439
1440 if (ivilayer == NULL) {
1441 weston_log("ivi_layout_layer_set_source_rectangle: invalid argument\n");
1442 return IVI_FAILED;
1443 }
1444
1445 prop = &ivilayer->pending.prop;
1446 prop->source_x = x;
1447 prop->source_y = y;
1448 prop->source_width = width;
1449 prop->source_height = height;
1450
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001451 if (ivilayer->prop.source_x != x || ivilayer->prop.source_y != y ||
1452 ivilayer->prop.source_width != width ||
1453 ivilayer->prop.source_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001454 prop->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001455 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001456 prop->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001457
1458 return IVI_SUCCEEDED;
1459}
1460
Ucan, Emre \(ADITG/SW1\)e62bfd82016-03-04 12:50:46 +00001461int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001462ivi_layout_layer_set_destination_rectangle(struct ivi_layout_layer *ivilayer,
1463 int32_t x, int32_t y,
1464 int32_t width, int32_t height)
1465{
1466 struct ivi_layout_layer_properties *prop = NULL;
1467
1468 if (ivilayer == NULL) {
1469 weston_log("ivi_layout_layer_set_destination_rectangle: invalid argument\n");
1470 return IVI_FAILED;
1471 }
1472
1473 prop = &ivilayer->pending.prop;
1474 prop->dest_x = x;
1475 prop->dest_y = y;
1476 prop->dest_width = width;
1477 prop->dest_height = height;
1478
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001479 if (ivilayer->prop.dest_x != x || ivilayer->prop.dest_y != y ||
1480 ivilayer->prop.dest_width != width ||
1481 ivilayer->prop.dest_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001482 prop->event_mask |= IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001483 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001484 prop->event_mask &= ~IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001485
1486 return IVI_SUCCEEDED;
1487}
1488
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001489static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001490ivi_layout_layer_set_orientation(struct ivi_layout_layer *ivilayer,
1491 enum wl_output_transform orientation)
1492{
1493 struct ivi_layout_layer_properties *prop = NULL;
1494
1495 if (ivilayer == NULL) {
1496 weston_log("ivi_layout_layer_set_orientation: invalid argument\n");
1497 return IVI_FAILED;
1498 }
1499
1500 prop = &ivilayer->pending.prop;
1501 prop->orientation = orientation;
1502
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001503 if (ivilayer->prop.orientation != orientation)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001504 prop->event_mask |= IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001505 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001506 prop->event_mask &= ~IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001507
1508 return IVI_SUCCEEDED;
1509}
1510
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001511int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001512ivi_layout_layer_set_render_order(struct ivi_layout_layer *ivilayer,
1513 struct ivi_layout_surface **pSurface,
1514 int32_t number)
1515{
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001516 int32_t i = 0;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001517 struct ivi_layout_view * ivi_view;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001518
1519 if (ivilayer == NULL) {
1520 weston_log("ivi_layout_layer_set_render_order: invalid argument\n");
1521 return IVI_FAILED;
1522 }
1523
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001524 clear_view_pending_list(ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001525
1526 for (i = 0; i < number; i++) {
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001527 ivi_view = get_ivi_view(ivilayer, pSurface[i]);
1528 if (!ivi_view)
1529 ivi_view = ivi_view_create(ivilayer, pSurface[i]);
1530
1531 assert(ivi_view != NULL);
1532
1533 wl_list_remove(&ivi_view->pending_link);
1534 wl_list_insert(&ivilayer->pending.view_list, &ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001535 }
1536
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +00001537 ivilayer->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001538
1539 return IVI_SUCCEEDED;
1540}
1541
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001542int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001543ivi_layout_surface_set_visibility(struct ivi_layout_surface *ivisurf,
1544 bool newVisibility)
1545{
1546 struct ivi_layout_surface_properties *prop = NULL;
1547
1548 if (ivisurf == NULL) {
1549 weston_log("ivi_layout_surface_set_visibility: invalid argument\n");
1550 return IVI_FAILED;
1551 }
1552
1553 prop = &ivisurf->pending.prop;
1554 prop->visibility = newVisibility;
1555
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001556 if (ivisurf->prop.visibility != newVisibility)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001557 prop->event_mask |= IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001558 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001559 prop->event_mask &= ~IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001560
1561 return IVI_SUCCEEDED;
1562}
1563
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001564int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001565ivi_layout_surface_set_opacity(struct ivi_layout_surface *ivisurf,
1566 wl_fixed_t opacity)
1567{
1568 struct ivi_layout_surface_properties *prop = NULL;
1569
Nobuhiko Tanibataa86226c2015-06-22 15:29:20 +09001570 if (ivisurf == NULL ||
1571 opacity < wl_fixed_from_double(0.0) ||
1572 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001573 weston_log("ivi_layout_surface_set_opacity: invalid argument\n");
1574 return IVI_FAILED;
1575 }
1576
1577 prop = &ivisurf->pending.prop;
1578 prop->opacity = opacity;
1579
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001580 if (ivisurf->prop.opacity != opacity)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001581 prop->event_mask |= IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001582 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001583 prop->event_mask &= ~IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001584
1585 return IVI_SUCCEEDED;
1586}
1587
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001588int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001589ivi_layout_surface_set_destination_rectangle(struct ivi_layout_surface *ivisurf,
1590 int32_t x, int32_t y,
1591 int32_t width, int32_t height)
1592{
1593 struct ivi_layout_surface_properties *prop = NULL;
1594
1595 if (ivisurf == NULL) {
1596 weston_log("ivi_layout_surface_set_destination_rectangle: invalid argument\n");
1597 return IVI_FAILED;
1598 }
1599
1600 prop = &ivisurf->pending.prop;
1601 prop->start_x = prop->dest_x;
1602 prop->start_y = prop->dest_y;
1603 prop->dest_x = x;
1604 prop->dest_y = y;
1605 prop->start_width = prop->dest_width;
1606 prop->start_height = prop->dest_height;
1607 prop->dest_width = width;
1608 prop->dest_height = height;
1609
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001610 if (ivisurf->prop.dest_x != x || ivisurf->prop.dest_y != y ||
1611 ivisurf->prop.dest_width != width ||
1612 ivisurf->prop.dest_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001613 prop->event_mask |= IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001614 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001615 prop->event_mask &= ~IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001616
1617 return IVI_SUCCEEDED;
1618}
1619
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001620static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001621ivi_layout_surface_set_orientation(struct ivi_layout_surface *ivisurf,
1622 enum wl_output_transform orientation)
1623{
1624 struct ivi_layout_surface_properties *prop = NULL;
1625
1626 if (ivisurf == NULL) {
1627 weston_log("ivi_layout_surface_set_orientation: invalid argument\n");
1628 return IVI_FAILED;
1629 }
1630
1631 prop = &ivisurf->pending.prop;
1632 prop->orientation = orientation;
1633
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001634 if (ivisurf->prop.orientation != orientation)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001635 prop->event_mask |= IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001636 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001637 prop->event_mask &= ~IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001638
1639 return IVI_SUCCEEDED;
1640}
1641
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001642static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001643ivi_layout_screen_add_layer(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001644 struct ivi_layout_layer *addlayer)
1645{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001646 struct ivi_layout_screen *iviscrn;
1647
1648 if (output == NULL || addlayer == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001649 weston_log("ivi_layout_screen_add_layer: invalid argument\n");
1650 return IVI_FAILED;
1651 }
1652
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001653 iviscrn = get_screen_from_output(output);
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001654
Ucan, Emre (ADITG/SW1)bb4ec0a2015-08-28 12:59:01 +00001655 if (addlayer->on_screen == iviscrn) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001656 weston_log("ivi_layout_screen_add_layer: addlayer is already available\n");
1657 return IVI_SUCCEEDED;
1658 }
1659
Ucan, Emre (ADITG/SW1)f46306f2016-03-16 13:37:07 +00001660 wl_list_remove(&addlayer->pending.link);
1661 wl_list_insert(&iviscrn->pending.layer_list, &addlayer->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001662
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001663 iviscrn->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001664
1665 return IVI_SUCCEEDED;
1666}
1667
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001668static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001669ivi_layout_screen_set_render_order(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001670 struct ivi_layout_layer **pLayer,
1671 const int32_t number)
1672{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001673 struct ivi_layout_screen *iviscrn;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001674 struct ivi_layout_layer *ivilayer = NULL;
1675 struct ivi_layout_layer *next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001676 int32_t i = 0;
1677
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001678 if (output == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001679 weston_log("ivi_layout_screen_set_render_order: invalid argument\n");
1680 return IVI_FAILED;
1681 }
1682
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001683 iviscrn = get_screen_from_output(output);
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001684
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001685 wl_list_for_each_safe(ivilayer, next,
1686 &iviscrn->pending.layer_list, pending.link) {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001687 wl_list_remove(&ivilayer->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001688 wl_list_init(&ivilayer->pending.link);
1689 }
1690
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001691 assert(wl_list_empty(&iviscrn->pending.layer_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001692
1693 for (i = 0; i < number; i++) {
Ucan, Emre (ADITG/SW1)4e221f02016-03-16 13:37:08 +00001694 wl_list_remove(&pLayer[i]->pending.link);
1695 wl_list_insert(&iviscrn->pending.layer_list,
1696 &pLayer[i]->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001697 }
1698
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001699 iviscrn->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001700
1701 return IVI_SUCCEEDED;
1702}
1703
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001704/**
1705 * This function is used by the additional ivi-module because of dumping ivi_surface sceenshot.
1706 * The ivi-module, e.g. ivi-controller.so, is in wayland-ivi-extension of Genivi's Layer Management.
1707 * This function is used to get the result of drawing by clients.
1708 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001709static struct weston_surface *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001710ivi_layout_surface_get_weston_surface(struct ivi_layout_surface *ivisurf)
1711{
1712 return ivisurf != NULL ? ivisurf->surface : NULL;
1713}
1714
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001715static int32_t
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09001716ivi_layout_surface_get_size(struct ivi_layout_surface *ivisurf,
1717 int32_t *width, int32_t *height,
1718 int32_t *stride)
1719{
1720 int32_t w;
1721 int32_t h;
1722 const size_t bytespp = 4; /* PIXMAN_a8b8g8r8 */
1723
1724 if (ivisurf == NULL || ivisurf->surface == NULL) {
1725 weston_log("%s: invalid argument\n", __func__);
1726 return IVI_FAILED;
1727 }
1728
1729 weston_surface_get_content_size(ivisurf->surface, &w, &h);
1730
1731 if (width != NULL)
1732 *width = w;
1733
1734 if (height != NULL)
1735 *height = h;
1736
1737 if (stride != NULL)
1738 *stride = w * bytespp;
1739
1740 return IVI_SUCCEEDED;
1741}
1742
1743static int32_t
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001744ivi_layout_layer_add_listener(struct ivi_layout_layer *ivilayer,
1745 struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001746{
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001747 if (ivilayer == NULL || listener == NULL) {
1748 weston_log("ivi_layout_layer_add_listener: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001749 return IVI_FAILED;
1750 }
1751
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001752 wl_signal_add(&ivilayer->property_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001753
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001754 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001755}
1756
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001757static const struct ivi_layout_surface_properties *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001758ivi_layout_get_properties_of_surface(struct ivi_layout_surface *ivisurf)
1759{
1760 if (ivisurf == NULL) {
1761 weston_log("ivi_layout_get_properties_of_surface: invalid argument\n");
1762 return NULL;
1763 }
1764
1765 return &ivisurf->prop;
1766}
1767
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001768static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001769ivi_layout_layer_add_surface(struct ivi_layout_layer *ivilayer,
1770 struct ivi_layout_surface *addsurf)
1771{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001772 struct ivi_layout_view *ivi_view;
1773
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001774 if (ivilayer == NULL || addsurf == NULL) {
1775 weston_log("ivi_layout_layer_add_surface: invalid argument\n");
1776 return IVI_FAILED;
1777 }
1778
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001779 ivi_view = get_ivi_view(ivilayer, addsurf);
1780 if (!ivi_view)
1781 ivi_view = ivi_view_create(ivilayer, addsurf);
1782 else if (ivi_view_is_rendered(ivi_view))
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001783 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001784
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001785 wl_list_remove(&ivi_view->pending_link);
1786 wl_list_insert(&ivilayer->pending.view_list, &ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001787
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +00001788 ivilayer->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001789
1790 return IVI_SUCCEEDED;
1791}
1792
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001793static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001794ivi_layout_layer_remove_surface(struct ivi_layout_layer *ivilayer,
1795 struct ivi_layout_surface *remsurf)
1796{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001797 struct ivi_layout_view *ivi_view;
1798
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001799 if (ivilayer == NULL || remsurf == NULL) {
1800 weston_log("ivi_layout_layer_remove_surface: invalid argument\n");
1801 return;
1802 }
1803
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001804 ivi_view = get_ivi_view(ivilayer, remsurf);
1805 if (ivi_view) {
1806 wl_list_remove(&ivi_view->pending_link);
1807 wl_list_init(&ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001808
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001809 ivilayer->order.dirty = 1;
1810 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001811}
1812
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001813static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001814ivi_layout_surface_set_source_rectangle(struct ivi_layout_surface *ivisurf,
1815 int32_t x, int32_t y,
1816 int32_t width, int32_t height)
1817{
1818 struct ivi_layout_surface_properties *prop = NULL;
1819
1820 if (ivisurf == NULL) {
1821 weston_log("ivi_layout_surface_set_source_rectangle: invalid argument\n");
1822 return IVI_FAILED;
1823 }
1824
1825 prop = &ivisurf->pending.prop;
1826 prop->source_x = x;
1827 prop->source_y = y;
1828 prop->source_width = width;
1829 prop->source_height = height;
1830
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001831 if (ivisurf->prop.source_x != x || ivisurf->prop.source_y != y ||
1832 ivisurf->prop.source_width != width ||
1833 ivisurf->prop.source_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001834 prop->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001835 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001836 prop->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001837
1838 return IVI_SUCCEEDED;
1839}
1840
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001841int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001842ivi_layout_commit_changes(void)
1843{
1844 struct ivi_layout *layout = get_instance();
1845
1846 commit_surface_list(layout);
1847 commit_layer_list(layout);
1848 commit_screen_list(layout);
1849
1850 commit_transition(layout);
1851
1852 commit_changes(layout);
1853 send_prop(layout);
1854 weston_compositor_schedule_repaint(layout->compositor);
1855
1856 return IVI_SUCCEEDED;
1857}
1858
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001859static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001860ivi_layout_layer_set_transition(struct ivi_layout_layer *ivilayer,
1861 enum ivi_layout_transition_type type,
1862 uint32_t duration)
1863{
1864 if (ivilayer == NULL) {
1865 weston_log("%s: invalid argument\n", __func__);
1866 return -1;
1867 }
1868
1869 ivilayer->pending.prop.transition_type = type;
1870 ivilayer->pending.prop.transition_duration = duration;
1871
1872 return 0;
1873}
1874
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001875static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001876ivi_layout_layer_set_fade_info(struct ivi_layout_layer* ivilayer,
1877 uint32_t is_fade_in,
1878 double start_alpha, double end_alpha)
1879{
1880 if (ivilayer == NULL) {
1881 weston_log("%s: invalid argument\n", __func__);
1882 return -1;
1883 }
1884
1885 ivilayer->pending.prop.is_fade_in = is_fade_in;
1886 ivilayer->pending.prop.start_alpha = start_alpha;
1887 ivilayer->pending.prop.end_alpha = end_alpha;
1888
1889 return 0;
1890}
1891
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001892static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001893ivi_layout_surface_set_transition_duration(struct ivi_layout_surface *ivisurf,
1894 uint32_t duration)
1895{
1896 struct ivi_layout_surface_properties *prop;
1897
1898 if (ivisurf == NULL) {
1899 weston_log("%s: invalid argument\n", __func__);
1900 return -1;
1901 }
1902
1903 prop = &ivisurf->pending.prop;
1904 prop->transition_duration = duration*10;
1905 return 0;
1906}
1907
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001908static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001909ivi_layout_surface_set_transition(struct ivi_layout_surface *ivisurf,
1910 enum ivi_layout_transition_type type,
1911 uint32_t duration)
1912{
1913 struct ivi_layout_surface_properties *prop;
1914
1915 if (ivisurf == NULL) {
1916 weston_log("%s: invalid argument\n", __func__);
1917 return -1;
1918 }
1919
1920 prop = &ivisurf->pending.prop;
1921 prop->transition_type = type;
1922 prop->transition_duration = duration;
1923 return 0;
1924}
1925
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09001926static int32_t
1927ivi_layout_surface_dump(struct weston_surface *surface,
1928 void *target, size_t size,int32_t x, int32_t y,
1929 int32_t width, int32_t height)
1930{
1931 int result = 0;
1932
1933 if (surface == NULL) {
1934 weston_log("%s: invalid argument\n", __func__);
1935 return IVI_FAILED;
1936 }
1937
1938 result = weston_surface_copy_content(
1939 surface, target, size,
1940 x, y, width, height);
1941
1942 return result == 0 ? IVI_SUCCEEDED : IVI_FAILED;
1943}
1944
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001945/**
1946 * methods of interaction between ivi-shell with ivi-layout
1947 */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001948
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001949void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001950ivi_layout_surface_configure(struct ivi_layout_surface *ivisurf,
1951 int32_t width, int32_t height)
1952{
1953 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001954
Nobuhiko Tanibatae6cc9972015-04-27 16:54:01 +09001955 /* emit callback which is set by ivi-layout api user */
1956 wl_signal_emit(&layout->surface_notification.configure_changed,
1957 ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001958}
1959
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001960struct ivi_layout_surface*
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001961ivi_layout_surface_create(struct weston_surface *wl_surface,
1962 uint32_t id_surface)
1963{
1964 struct ivi_layout *layout = get_instance();
1965 struct ivi_layout_surface *ivisurf = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001966
1967 if (wl_surface == NULL) {
1968 weston_log("ivi_layout_surface_create: invalid argument\n");
1969 return NULL;
1970 }
1971
1972 ivisurf = get_surface(&layout->surface_list, id_surface);
1973 if (ivisurf != NULL) {
1974 if (ivisurf->surface != NULL) {
1975 weston_log("id_surface(%d) is already created\n", id_surface);
1976 return NULL;
1977 }
1978 }
1979
1980 ivisurf = calloc(1, sizeof *ivisurf);
1981 if (ivisurf == NULL) {
1982 weston_log("fails to allocate memory\n");
1983 return NULL;
1984 }
1985
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001986 wl_signal_init(&ivisurf->property_changed);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001987 ivisurf->id_surface = id_surface;
1988 ivisurf->layout = layout;
1989
1990 ivisurf->surface = wl_surface;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001991
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001992 ivisurf->surface->width_from_buffer = 0;
1993 ivisurf->surface->height_from_buffer = 0;
1994
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001995 init_surface_properties(&ivisurf->prop);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001996
1997 ivisurf->pending.prop = ivisurf->prop;
1998 wl_list_init(&ivisurf->pending.link);
1999
2000 wl_list_init(&ivisurf->order.link);
2001 wl_list_init(&ivisurf->order.layer_list);
2002
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00002003 wl_list_init(&ivisurf->view_list);
2004
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002005 wl_list_insert(&layout->surface_list, &ivisurf->link);
2006
2007 wl_signal_emit(&layout->surface_notification.created, ivisurf);
2008
2009 return ivisurf;
2010}
2011
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002012void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002013ivi_layout_init_with_compositor(struct weston_compositor *ec)
2014{
2015 struct ivi_layout *layout = get_instance();
2016
2017 layout->compositor = ec;
2018
2019 wl_list_init(&layout->surface_list);
2020 wl_list_init(&layout->layer_list);
2021 wl_list_init(&layout->screen_list);
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00002022 wl_list_init(&layout->view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002023
2024 wl_signal_init(&layout->layer_notification.created);
2025 wl_signal_init(&layout->layer_notification.removed);
2026
2027 wl_signal_init(&layout->surface_notification.created);
2028 wl_signal_init(&layout->surface_notification.removed);
2029 wl_signal_init(&layout->surface_notification.configure_changed);
2030
2031 /* Add layout_layer at the last of weston_compositor.layer_list */
2032 weston_layer_init(&layout->layout_layer, ec->layer_list.prev);
2033
2034 create_screen(ec);
2035
2036 layout->transitions = ivi_layout_transition_set_create(ec);
2037 wl_list_init(&layout->pending_transition_list);
2038}
2039
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002040static struct ivi_layout_interface ivi_layout_interface = {
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002041 /**
2042 * commit all changes
2043 */
2044 .commit_changes = ivi_layout_commit_changes,
2045
2046 /**
2047 * surface controller interfaces
2048 */
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00002049 .add_listener_create_surface = ivi_layout_add_listener_create_surface,
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00002050 .add_listener_remove_surface = ivi_layout_add_listener_remove_surface,
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00002051 .add_listener_configure_surface = ivi_layout_add_listener_configure_surface,
Pekka Paalaneneaa43fc2016-04-12 16:06:58 +03002052 .get_surface = shell_get_ivi_layout_surface,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002053 .get_surfaces = ivi_layout_get_surfaces,
2054 .get_id_of_surface = ivi_layout_get_id_of_surface,
2055 .get_surface_from_id = ivi_layout_get_surface_from_id,
2056 .get_properties_of_surface = ivi_layout_get_properties_of_surface,
2057 .get_surfaces_on_layer = ivi_layout_get_surfaces_on_layer,
2058 .surface_set_visibility = ivi_layout_surface_set_visibility,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002059 .surface_set_opacity = ivi_layout_surface_set_opacity,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002060 .surface_set_source_rectangle = ivi_layout_surface_set_source_rectangle,
2061 .surface_set_destination_rectangle = ivi_layout_surface_set_destination_rectangle,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002062 .surface_set_orientation = ivi_layout_surface_set_orientation,
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00002063 .surface_add_listener = ivi_layout_surface_add_listener,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002064 .surface_get_weston_surface = ivi_layout_surface_get_weston_surface,
2065 .surface_set_transition = ivi_layout_surface_set_transition,
2066 .surface_set_transition_duration = ivi_layout_surface_set_transition_duration,
2067
2068 /**
2069 * layer controller interfaces
2070 */
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +00002071 .add_listener_create_layer = ivi_layout_add_listener_create_layer,
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +00002072 .add_listener_remove_layer = ivi_layout_add_listener_remove_layer,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002073 .layer_create_with_dimension = ivi_layout_layer_create_with_dimension,
Nobuhiko Tanibata3aa8aed2015-06-22 15:32:23 +09002074 .layer_destroy = ivi_layout_layer_destroy,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002075 .get_layers = ivi_layout_get_layers,
2076 .get_id_of_layer = ivi_layout_get_id_of_layer,
2077 .get_layer_from_id = ivi_layout_get_layer_from_id,
2078 .get_properties_of_layer = ivi_layout_get_properties_of_layer,
2079 .get_layers_under_surface = ivi_layout_get_layers_under_surface,
2080 .get_layers_on_screen = ivi_layout_get_layers_on_screen,
2081 .layer_set_visibility = ivi_layout_layer_set_visibility,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002082 .layer_set_opacity = ivi_layout_layer_set_opacity,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002083 .layer_set_source_rectangle = ivi_layout_layer_set_source_rectangle,
2084 .layer_set_destination_rectangle = ivi_layout_layer_set_destination_rectangle,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002085 .layer_set_orientation = ivi_layout_layer_set_orientation,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002086 .layer_add_surface = ivi_layout_layer_add_surface,
2087 .layer_remove_surface = ivi_layout_layer_remove_surface,
2088 .layer_set_render_order = ivi_layout_layer_set_render_order,
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00002089 .layer_add_listener = ivi_layout_layer_add_listener,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002090 .layer_set_transition = ivi_layout_layer_set_transition,
2091
2092 /**
Ucan, Emre (ADITG/SW1)6d89b1c2016-03-17 15:30:49 +00002093 * screen controller interfaces
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002094 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002095 .get_screens_under_layer = ivi_layout_get_screens_under_layer,
2096 .screen_add_layer = ivi_layout_screen_add_layer,
2097 .screen_set_render_order = ivi_layout_screen_set_render_order,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002098
2099 /**
2100 * animation
2101 */
2102 .transition_move_layer_cancel = ivi_layout_transition_move_layer_cancel,
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09002103 .layer_set_fade_info = ivi_layout_layer_set_fade_info,
2104
2105 /**
2106 * surface content dumping for debugging
2107 */
2108 .surface_get_size = ivi_layout_surface_get_size,
2109 .surface_dump = ivi_layout_surface_dump,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002110};
2111
2112int
2113load_controller_modules(struct weston_compositor *compositor, const char *modules,
2114 int *argc, char *argv[])
2115{
2116 const char *p, *end;
2117 char buffer[256];
2118 int (*controller_module_init)(struct weston_compositor *compositor,
2119 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002120 const struct ivi_layout_interface *interface,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002121 size_t interface_version);
2122
2123 if (modules == NULL)
2124 return 0;
2125
2126 p = modules;
2127 while (*p) {
2128 end = strchrnul(p, ',');
2129 snprintf(buffer, sizeof buffer, "%.*s", (int)(end - p), p);
2130
Giulio Camuffo179fcda2016-06-02 21:48:14 +03002131 controller_module_init = wet_load_module(buffer, "controller_module_init");
Pekka Paalanen97246c02015-03-26 15:47:29 +02002132 if (!controller_module_init)
2133 return -1;
2134
2135 if (controller_module_init(compositor, argc, argv,
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002136 &ivi_layout_interface,
2137 sizeof(struct ivi_layout_interface)) != 0) {
Pekka Paalanen97246c02015-03-26 15:47:29 +02002138 weston_log("ivi-shell: Initialization of controller module fails");
2139 return -1;
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002140 }
2141
2142 p = end;
2143 while (*p == ',')
2144 p++;
2145 }
2146
2147 return 0;
2148}