blob: 712cc30da0b3477d9b13333ebc4fa6c53e9cfa15 [file] [log] [blame]
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001/*
2 * Copyright (C) 2013 DENSO CORPORATION
3 *
Bryce Harringtonaf637c22015-06-11 12:55:55 -07004 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090011 *
Bryce Harringtonaf637c22015-06-11 12:55:55 -070012 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial
14 * portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090024 */
25
26/**
27 * Implementation of ivi-layout library. The actual view on ivi_screen is
Bryce Harringtone6da35d2016-05-19 17:35:02 -070028 * not updated until ivi_layout_commit_changes is called. An overview from
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090029 * calling API for updating properties of ivi_surface/ivi_layer to asking
30 * compositor to compose them by using weston_compositor_schedule_repaint,
31 * 0/ initialize this library by ivi_layout_init_with_compositor
32 * with (struct weston_compositor *ec) from ivi-shell.
Bryce Harringtone6da35d2016-05-19 17:35:02 -070033 * 1/ When an API for updating properties of ivi_surface/ivi_layer, it updates
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090034 * pending prop of ivi_surface/ivi_layer/ivi_screen which are structure to
35 * store properties.
Bryce Harringtone6da35d2016-05-19 17:35:02 -070036 * 2/ Before calling commitChanges, in case of calling an API to get a property,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090037 * return current property, not pending property.
38 * 3/ At the timing of calling ivi_layout_commitChanges, pending properties
39 * are applied to properties.
40 *
41 * *) ivi_layout_commitChanges is also called by transition animation
42 * per each frame. See ivi-layout-transition.c in details. Transition
43 * animation interpolates frames between previous properties of ivi_surface
44 * and new ones.
Bryce Harringtone6da35d2016-05-19 17:35:02 -070045 * For example, when a property of ivi_surface is changed from invisibile
46 * to visibile, it behaves like fade-in. When ivi_layout_commitChange is
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090047 * called during transition animation, it cancels the transition and
48 * re-start transition to new properties from current properties of final
Bryce Harringtone6da35d2016-05-19 17:35:02 -070049 * frame just before the cancellation.
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090050 *
51 * 4/ According properties, set transformation by using weston_matrix and
52 * weston_view per ivi_surfaces and ivi_layers in while loop.
53 * 5/ Set damage and trigger transform by using weston_view_geometry_dirty.
54 * 6/ Notify update of properties.
55 * 7/ Trigger composition by weston_compositor_schedule_repaint.
56 *
57 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +090058#include "config.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090059
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090060#include <string.h>
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +000061#include <assert.h>
Jussi Kukkonen649bbce2016-07-19 14:16:27 +030062#include <stdint.h>
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090063
Pekka Paalanen58f98c92016-06-03 16:45:21 +030064#include "compositor/weston.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090065#include "compositor.h"
Pekka Paalanen1f821932016-03-15 16:57:51 +020066#include "ivi-shell.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090067#include "ivi-layout-export.h"
68#include "ivi-layout-private.h"
Pekka Paalanen32ca7912016-03-15 17:21:00 +020069#include "ivi-layout-shell.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090070
Jon Cruz867d50e2015-06-15 15:37:10 -070071#include "shared/helpers.h"
Jon Cruz4678bab2015-06-15 15:37:07 -070072#include "shared/os-compatibility.h"
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +090073
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +090074#define max(a, b) ((a) > (b) ? (a) : (b))
75
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090076struct ivi_layout;
77
78struct ivi_layout_screen {
Ucan, Emre (ADITG/SW1)7da38232016-07-01 09:34:50 +000079 struct wl_list link; /* ivi_layout::screen_list */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090080
81 struct ivi_layout *layout;
82 struct weston_output *output;
83
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090084 struct {
Ucan, Emre (ADITG/SW1)7da38232016-07-01 09:34:50 +000085 struct wl_list layer_list; /* ivi_layout_layer::pending.link */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090086 } pending;
87
88 struct {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +000089 int dirty;
Ucan, Emre (ADITG/SW1)7da38232016-07-01 09:34:50 +000090 struct wl_list layer_list; /* ivi_layout_layer::order.link */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090091 } order;
92};
93
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +090094struct ivi_rectangle
95{
96 int32_t x;
97 int32_t y;
98 int32_t width;
99 int32_t height;
100};
101
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900102static struct ivi_layout ivilayout = {0};
103
104struct ivi_layout *
105get_instance(void)
106{
107 return &ivilayout;
108}
109
110/**
Bryce Harringtone6da35d2016-05-19 17:35:02 -0700111 * Internal API to add/remove an ivi_layer to/from ivi_screen.
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900112 */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900113static struct ivi_layout_surface *
114get_surface(struct wl_list *surf_list, uint32_t id_surface)
115{
116 struct ivi_layout_surface *ivisurf;
117
118 wl_list_for_each(ivisurf, surf_list, link) {
119 if (ivisurf->id_surface == id_surface) {
120 return ivisurf;
121 }
122 }
123
124 return NULL;
125}
126
127static struct ivi_layout_layer *
128get_layer(struct wl_list *layer_list, uint32_t id_layer)
129{
130 struct ivi_layout_layer *ivilayer;
131
132 wl_list_for_each(ivilayer, layer_list, link) {
133 if (ivilayer->id_layer == id_layer) {
134 return ivilayer;
135 }
136 }
137
138 return NULL;
139}
140
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000141static bool
142ivi_view_is_rendered(struct ivi_layout_view *view)
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000143{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000144 return !wl_list_empty(&view->order_link);
145}
146
147static void
148ivi_view_destroy(struct ivi_layout_view *ivi_view)
149{
150 wl_list_remove(&ivi_view->transform.link);
151 wl_list_remove(&ivi_view->link);
152 wl_list_remove(&ivi_view->surf_link);
153 wl_list_remove(&ivi_view->pending_link);
154 wl_list_remove(&ivi_view->order_link);
155
156 weston_view_destroy(ivi_view->view);
157
158 free(ivi_view);
159}
160
161static struct ivi_layout_view*
162ivi_view_create(struct ivi_layout_layer *ivilayer,
163 struct ivi_layout_surface *ivisurf)
164{
165 struct ivi_layout_view *ivi_view;
166
167 ivi_view = calloc(1, sizeof *ivi_view);
168 if (ivi_view == NULL) {
169 weston_log("fails to allocate memory\n");
170 return NULL;
171 }
172
173 ivi_view->view = weston_view_create(ivisurf->surface);
174 if (ivi_view->view == NULL) {
175 weston_log("fails to allocate memory\n");
176 return NULL;
177 }
178
179 weston_matrix_init(&ivi_view->transform.matrix);
180 wl_list_init(&ivi_view->transform.link);
181
182 ivi_view->ivisurf = ivisurf;
183 ivi_view->on_layer = ivilayer;
184 wl_list_insert(&ivilayer->layout->view_list,
185 &ivi_view->link);
186 wl_list_insert(&ivisurf->view_list,
187 &ivi_view->surf_link);
188
189 wl_list_init(&ivi_view->pending_link);
190 wl_list_init(&ivi_view->order_link);
191
192 return ivi_view;
193}
194
195static struct ivi_layout_view *
196get_ivi_view(struct ivi_layout_layer *ivilayer,
197 struct ivi_layout_surface *ivisurf)
198{
199 struct ivi_layout_view *ivi_view;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000200
201 assert(ivisurf->surface != NULL);
202
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000203 wl_list_for_each(ivi_view, &ivisurf->view_list, surf_link) {
204 if (ivi_view->on_layer == ivilayer)
205 return ivi_view;
206 }
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000207
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000208 return NULL;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000209}
210
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +0000211static struct ivi_layout_screen *
212get_screen_from_output(struct weston_output *output)
213{
214 struct ivi_layout *layout = get_instance();
215 struct ivi_layout_screen *iviscrn = NULL;
216
217 wl_list_for_each(iviscrn, &layout->screen_list, link) {
218 if (iviscrn->output == output)
219 return iviscrn;
220 }
221
222 return NULL;
223}
224
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900225/**
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900226 * Called at destruction of wl_surface/ivi_surface
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900227 */
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900228void
229ivi_layout_surface_destroy(struct ivi_layout_surface *ivisurf)
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900230{
231 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000232 struct ivi_layout_view *ivi_view ,*next;
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900233
234 if (ivisurf == NULL) {
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900235 weston_log("%s: invalid argument\n", __func__);
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900236 return;
237 }
238
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900239 wl_list_remove(&ivisurf->link);
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900240
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000241 wl_list_for_each_safe(ivi_view, next, &ivisurf->view_list, surf_link) {
242 ivi_view_destroy(ivi_view);
243 }
244
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900245 wl_signal_emit(&layout->surface_notification.removed, ivisurf);
246
Mateusz Polroladada6e32016-03-09 09:13:26 +0000247 ivi_layout_remove_all_surface_transitions(ivisurf);
248
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900249 free(ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900250}
251
252/**
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900253 * Internal API to initialize ivi_screens found from output_list of weston_compositor.
254 * Called by ivi_layout_init_with_compositor.
255 */
256static void
257create_screen(struct weston_compositor *ec)
258{
259 struct ivi_layout *layout = get_instance();
260 struct ivi_layout_screen *iviscrn = NULL;
261 struct weston_output *output = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900262
263 wl_list_for_each(output, &ec->output_list, link) {
264 iviscrn = calloc(1, sizeof *iviscrn);
265 if (iviscrn == NULL) {
266 weston_log("fails to allocate memory\n");
267 continue;
268 }
269
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900270 iviscrn->layout = layout;
271
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900272 iviscrn->output = output;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900273
274 wl_list_init(&iviscrn->pending.layer_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900275
276 wl_list_init(&iviscrn->order.layer_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900277
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900278 wl_list_insert(&layout->screen_list, &iviscrn->link);
279 }
280}
281
282/**
283 * Internal APIs to initialize properties of ivi_surface/ivi_layer when they are created.
284 */
285static void
286init_layer_properties(struct ivi_layout_layer_properties *prop,
287 int32_t width, int32_t height)
288{
289 memset(prop, 0, sizeof *prop);
290 prop->opacity = wl_fixed_from_double(1.0);
291 prop->source_width = width;
292 prop->source_height = height;
293 prop->dest_width = width;
294 prop->dest_height = height;
295}
296
297static void
298init_surface_properties(struct ivi_layout_surface_properties *prop)
299{
300 memset(prop, 0, sizeof *prop);
301 prop->opacity = wl_fixed_from_double(1.0);
Nobuhiko Tanibatae259a7a2015-04-27 17:02:54 +0900302 /*
Bryce Harringtone6da35d2016-05-19 17:35:02 -0700303 * FIXME: this shall be fixed by ivi-layout-transition.
Nobuhiko Tanibatae259a7a2015-04-27 17:02:54 +0900304 */
305 prop->dest_width = 1;
306 prop->dest_height = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900307}
308
309/**
310 * Internal APIs to be called from ivi_layout_commit_changes.
311 */
312static void
313update_opacity(struct ivi_layout_layer *ivilayer,
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000314 struct ivi_layout_surface *ivisurf,
315 struct weston_view *view)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900316{
317 double layer_alpha = wl_fixed_to_double(ivilayer->prop.opacity);
318 double surf_alpha = wl_fixed_to_double(ivisurf->prop.opacity);
319
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000320 view->alpha = layer_alpha * surf_alpha;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900321}
322
323static void
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900324get_rotate_values(enum wl_output_transform orientation,
325 float *v_sin,
326 float *v_cos)
327{
328 switch (orientation) {
329 case WL_OUTPUT_TRANSFORM_90:
330 *v_sin = 1.0f;
331 *v_cos = 0.0f;
332 break;
333 case WL_OUTPUT_TRANSFORM_180:
334 *v_sin = 0.0f;
335 *v_cos = -1.0f;
336 break;
337 case WL_OUTPUT_TRANSFORM_270:
338 *v_sin = -1.0f;
339 *v_cos = 0.0f;
340 break;
341 case WL_OUTPUT_TRANSFORM_NORMAL:
342 default:
343 *v_sin = 0.0f;
344 *v_cos = 1.0f;
345 break;
346 }
347}
348
349static void
350get_scale(enum wl_output_transform orientation,
351 float dest_width,
352 float dest_height,
353 float source_width,
354 float source_height,
355 float *scale_x,
356 float *scale_y)
357{
358 switch (orientation) {
359 case WL_OUTPUT_TRANSFORM_90:
360 *scale_x = dest_width / source_height;
361 *scale_y = dest_height / source_width;
362 break;
363 case WL_OUTPUT_TRANSFORM_180:
364 *scale_x = dest_width / source_width;
365 *scale_y = dest_height / source_height;
366 break;
367 case WL_OUTPUT_TRANSFORM_270:
368 *scale_x = dest_width / source_height;
369 *scale_y = dest_height / source_width;
370 break;
371 case WL_OUTPUT_TRANSFORM_NORMAL:
372 default:
373 *scale_x = dest_width / source_width;
374 *scale_y = dest_height / source_height;
375 break;
376 }
377}
378
379static void
380calc_transformation_matrix(struct ivi_rectangle *source_rect,
381 struct ivi_rectangle *dest_rect,
382 enum wl_output_transform orientation,
383 struct weston_matrix *m)
384{
385 float source_center_x;
386 float source_center_y;
387 float vsin;
388 float vcos;
389 float scale_x;
390 float scale_y;
391 float translate_x;
392 float translate_y;
393
394 source_center_x = source_rect->x + source_rect->width * 0.5f;
395 source_center_y = source_rect->y + source_rect->height * 0.5f;
396 weston_matrix_translate(m, -source_center_x, -source_center_y, 0.0f);
397
398 get_rotate_values(orientation, &vsin, &vcos);
399 weston_matrix_rotate_xy(m, vcos, vsin);
400
401 get_scale(orientation,
402 dest_rect->width,
403 dest_rect->height,
404 source_rect->width,
405 source_rect->height,
406 &scale_x,
407 &scale_y);
408 weston_matrix_scale(m, scale_x, scale_y, 1.0f);
409
410 translate_x = dest_rect->width * 0.5f + dest_rect->x;
411 translate_y = dest_rect->height * 0.5f + dest_rect->y;
412 weston_matrix_translate(m, translate_x, translate_y, 0.0f);
413}
414
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900415/*
416 * This computes intersected rect_output from two ivi_rectangles
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900417 */
418static void
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900419ivi_rectangle_intersect(const struct ivi_rectangle *rect1,
420 const struct ivi_rectangle *rect2,
421 struct ivi_rectangle *rect_output)
422{
423 int32_t rect1_right = rect1->x + rect1->width;
424 int32_t rect1_bottom = rect1->y + rect1->height;
425 int32_t rect2_right = rect2->x + rect2->width;
426 int32_t rect2_bottom = rect2->y + rect2->height;
427
428 rect_output->x = max(rect1->x, rect2->x);
429 rect_output->y = max(rect1->y, rect2->y);
430 rect_output->width = rect1_right < rect2_right ?
431 rect1_right - rect_output->x :
432 rect2_right - rect_output->x;
433 rect_output->height = rect1_bottom < rect2_bottom ?
434 rect1_bottom - rect_output->y :
435 rect2_bottom - rect_output->y;
436
437 if (rect_output->width < 0 || rect_output->height < 0) {
438 rect_output->width = 0;
439 rect_output->height = 0;
440 }
441}
442
443/*
444 * Transform rect_input by the inverse of matrix, intersect with boundingbox,
445 * and store the result in rect_output.
446 * The boundingbox must be given in the same coordinate space as rect_output.
447 * Additionally, there are the following restrictions on the matrix:
448 * - no projective transformations
449 * - no skew
450 * - only multiples of 90-degree rotations supported
451 *
452 * In failure case of weston_matrix_invert, rect_output is set to boundingbox
453 * as a fail-safe with log.
454 */
455static void
456calc_inverse_matrix_transform(const struct weston_matrix *matrix,
457 const struct ivi_rectangle *rect_input,
458 const struct ivi_rectangle *boundingbox,
459 struct ivi_rectangle *rect_output)
460{
461 struct weston_matrix m;
462 struct weston_vector top_left;
463 struct weston_vector bottom_right;
464
465 assert(boundingbox != rect_output);
466
467 if (weston_matrix_invert(&m, matrix) < 0) {
468 weston_log("ivi-shell: calc_inverse_matrix_transform fails to invert a matrix.\n");
469 weston_log("ivi-shell: boundingbox is set to the rect_output.\n");
470 rect_output->x = boundingbox->x;
471 rect_output->y = boundingbox->y;
472 rect_output->width = boundingbox->width;
473 rect_output->height = boundingbox->height;
474 }
475
476 /* The vectors and matrices involved will always produce f[3] == 1.0. */
477 top_left.f[0] = rect_input->x;
478 top_left.f[1] = rect_input->y;
479 top_left.f[2] = 0.0f;
480 top_left.f[3] = 1.0f;
481
482 bottom_right.f[0] = rect_input->x + rect_input->width;
483 bottom_right.f[1] = rect_input->y + rect_input->height;
484 bottom_right.f[2] = 0.0f;
485 bottom_right.f[3] = 1.0f;
486
487 weston_matrix_transform(&m, &top_left);
488 weston_matrix_transform(&m, &bottom_right);
489
490 if (top_left.f[0] < bottom_right.f[0]) {
491 rect_output->x = top_left.f[0];
492 rect_output->width = bottom_right.f[0] - rect_output->x;
493 } else {
494 rect_output->x = bottom_right.f[0];
495 rect_output->width = top_left.f[0] - rect_output->x;
496 }
497
498 if (top_left.f[1] < bottom_right.f[1]) {
499 rect_output->y = top_left.f[1];
500 rect_output->height = bottom_right.f[1] - rect_output->y;
501 } else {
502 rect_output->y = bottom_right.f[1];
503 rect_output->height = top_left.f[1] - rect_output->y;
504 }
505
506 ivi_rectangle_intersect(rect_output, boundingbox, rect_output);
507}
508
509/**
510 * This computes the whole transformation matrix:m from surface-local
Yong Bakose0698712016-04-28 11:59:08 -0500511 * coordinates to multi-screen coordinates, which are global coordinates.
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900512 * It is assumed that weston_view::geometry.{x,y} are zero.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900513 *
Bryce Harringtone6da35d2016-05-19 17:35:02 -0700514 * Additionally, this computes the mask on surface-local coordinates as an
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900515 * ivi_rectangle. This can be set to weston_view_set_mask.
516 *
517 * The mask is computed by following steps
Yong Bakose0698712016-04-28 11:59:08 -0500518 * - destination rectangle of layer is transformed to multi-screen coordinates,
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900519 * global coordinates. This is done by adding weston_output.{x,y} in simple
520 * because there is no scaled and rotated transformation.
Yong Bakose0698712016-04-28 11:59:08 -0500521 * - destination rectangle of layer in multi-screen coordinates needs to be
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900522 * intersected inside of a screen the layer is assigned to. This is because
523 * overlapped region of weston surface in another screen shall not be
524 * displayed according to ivi use case.
525 * - destination rectangle of layer
Yong Bakose0698712016-04-28 11:59:08 -0500526 * - in multi-screen coordinates,
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900527 * - and intersected inside of an assigned screen,
Yong Bakose0698712016-04-28 11:59:08 -0500528 * is inversed to surface-local coordinates by inversed matrix:m.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900529 * - the area is intersected by intersected area between weston_surface and
530 * source rectangle of ivi_surface.
531 */
532static void
533calc_surface_to_global_matrix_and_mask_to_weston_surface(
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900534 struct ivi_layout_screen *iviscrn,
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900535 struct ivi_layout_layer *ivilayer,
536 struct ivi_layout_surface *ivisurf,
537 struct weston_matrix *m,
538 struct ivi_rectangle *result)
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900539{
540 const struct ivi_layout_surface_properties *sp = &ivisurf->prop;
541 const struct ivi_layout_layer_properties *lp = &ivilayer->prop;
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900542 struct weston_output *output = iviscrn->output;
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900543 struct ivi_rectangle weston_surface_rect = { 0,
544 0,
545 ivisurf->surface->width,
546 ivisurf->surface->height };
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900547 struct ivi_rectangle surface_source_rect = { sp->source_x,
548 sp->source_y,
549 sp->source_width,
550 sp->source_height };
551 struct ivi_rectangle surface_dest_rect = { sp->dest_x,
552 sp->dest_y,
553 sp->dest_width,
554 sp->dest_height };
555 struct ivi_rectangle layer_source_rect = { lp->source_x,
556 lp->source_y,
557 lp->source_width,
558 lp->source_height };
559 struct ivi_rectangle layer_dest_rect = { lp->dest_x,
560 lp->dest_y,
561 lp->dest_width,
562 lp->dest_height };
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900563 struct ivi_rectangle screen_dest_rect = { output->x,
564 output->y,
565 output->width,
566 output->height };
567 struct ivi_rectangle layer_dest_rect_in_global =
568 { lp->dest_x + output->x,
569 lp->dest_y + output->y,
570 lp->dest_width,
571 lp->dest_height };
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900572 struct ivi_rectangle surface_result;
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900573 struct ivi_rectangle layer_dest_rect_in_global_intersected;
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900574
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900575 /*
576 * the whole transformation matrix:m from surface-local
577 * coordinates to global coordinates, which is computed by
578 * two steps,
579 * - surface-local coordinates to layer-local coordinates
Yong Bakose0698712016-04-28 11:59:08 -0500580 * - layer-local coordinates to single screen-local coordinates
581 * - single screen-local coordinates to multi-screen coordinates,
582 * which are global coordinates.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900583 */
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900584 calc_transformation_matrix(&surface_source_rect,
585 &surface_dest_rect,
586 sp->orientation, m);
587
588 calc_transformation_matrix(&layer_source_rect,
589 &layer_dest_rect,
590 lp->orientation, m);
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900591
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900592 weston_matrix_translate(m, output->x, output->y, 0.0f);
593
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900594 /* this intersected ivi_rectangle would be used for masking
595 * weston_surface
596 */
597 ivi_rectangle_intersect(&surface_source_rect, &weston_surface_rect,
598 &surface_result);
599
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900600 /*
601 * destination rectangle of layer in multi screens coordinate
602 * is intersected to avoid displaying outside of an assigned screen.
603 */
604 ivi_rectangle_intersect(&layer_dest_rect_in_global, &screen_dest_rect,
605 &layer_dest_rect_in_global_intersected);
606
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900607 /* calc masking area of weston_surface from m */
608 calc_inverse_matrix_transform(m,
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900609 &layer_dest_rect_in_global_intersected,
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900610 &surface_result,
611 result);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900612}
613
614static void
Ucan, Emre (ADITG/SW1)1b92ba22017-01-30 13:36:05 +0000615update_prop(struct ivi_layout_view *ivi_view)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900616{
Ucan, Emre (ADITG/SW1)1b92ba22017-01-30 13:36:05 +0000617 struct ivi_layout_surface *ivisurf = ivi_view->ivisurf;
618 struct ivi_layout_layer *ivilayer = ivi_view->on_layer;
619 struct ivi_layout_screen *iviscrn = ivilayer->on_screen;
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900620 struct ivi_rectangle r;
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900621 bool can_calc = true;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900622
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900623 /*In case of no prop change, this just returns*/
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000624 if (!ivilayer->prop.event_mask && !ivisurf->prop.event_mask)
Nobuhiko Tanibata4c1dbf72015-07-15 13:55:50 +0900625 return;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900626
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000627 update_opacity(ivilayer, ivisurf, ivi_view->view);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900628
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900629 if (ivisurf->prop.source_width == 0 || ivisurf->prop.source_height == 0) {
630 weston_log("ivi-shell: source rectangle is not yet set by ivi_layout_surface_set_source_rectangle\n");
631 can_calc = false;
632 }
633
634 if (ivisurf->prop.dest_width == 0 || ivisurf->prop.dest_height == 0) {
635 weston_log("ivi-shell: destination rectangle is not yet set by ivi_layout_surface_set_destination_rectangle\n");
636 can_calc = false;
637 }
638
639 if (can_calc) {
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000640 wl_list_remove(&ivi_view->transform.link);
641 weston_matrix_init(&ivi_view->transform.matrix);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900642
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900643 calc_surface_to_global_matrix_and_mask_to_weston_surface(
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000644 iviscrn, ivilayer, ivisurf, &ivi_view->transform.matrix, &r);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900645
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000646 weston_view_set_mask(ivi_view->view, r.x, r.y, r.width, r.height);
647 wl_list_insert(&ivi_view->view->geometry.transformation_list,
648 &ivi_view->transform.link);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900649
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000650 weston_view_set_transform_parent(ivi_view->view, NULL);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900651 }
652
653 ivisurf->update_count++;
654
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000655 weston_view_geometry_dirty(ivi_view->view);
Nobuhiko Tanibata4c1dbf72015-07-15 13:55:50 +0900656
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000657 weston_surface_damage(ivisurf->surface);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900658}
659
660static void
661commit_changes(struct ivi_layout *layout)
662{
Ucan, Emre (ADITG/SW1)27799352017-01-30 13:36:07 +0000663 struct ivi_layout_screen *iviscrn = NULL;
664 struct ivi_layout_layer *ivilayer = NULL;
665 struct ivi_layout_surface *ivisurf = NULL;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000666 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900667
Ucan, Emre (ADITG/SW1)27799352017-01-30 13:36:07 +0000668 wl_list_for_each(ivi_view, &layout->view_list, link) {
669 ivisurf = ivi_view->ivisurf;
670 ivilayer = ivi_view->on_layer;
671 iviscrn = ivilayer->on_screen;
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900672
Ucan, Emre (ADITG/SW1)27799352017-01-30 13:36:07 +0000673 /*
674 * If the view is not on the currently rendered scenegraph,
675 * we do not need to update its properties.
676 */
677 if (wl_list_empty(&ivi_view->order_link) || !iviscrn)
678 continue;
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900679
Ucan, Emre (ADITG/SW1)27799352017-01-30 13:36:07 +0000680 /*
681 * If the view's layer or surface is invisible, we do not need
682 * to update its properties.
683 */
684 if (!ivilayer->prop.visibility || !ivisurf->prop.visibility)
685 continue;
686
687 update_prop(ivi_view);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900688 }
689}
690
691static void
692commit_surface_list(struct ivi_layout *layout)
693{
694 struct ivi_layout_surface *ivisurf = NULL;
695 int32_t dest_x = 0;
696 int32_t dest_y = 0;
697 int32_t dest_width = 0;
698 int32_t dest_height = 0;
699 int32_t configured = 0;
700
701 wl_list_for_each(ivisurf, &layout->surface_list, link) {
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300702 if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEFAULT) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900703 dest_x = ivisurf->prop.dest_x;
704 dest_y = ivisurf->prop.dest_y;
705 dest_width = ivisurf->prop.dest_width;
706 dest_height = ivisurf->prop.dest_height;
707
708 ivi_layout_transition_move_resize_view(ivisurf,
709 ivisurf->pending.prop.dest_x,
710 ivisurf->pending.prop.dest_y,
711 ivisurf->pending.prop.dest_width,
712 ivisurf->pending.prop.dest_height,
713 ivisurf->pending.prop.transition_duration);
714
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300715 if (ivisurf->pending.prop.visibility) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900716 ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration);
717 } else {
718 ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration);
719 }
720
721 ivisurf->prop = ivisurf->pending.prop;
722 ivisurf->prop.dest_x = dest_x;
723 ivisurf->prop.dest_y = dest_y;
724 ivisurf->prop.dest_width = dest_width;
725 ivisurf->prop.dest_height = dest_height;
726 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
727 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
728
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300729 } else if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEST_RECT_ONLY) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900730 dest_x = ivisurf->prop.dest_x;
731 dest_y = ivisurf->prop.dest_y;
732 dest_width = ivisurf->prop.dest_width;
733 dest_height = ivisurf->prop.dest_height;
734
735 ivi_layout_transition_move_resize_view(ivisurf,
736 ivisurf->pending.prop.dest_x,
737 ivisurf->pending.prop.dest_y,
738 ivisurf->pending.prop.dest_width,
739 ivisurf->pending.prop.dest_height,
740 ivisurf->pending.prop.transition_duration);
741
742 ivisurf->prop = ivisurf->pending.prop;
743 ivisurf->prop.dest_x = dest_x;
744 ivisurf->prop.dest_y = dest_y;
745 ivisurf->prop.dest_width = dest_width;
746 ivisurf->prop.dest_height = dest_height;
747
748 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
749 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
750
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300751 } else if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900752 configured = 0;
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300753 if (ivisurf->pending.prop.visibility) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900754 ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration);
755 } else {
756 ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration);
757 }
758
759 if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width ||
760 ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) {
761 configured = 1;
762 }
763
764 ivisurf->prop = ivisurf->pending.prop;
765 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
766 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
767
Pekka Paalanen1f821932016-03-15 16:57:51 +0200768 if (configured && !is_surface_transition(ivisurf)) {
Pekka Paalanen1f821932016-03-15 16:57:51 +0200769 shell_surface_send_configure(ivisurf->surface,
770 ivisurf->prop.dest_width,
771 ivisurf->prop.dest_height);
772 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900773 } else {
774 configured = 0;
775 if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width ||
776 ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) {
777 configured = 1;
778 }
779
780 ivisurf->prop = ivisurf->pending.prop;
781 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
782 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
783
Pekka Paalanen1f821932016-03-15 16:57:51 +0200784 if (configured && !is_surface_transition(ivisurf)) {
Pekka Paalanen1f821932016-03-15 16:57:51 +0200785 shell_surface_send_configure(ivisurf->surface,
786 ivisurf->prop.dest_width,
787 ivisurf->prop.dest_height);
788 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900789 }
790 }
791}
792
793static void
794commit_layer_list(struct ivi_layout *layout)
795{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000796 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900797 struct ivi_layout_layer *ivilayer = NULL;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000798 struct ivi_layout_view *next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900799
800 wl_list_for_each(ivilayer, &layout->layer_list, link) {
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300801 if (ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_MOVE) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900802 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 -0300803 } else if (ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_FADE) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900804 ivi_layout_transition_fade_layer(ivilayer,ivilayer->pending.prop.is_fade_in,
805 ivilayer->pending.prop.start_alpha,ivilayer->pending.prop.end_alpha,
806 NULL, NULL,
807 ivilayer->pending.prop.transition_duration);
808 }
809 ivilayer->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
810
811 ivilayer->prop = ivilayer->pending.prop;
812
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +0000813 if (!ivilayer->order.dirty) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900814 continue;
815 }
816
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000817 wl_list_for_each_safe(ivi_view, next, &ivilayer->order.view_list,
818 order_link) {
819 wl_list_remove(&ivi_view->order_link);
820 wl_list_init(&ivi_view->order_link);
821 ivi_view->ivisurf->prop.event_mask |= IVI_NOTIFICATION_REMOVE;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900822 }
823
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000824 assert(wl_list_empty(&ivilayer->order.view_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900825
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000826 wl_list_for_each(ivi_view, &ivilayer->pending.view_list,
827 pending_link) {
828 wl_list_remove(&ivi_view->order_link);
829 wl_list_insert(&ivilayer->order.view_list, &ivi_view->order_link);
830 ivi_view->ivisurf->prop.event_mask |= IVI_NOTIFICATION_ADD;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900831 }
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +0000832
833 ivilayer->order.dirty = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900834 }
835}
836
837static void
838commit_screen_list(struct ivi_layout *layout)
839{
840 struct ivi_layout_screen *iviscrn = NULL;
841 struct ivi_layout_layer *ivilayer = NULL;
842 struct ivi_layout_layer *next = NULL;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000843 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900844
Nobuhiko Tanibatafbfa8f22015-11-25 23:36:57 +0900845 /* Clear view list of layout ivi_layer */
846 wl_list_init(&layout->layout_layer.view_list.link);
847
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900848 wl_list_for_each(iviscrn, &layout->screen_list, link) {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000849 if (iviscrn->order.dirty) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900850 wl_list_for_each_safe(ivilayer, next,
851 &iviscrn->order.layer_list, order.link) {
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +0000852 ivilayer->on_screen = NULL;
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000853 wl_list_remove(&ivilayer->order.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900854 wl_list_init(&ivilayer->order.link);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000855 ivilayer->prop.event_mask |= IVI_NOTIFICATION_REMOVE;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900856 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900857
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000858 assert(wl_list_empty(&iviscrn->order.layer_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900859
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900860 wl_list_for_each(ivilayer, &iviscrn->pending.layer_list,
861 pending.link) {
Nobuhiko Tanibata77b0ee12015-11-25 23:36:46 +0900862 /* FIXME: avoid to insert order.link to multiple screens */
863 wl_list_remove(&ivilayer->order.link);
864
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900865 wl_list_insert(&iviscrn->order.layer_list,
866 &ivilayer->order.link);
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +0000867 ivilayer->on_screen = iviscrn;
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000868 ivilayer->prop.event_mask |= IVI_NOTIFICATION_ADD;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900869 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900870
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000871 iviscrn->order.dirty = 0;
872 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900873
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900874 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
875 if (ivilayer->prop.visibility == false)
876 continue;
877
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000878 wl_list_for_each(ivi_view, &ivilayer->order.view_list, order_link) {
879 if (ivi_view->ivisurf->prop.visibility == false)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900880 continue;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000881
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900882 weston_layer_entry_insert(&layout->layout_layer.view_list,
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000883 &ivi_view->view->layer_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900884
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000885 ivi_view->view->output = iviscrn->output;
Armin Krezović50ff4bf2016-06-30 06:04:31 +0200886 ivi_view->ivisurf->surface->is_mapped = true;
887 ivi_view->view->is_mapped = true;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900888 }
889 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900890 }
891}
892
893static void
894commit_transition(struct ivi_layout* layout)
895{
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300896 if (wl_list_empty(&layout->pending_transition_list)) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900897 return;
898 }
899
900 wl_list_insert_list(&layout->transitions->transition_list,
901 &layout->pending_transition_list);
902
903 wl_list_init(&layout->pending_transition_list);
904
905 wl_event_source_timer_update(layout->transitions->event_source, 1);
906}
907
908static void
909send_surface_prop(struct ivi_layout_surface *ivisurf)
910{
911 wl_signal_emit(&ivisurf->property_changed, ivisurf);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000912 ivisurf->pending.prop.event_mask = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900913}
914
915static void
916send_layer_prop(struct ivi_layout_layer *ivilayer)
917{
918 wl_signal_emit(&ivilayer->property_changed, ivilayer);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000919 ivilayer->pending.prop.event_mask = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900920}
921
922static void
923send_prop(struct ivi_layout *layout)
924{
925 struct ivi_layout_layer *ivilayer = NULL;
926 struct ivi_layout_surface *ivisurf = NULL;
927
928 wl_list_for_each_reverse(ivilayer, &layout->layer_list, link) {
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000929 if (ivilayer->prop.event_mask)
Nobuhiko Tanibata6ce3ef82015-06-22 15:32:06 +0900930 send_layer_prop(ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900931 }
932
933 wl_list_for_each_reverse(ivisurf, &layout->surface_list, link) {
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000934 if (ivisurf->prop.event_mask)
Nobuhiko Tanibata6ce3ef82015-06-22 15:32:06 +0900935 send_surface_prop(ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900936 }
937}
938
939static void
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000940clear_view_pending_list(struct ivi_layout_layer *ivilayer)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900941{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000942 struct ivi_layout_view *view_link = NULL;
943 struct ivi_layout_view *view_next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900944
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +0000945 wl_list_for_each_safe(view_link, view_next,
946 &ivilayer->pending.view_list, pending_link) {
947 wl_list_remove(&view_link->pending_link);
948 wl_list_init(&view_link->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900949 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900950}
951
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900952/**
953 * Exported APIs of ivi-layout library are implemented from here.
954 * Brief of APIs is described in ivi-layout-export.h.
955 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900956static int32_t
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000957ivi_layout_add_listener_create_layer(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900958{
959 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900960
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000961 if (listener == NULL) {
962 weston_log("ivi_layout_add_listener_create_layer: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900963 return IVI_FAILED;
964 }
965
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000966 wl_signal_add(&layout->layer_notification.created, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900967
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +0000968 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900969}
970
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900971static int32_t
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000972ivi_layout_add_listener_remove_layer(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900973{
974 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900975
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000976 if (listener == NULL) {
977 weston_log("ivi_layout_add_listener_remove_layer: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900978 return IVI_FAILED;
979 }
980
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000981 wl_signal_add(&layout->layer_notification.removed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900982
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +0000983 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900984}
985
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900986static int32_t
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000987ivi_layout_add_listener_create_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900988{
989 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900990
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000991 if (listener == NULL) {
992 weston_log("ivi_layout_add_listener_create_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900993 return IVI_FAILED;
994 }
995
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000996 wl_signal_add(&layout->surface_notification.created, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900997
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +0000998 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900999}
1000
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001001static int32_t
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001002ivi_layout_add_listener_remove_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001003{
1004 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001005
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001006 if (listener == NULL) {
1007 weston_log("ivi_layout_add_listener_remove_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001008 return IVI_FAILED;
1009 }
1010
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001011 wl_signal_add(&layout->surface_notification.removed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001012
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00001013 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001014}
1015
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001016static int32_t
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001017ivi_layout_add_listener_configure_surface(struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001018{
1019 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001020
1021 if (listener == NULL) {
1022 weston_log("ivi_layout_add_listener_configure_surface: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001023 return IVI_FAILED;
1024 }
1025
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001026 wl_signal_add(&layout->surface_notification.configure_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001027
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00001028 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001029}
1030
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001031uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001032ivi_layout_get_id_of_surface(struct ivi_layout_surface *ivisurf)
1033{
1034 return ivisurf->id_surface;
1035}
1036
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001037static uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001038ivi_layout_get_id_of_layer(struct ivi_layout_layer *ivilayer)
1039{
1040 return ivilayer->id_layer;
1041}
1042
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001043static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001044ivi_layout_get_layer_from_id(uint32_t id_layer)
1045{
1046 struct ivi_layout *layout = get_instance();
1047 struct ivi_layout_layer *ivilayer = NULL;
1048
1049 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1050 if (ivilayer->id_layer == id_layer) {
1051 return ivilayer;
1052 }
1053 }
1054
1055 return NULL;
1056}
1057
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001058struct ivi_layout_surface *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001059ivi_layout_get_surface_from_id(uint32_t id_surface)
1060{
1061 struct ivi_layout *layout = get_instance();
1062 struct ivi_layout_surface *ivisurf = NULL;
1063
1064 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1065 if (ivisurf->id_surface == id_surface) {
1066 return ivisurf;
1067 }
1068 }
1069
1070 return NULL;
1071}
1072
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001073static int32_t
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001074ivi_layout_surface_add_listener(struct ivi_layout_surface *ivisurf,
1075 struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001076{
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001077 if (ivisurf == NULL || listener == NULL) {
1078 weston_log("ivi_layout_surface_add_listener: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001079 return IVI_FAILED;
1080 }
1081
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001082 wl_signal_add(&ivisurf->property_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001083
1084 return IVI_SUCCEEDED;
1085}
1086
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001087static const struct ivi_layout_layer_properties *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001088ivi_layout_get_properties_of_layer(struct ivi_layout_layer *ivilayer)
1089{
1090 if (ivilayer == NULL) {
1091 weston_log("ivi_layout_get_properties_of_layer: invalid argument\n");
1092 return NULL;
1093 }
1094
1095 return &ivilayer->prop;
1096}
1097
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001098static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001099ivi_layout_get_screens_under_layer(struct ivi_layout_layer *ivilayer,
1100 int32_t *pLength,
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001101 struct weston_output ***ppArray)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001102{
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001103 int32_t length = 0;
1104 int32_t n = 0;
1105
1106 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1107 weston_log("ivi_layout_get_screens_under_layer: invalid argument\n");
1108 return IVI_FAILED;
1109 }
1110
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +00001111 if (ivilayer->on_screen != NULL)
1112 length = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001113
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001114 if (length != 0) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001115 /* the Array must be free by module which called this function */
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001116 *ppArray = calloc(length, sizeof(struct weston_output *));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001117 if (*ppArray == NULL) {
1118 weston_log("fails to allocate memory\n");
1119 return IVI_FAILED;
1120 }
1121
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001122 (*ppArray)[n++] = ivilayer->on_screen->output;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001123 }
1124
1125 *pLength = length;
1126
1127 return IVI_SUCCEEDED;
1128}
1129
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001130static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001131ivi_layout_get_layers(int32_t *pLength, struct ivi_layout_layer ***ppArray)
1132{
1133 struct ivi_layout *layout = get_instance();
1134 struct ivi_layout_layer *ivilayer = NULL;
1135 int32_t length = 0;
1136 int32_t n = 0;
1137
1138 if (pLength == NULL || ppArray == NULL) {
1139 weston_log("ivi_layout_get_layers: invalid argument\n");
1140 return IVI_FAILED;
1141 }
1142
1143 length = wl_list_length(&layout->layer_list);
1144
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001145 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001146 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001147 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1148 if (*ppArray == NULL) {
1149 weston_log("fails to allocate memory\n");
1150 return IVI_FAILED;
1151 }
1152
1153 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1154 (*ppArray)[n++] = ivilayer;
1155 }
1156 }
1157
1158 *pLength = length;
1159
1160 return IVI_SUCCEEDED;
1161}
1162
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001163static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001164ivi_layout_get_layers_on_screen(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001165 int32_t *pLength,
1166 struct ivi_layout_layer ***ppArray)
1167{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001168 struct ivi_layout_screen *iviscrn = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001169 struct ivi_layout_layer *ivilayer = NULL;
1170 int32_t length = 0;
1171 int32_t n = 0;
1172
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001173 if (output == NULL || pLength == NULL || ppArray == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001174 weston_log("ivi_layout_get_layers_on_screen: invalid argument\n");
1175 return IVI_FAILED;
1176 }
1177
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001178 iviscrn = get_screen_from_output(output);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001179 length = wl_list_length(&iviscrn->order.layer_list);
1180
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001181 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001182 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001183 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1184 if (*ppArray == NULL) {
1185 weston_log("fails to allocate memory\n");
1186 return IVI_FAILED;
1187 }
1188
Nobuhiko Tanibatae2b82142015-06-22 15:30:19 +09001189 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001190 (*ppArray)[n++] = ivilayer;
1191 }
1192 }
1193
1194 *pLength = length;
1195
1196 return IVI_SUCCEEDED;
1197}
1198
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001199static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001200ivi_layout_get_layers_under_surface(struct ivi_layout_surface *ivisurf,
1201 int32_t *pLength,
1202 struct ivi_layout_layer ***ppArray)
1203{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001204 struct ivi_layout_view *ivi_view;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001205 int32_t length = 0;
1206 int32_t n = 0;
1207
1208 if (ivisurf == NULL || pLength == NULL || ppArray == NULL) {
1209 weston_log("ivi_layout_getLayers: invalid argument\n");
1210 return IVI_FAILED;
1211 }
1212
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001213 if (!wl_list_empty(&ivisurf->view_list)) {
1214 /* the Array must be free by module which called this function */
1215 length = wl_list_length(&ivisurf->view_list);
1216 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001217 if (*ppArray == NULL) {
1218 weston_log("fails to allocate memory\n");
1219 return IVI_FAILED;
1220 }
1221
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001222 wl_list_for_each_reverse(ivi_view, &ivisurf->view_list, surf_link) {
1223 if (ivi_view_is_rendered(ivi_view))
1224 (*ppArray)[n++] = ivi_view->on_layer;
1225 else
1226 length--;
1227 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001228 }
1229
1230 *pLength = length;
1231
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001232 if (!length) {
1233 free(*ppArray);
1234 *ppArray = NULL;
1235 }
1236
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001237 return IVI_SUCCEEDED;
1238}
1239
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001240static
1241int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001242ivi_layout_get_surfaces(int32_t *pLength, struct ivi_layout_surface ***ppArray)
1243{
1244 struct ivi_layout *layout = get_instance();
1245 struct ivi_layout_surface *ivisurf = NULL;
1246 int32_t length = 0;
1247 int32_t n = 0;
1248
1249 if (pLength == NULL || ppArray == NULL) {
1250 weston_log("ivi_layout_get_surfaces: invalid argument\n");
1251 return IVI_FAILED;
1252 }
1253
1254 length = wl_list_length(&layout->surface_list);
1255
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001256 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001257 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001258 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1259 if (*ppArray == NULL) {
1260 weston_log("fails to allocate memory\n");
1261 return IVI_FAILED;
1262 }
1263
1264 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1265 (*ppArray)[n++] = ivisurf;
1266 }
1267 }
1268
1269 *pLength = length;
1270
1271 return IVI_SUCCEEDED;
1272}
1273
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001274static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001275ivi_layout_get_surfaces_on_layer(struct ivi_layout_layer *ivilayer,
1276 int32_t *pLength,
1277 struct ivi_layout_surface ***ppArray)
1278{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001279 struct ivi_layout_view *ivi_view = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001280 int32_t length = 0;
1281 int32_t n = 0;
1282
1283 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1284 weston_log("ivi_layout_getSurfaceIDsOnLayer: invalid argument\n");
1285 return IVI_FAILED;
1286 }
1287
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001288 length = wl_list_length(&ivilayer->order.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001289
1290 if (length != 0) {
Bryce Harringtone6da35d2016-05-19 17:35:02 -07001291 /* the Array must be freed by module which called this function */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001292 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1293 if (*ppArray == NULL) {
1294 weston_log("fails to allocate memory\n");
1295 return IVI_FAILED;
1296 }
1297
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001298 wl_list_for_each(ivi_view, &ivilayer->order.view_list, order_link) {
1299 (*ppArray)[n++] = ivi_view->ivisurf;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001300 }
1301 }
1302
1303 *pLength = length;
1304
1305 return IVI_SUCCEEDED;
1306}
1307
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001308static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001309ivi_layout_layer_create_with_dimension(uint32_t id_layer,
1310 int32_t width, int32_t height)
1311{
1312 struct ivi_layout *layout = get_instance();
1313 struct ivi_layout_layer *ivilayer = NULL;
1314
1315 ivilayer = get_layer(&layout->layer_list, id_layer);
1316 if (ivilayer != NULL) {
1317 weston_log("id_layer is already created\n");
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001318 ++ivilayer->ref_count;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001319 return ivilayer;
1320 }
1321
1322 ivilayer = calloc(1, sizeof *ivilayer);
1323 if (ivilayer == NULL) {
1324 weston_log("fails to allocate memory\n");
1325 return NULL;
1326 }
1327
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001328 ivilayer->ref_count = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001329 wl_signal_init(&ivilayer->property_changed);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001330 ivilayer->layout = layout;
1331 ivilayer->id_layer = id_layer;
1332
1333 init_layer_properties(&ivilayer->prop, width, height);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001334
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001335 wl_list_init(&ivilayer->pending.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001336 wl_list_init(&ivilayer->pending.link);
1337 ivilayer->pending.prop = ivilayer->prop;
1338
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001339 wl_list_init(&ivilayer->order.view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001340 wl_list_init(&ivilayer->order.link);
1341
1342 wl_list_insert(&layout->layer_list, &ivilayer->link);
1343
1344 wl_signal_emit(&layout->layer_notification.created, ivilayer);
1345
1346 return ivilayer;
1347}
1348
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001349static void
Nobuhiko Tanibata3aa8aed2015-06-22 15:32:23 +09001350ivi_layout_layer_destroy(struct ivi_layout_layer *ivilayer)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001351{
1352 struct ivi_layout *layout = get_instance();
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001353 struct ivi_layout_view *ivi_view, *next;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001354
1355 if (ivilayer == NULL) {
Ucan, Emre (ADITG/SW1)66602522017-01-17 12:35:20 +00001356 weston_log("ivi_layout_layer_destroy: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001357 return;
1358 }
1359
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001360 if (--ivilayer->ref_count > 0)
1361 return;
1362
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001363 /*Destroy all ivi_views*/
1364 wl_list_for_each_safe(ivi_view, next, &layout->view_list, link) {
1365 if (ivi_view->on_layer == ivilayer)
1366 ivi_view_destroy(ivi_view);
1367 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001368
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001369 wl_signal_emit(&layout->layer_notification.removed, ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001370
Ucan, Emre (ADITG/SW1)cf34dc22015-08-20 14:13:33 +00001371 wl_list_remove(&ivilayer->pending.link);
1372 wl_list_remove(&ivilayer->order.link);
1373 wl_list_remove(&ivilayer->link);
1374
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001375 free(ivilayer);
1376}
1377
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001378int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001379ivi_layout_layer_set_visibility(struct ivi_layout_layer *ivilayer,
1380 bool newVisibility)
1381{
1382 struct ivi_layout_layer_properties *prop = NULL;
1383
1384 if (ivilayer == NULL) {
1385 weston_log("ivi_layout_layer_set_visibility: invalid argument\n");
1386 return IVI_FAILED;
1387 }
1388
1389 prop = &ivilayer->pending.prop;
1390 prop->visibility = newVisibility;
1391
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001392 if (ivilayer->prop.visibility != newVisibility)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001393 prop->event_mask |= IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001394 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001395 prop->event_mask &= ~IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001396
1397 return IVI_SUCCEEDED;
1398}
1399
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001400int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001401ivi_layout_layer_set_opacity(struct ivi_layout_layer *ivilayer,
1402 wl_fixed_t opacity)
1403{
1404 struct ivi_layout_layer_properties *prop = NULL;
1405
Nobuhiko Tanibata7bbacc62015-06-22 15:30:09 +09001406 if (ivilayer == NULL ||
1407 opacity < wl_fixed_from_double(0.0) ||
1408 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001409 weston_log("ivi_layout_layer_set_opacity: invalid argument\n");
1410 return IVI_FAILED;
1411 }
1412
1413 prop = &ivilayer->pending.prop;
1414 prop->opacity = opacity;
1415
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001416 if (ivilayer->prop.opacity != opacity)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001417 prop->event_mask |= IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001418 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001419 prop->event_mask &= ~IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001420
1421 return IVI_SUCCEEDED;
1422}
1423
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001424static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001425ivi_layout_layer_set_source_rectangle(struct ivi_layout_layer *ivilayer,
1426 int32_t x, int32_t y,
1427 int32_t width, int32_t height)
1428{
1429 struct ivi_layout_layer_properties *prop = NULL;
1430
1431 if (ivilayer == NULL) {
1432 weston_log("ivi_layout_layer_set_source_rectangle: invalid argument\n");
1433 return IVI_FAILED;
1434 }
1435
1436 prop = &ivilayer->pending.prop;
1437 prop->source_x = x;
1438 prop->source_y = y;
1439 prop->source_width = width;
1440 prop->source_height = height;
1441
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001442 if (ivilayer->prop.source_x != x || ivilayer->prop.source_y != y ||
1443 ivilayer->prop.source_width != width ||
1444 ivilayer->prop.source_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001445 prop->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001446 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001447 prop->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001448
1449 return IVI_SUCCEEDED;
1450}
1451
Ucan, Emre \(ADITG/SW1\)e62bfd82016-03-04 12:50:46 +00001452int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001453ivi_layout_layer_set_destination_rectangle(struct ivi_layout_layer *ivilayer,
1454 int32_t x, int32_t y,
1455 int32_t width, int32_t height)
1456{
1457 struct ivi_layout_layer_properties *prop = NULL;
1458
1459 if (ivilayer == NULL) {
1460 weston_log("ivi_layout_layer_set_destination_rectangle: invalid argument\n");
1461 return IVI_FAILED;
1462 }
1463
1464 prop = &ivilayer->pending.prop;
1465 prop->dest_x = x;
1466 prop->dest_y = y;
1467 prop->dest_width = width;
1468 prop->dest_height = height;
1469
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001470 if (ivilayer->prop.dest_x != x || ivilayer->prop.dest_y != y ||
1471 ivilayer->prop.dest_width != width ||
1472 ivilayer->prop.dest_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001473 prop->event_mask |= IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001474 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001475 prop->event_mask &= ~IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001476
1477 return IVI_SUCCEEDED;
1478}
1479
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001480static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001481ivi_layout_layer_set_orientation(struct ivi_layout_layer *ivilayer,
1482 enum wl_output_transform orientation)
1483{
1484 struct ivi_layout_layer_properties *prop = NULL;
1485
1486 if (ivilayer == NULL) {
1487 weston_log("ivi_layout_layer_set_orientation: invalid argument\n");
1488 return IVI_FAILED;
1489 }
1490
1491 prop = &ivilayer->pending.prop;
1492 prop->orientation = orientation;
1493
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001494 if (ivilayer->prop.orientation != orientation)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001495 prop->event_mask |= IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001496 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001497 prop->event_mask &= ~IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001498
1499 return IVI_SUCCEEDED;
1500}
1501
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001502int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001503ivi_layout_layer_set_render_order(struct ivi_layout_layer *ivilayer,
1504 struct ivi_layout_surface **pSurface,
1505 int32_t number)
1506{
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001507 int32_t i = 0;
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001508 struct ivi_layout_view * ivi_view;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001509
1510 if (ivilayer == NULL) {
1511 weston_log("ivi_layout_layer_set_render_order: invalid argument\n");
1512 return IVI_FAILED;
1513 }
1514
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001515 clear_view_pending_list(ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001516
1517 for (i = 0; i < number; i++) {
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001518 ivi_view = get_ivi_view(ivilayer, pSurface[i]);
1519 if (!ivi_view)
1520 ivi_view = ivi_view_create(ivilayer, pSurface[i]);
1521
1522 assert(ivi_view != NULL);
1523
1524 wl_list_remove(&ivi_view->pending_link);
1525 wl_list_insert(&ivilayer->pending.view_list, &ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001526 }
1527
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +00001528 ivilayer->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001529
1530 return IVI_SUCCEEDED;
1531}
1532
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001533int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001534ivi_layout_surface_set_visibility(struct ivi_layout_surface *ivisurf,
1535 bool newVisibility)
1536{
1537 struct ivi_layout_surface_properties *prop = NULL;
1538
1539 if (ivisurf == NULL) {
1540 weston_log("ivi_layout_surface_set_visibility: invalid argument\n");
1541 return IVI_FAILED;
1542 }
1543
1544 prop = &ivisurf->pending.prop;
1545 prop->visibility = newVisibility;
1546
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001547 if (ivisurf->prop.visibility != newVisibility)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001548 prop->event_mask |= IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001549 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001550 prop->event_mask &= ~IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001551
1552 return IVI_SUCCEEDED;
1553}
1554
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001555int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001556ivi_layout_surface_set_opacity(struct ivi_layout_surface *ivisurf,
1557 wl_fixed_t opacity)
1558{
1559 struct ivi_layout_surface_properties *prop = NULL;
1560
Nobuhiko Tanibataa86226c2015-06-22 15:29:20 +09001561 if (ivisurf == NULL ||
1562 opacity < wl_fixed_from_double(0.0) ||
1563 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001564 weston_log("ivi_layout_surface_set_opacity: invalid argument\n");
1565 return IVI_FAILED;
1566 }
1567
1568 prop = &ivisurf->pending.prop;
1569 prop->opacity = opacity;
1570
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001571 if (ivisurf->prop.opacity != opacity)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001572 prop->event_mask |= IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001573 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001574 prop->event_mask &= ~IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001575
1576 return IVI_SUCCEEDED;
1577}
1578
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001579int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001580ivi_layout_surface_set_destination_rectangle(struct ivi_layout_surface *ivisurf,
1581 int32_t x, int32_t y,
1582 int32_t width, int32_t height)
1583{
1584 struct ivi_layout_surface_properties *prop = NULL;
1585
1586 if (ivisurf == NULL) {
1587 weston_log("ivi_layout_surface_set_destination_rectangle: invalid argument\n");
1588 return IVI_FAILED;
1589 }
1590
1591 prop = &ivisurf->pending.prop;
1592 prop->start_x = prop->dest_x;
1593 prop->start_y = prop->dest_y;
1594 prop->dest_x = x;
1595 prop->dest_y = y;
1596 prop->start_width = prop->dest_width;
1597 prop->start_height = prop->dest_height;
1598 prop->dest_width = width;
1599 prop->dest_height = height;
1600
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001601 if (ivisurf->prop.dest_x != x || ivisurf->prop.dest_y != y ||
1602 ivisurf->prop.dest_width != width ||
1603 ivisurf->prop.dest_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001604 prop->event_mask |= IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001605 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001606 prop->event_mask &= ~IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001607
1608 return IVI_SUCCEEDED;
1609}
1610
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001611static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001612ivi_layout_surface_set_orientation(struct ivi_layout_surface *ivisurf,
1613 enum wl_output_transform orientation)
1614{
1615 struct ivi_layout_surface_properties *prop = NULL;
1616
1617 if (ivisurf == NULL) {
1618 weston_log("ivi_layout_surface_set_orientation: invalid argument\n");
1619 return IVI_FAILED;
1620 }
1621
1622 prop = &ivisurf->pending.prop;
1623 prop->orientation = orientation;
1624
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001625 if (ivisurf->prop.orientation != orientation)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001626 prop->event_mask |= IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001627 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001628 prop->event_mask &= ~IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001629
1630 return IVI_SUCCEEDED;
1631}
1632
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001633static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001634ivi_layout_screen_add_layer(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001635 struct ivi_layout_layer *addlayer)
1636{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001637 struct ivi_layout_screen *iviscrn;
1638
1639 if (output == NULL || addlayer == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001640 weston_log("ivi_layout_screen_add_layer: invalid argument\n");
1641 return IVI_FAILED;
1642 }
1643
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001644 iviscrn = get_screen_from_output(output);
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001645
Ucan, Emre (ADITG/SW1)f46306f2016-03-16 13:37:07 +00001646 wl_list_remove(&addlayer->pending.link);
1647 wl_list_insert(&iviscrn->pending.layer_list, &addlayer->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001648
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001649 iviscrn->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001650
1651 return IVI_SUCCEEDED;
1652}
1653
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001654static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001655ivi_layout_screen_set_render_order(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001656 struct ivi_layout_layer **pLayer,
1657 const int32_t number)
1658{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001659 struct ivi_layout_screen *iviscrn;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001660 struct ivi_layout_layer *ivilayer = NULL;
1661 struct ivi_layout_layer *next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001662 int32_t i = 0;
1663
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001664 if (output == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001665 weston_log("ivi_layout_screen_set_render_order: invalid argument\n");
1666 return IVI_FAILED;
1667 }
1668
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001669 iviscrn = get_screen_from_output(output);
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001670
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001671 wl_list_for_each_safe(ivilayer, next,
1672 &iviscrn->pending.layer_list, pending.link) {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001673 wl_list_remove(&ivilayer->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001674 wl_list_init(&ivilayer->pending.link);
1675 }
1676
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001677 assert(wl_list_empty(&iviscrn->pending.layer_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001678
1679 for (i = 0; i < number; i++) {
Ucan, Emre (ADITG/SW1)4e221f02016-03-16 13:37:08 +00001680 wl_list_remove(&pLayer[i]->pending.link);
1681 wl_list_insert(&iviscrn->pending.layer_list,
1682 &pLayer[i]->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001683 }
1684
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001685 iviscrn->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001686
1687 return IVI_SUCCEEDED;
1688}
1689
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001690/**
1691 * This function is used by the additional ivi-module because of dumping ivi_surface sceenshot.
1692 * The ivi-module, e.g. ivi-controller.so, is in wayland-ivi-extension of Genivi's Layer Management.
1693 * This function is used to get the result of drawing by clients.
1694 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001695static struct weston_surface *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001696ivi_layout_surface_get_weston_surface(struct ivi_layout_surface *ivisurf)
1697{
1698 return ivisurf != NULL ? ivisurf->surface : NULL;
1699}
1700
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001701static int32_t
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09001702ivi_layout_surface_get_size(struct ivi_layout_surface *ivisurf,
1703 int32_t *width, int32_t *height,
1704 int32_t *stride)
1705{
1706 int32_t w;
1707 int32_t h;
1708 const size_t bytespp = 4; /* PIXMAN_a8b8g8r8 */
1709
1710 if (ivisurf == NULL || ivisurf->surface == NULL) {
1711 weston_log("%s: invalid argument\n", __func__);
1712 return IVI_FAILED;
1713 }
1714
1715 weston_surface_get_content_size(ivisurf->surface, &w, &h);
1716
1717 if (width != NULL)
1718 *width = w;
1719
1720 if (height != NULL)
1721 *height = h;
1722
1723 if (stride != NULL)
1724 *stride = w * bytespp;
1725
1726 return IVI_SUCCEEDED;
1727}
1728
1729static int32_t
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001730ivi_layout_layer_add_listener(struct ivi_layout_layer *ivilayer,
1731 struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001732{
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001733 if (ivilayer == NULL || listener == NULL) {
1734 weston_log("ivi_layout_layer_add_listener: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001735 return IVI_FAILED;
1736 }
1737
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001738 wl_signal_add(&ivilayer->property_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001739
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00001740 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001741}
1742
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001743static const struct ivi_layout_surface_properties *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001744ivi_layout_get_properties_of_surface(struct ivi_layout_surface *ivisurf)
1745{
1746 if (ivisurf == NULL) {
1747 weston_log("ivi_layout_get_properties_of_surface: invalid argument\n");
1748 return NULL;
1749 }
1750
1751 return &ivisurf->prop;
1752}
1753
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001754static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001755ivi_layout_layer_add_surface(struct ivi_layout_layer *ivilayer,
1756 struct ivi_layout_surface *addsurf)
1757{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001758 struct ivi_layout_view *ivi_view;
1759
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001760 if (ivilayer == NULL || addsurf == NULL) {
1761 weston_log("ivi_layout_layer_add_surface: invalid argument\n");
1762 return IVI_FAILED;
1763 }
1764
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001765 ivi_view = get_ivi_view(ivilayer, addsurf);
1766 if (!ivi_view)
1767 ivi_view = ivi_view_create(ivilayer, addsurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001768
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001769 wl_list_remove(&ivi_view->pending_link);
1770 wl_list_insert(&ivilayer->pending.view_list, &ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001771
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +00001772 ivilayer->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001773
1774 return IVI_SUCCEEDED;
1775}
1776
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001777static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001778ivi_layout_layer_remove_surface(struct ivi_layout_layer *ivilayer,
1779 struct ivi_layout_surface *remsurf)
1780{
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001781 struct ivi_layout_view *ivi_view;
1782
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001783 if (ivilayer == NULL || remsurf == NULL) {
1784 weston_log("ivi_layout_layer_remove_surface: invalid argument\n");
1785 return;
1786 }
1787
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001788 ivi_view = get_ivi_view(ivilayer, remsurf);
1789 if (ivi_view) {
1790 wl_list_remove(&ivi_view->pending_link);
1791 wl_list_init(&ivi_view->pending_link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001792
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001793 ivilayer->order.dirty = 1;
1794 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001795}
1796
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001797static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001798ivi_layout_surface_set_source_rectangle(struct ivi_layout_surface *ivisurf,
1799 int32_t x, int32_t y,
1800 int32_t width, int32_t height)
1801{
1802 struct ivi_layout_surface_properties *prop = NULL;
1803
1804 if (ivisurf == NULL) {
1805 weston_log("ivi_layout_surface_set_source_rectangle: invalid argument\n");
1806 return IVI_FAILED;
1807 }
1808
1809 prop = &ivisurf->pending.prop;
1810 prop->source_x = x;
1811 prop->source_y = y;
1812 prop->source_width = width;
1813 prop->source_height = height;
1814
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001815 if (ivisurf->prop.source_x != x || ivisurf->prop.source_y != y ||
1816 ivisurf->prop.source_width != width ||
1817 ivisurf->prop.source_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001818 prop->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001819 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001820 prop->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001821
1822 return IVI_SUCCEEDED;
1823}
1824
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001825int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001826ivi_layout_commit_changes(void)
1827{
1828 struct ivi_layout *layout = get_instance();
1829
1830 commit_surface_list(layout);
1831 commit_layer_list(layout);
1832 commit_screen_list(layout);
1833
1834 commit_transition(layout);
1835
1836 commit_changes(layout);
1837 send_prop(layout);
1838 weston_compositor_schedule_repaint(layout->compositor);
1839
1840 return IVI_SUCCEEDED;
1841}
1842
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001843static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001844ivi_layout_layer_set_transition(struct ivi_layout_layer *ivilayer,
1845 enum ivi_layout_transition_type type,
1846 uint32_t duration)
1847{
1848 if (ivilayer == NULL) {
1849 weston_log("%s: invalid argument\n", __func__);
1850 return -1;
1851 }
1852
1853 ivilayer->pending.prop.transition_type = type;
1854 ivilayer->pending.prop.transition_duration = duration;
1855
1856 return 0;
1857}
1858
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001859static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001860ivi_layout_layer_set_fade_info(struct ivi_layout_layer* ivilayer,
1861 uint32_t is_fade_in,
1862 double start_alpha, double end_alpha)
1863{
1864 if (ivilayer == NULL) {
1865 weston_log("%s: invalid argument\n", __func__);
1866 return -1;
1867 }
1868
1869 ivilayer->pending.prop.is_fade_in = is_fade_in;
1870 ivilayer->pending.prop.start_alpha = start_alpha;
1871 ivilayer->pending.prop.end_alpha = end_alpha;
1872
1873 return 0;
1874}
1875
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001876static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09001877ivi_layout_surface_set_transition_duration(struct ivi_layout_surface *ivisurf,
1878 uint32_t duration)
1879{
1880 struct ivi_layout_surface_properties *prop;
1881
1882 if (ivisurf == NULL) {
1883 weston_log("%s: invalid argument\n", __func__);
1884 return -1;
1885 }
1886
1887 prop = &ivisurf->pending.prop;
1888 prop->transition_duration = duration*10;
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(struct ivi_layout_surface *ivisurf,
1894 enum ivi_layout_transition_type type,
1895 uint32_t duration)
1896{
1897 struct ivi_layout_surface_properties *prop;
1898
1899 if (ivisurf == NULL) {
1900 weston_log("%s: invalid argument\n", __func__);
1901 return -1;
1902 }
1903
1904 prop = &ivisurf->pending.prop;
1905 prop->transition_type = type;
1906 prop->transition_duration = duration;
1907 return 0;
1908}
1909
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09001910static int32_t
1911ivi_layout_surface_dump(struct weston_surface *surface,
1912 void *target, size_t size,int32_t x, int32_t y,
1913 int32_t width, int32_t height)
1914{
1915 int result = 0;
1916
1917 if (surface == NULL) {
1918 weston_log("%s: invalid argument\n", __func__);
1919 return IVI_FAILED;
1920 }
1921
1922 result = weston_surface_copy_content(
1923 surface, target, size,
1924 x, y, width, height);
1925
1926 return result == 0 ? IVI_SUCCEEDED : IVI_FAILED;
1927}
1928
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001929/**
1930 * methods of interaction between ivi-shell with ivi-layout
1931 */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001932
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001933void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001934ivi_layout_surface_configure(struct ivi_layout_surface *ivisurf,
1935 int32_t width, int32_t height)
1936{
1937 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001938
Nobuhiko Tanibatae6cc9972015-04-27 16:54:01 +09001939 /* emit callback which is set by ivi-layout api user */
1940 wl_signal_emit(&layout->surface_notification.configure_changed,
1941 ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001942}
1943
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001944struct ivi_layout_surface*
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001945ivi_layout_surface_create(struct weston_surface *wl_surface,
1946 uint32_t id_surface)
1947{
1948 struct ivi_layout *layout = get_instance();
1949 struct ivi_layout_surface *ivisurf = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001950
1951 if (wl_surface == NULL) {
1952 weston_log("ivi_layout_surface_create: invalid argument\n");
1953 return NULL;
1954 }
1955
1956 ivisurf = get_surface(&layout->surface_list, id_surface);
1957 if (ivisurf != NULL) {
1958 if (ivisurf->surface != NULL) {
1959 weston_log("id_surface(%d) is already created\n", id_surface);
1960 return NULL;
1961 }
1962 }
1963
1964 ivisurf = calloc(1, sizeof *ivisurf);
1965 if (ivisurf == NULL) {
1966 weston_log("fails to allocate memory\n");
1967 return NULL;
1968 }
1969
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001970 wl_signal_init(&ivisurf->property_changed);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001971 ivisurf->id_surface = id_surface;
1972 ivisurf->layout = layout;
1973
1974 ivisurf->surface = wl_surface;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001975
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001976 ivisurf->surface->width_from_buffer = 0;
1977 ivisurf->surface->height_from_buffer = 0;
1978
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001979 init_surface_properties(&ivisurf->prop);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001980
1981 ivisurf->pending.prop = ivisurf->prop;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001982
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00001983 wl_list_init(&ivisurf->view_list);
1984
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001985 wl_list_insert(&layout->surface_list, &ivisurf->link);
1986
1987 wl_signal_emit(&layout->surface_notification.created, ivisurf);
1988
1989 return ivisurf;
1990}
1991
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09001992void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001993ivi_layout_init_with_compositor(struct weston_compositor *ec)
1994{
1995 struct ivi_layout *layout = get_instance();
1996
1997 layout->compositor = ec;
1998
1999 wl_list_init(&layout->surface_list);
2000 wl_list_init(&layout->layer_list);
2001 wl_list_init(&layout->screen_list);
Ucan, Emre (ADITG/SW1)5e8d55d2016-06-14 14:43:40 +00002002 wl_list_init(&layout->view_list);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002003
2004 wl_signal_init(&layout->layer_notification.created);
2005 wl_signal_init(&layout->layer_notification.removed);
2006
2007 wl_signal_init(&layout->surface_notification.created);
2008 wl_signal_init(&layout->surface_notification.removed);
2009 wl_signal_init(&layout->surface_notification.configure_changed);
2010
2011 /* Add layout_layer at the last of weston_compositor.layer_list */
Quentin Glidic82681572016-12-17 13:40:51 +01002012 weston_layer_init(&layout->layout_layer, ec);
2013 weston_layer_set_position(&layout->layout_layer,
2014 WESTON_LAYER_POSITION_NORMAL);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002015
2016 create_screen(ec);
2017
2018 layout->transitions = ivi_layout_transition_set_create(ec);
2019 wl_list_init(&layout->pending_transition_list);
2020}
2021
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002022static struct ivi_layout_interface ivi_layout_interface = {
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002023 /**
2024 * commit all changes
2025 */
2026 .commit_changes = ivi_layout_commit_changes,
2027
2028 /**
2029 * surface controller interfaces
2030 */
Ucan, Emre (ADITG/SW1)970f8312016-04-04 08:05:09 +00002031 .add_listener_create_surface = ivi_layout_add_listener_create_surface,
Ucan, Emre (ADITG/SW1)67f0aa82016-04-04 08:05:18 +00002032 .add_listener_remove_surface = ivi_layout_add_listener_remove_surface,
Ucan, Emre (ADITG/SW1)c49aa5a2016-04-04 08:05:20 +00002033 .add_listener_configure_surface = ivi_layout_add_listener_configure_surface,
Pekka Paalaneneaa43fc2016-04-12 16:06:58 +03002034 .get_surface = shell_get_ivi_layout_surface,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002035 .get_surfaces = ivi_layout_get_surfaces,
2036 .get_id_of_surface = ivi_layout_get_id_of_surface,
2037 .get_surface_from_id = ivi_layout_get_surface_from_id,
2038 .get_properties_of_surface = ivi_layout_get_properties_of_surface,
2039 .get_surfaces_on_layer = ivi_layout_get_surfaces_on_layer,
2040 .surface_set_visibility = ivi_layout_surface_set_visibility,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002041 .surface_set_opacity = ivi_layout_surface_set_opacity,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002042 .surface_set_source_rectangle = ivi_layout_surface_set_source_rectangle,
2043 .surface_set_destination_rectangle = ivi_layout_surface_set_destination_rectangle,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002044 .surface_set_orientation = ivi_layout_surface_set_orientation,
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00002045 .surface_add_listener = ivi_layout_surface_add_listener,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002046 .surface_get_weston_surface = ivi_layout_surface_get_weston_surface,
2047 .surface_set_transition = ivi_layout_surface_set_transition,
2048 .surface_set_transition_duration = ivi_layout_surface_set_transition_duration,
2049
2050 /**
2051 * layer controller interfaces
2052 */
Ucan, Emre (ADITG/SW1)c98f2cf2016-04-04 08:05:12 +00002053 .add_listener_create_layer = ivi_layout_add_listener_create_layer,
Ucan, Emre (ADITG/SW1)562f2ec2016-04-04 08:05:15 +00002054 .add_listener_remove_layer = ivi_layout_add_listener_remove_layer,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002055 .layer_create_with_dimension = ivi_layout_layer_create_with_dimension,
Nobuhiko Tanibata3aa8aed2015-06-22 15:32:23 +09002056 .layer_destroy = ivi_layout_layer_destroy,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002057 .get_layers = ivi_layout_get_layers,
2058 .get_id_of_layer = ivi_layout_get_id_of_layer,
2059 .get_layer_from_id = ivi_layout_get_layer_from_id,
2060 .get_properties_of_layer = ivi_layout_get_properties_of_layer,
2061 .get_layers_under_surface = ivi_layout_get_layers_under_surface,
2062 .get_layers_on_screen = ivi_layout_get_layers_on_screen,
2063 .layer_set_visibility = ivi_layout_layer_set_visibility,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002064 .layer_set_opacity = ivi_layout_layer_set_opacity,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002065 .layer_set_source_rectangle = ivi_layout_layer_set_source_rectangle,
2066 .layer_set_destination_rectangle = ivi_layout_layer_set_destination_rectangle,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002067 .layer_set_orientation = ivi_layout_layer_set_orientation,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002068 .layer_add_surface = ivi_layout_layer_add_surface,
2069 .layer_remove_surface = ivi_layout_layer_remove_surface,
2070 .layer_set_render_order = ivi_layout_layer_set_render_order,
Ucan, Emre (ADITG/SW1)3750d1b2016-04-04 08:05:05 +00002071 .layer_add_listener = ivi_layout_layer_add_listener,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002072 .layer_set_transition = ivi_layout_layer_set_transition,
2073
2074 /**
Ucan, Emre (ADITG/SW1)6d89b1c2016-03-17 15:30:49 +00002075 * screen controller interfaces
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002076 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002077 .get_screens_under_layer = ivi_layout_get_screens_under_layer,
2078 .screen_add_layer = ivi_layout_screen_add_layer,
2079 .screen_set_render_order = ivi_layout_screen_set_render_order,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002080
2081 /**
2082 * animation
2083 */
2084 .transition_move_layer_cancel = ivi_layout_transition_move_layer_cancel,
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09002085 .layer_set_fade_info = ivi_layout_layer_set_fade_info,
2086
2087 /**
2088 * surface content dumping for debugging
2089 */
2090 .surface_get_size = ivi_layout_surface_get_size,
2091 .surface_dump = ivi_layout_surface_dump,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002092};
2093
2094int
2095load_controller_modules(struct weston_compositor *compositor, const char *modules,
2096 int *argc, char *argv[])
2097{
2098 const char *p, *end;
2099 char buffer[256];
2100 int (*controller_module_init)(struct weston_compositor *compositor,
2101 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002102 const struct ivi_layout_interface *interface,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002103 size_t interface_version);
2104
2105 if (modules == NULL)
2106 return 0;
2107
2108 p = modules;
2109 while (*p) {
2110 end = strchrnul(p, ',');
2111 snprintf(buffer, sizeof buffer, "%.*s", (int)(end - p), p);
2112
Quentin Glidic8af2bec2016-12-02 14:21:46 +01002113 controller_module_init =
2114 wet_load_module_entrypoint(buffer,
2115 "controller_module_init");
Pekka Paalanen97246c02015-03-26 15:47:29 +02002116 if (!controller_module_init)
2117 return -1;
2118
2119 if (controller_module_init(compositor, argc, argv,
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002120 &ivi_layout_interface,
2121 sizeof(struct ivi_layout_interface)) != 0) {
Pekka Paalanen97246c02015-03-26 15:47:29 +02002122 weston_log("ivi-shell: Initialization of controller module fails");
2123 return -1;
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002124 }
2125
2126 p = end;
2127 while (*p == ',')
2128 p++;
2129 }
2130
2131 return 0;
2132}