blob: 013e096890e18ae9246d4c898b611df570d3cee7 [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
28 * not updated till calling ivi_layout_commit_changes. A overview from
29 * 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.
33 * 1/ When a API for updating properties of ivi_surface/ivi_layer, it updates
34 * pending prop of ivi_surface/ivi_layer/ivi_screen which are structure to
35 * store properties.
36 * 2/ Before calling commitChanges, in case of calling a API to get a property,
37 * 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.
45 * For example, when a property of ivi_surface is changed from invisibility
46 * to visibility, it behaves like fade-in. When ivi_layout_commitChange is
47 * called during transition animation, it cancels the transition and
48 * re-start transition to new properties from current properties of final
49 * frame just before the the cancellation.
50 *
51 * 4/ According properties, set transformation by using weston_matrix and
52 * weston_view per ivi_surfaces and ivi_layers in while loop.
53 * 5/ Set damage and trigger transform by using weston_view_geometry_dirty.
54 * 6/ Notify update of properties.
55 * 7/ Trigger composition by weston_compositor_schedule_repaint.
56 *
57 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +090058#include "config.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090059
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090060#include <string.h>
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +000061#include <assert.h>
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090062
63#include "compositor.h"
Pekka Paalanen1f821932016-03-15 16:57:51 +020064#include "ivi-shell.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090065#include "ivi-layout-export.h"
66#include "ivi-layout-private.h"
Pekka Paalanen32ca7912016-03-15 17:21:00 +020067#include "ivi-layout-shell.h"
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090068
Jon Cruz867d50e2015-06-15 15:37:10 -070069#include "shared/helpers.h"
Jon Cruz4678bab2015-06-15 15:37:07 -070070#include "shared/os-compatibility.h"
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +090071
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +090072#define max(a, b) ((a) > (b) ? (a) : (b))
73
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090074struct listener_layout_notification {
75 void *userdata;
76 struct wl_listener listener;
77};
78
79struct ivi_layout;
80
81struct ivi_layout_screen {
82 struct wl_list link;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090083
84 struct ivi_layout *layout;
85 struct weston_output *output;
86
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090087 struct {
88 struct wl_list layer_list;
89 struct wl_list link;
90 } pending;
91
92 struct {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +000093 int dirty;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090094 struct wl_list layer_list;
95 struct wl_list link;
96 } order;
97};
98
99struct ivi_layout_notification_callback {
100 void *callback;
101 void *data;
102};
103
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900104struct ivi_rectangle
105{
106 int32_t x;
107 int32_t y;
108 int32_t width;
109 int32_t height;
110};
111
Nobuhiko Tanibata82051702015-06-22 15:31:26 +0900112static void
113remove_notification(struct wl_list *listener_list, void *callback, void *userdata);
114
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900115static struct ivi_layout ivilayout = {0};
116
117struct ivi_layout *
118get_instance(void)
119{
120 return &ivilayout;
121}
122
123/**
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900124 * Internal API to add/remove a ivi_layer to/from ivi_screen.
125 */
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900126static struct ivi_layout_surface *
127get_surface(struct wl_list *surf_list, uint32_t id_surface)
128{
129 struct ivi_layout_surface *ivisurf;
130
131 wl_list_for_each(ivisurf, surf_list, link) {
132 if (ivisurf->id_surface == id_surface) {
133 return ivisurf;
134 }
135 }
136
137 return NULL;
138}
139
140static struct ivi_layout_layer *
141get_layer(struct wl_list *layer_list, uint32_t id_layer)
142{
143 struct ivi_layout_layer *ivilayer;
144
145 wl_list_for_each(ivilayer, layer_list, link) {
146 if (ivilayer->id_layer == id_layer) {
147 return ivilayer;
148 }
149 }
150
151 return NULL;
152}
153
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000154static struct weston_view *
155get_weston_view(struct ivi_layout_surface *ivisurf)
156{
157 struct weston_view *view = NULL;
158
159 assert(ivisurf->surface != NULL);
160
161 /* One view per surface */
162 if(wl_list_empty(&ivisurf->surface->views))
163 view = NULL;
164 else
165 view = wl_container_of(ivisurf->surface->views.next, view, surface_link);
166
167 return view;
168}
169
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +0000170static struct ivi_layout_screen *
171get_screen_from_output(struct weston_output *output)
172{
173 struct ivi_layout *layout = get_instance();
174 struct ivi_layout_screen *iviscrn = NULL;
175
176 wl_list_for_each(iviscrn, &layout->screen_list, link) {
177 if (iviscrn->output == output)
178 return iviscrn;
179 }
180
181 return NULL;
182}
183
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900184static void
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900185remove_all_notification(struct wl_list *listener_list)
186{
187 struct wl_listener *listener = NULL;
188 struct wl_listener *next = NULL;
189
190 wl_list_for_each_safe(listener, next, listener_list, link) {
191 struct listener_layout_notification *notification = NULL;
Ucan, Emre (ADITG/SW1)cf34dc22015-08-20 14:13:33 +0000192 wl_list_remove(&listener->link);
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900193
194 notification =
195 container_of(listener,
196 struct listener_layout_notification,
197 listener);
198
199 free(notification->userdata);
200 free(notification);
201 }
202}
203
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900204/**
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900205 * Called at destruction of wl_surface/ivi_surface
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900206 */
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900207void
208ivi_layout_surface_destroy(struct ivi_layout_surface *ivisurf)
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900209{
210 struct ivi_layout *layout = get_instance();
211
212 if (ivisurf == NULL) {
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900213 weston_log("%s: invalid argument\n", __func__);
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900214 return;
215 }
216
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900217 wl_list_remove(&ivisurf->transform.link);
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900218 wl_list_remove(&ivisurf->pending.link);
219 wl_list_remove(&ivisurf->order.link);
220 wl_list_remove(&ivisurf->link);
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900221
222 wl_signal_emit(&layout->surface_notification.removed, ivisurf);
223
Mateusz Polroladada6e32016-03-09 09:13:26 +0000224 ivi_layout_remove_all_surface_transitions(ivisurf);
225
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900226 free(ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900227}
228
229/**
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900230 * Internal API to initialize ivi_screens found from output_list of weston_compositor.
231 * Called by ivi_layout_init_with_compositor.
232 */
233static void
234create_screen(struct weston_compositor *ec)
235{
236 struct ivi_layout *layout = get_instance();
237 struct ivi_layout_screen *iviscrn = NULL;
238 struct weston_output *output = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900239
240 wl_list_for_each(output, &ec->output_list, link) {
241 iviscrn = calloc(1, sizeof *iviscrn);
242 if (iviscrn == NULL) {
243 weston_log("fails to allocate memory\n");
244 continue;
245 }
246
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900247 iviscrn->layout = layout;
248
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900249 iviscrn->output = output;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900250
251 wl_list_init(&iviscrn->pending.layer_list);
252 wl_list_init(&iviscrn->pending.link);
253
254 wl_list_init(&iviscrn->order.layer_list);
255 wl_list_init(&iviscrn->order.link);
256
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900257 wl_list_insert(&layout->screen_list, &iviscrn->link);
258 }
259}
260
261/**
262 * Internal APIs to initialize properties of ivi_surface/ivi_layer when they are created.
263 */
264static void
265init_layer_properties(struct ivi_layout_layer_properties *prop,
266 int32_t width, int32_t height)
267{
268 memset(prop, 0, sizeof *prop);
269 prop->opacity = wl_fixed_from_double(1.0);
270 prop->source_width = width;
271 prop->source_height = height;
272 prop->dest_width = width;
273 prop->dest_height = height;
274}
275
276static void
277init_surface_properties(struct ivi_layout_surface_properties *prop)
278{
279 memset(prop, 0, sizeof *prop);
280 prop->opacity = wl_fixed_from_double(1.0);
Nobuhiko Tanibatae259a7a2015-04-27 17:02:54 +0900281 /*
282 * FIXME: this shall be finxed by ivi-layout-transition.
283 */
284 prop->dest_width = 1;
285 prop->dest_height = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900286}
287
288/**
289 * Internal APIs to be called from ivi_layout_commit_changes.
290 */
291static void
292update_opacity(struct ivi_layout_layer *ivilayer,
293 struct ivi_layout_surface *ivisurf)
294{
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000295 struct weston_view *tmpview = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900296 double layer_alpha = wl_fixed_to_double(ivilayer->prop.opacity);
297 double surf_alpha = wl_fixed_to_double(ivisurf->prop.opacity);
298
Nobuhiko Tanibata90c27892015-12-26 23:52:51 +0900299 tmpview = get_weston_view(ivisurf);
300 assert(tmpview != NULL);
301 tmpview->alpha = layer_alpha * surf_alpha;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900302}
303
304static void
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900305get_rotate_values(enum wl_output_transform orientation,
306 float *v_sin,
307 float *v_cos)
308{
309 switch (orientation) {
310 case WL_OUTPUT_TRANSFORM_90:
311 *v_sin = 1.0f;
312 *v_cos = 0.0f;
313 break;
314 case WL_OUTPUT_TRANSFORM_180:
315 *v_sin = 0.0f;
316 *v_cos = -1.0f;
317 break;
318 case WL_OUTPUT_TRANSFORM_270:
319 *v_sin = -1.0f;
320 *v_cos = 0.0f;
321 break;
322 case WL_OUTPUT_TRANSFORM_NORMAL:
323 default:
324 *v_sin = 0.0f;
325 *v_cos = 1.0f;
326 break;
327 }
328}
329
330static void
331get_scale(enum wl_output_transform orientation,
332 float dest_width,
333 float dest_height,
334 float source_width,
335 float source_height,
336 float *scale_x,
337 float *scale_y)
338{
339 switch (orientation) {
340 case WL_OUTPUT_TRANSFORM_90:
341 *scale_x = dest_width / source_height;
342 *scale_y = dest_height / source_width;
343 break;
344 case WL_OUTPUT_TRANSFORM_180:
345 *scale_x = dest_width / source_width;
346 *scale_y = dest_height / source_height;
347 break;
348 case WL_OUTPUT_TRANSFORM_270:
349 *scale_x = dest_width / source_height;
350 *scale_y = dest_height / source_width;
351 break;
352 case WL_OUTPUT_TRANSFORM_NORMAL:
353 default:
354 *scale_x = dest_width / source_width;
355 *scale_y = dest_height / source_height;
356 break;
357 }
358}
359
360static void
361calc_transformation_matrix(struct ivi_rectangle *source_rect,
362 struct ivi_rectangle *dest_rect,
363 enum wl_output_transform orientation,
364 struct weston_matrix *m)
365{
366 float source_center_x;
367 float source_center_y;
368 float vsin;
369 float vcos;
370 float scale_x;
371 float scale_y;
372 float translate_x;
373 float translate_y;
374
375 source_center_x = source_rect->x + source_rect->width * 0.5f;
376 source_center_y = source_rect->y + source_rect->height * 0.5f;
377 weston_matrix_translate(m, -source_center_x, -source_center_y, 0.0f);
378
379 get_rotate_values(orientation, &vsin, &vcos);
380 weston_matrix_rotate_xy(m, vcos, vsin);
381
382 get_scale(orientation,
383 dest_rect->width,
384 dest_rect->height,
385 source_rect->width,
386 source_rect->height,
387 &scale_x,
388 &scale_y);
389 weston_matrix_scale(m, scale_x, scale_y, 1.0f);
390
391 translate_x = dest_rect->width * 0.5f + dest_rect->x;
392 translate_y = dest_rect->height * 0.5f + dest_rect->y;
393 weston_matrix_translate(m, translate_x, translate_y, 0.0f);
394}
395
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900396/*
397 * This computes intersected rect_output from two ivi_rectangles
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900398 */
399static void
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900400ivi_rectangle_intersect(const struct ivi_rectangle *rect1,
401 const struct ivi_rectangle *rect2,
402 struct ivi_rectangle *rect_output)
403{
404 int32_t rect1_right = rect1->x + rect1->width;
405 int32_t rect1_bottom = rect1->y + rect1->height;
406 int32_t rect2_right = rect2->x + rect2->width;
407 int32_t rect2_bottom = rect2->y + rect2->height;
408
409 rect_output->x = max(rect1->x, rect2->x);
410 rect_output->y = max(rect1->y, rect2->y);
411 rect_output->width = rect1_right < rect2_right ?
412 rect1_right - rect_output->x :
413 rect2_right - rect_output->x;
414 rect_output->height = rect1_bottom < rect2_bottom ?
415 rect1_bottom - rect_output->y :
416 rect2_bottom - rect_output->y;
417
418 if (rect_output->width < 0 || rect_output->height < 0) {
419 rect_output->width = 0;
420 rect_output->height = 0;
421 }
422}
423
424/*
425 * Transform rect_input by the inverse of matrix, intersect with boundingbox,
426 * and store the result in rect_output.
427 * The boundingbox must be given in the same coordinate space as rect_output.
428 * Additionally, there are the following restrictions on the matrix:
429 * - no projective transformations
430 * - no skew
431 * - only multiples of 90-degree rotations supported
432 *
433 * In failure case of weston_matrix_invert, rect_output is set to boundingbox
434 * as a fail-safe with log.
435 */
436static void
437calc_inverse_matrix_transform(const struct weston_matrix *matrix,
438 const struct ivi_rectangle *rect_input,
439 const struct ivi_rectangle *boundingbox,
440 struct ivi_rectangle *rect_output)
441{
442 struct weston_matrix m;
443 struct weston_vector top_left;
444 struct weston_vector bottom_right;
445
446 assert(boundingbox != rect_output);
447
448 if (weston_matrix_invert(&m, matrix) < 0) {
449 weston_log("ivi-shell: calc_inverse_matrix_transform fails to invert a matrix.\n");
450 weston_log("ivi-shell: boundingbox is set to the rect_output.\n");
451 rect_output->x = boundingbox->x;
452 rect_output->y = boundingbox->y;
453 rect_output->width = boundingbox->width;
454 rect_output->height = boundingbox->height;
455 }
456
457 /* The vectors and matrices involved will always produce f[3] == 1.0. */
458 top_left.f[0] = rect_input->x;
459 top_left.f[1] = rect_input->y;
460 top_left.f[2] = 0.0f;
461 top_left.f[3] = 1.0f;
462
463 bottom_right.f[0] = rect_input->x + rect_input->width;
464 bottom_right.f[1] = rect_input->y + rect_input->height;
465 bottom_right.f[2] = 0.0f;
466 bottom_right.f[3] = 1.0f;
467
468 weston_matrix_transform(&m, &top_left);
469 weston_matrix_transform(&m, &bottom_right);
470
471 if (top_left.f[0] < bottom_right.f[0]) {
472 rect_output->x = top_left.f[0];
473 rect_output->width = bottom_right.f[0] - rect_output->x;
474 } else {
475 rect_output->x = bottom_right.f[0];
476 rect_output->width = top_left.f[0] - rect_output->x;
477 }
478
479 if (top_left.f[1] < bottom_right.f[1]) {
480 rect_output->y = top_left.f[1];
481 rect_output->height = bottom_right.f[1] - rect_output->y;
482 } else {
483 rect_output->y = bottom_right.f[1];
484 rect_output->height = top_left.f[1] - rect_output->y;
485 }
486
487 ivi_rectangle_intersect(rect_output, boundingbox, rect_output);
488}
489
490/**
491 * This computes the whole transformation matrix:m from surface-local
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900492 * coordinates to multi screens coordinate, which is global coordinates.
493 * It is assumed that weston_view::geometry.{x,y} are zero.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900494 *
495 * Additionally, this computes the mask on surface-local coordinates as a
496 * ivi_rectangle. This can be set to weston_view_set_mask.
497 *
498 * The mask is computed by following steps
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900499 * - destination rectangle of layer is tansformed to multi screen coordinate,
500 * global coordinates. This is done by adding weston_output.{x,y} in simple
501 * because there is no scaled and rotated transformation.
502 * - destination rectangle of layer in multi screens coordinate needs to be
503 * intersected inside of a screen the layer is assigned to. This is because
504 * overlapped region of weston surface in another screen shall not be
505 * displayed according to ivi use case.
506 * - destination rectangle of layer
507 * - in multi screen coordinates,
508 * - and intersected inside of an assigned screen,
509 * is inversed to surface-local cooodinates by inversed matrix:m.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900510 * - the area is intersected by intersected area between weston_surface and
511 * source rectangle of ivi_surface.
512 */
513static void
514calc_surface_to_global_matrix_and_mask_to_weston_surface(
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900515 struct ivi_layout_screen *iviscrn,
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900516 struct ivi_layout_layer *ivilayer,
517 struct ivi_layout_surface *ivisurf,
518 struct weston_matrix *m,
519 struct ivi_rectangle *result)
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900520{
521 const struct ivi_layout_surface_properties *sp = &ivisurf->prop;
522 const struct ivi_layout_layer_properties *lp = &ivilayer->prop;
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900523 struct weston_output *output = iviscrn->output;
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900524 struct ivi_rectangle weston_surface_rect = { 0,
525 0,
526 ivisurf->surface->width,
527 ivisurf->surface->height };
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900528 struct ivi_rectangle surface_source_rect = { sp->source_x,
529 sp->source_y,
530 sp->source_width,
531 sp->source_height };
532 struct ivi_rectangle surface_dest_rect = { sp->dest_x,
533 sp->dest_y,
534 sp->dest_width,
535 sp->dest_height };
536 struct ivi_rectangle layer_source_rect = { lp->source_x,
537 lp->source_y,
538 lp->source_width,
539 lp->source_height };
540 struct ivi_rectangle layer_dest_rect = { lp->dest_x,
541 lp->dest_y,
542 lp->dest_width,
543 lp->dest_height };
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900544 struct ivi_rectangle screen_dest_rect = { output->x,
545 output->y,
546 output->width,
547 output->height };
548 struct ivi_rectangle layer_dest_rect_in_global =
549 { lp->dest_x + output->x,
550 lp->dest_y + output->y,
551 lp->dest_width,
552 lp->dest_height };
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900553 struct ivi_rectangle surface_result;
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900554 struct ivi_rectangle layer_dest_rect_in_global_intersected;
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900555
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900556 /*
557 * the whole transformation matrix:m from surface-local
558 * coordinates to global coordinates, which is computed by
559 * two steps,
560 * - surface-local coordinates to layer-local coordinates
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900561 * - layer-local coordinates to a single screen-local coordinates
562 * - a single screen-local coordinates to multi screen coordinates,
563 * which is global coordinates.
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900564 */
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900565 calc_transformation_matrix(&surface_source_rect,
566 &surface_dest_rect,
567 sp->orientation, m);
568
569 calc_transformation_matrix(&layer_source_rect,
570 &layer_dest_rect,
571 lp->orientation, m);
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900572
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900573 weston_matrix_translate(m, output->x, output->y, 0.0f);
574
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900575 /* this intersected ivi_rectangle would be used for masking
576 * weston_surface
577 */
578 ivi_rectangle_intersect(&surface_source_rect, &weston_surface_rect,
579 &surface_result);
580
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900581 /*
582 * destination rectangle of layer in multi screens coordinate
583 * is intersected to avoid displaying outside of an assigned screen.
584 */
585 ivi_rectangle_intersect(&layer_dest_rect_in_global, &screen_dest_rect,
586 &layer_dest_rect_in_global_intersected);
587
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900588 /* calc masking area of weston_surface from m */
589 calc_inverse_matrix_transform(m,
Nobuhiko Tanibata1c2618e2015-12-09 15:39:26 +0900590 &layer_dest_rect_in_global_intersected,
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900591 &surface_result,
592 result);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900593}
594
595static void
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900596update_prop(struct ivi_layout_screen *iviscrn,
597 struct ivi_layout_layer *ivilayer,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900598 struct ivi_layout_surface *ivisurf)
599{
Nobuhiko Tanibata4c1dbf72015-07-15 13:55:50 +0900600 struct weston_view *tmpview;
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900601 struct ivi_rectangle r;
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900602 bool can_calc = true;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900603
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900604 /*In case of no prop change, this just returns*/
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000605 if (!ivilayer->prop.event_mask && !ivisurf->prop.event_mask)
Nobuhiko Tanibata4c1dbf72015-07-15 13:55:50 +0900606 return;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900607
Nobuhiko Tanibata4c1dbf72015-07-15 13:55:50 +0900608 update_opacity(ivilayer, ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900609
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000610 tmpview = get_weston_view(ivisurf);
611 assert(tmpview != NULL);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900612
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900613 if (ivisurf->prop.source_width == 0 || ivisurf->prop.source_height == 0) {
614 weston_log("ivi-shell: source rectangle is not yet set by ivi_layout_surface_set_source_rectangle\n");
615 can_calc = false;
616 }
617
618 if (ivisurf->prop.dest_width == 0 || ivisurf->prop.dest_height == 0) {
619 weston_log("ivi-shell: destination rectangle is not yet set by ivi_layout_surface_set_destination_rectangle\n");
620 can_calc = false;
621 }
622
623 if (can_calc) {
624 wl_list_remove(&ivisurf->transform.link);
625 weston_matrix_init(&ivisurf->transform.matrix);
626
Nobuhiko Tanibataacbcc6c2015-08-24 10:24:15 +0900627 calc_surface_to_global_matrix_and_mask_to_weston_surface(
Nobuhiko Tanibata29babdf2015-12-09 15:38:41 +0900628 iviscrn, ivilayer, ivisurf, &ivisurf->transform.matrix, &r);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900629
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000630 weston_view_set_mask(tmpview, r.x, r.y, r.width, r.height);
631 wl_list_insert(&tmpview->geometry.transformation_list,
632 &ivisurf->transform.link);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900633
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000634 weston_view_set_transform_parent(tmpview, NULL);
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +0900635 }
636
637 ivisurf->update_count++;
638
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000639 weston_view_geometry_dirty(tmpview);
Nobuhiko Tanibata4c1dbf72015-07-15 13:55:50 +0900640
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000641 weston_surface_damage(ivisurf->surface);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900642}
643
644static void
645commit_changes(struct ivi_layout *layout)
646{
647 struct ivi_layout_screen *iviscrn = NULL;
648 struct ivi_layout_layer *ivilayer = NULL;
649 struct ivi_layout_surface *ivisurf = NULL;
650
651 wl_list_for_each(iviscrn, &layout->screen_list, link) {
652 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900653 /*
654 * If ivilayer is invisible, weston_view of ivisurf doesn't
655 * need to be modified.
656 */
657 if (ivilayer->prop.visibility == false)
658 continue;
659
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900660 wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) {
Nobuhiko Tanibatab4cb25d2015-12-09 15:36:58 +0900661 /*
662 * If ivilayer is invisible, weston_view of ivisurf doesn't
663 * need to be modified.
664 */
665 if (ivisurf->prop.visibility == false)
666 continue;
667
668 update_prop(iviscrn, ivilayer, ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900669 }
670 }
671 }
672}
673
674static void
675commit_surface_list(struct ivi_layout *layout)
676{
677 struct ivi_layout_surface *ivisurf = NULL;
678 int32_t dest_x = 0;
679 int32_t dest_y = 0;
680 int32_t dest_width = 0;
681 int32_t dest_height = 0;
682 int32_t configured = 0;
683
684 wl_list_for_each(ivisurf, &layout->surface_list, link) {
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300685 if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEFAULT) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900686 dest_x = ivisurf->prop.dest_x;
687 dest_y = ivisurf->prop.dest_y;
688 dest_width = ivisurf->prop.dest_width;
689 dest_height = ivisurf->prop.dest_height;
690
691 ivi_layout_transition_move_resize_view(ivisurf,
692 ivisurf->pending.prop.dest_x,
693 ivisurf->pending.prop.dest_y,
694 ivisurf->pending.prop.dest_width,
695 ivisurf->pending.prop.dest_height,
696 ivisurf->pending.prop.transition_duration);
697
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300698 if (ivisurf->pending.prop.visibility) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900699 ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration);
700 } else {
701 ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration);
702 }
703
704 ivisurf->prop = ivisurf->pending.prop;
705 ivisurf->prop.dest_x = dest_x;
706 ivisurf->prop.dest_y = dest_y;
707 ivisurf->prop.dest_width = dest_width;
708 ivisurf->prop.dest_height = dest_height;
709 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
710 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
711
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300712 } else if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEST_RECT_ONLY) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900713 dest_x = ivisurf->prop.dest_x;
714 dest_y = ivisurf->prop.dest_y;
715 dest_width = ivisurf->prop.dest_width;
716 dest_height = ivisurf->prop.dest_height;
717
718 ivi_layout_transition_move_resize_view(ivisurf,
719 ivisurf->pending.prop.dest_x,
720 ivisurf->pending.prop.dest_y,
721 ivisurf->pending.prop.dest_width,
722 ivisurf->pending.prop.dest_height,
723 ivisurf->pending.prop.transition_duration);
724
725 ivisurf->prop = ivisurf->pending.prop;
726 ivisurf->prop.dest_x = dest_x;
727 ivisurf->prop.dest_y = dest_y;
728 ivisurf->prop.dest_width = dest_width;
729 ivisurf->prop.dest_height = dest_height;
730
731 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
732 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
733
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300734 } else if (ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900735 configured = 0;
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300736 if (ivisurf->pending.prop.visibility) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900737 ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration);
738 } else {
739 ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration);
740 }
741
742 if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width ||
743 ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) {
744 configured = 1;
745 }
746
747 ivisurf->prop = ivisurf->pending.prop;
748 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
749 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
750
Pekka Paalanen1f821932016-03-15 16:57:51 +0200751 if (configured && !is_surface_transition(ivisurf)) {
Pekka Paalanen1f821932016-03-15 16:57:51 +0200752 shell_surface_send_configure(ivisurf->surface,
753 ivisurf->prop.dest_width,
754 ivisurf->prop.dest_height);
755 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900756 } else {
757 configured = 0;
758 if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width ||
759 ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) {
760 configured = 1;
761 }
762
763 ivisurf->prop = ivisurf->pending.prop;
764 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
765 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
766
Pekka Paalanen1f821932016-03-15 16:57:51 +0200767 if (configured && !is_surface_transition(ivisurf)) {
Pekka Paalanen1f821932016-03-15 16:57:51 +0200768 shell_surface_send_configure(ivisurf->surface,
769 ivisurf->prop.dest_width,
770 ivisurf->prop.dest_height);
771 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900772 }
773 }
774}
775
776static void
777commit_layer_list(struct ivi_layout *layout)
778{
779 struct ivi_layout_layer *ivilayer = NULL;
780 struct ivi_layout_surface *ivisurf = NULL;
781 struct ivi_layout_surface *next = NULL;
782
783 wl_list_for_each(ivilayer, &layout->layer_list, link) {
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300784 if (ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_MOVE) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900785 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 -0300786 } else if (ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_FADE) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900787 ivi_layout_transition_fade_layer(ivilayer,ivilayer->pending.prop.is_fade_in,
788 ivilayer->pending.prop.start_alpha,ivilayer->pending.prop.end_alpha,
789 NULL, NULL,
790 ivilayer->pending.prop.transition_duration);
791 }
792 ivilayer->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
793
794 ivilayer->prop = ivilayer->pending.prop;
795
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +0000796 if (!ivilayer->order.dirty) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900797 continue;
798 }
799
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +0000800 wl_list_for_each_safe(ivisurf, next, &ivilayer->order.surface_list,
801 order.link) {
Ucan, Emre (ADITG/SW1)dfac3752015-08-28 12:58:58 +0000802 ivisurf->on_layer = NULL;
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +0000803 wl_list_remove(&ivisurf->order.link);
804 wl_list_init(&ivisurf->order.link);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000805 ivisurf->prop.event_mask |= IVI_NOTIFICATION_REMOVE;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900806 }
807
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +0000808 assert(wl_list_empty(&ivilayer->order.surface_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900809
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +0000810 wl_list_for_each(ivisurf, &ivilayer->pending.surface_list,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900811 pending.link) {
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +0000812 wl_list_remove(&ivisurf->order.link);
813 wl_list_insert(&ivilayer->order.surface_list,
814 &ivisurf->order.link);
Ucan, Emre (ADITG/SW1)dfac3752015-08-28 12:58:58 +0000815 ivisurf->on_layer = ivilayer;
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000816 ivisurf->prop.event_mask |= IVI_NOTIFICATION_ADD;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900817 }
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +0000818
819 ivilayer->order.dirty = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900820 }
821}
822
823static void
824commit_screen_list(struct ivi_layout *layout)
825{
826 struct ivi_layout_screen *iviscrn = NULL;
827 struct ivi_layout_layer *ivilayer = NULL;
828 struct ivi_layout_layer *next = NULL;
829 struct ivi_layout_surface *ivisurf = NULL;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000830 struct weston_view *tmpview = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900831
Nobuhiko Tanibatafbfa8f22015-11-25 23:36:57 +0900832 /* Clear view list of layout ivi_layer */
833 wl_list_init(&layout->layout_layer.view_list.link);
834
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900835 wl_list_for_each(iviscrn, &layout->screen_list, link) {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000836 if (iviscrn->order.dirty) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900837 wl_list_for_each_safe(ivilayer, next,
838 &iviscrn->order.layer_list, order.link) {
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +0000839 ivilayer->on_screen = NULL;
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000840 wl_list_remove(&ivilayer->order.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900841 wl_list_init(&ivilayer->order.link);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000842 ivilayer->prop.event_mask |= IVI_NOTIFICATION_REMOVE;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900843 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900844
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +0000845 assert(wl_list_empty(&iviscrn->order.layer_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900846
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900847 wl_list_for_each(ivilayer, &iviscrn->pending.layer_list,
848 pending.link) {
Nobuhiko Tanibata77b0ee12015-11-25 23:36:46 +0900849 /* FIXME: avoid to insert order.link to multiple screens */
850 wl_list_remove(&ivilayer->order.link);
851
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900852 wl_list_insert(&iviscrn->order.layer_list,
853 &ivilayer->order.link);
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +0000854 ivilayer->on_screen = iviscrn;
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000855 ivilayer->prop.event_mask |= IVI_NOTIFICATION_ADD;
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 iviscrn->order.dirty = 0;
859 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900860
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900861 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
862 if (ivilayer->prop.visibility == false)
863 continue;
864
865 wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900866 if (ivisurf->prop.visibility == false)
867 continue;
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +0000868
869 tmpview = get_weston_view(ivisurf);
870 assert(tmpview != NULL);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900871
872 weston_layer_entry_insert(&layout->layout_layer.view_list,
873 &tmpview->layer_link);
874
875 ivisurf->surface->output = iviscrn->output;
876 }
877 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900878 }
879}
880
881static void
882commit_transition(struct ivi_layout* layout)
883{
Dawid Gajownik74a635b2015-08-06 17:12:19 -0300884 if (wl_list_empty(&layout->pending_transition_list)) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900885 return;
886 }
887
888 wl_list_insert_list(&layout->transitions->transition_list,
889 &layout->pending_transition_list);
890
891 wl_list_init(&layout->pending_transition_list);
892
893 wl_event_source_timer_update(layout->transitions->event_source, 1);
894}
895
896static void
897send_surface_prop(struct ivi_layout_surface *ivisurf)
898{
899 wl_signal_emit(&ivisurf->property_changed, ivisurf);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000900 ivisurf->pending.prop.event_mask = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900901}
902
903static void
904send_layer_prop(struct ivi_layout_layer *ivilayer)
905{
906 wl_signal_emit(&ivilayer->property_changed, ivilayer);
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000907 ivilayer->pending.prop.event_mask = 0;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900908}
909
910static void
911send_prop(struct ivi_layout *layout)
912{
913 struct ivi_layout_layer *ivilayer = NULL;
914 struct ivi_layout_surface *ivisurf = NULL;
915
916 wl_list_for_each_reverse(ivilayer, &layout->layer_list, link) {
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000917 if (ivilayer->prop.event_mask)
Nobuhiko Tanibata6ce3ef82015-06-22 15:32:06 +0900918 send_layer_prop(ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900919 }
920
921 wl_list_for_each_reverse(ivisurf, &layout->surface_list, link) {
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +0000922 if (ivisurf->prop.event_mask)
Nobuhiko Tanibata6ce3ef82015-06-22 15:32:06 +0900923 send_surface_prop(ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900924 }
925}
926
927static void
928clear_surface_pending_list(struct ivi_layout_layer *ivilayer)
929{
930 struct ivi_layout_surface *surface_link = NULL;
931 struct ivi_layout_surface *surface_next = NULL;
932
933 wl_list_for_each_safe(surface_link, surface_next,
934 &ivilayer->pending.surface_list, pending.link) {
Ucan, Emre (ADITG/SW1)cf34dc22015-08-20 14:13:33 +0000935 wl_list_remove(&surface_link->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900936 wl_list_init(&surface_link->pending.link);
937 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900938}
939
940static void
941clear_surface_order_list(struct ivi_layout_layer *ivilayer)
942{
943 struct ivi_layout_surface *surface_link = NULL;
944 struct ivi_layout_surface *surface_next = NULL;
945
946 wl_list_for_each_safe(surface_link, surface_next,
947 &ivilayer->order.surface_list, order.link) {
Ucan, Emre (ADITG/SW1)cf34dc22015-08-20 14:13:33 +0000948 wl_list_remove(&surface_link->order.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900949 wl_list_init(&surface_link->order.link);
950 }
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900951}
952
953static void
954layer_created(struct wl_listener *listener, void *data)
955{
956 struct ivi_layout_layer *ivilayer = data;
957
958 struct listener_layout_notification *notification =
959 container_of(listener,
960 struct listener_layout_notification,
961 listener);
962
963 struct ivi_layout_notification_callback *created_callback =
964 notification->userdata;
965
966 ((layer_create_notification_func)created_callback->callback)
967 (ivilayer, created_callback->data);
968}
969
970static void
971layer_removed(struct wl_listener *listener, void *data)
972{
973 struct ivi_layout_layer *ivilayer = data;
974
975 struct listener_layout_notification *notification =
976 container_of(listener,
977 struct listener_layout_notification,
978 listener);
979
980 struct ivi_layout_notification_callback *removed_callback =
981 notification->userdata;
982
983 ((layer_remove_notification_func)removed_callback->callback)
984 (ivilayer, removed_callback->data);
985}
986
987static void
988layer_prop_changed(struct wl_listener *listener, void *data)
989{
990 struct ivi_layout_layer *ivilayer = data;
991
992 struct listener_layout_notification *layout_listener =
993 container_of(listener,
994 struct listener_layout_notification,
995 listener);
996
997 struct ivi_layout_notification_callback *prop_callback =
998 layout_listener->userdata;
999
1000 ((layer_property_notification_func)prop_callback->callback)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001001 (ivilayer, &ivilayer->prop, ivilayer->prop.event_mask, prop_callback->data);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001002}
1003
1004static void
1005surface_created(struct wl_listener *listener, void *data)
1006{
1007 struct ivi_layout_surface *ivisurface = data;
1008
1009 struct listener_layout_notification *notification =
1010 container_of(listener,
1011 struct listener_layout_notification,
1012 listener);
1013
1014 struct ivi_layout_notification_callback *created_callback =
1015 notification->userdata;
1016
1017 ((surface_create_notification_func)created_callback->callback)
1018 (ivisurface, created_callback->data);
1019}
1020
1021static void
1022surface_removed(struct wl_listener *listener, void *data)
1023{
1024 struct ivi_layout_surface *ivisurface = data;
1025
1026 struct listener_layout_notification *notification =
1027 container_of(listener,
1028 struct listener_layout_notification,
1029 listener);
1030
1031 struct ivi_layout_notification_callback *removed_callback =
1032 notification->userdata;
1033
1034 ((surface_remove_notification_func)removed_callback->callback)
1035 (ivisurface, removed_callback->data);
1036}
1037
1038static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001039surface_configure_changed(struct wl_listener *listener,
1040 void *data)
1041{
1042 struct ivi_layout_surface *ivisurface = data;
1043
1044 struct listener_layout_notification *notification =
1045 container_of(listener,
1046 struct listener_layout_notification,
1047 listener);
1048
1049 struct ivi_layout_notification_callback *configure_changed_callback =
1050 notification->userdata;
1051
1052 ((surface_configure_notification_func)configure_changed_callback->callback)
1053 (ivisurface, configure_changed_callback->data);
1054}
1055
1056static int32_t
1057add_notification(struct wl_signal *signal,
1058 wl_notify_func_t callback,
1059 void *userdata)
1060{
1061 struct listener_layout_notification *notification = NULL;
1062
1063 notification = malloc(sizeof *notification);
1064 if (notification == NULL) {
1065 weston_log("fails to allocate memory\n");
1066 free(userdata);
1067 return IVI_FAILED;
1068 }
1069
1070 notification->listener.notify = callback;
1071 notification->userdata = userdata;
1072
1073 wl_signal_add(signal, &notification->listener);
1074
1075 return IVI_SUCCEEDED;
1076}
1077
1078static void
1079remove_notification(struct wl_list *listener_list, void *callback, void *userdata)
1080{
1081 struct wl_listener *listener = NULL;
1082 struct wl_listener *next = NULL;
1083
1084 wl_list_for_each_safe(listener, next, listener_list, link) {
1085 struct listener_layout_notification *notification =
1086 container_of(listener,
1087 struct listener_layout_notification,
1088 listener);
1089
1090 struct ivi_layout_notification_callback *notification_callback =
1091 notification->userdata;
1092
1093 if ((notification_callback->callback != callback) ||
1094 (notification_callback->data != userdata)) {
1095 continue;
1096 }
1097
Ucan, Emre (ADITG/SW1)cf34dc22015-08-20 14:13:33 +00001098 wl_list_remove(&listener->link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001099
1100 free(notification->userdata);
1101 free(notification);
1102 }
1103}
1104
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001105/**
1106 * Exported APIs of ivi-layout library are implemented from here.
1107 * Brief of APIs is described in ivi-layout-export.h.
1108 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001109static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001110ivi_layout_add_notification_create_layer(layer_create_notification_func callback,
1111 void *userdata)
1112{
1113 struct ivi_layout *layout = get_instance();
1114 struct ivi_layout_notification_callback *created_callback = NULL;
1115
1116 if (callback == NULL) {
1117 weston_log("ivi_layout_add_notification_create_layer: invalid argument\n");
1118 return IVI_FAILED;
1119 }
1120
1121 created_callback = malloc(sizeof *created_callback);
1122 if (created_callback == NULL) {
1123 weston_log("fails to allocate memory\n");
1124 return IVI_FAILED;
1125 }
1126
1127 created_callback->callback = callback;
1128 created_callback->data = userdata;
1129
1130 return add_notification(&layout->layer_notification.created,
1131 layer_created,
1132 created_callback);
1133}
1134
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001135static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001136ivi_layout_remove_notification_create_layer(layer_create_notification_func callback,
1137 void *userdata)
1138{
1139 struct ivi_layout *layout = get_instance();
1140 remove_notification(&layout->layer_notification.created.listener_list, callback, userdata);
1141}
1142
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001143static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001144ivi_layout_add_notification_remove_layer(layer_remove_notification_func callback,
1145 void *userdata)
1146{
1147 struct ivi_layout *layout = get_instance();
1148 struct ivi_layout_notification_callback *removed_callback = NULL;
1149
1150 if (callback == NULL) {
1151 weston_log("ivi_layout_add_notification_remove_layer: invalid argument\n");
1152 return IVI_FAILED;
1153 }
1154
1155 removed_callback = malloc(sizeof *removed_callback);
1156 if (removed_callback == NULL) {
1157 weston_log("fails to allocate memory\n");
1158 return IVI_FAILED;
1159 }
1160
1161 removed_callback->callback = callback;
1162 removed_callback->data = userdata;
1163 return add_notification(&layout->layer_notification.removed,
1164 layer_removed,
1165 removed_callback);
1166}
1167
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001168static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001169ivi_layout_remove_notification_remove_layer(layer_remove_notification_func callback,
1170 void *userdata)
1171{
1172 struct ivi_layout *layout = get_instance();
1173 remove_notification(&layout->layer_notification.removed.listener_list, callback, userdata);
1174}
1175
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001176static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001177ivi_layout_add_notification_create_surface(surface_create_notification_func callback,
1178 void *userdata)
1179{
1180 struct ivi_layout *layout = get_instance();
1181 struct ivi_layout_notification_callback *created_callback = NULL;
1182
1183 if (callback == NULL) {
1184 weston_log("ivi_layout_add_notification_create_surface: invalid argument\n");
1185 return IVI_FAILED;
1186 }
1187
1188 created_callback = malloc(sizeof *created_callback);
1189 if (created_callback == NULL) {
1190 weston_log("fails to allocate memory\n");
1191 return IVI_FAILED;
1192 }
1193
1194 created_callback->callback = callback;
1195 created_callback->data = userdata;
1196
1197 return add_notification(&layout->surface_notification.created,
1198 surface_created,
1199 created_callback);
1200}
1201
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001202static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001203ivi_layout_remove_notification_create_surface(surface_create_notification_func callback,
1204 void *userdata)
1205{
1206 struct ivi_layout *layout = get_instance();
1207 remove_notification(&layout->surface_notification.created.listener_list, callback, userdata);
1208}
1209
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001210static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001211ivi_layout_add_notification_remove_surface(surface_remove_notification_func callback,
1212 void *userdata)
1213{
1214 struct ivi_layout *layout = get_instance();
1215 struct ivi_layout_notification_callback *removed_callback = NULL;
1216
1217 if (callback == NULL) {
1218 weston_log("ivi_layout_add_notification_remove_surface: invalid argument\n");
1219 return IVI_FAILED;
1220 }
1221
1222 removed_callback = malloc(sizeof *removed_callback);
1223 if (removed_callback == NULL) {
1224 weston_log("fails to allocate memory\n");
1225 return IVI_FAILED;
1226 }
1227
1228 removed_callback->callback = callback;
1229 removed_callback->data = userdata;
1230
1231 return add_notification(&layout->surface_notification.removed,
1232 surface_removed,
1233 removed_callback);
1234}
1235
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001236static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001237ivi_layout_remove_notification_remove_surface(surface_remove_notification_func callback,
1238 void *userdata)
1239{
1240 struct ivi_layout *layout = get_instance();
1241 remove_notification(&layout->surface_notification.removed.listener_list, callback, userdata);
1242}
1243
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001244static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001245ivi_layout_add_notification_configure_surface(surface_configure_notification_func callback,
1246 void *userdata)
1247{
1248 struct ivi_layout *layout = get_instance();
1249 struct ivi_layout_notification_callback *configure_changed_callback = NULL;
1250 if (callback == NULL) {
1251 weston_log("ivi_layout_add_notification_configure_surface: invalid argument\n");
1252 return IVI_FAILED;
1253 }
1254
1255 configure_changed_callback = malloc(sizeof *configure_changed_callback);
1256 if (configure_changed_callback == NULL) {
1257 weston_log("fails to allocate memory\n");
1258 return IVI_FAILED;
1259 }
1260
1261 configure_changed_callback->callback = callback;
1262 configure_changed_callback->data = userdata;
1263
1264 return add_notification(&layout->surface_notification.configure_changed,
1265 surface_configure_changed,
1266 configure_changed_callback);
1267}
1268
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001269static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001270ivi_layout_remove_notification_configure_surface(surface_configure_notification_func callback,
1271 void *userdata)
1272{
1273 struct ivi_layout *layout = get_instance();
1274 remove_notification(&layout->surface_notification.configure_changed.listener_list, callback, userdata);
1275}
1276
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001277uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001278ivi_layout_get_id_of_surface(struct ivi_layout_surface *ivisurf)
1279{
1280 return ivisurf->id_surface;
1281}
1282
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001283static uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001284ivi_layout_get_id_of_layer(struct ivi_layout_layer *ivilayer)
1285{
1286 return ivilayer->id_layer;
1287}
1288
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001289static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001290ivi_layout_get_layer_from_id(uint32_t id_layer)
1291{
1292 struct ivi_layout *layout = get_instance();
1293 struct ivi_layout_layer *ivilayer = NULL;
1294
1295 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1296 if (ivilayer->id_layer == id_layer) {
1297 return ivilayer;
1298 }
1299 }
1300
1301 return NULL;
1302}
1303
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001304struct ivi_layout_surface *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001305ivi_layout_get_surface_from_id(uint32_t id_surface)
1306{
1307 struct ivi_layout *layout = get_instance();
1308 struct ivi_layout_surface *ivisurf = NULL;
1309
1310 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1311 if (ivisurf->id_surface == id_surface) {
1312 return ivisurf;
1313 }
1314 }
1315
1316 return NULL;
1317}
1318
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001319static int32_t
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001320ivi_layout_surface_add_listener(struct ivi_layout_surface *ivisurf,
1321 struct wl_listener *listener)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001322{
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001323 if (ivisurf == NULL || listener == NULL) {
1324 weston_log("ivi_layout_surface_add_listener: invalid argument\n");
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001325 return IVI_FAILED;
1326 }
1327
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00001328 wl_signal_add(&ivisurf->property_changed, listener);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001329
1330 return IVI_SUCCEEDED;
1331}
1332
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001333static const struct ivi_layout_layer_properties *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001334ivi_layout_get_properties_of_layer(struct ivi_layout_layer *ivilayer)
1335{
1336 if (ivilayer == NULL) {
1337 weston_log("ivi_layout_get_properties_of_layer: invalid argument\n");
1338 return NULL;
1339 }
1340
1341 return &ivilayer->prop;
1342}
1343
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001344static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001345ivi_layout_get_screens_under_layer(struct ivi_layout_layer *ivilayer,
1346 int32_t *pLength,
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001347 struct weston_output ***ppArray)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001348{
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001349 int32_t length = 0;
1350 int32_t n = 0;
1351
1352 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1353 weston_log("ivi_layout_get_screens_under_layer: invalid argument\n");
1354 return IVI_FAILED;
1355 }
1356
Ucan, Emre (ADITG/SW1)8a223672015-08-28 12:58:55 +00001357 if (ivilayer->on_screen != NULL)
1358 length = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001359
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001360 if (length != 0) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001361 /* the Array must be free by module which called this function */
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001362 *ppArray = calloc(length, sizeof(struct weston_output *));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001363 if (*ppArray == NULL) {
1364 weston_log("fails to allocate memory\n");
1365 return IVI_FAILED;
1366 }
1367
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001368 (*ppArray)[n++] = ivilayer->on_screen->output;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001369 }
1370
1371 *pLength = length;
1372
1373 return IVI_SUCCEEDED;
1374}
1375
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001376static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001377ivi_layout_get_layers(int32_t *pLength, struct ivi_layout_layer ***ppArray)
1378{
1379 struct ivi_layout *layout = get_instance();
1380 struct ivi_layout_layer *ivilayer = NULL;
1381 int32_t length = 0;
1382 int32_t n = 0;
1383
1384 if (pLength == NULL || ppArray == NULL) {
1385 weston_log("ivi_layout_get_layers: invalid argument\n");
1386 return IVI_FAILED;
1387 }
1388
1389 length = wl_list_length(&layout->layer_list);
1390
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001391 if (length != 0) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001392 /* the Array must be free by module which called this function */
1393 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1394 if (*ppArray == NULL) {
1395 weston_log("fails to allocate memory\n");
1396 return IVI_FAILED;
1397 }
1398
1399 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1400 (*ppArray)[n++] = ivilayer;
1401 }
1402 }
1403
1404 *pLength = length;
1405
1406 return IVI_SUCCEEDED;
1407}
1408
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001409static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001410ivi_layout_get_layers_on_screen(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001411 int32_t *pLength,
1412 struct ivi_layout_layer ***ppArray)
1413{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001414 struct ivi_layout_screen *iviscrn = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001415 struct ivi_layout_layer *ivilayer = NULL;
1416 int32_t length = 0;
1417 int32_t n = 0;
1418
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001419 if (output == NULL || pLength == NULL || ppArray == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001420 weston_log("ivi_layout_get_layers_on_screen: invalid argument\n");
1421 return IVI_FAILED;
1422 }
1423
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001424 iviscrn = get_screen_from_output(output);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001425 length = wl_list_length(&iviscrn->order.layer_list);
1426
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001427 if (length != 0) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001428 /* the Array must be free by module which called this function */
1429 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1430 if (*ppArray == NULL) {
1431 weston_log("fails to allocate memory\n");
1432 return IVI_FAILED;
1433 }
1434
Nobuhiko Tanibatae2b82142015-06-22 15:30:19 +09001435 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001436 (*ppArray)[n++] = ivilayer;
1437 }
1438 }
1439
1440 *pLength = length;
1441
1442 return IVI_SUCCEEDED;
1443}
1444
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001445static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001446ivi_layout_get_layers_under_surface(struct ivi_layout_surface *ivisurf,
1447 int32_t *pLength,
1448 struct ivi_layout_layer ***ppArray)
1449{
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001450 int32_t length = 0;
1451 int32_t n = 0;
1452
1453 if (ivisurf == NULL || pLength == NULL || ppArray == NULL) {
1454 weston_log("ivi_layout_getLayers: invalid argument\n");
1455 return IVI_FAILED;
1456 }
1457
Ucan, Emre (ADITG/SW1)dfac3752015-08-28 12:58:58 +00001458 if (ivisurf->on_layer != NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001459 /* the Array must be free by module which called this function */
Ucan, Emre (ADITG/SW1)dfac3752015-08-28 12:58:58 +00001460 length = 1;
1461 *ppArray = calloc(length, sizeof(struct ivi_layout_screen *));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001462 if (*ppArray == NULL) {
1463 weston_log("fails to allocate memory\n");
1464 return IVI_FAILED;
1465 }
1466
Ucan, Emre (ADITG/SW1)dfac3752015-08-28 12:58:58 +00001467 (*ppArray)[n++] = ivisurf->on_layer;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001468 }
1469
1470 *pLength = length;
1471
1472 return IVI_SUCCEEDED;
1473}
1474
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001475static
1476int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001477ivi_layout_get_surfaces(int32_t *pLength, struct ivi_layout_surface ***ppArray)
1478{
1479 struct ivi_layout *layout = get_instance();
1480 struct ivi_layout_surface *ivisurf = NULL;
1481 int32_t length = 0;
1482 int32_t n = 0;
1483
1484 if (pLength == NULL || ppArray == NULL) {
1485 weston_log("ivi_layout_get_surfaces: invalid argument\n");
1486 return IVI_FAILED;
1487 }
1488
1489 length = wl_list_length(&layout->surface_list);
1490
Dawid Gajownik74a635b2015-08-06 17:12:19 -03001491 if (length != 0) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001492 /* the Array must be free by module which called this function */
1493 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1494 if (*ppArray == NULL) {
1495 weston_log("fails to allocate memory\n");
1496 return IVI_FAILED;
1497 }
1498
1499 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1500 (*ppArray)[n++] = ivisurf;
1501 }
1502 }
1503
1504 *pLength = length;
1505
1506 return IVI_SUCCEEDED;
1507}
1508
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001509static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001510ivi_layout_get_surfaces_on_layer(struct ivi_layout_layer *ivilayer,
1511 int32_t *pLength,
1512 struct ivi_layout_surface ***ppArray)
1513{
1514 struct ivi_layout_surface *ivisurf = NULL;
1515 int32_t length = 0;
1516 int32_t n = 0;
1517
1518 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1519 weston_log("ivi_layout_getSurfaceIDsOnLayer: invalid argument\n");
1520 return IVI_FAILED;
1521 }
1522
1523 length = wl_list_length(&ivilayer->order.surface_list);
1524
1525 if (length != 0) {
1526 /* the Array must be free by module which called this function */
1527 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1528 if (*ppArray == NULL) {
1529 weston_log("fails to allocate memory\n");
1530 return IVI_FAILED;
1531 }
1532
1533 wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) {
1534 (*ppArray)[n++] = ivisurf;
1535 }
1536 }
1537
1538 *pLength = length;
1539
1540 return IVI_SUCCEEDED;
1541}
1542
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001543static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001544ivi_layout_layer_create_with_dimension(uint32_t id_layer,
1545 int32_t width, int32_t height)
1546{
1547 struct ivi_layout *layout = get_instance();
1548 struct ivi_layout_layer *ivilayer = NULL;
1549
1550 ivilayer = get_layer(&layout->layer_list, id_layer);
1551 if (ivilayer != NULL) {
1552 weston_log("id_layer is already created\n");
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001553 ++ivilayer->ref_count;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001554 return ivilayer;
1555 }
1556
1557 ivilayer = calloc(1, sizeof *ivilayer);
1558 if (ivilayer == NULL) {
1559 weston_log("fails to allocate memory\n");
1560 return NULL;
1561 }
1562
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001563 ivilayer->ref_count = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001564 wl_signal_init(&ivilayer->property_changed);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001565 ivilayer->layout = layout;
1566 ivilayer->id_layer = id_layer;
1567
1568 init_layer_properties(&ivilayer->prop, width, height);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001569
1570 wl_list_init(&ivilayer->pending.surface_list);
1571 wl_list_init(&ivilayer->pending.link);
1572 ivilayer->pending.prop = ivilayer->prop;
1573
1574 wl_list_init(&ivilayer->order.surface_list);
1575 wl_list_init(&ivilayer->order.link);
1576
1577 wl_list_insert(&layout->layer_list, &ivilayer->link);
1578
1579 wl_signal_emit(&layout->layer_notification.created, ivilayer);
1580
1581 return ivilayer;
1582}
1583
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001584static void
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +09001585ivi_layout_layer_remove_notification(struct ivi_layout_layer *ivilayer)
1586{
1587 if (ivilayer == NULL) {
1588 weston_log("ivi_layout_layer_remove_notification: invalid argument\n");
1589 return;
1590 }
1591
1592 remove_all_notification(&ivilayer->property_changed.listener_list);
1593}
1594
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001595static void
Nobuhiko Tanibatadb8efd12015-06-22 15:31:39 +09001596ivi_layout_layer_remove_notification_by_callback(struct ivi_layout_layer *ivilayer,
1597 layer_property_notification_func callback,
1598 void *userdata)
1599{
1600 if (ivilayer == NULL) {
1601 weston_log("ivi_layout_layer_remove_notification_by_callback: invalid argument\n");
1602 return;
1603 }
1604
1605 remove_notification(&ivilayer->property_changed.listener_list, callback, userdata);
1606}
1607
1608static void
Nobuhiko Tanibata3aa8aed2015-06-22 15:32:23 +09001609ivi_layout_layer_destroy(struct ivi_layout_layer *ivilayer)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001610{
1611 struct ivi_layout *layout = get_instance();
1612
1613 if (ivilayer == NULL) {
1614 weston_log("ivi_layout_layer_remove: invalid argument\n");
1615 return;
1616 }
1617
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001618 if (--ivilayer->ref_count > 0)
1619 return;
1620
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001621 wl_signal_emit(&layout->layer_notification.removed, ivilayer);
1622
1623 clear_surface_pending_list(ivilayer);
1624 clear_surface_order_list(ivilayer);
1625
Ucan, Emre (ADITG/SW1)cf34dc22015-08-20 14:13:33 +00001626 wl_list_remove(&ivilayer->pending.link);
1627 wl_list_remove(&ivilayer->order.link);
1628 wl_list_remove(&ivilayer->link);
1629
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001630 ivi_layout_layer_remove_notification(ivilayer);
1631
1632 free(ivilayer);
1633}
1634
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001635int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001636ivi_layout_layer_set_visibility(struct ivi_layout_layer *ivilayer,
1637 bool newVisibility)
1638{
1639 struct ivi_layout_layer_properties *prop = NULL;
1640
1641 if (ivilayer == NULL) {
1642 weston_log("ivi_layout_layer_set_visibility: invalid argument\n");
1643 return IVI_FAILED;
1644 }
1645
1646 prop = &ivilayer->pending.prop;
1647 prop->visibility = newVisibility;
1648
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001649 if (ivilayer->prop.visibility != newVisibility)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001650 prop->event_mask |= IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001651 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001652 prop->event_mask &= ~IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001653
1654 return IVI_SUCCEEDED;
1655}
1656
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001657int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001658ivi_layout_layer_set_opacity(struct ivi_layout_layer *ivilayer,
1659 wl_fixed_t opacity)
1660{
1661 struct ivi_layout_layer_properties *prop = NULL;
1662
Nobuhiko Tanibata7bbacc62015-06-22 15:30:09 +09001663 if (ivilayer == NULL ||
1664 opacity < wl_fixed_from_double(0.0) ||
1665 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001666 weston_log("ivi_layout_layer_set_opacity: invalid argument\n");
1667 return IVI_FAILED;
1668 }
1669
1670 prop = &ivilayer->pending.prop;
1671 prop->opacity = opacity;
1672
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001673 if (ivilayer->prop.opacity != opacity)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001674 prop->event_mask |= IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001675 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001676 prop->event_mask &= ~IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001677
1678 return IVI_SUCCEEDED;
1679}
1680
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001681static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001682ivi_layout_layer_set_source_rectangle(struct ivi_layout_layer *ivilayer,
1683 int32_t x, int32_t y,
1684 int32_t width, int32_t height)
1685{
1686 struct ivi_layout_layer_properties *prop = NULL;
1687
1688 if (ivilayer == NULL) {
1689 weston_log("ivi_layout_layer_set_source_rectangle: invalid argument\n");
1690 return IVI_FAILED;
1691 }
1692
1693 prop = &ivilayer->pending.prop;
1694 prop->source_x = x;
1695 prop->source_y = y;
1696 prop->source_width = width;
1697 prop->source_height = height;
1698
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001699 if (ivilayer->prop.source_x != x || ivilayer->prop.source_y != y ||
1700 ivilayer->prop.source_width != width ||
1701 ivilayer->prop.source_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001702 prop->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001703 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001704 prop->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001705
1706 return IVI_SUCCEEDED;
1707}
1708
Ucan, Emre \(ADITG/SW1\)e62bfd82016-03-04 12:50:46 +00001709int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001710ivi_layout_layer_set_destination_rectangle(struct ivi_layout_layer *ivilayer,
1711 int32_t x, int32_t y,
1712 int32_t width, int32_t height)
1713{
1714 struct ivi_layout_layer_properties *prop = NULL;
1715
1716 if (ivilayer == NULL) {
1717 weston_log("ivi_layout_layer_set_destination_rectangle: invalid argument\n");
1718 return IVI_FAILED;
1719 }
1720
1721 prop = &ivilayer->pending.prop;
1722 prop->dest_x = x;
1723 prop->dest_y = y;
1724 prop->dest_width = width;
1725 prop->dest_height = height;
1726
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001727 if (ivilayer->prop.dest_x != x || ivilayer->prop.dest_y != y ||
1728 ivilayer->prop.dest_width != width ||
1729 ivilayer->prop.dest_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001730 prop->event_mask |= IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001731 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001732 prop->event_mask &= ~IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001733
1734 return IVI_SUCCEEDED;
1735}
1736
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001737static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001738ivi_layout_layer_set_orientation(struct ivi_layout_layer *ivilayer,
1739 enum wl_output_transform orientation)
1740{
1741 struct ivi_layout_layer_properties *prop = NULL;
1742
1743 if (ivilayer == NULL) {
1744 weston_log("ivi_layout_layer_set_orientation: invalid argument\n");
1745 return IVI_FAILED;
1746 }
1747
1748 prop = &ivilayer->pending.prop;
1749 prop->orientation = orientation;
1750
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001751 if (ivilayer->prop.orientation != orientation)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001752 prop->event_mask |= IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001753 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001754 prop->event_mask &= ~IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001755
1756 return IVI_SUCCEEDED;
1757}
1758
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001759int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001760ivi_layout_layer_set_render_order(struct ivi_layout_layer *ivilayer,
1761 struct ivi_layout_surface **pSurface,
1762 int32_t number)
1763{
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001764 int32_t i = 0;
1765
1766 if (ivilayer == NULL) {
1767 weston_log("ivi_layout_layer_set_render_order: invalid argument\n");
1768 return IVI_FAILED;
1769 }
1770
Ucan, Emre (ADITG/SW1)c2be6382015-08-19 11:25:01 +00001771 clear_surface_pending_list(ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001772
1773 for (i = 0; i < number; i++) {
Ucan, Emre (ADITG/SW1)72ad1642016-03-16 13:37:05 +00001774 wl_list_remove(&pSurface[i]->pending.link);
1775 wl_list_insert(&ivilayer->pending.surface_list,
1776 &pSurface[i]->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001777 }
1778
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +00001779 ivilayer->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001780
1781 return IVI_SUCCEEDED;
1782}
1783
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001784int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001785ivi_layout_surface_set_visibility(struct ivi_layout_surface *ivisurf,
1786 bool newVisibility)
1787{
1788 struct ivi_layout_surface_properties *prop = NULL;
1789
1790 if (ivisurf == NULL) {
1791 weston_log("ivi_layout_surface_set_visibility: invalid argument\n");
1792 return IVI_FAILED;
1793 }
1794
1795 prop = &ivisurf->pending.prop;
1796 prop->visibility = newVisibility;
1797
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001798 if (ivisurf->prop.visibility != newVisibility)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001799 prop->event_mask |= IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001800 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001801 prop->event_mask &= ~IVI_NOTIFICATION_VISIBILITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001802
1803 return IVI_SUCCEEDED;
1804}
1805
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001806int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001807ivi_layout_surface_set_opacity(struct ivi_layout_surface *ivisurf,
1808 wl_fixed_t opacity)
1809{
1810 struct ivi_layout_surface_properties *prop = NULL;
1811
Nobuhiko Tanibataa86226c2015-06-22 15:29:20 +09001812 if (ivisurf == NULL ||
1813 opacity < wl_fixed_from_double(0.0) ||
1814 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001815 weston_log("ivi_layout_surface_set_opacity: invalid argument\n");
1816 return IVI_FAILED;
1817 }
1818
1819 prop = &ivisurf->pending.prop;
1820 prop->opacity = opacity;
1821
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001822 if (ivisurf->prop.opacity != opacity)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001823 prop->event_mask |= IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001824 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001825 prop->event_mask &= ~IVI_NOTIFICATION_OPACITY;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001826
1827 return IVI_SUCCEEDED;
1828}
1829
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001830int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001831ivi_layout_surface_set_destination_rectangle(struct ivi_layout_surface *ivisurf,
1832 int32_t x, int32_t y,
1833 int32_t width, int32_t height)
1834{
1835 struct ivi_layout_surface_properties *prop = NULL;
1836
1837 if (ivisurf == NULL) {
1838 weston_log("ivi_layout_surface_set_destination_rectangle: invalid argument\n");
1839 return IVI_FAILED;
1840 }
1841
1842 prop = &ivisurf->pending.prop;
1843 prop->start_x = prop->dest_x;
1844 prop->start_y = prop->dest_y;
1845 prop->dest_x = x;
1846 prop->dest_y = y;
1847 prop->start_width = prop->dest_width;
1848 prop->start_height = prop->dest_height;
1849 prop->dest_width = width;
1850 prop->dest_height = height;
1851
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001852 if (ivisurf->prop.dest_x != x || ivisurf->prop.dest_y != y ||
1853 ivisurf->prop.dest_width != width ||
1854 ivisurf->prop.dest_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001855 prop->event_mask |= IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001856 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001857 prop->event_mask &= ~IVI_NOTIFICATION_DEST_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001858
1859 return IVI_SUCCEEDED;
1860}
1861
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001862static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001863ivi_layout_surface_set_orientation(struct ivi_layout_surface *ivisurf,
1864 enum wl_output_transform orientation)
1865{
1866 struct ivi_layout_surface_properties *prop = NULL;
1867
1868 if (ivisurf == NULL) {
1869 weston_log("ivi_layout_surface_set_orientation: invalid argument\n");
1870 return IVI_FAILED;
1871 }
1872
1873 prop = &ivisurf->pending.prop;
1874 prop->orientation = orientation;
1875
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001876 if (ivisurf->prop.orientation != orientation)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001877 prop->event_mask |= IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09001878 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00001879 prop->event_mask &= ~IVI_NOTIFICATION_ORIENTATION;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001880
1881 return IVI_SUCCEEDED;
1882}
1883
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001884static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001885ivi_layout_screen_add_layer(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001886 struct ivi_layout_layer *addlayer)
1887{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001888 struct ivi_layout_screen *iviscrn;
1889
1890 if (output == NULL || addlayer == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001891 weston_log("ivi_layout_screen_add_layer: invalid argument\n");
1892 return IVI_FAILED;
1893 }
1894
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001895 iviscrn = get_screen_from_output(output);
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001896
Ucan, Emre (ADITG/SW1)bb4ec0a2015-08-28 12:59:01 +00001897 if (addlayer->on_screen == iviscrn) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001898 weston_log("ivi_layout_screen_add_layer: addlayer is already available\n");
1899 return IVI_SUCCEEDED;
1900 }
1901
Ucan, Emre (ADITG/SW1)f46306f2016-03-16 13:37:07 +00001902 wl_list_remove(&addlayer->pending.link);
1903 wl_list_insert(&iviscrn->pending.layer_list, &addlayer->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001904
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001905 iviscrn->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001906
1907 return IVI_SUCCEEDED;
1908}
1909
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001910static int32_t
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001911ivi_layout_screen_set_render_order(struct weston_output *output,
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001912 struct ivi_layout_layer **pLayer,
1913 const int32_t number)
1914{
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001915 struct ivi_layout_screen *iviscrn;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001916 struct ivi_layout_layer *ivilayer = NULL;
1917 struct ivi_layout_layer *next = NULL;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001918 int32_t i = 0;
1919
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001920 if (output == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001921 weston_log("ivi_layout_screen_set_render_order: invalid argument\n");
1922 return IVI_FAILED;
1923 }
1924
Ucan, Emre (ADITG/SW1)b216c922016-03-17 15:30:46 +00001925 iviscrn = get_screen_from_output(output);
Ucan, Emre (ADITG/SW1)273874e2016-03-17 15:30:42 +00001926
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001927 wl_list_for_each_safe(ivilayer, next,
1928 &iviscrn->pending.layer_list, pending.link) {
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001929 wl_list_remove(&ivilayer->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001930 wl_list_init(&ivilayer->pending.link);
1931 }
1932
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001933 assert(wl_list_empty(&iviscrn->pending.layer_list));
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001934
1935 for (i = 0; i < number; i++) {
Ucan, Emre (ADITG/SW1)4e221f02016-03-16 13:37:08 +00001936 wl_list_remove(&pLayer[i]->pending.link);
1937 wl_list_insert(&iviscrn->pending.layer_list,
1938 &pLayer[i]->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001939 }
1940
Ucan, Emre (ADITG/SW1)174257b2015-08-20 14:13:30 +00001941 iviscrn->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001942
1943 return IVI_SUCCEEDED;
1944}
1945
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001946/**
1947 * This function is used by the additional ivi-module because of dumping ivi_surface sceenshot.
1948 * The ivi-module, e.g. ivi-controller.so, is in wayland-ivi-extension of Genivi's Layer Management.
1949 * This function is used to get the result of drawing by clients.
1950 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001951static struct weston_surface *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001952ivi_layout_surface_get_weston_surface(struct ivi_layout_surface *ivisurf)
1953{
1954 return ivisurf != NULL ? ivisurf->surface : NULL;
1955}
1956
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001957static int32_t
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09001958ivi_layout_surface_get_size(struct ivi_layout_surface *ivisurf,
1959 int32_t *width, int32_t *height,
1960 int32_t *stride)
1961{
1962 int32_t w;
1963 int32_t h;
1964 const size_t bytespp = 4; /* PIXMAN_a8b8g8r8 */
1965
1966 if (ivisurf == NULL || ivisurf->surface == NULL) {
1967 weston_log("%s: invalid argument\n", __func__);
1968 return IVI_FAILED;
1969 }
1970
1971 weston_surface_get_content_size(ivisurf->surface, &w, &h);
1972
1973 if (width != NULL)
1974 *width = w;
1975
1976 if (height != NULL)
1977 *height = h;
1978
1979 if (stride != NULL)
1980 *stride = w * bytespp;
1981
1982 return IVI_SUCCEEDED;
1983}
1984
1985static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001986ivi_layout_layer_add_notification(struct ivi_layout_layer *ivilayer,
1987 layer_property_notification_func callback,
1988 void *userdata)
1989{
1990 struct ivi_layout_notification_callback *prop_callback = NULL;
1991
1992 if (ivilayer == NULL || callback == NULL) {
1993 weston_log("ivi_layout_layer_add_notification: invalid argument\n");
1994 return IVI_FAILED;
1995 }
1996
1997 prop_callback = malloc(sizeof *prop_callback);
1998 if (prop_callback == NULL) {
1999 weston_log("fails to allocate memory\n");
2000 return IVI_FAILED;
2001 }
2002
2003 prop_callback->callback = callback;
2004 prop_callback->data = userdata;
2005
2006 return add_notification(&ivilayer->property_changed,
2007 layer_prop_changed,
2008 prop_callback);
2009}
2010
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002011static const struct ivi_layout_surface_properties *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002012ivi_layout_get_properties_of_surface(struct ivi_layout_surface *ivisurf)
2013{
2014 if (ivisurf == NULL) {
2015 weston_log("ivi_layout_get_properties_of_surface: invalid argument\n");
2016 return NULL;
2017 }
2018
2019 return &ivisurf->prop;
2020}
2021
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002022static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002023ivi_layout_layer_add_surface(struct ivi_layout_layer *ivilayer,
2024 struct ivi_layout_surface *addsurf)
2025{
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002026 if (ivilayer == NULL || addsurf == NULL) {
2027 weston_log("ivi_layout_layer_add_surface: invalid argument\n");
2028 return IVI_FAILED;
2029 }
2030
Wataru Natsume9c926fe2016-03-03 19:56:09 +09002031 if (addsurf->on_layer == ivilayer)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002032 return IVI_SUCCEEDED;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002033
Ucan, Emre (ADITG/SW1)10942372016-03-16 13:37:02 +00002034 wl_list_remove(&addsurf->pending.link);
2035 wl_list_insert(&ivilayer->pending.surface_list, &addsurf->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002036
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +00002037 ivilayer->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002038
2039 return IVI_SUCCEEDED;
2040}
2041
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002042static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002043ivi_layout_layer_remove_surface(struct ivi_layout_layer *ivilayer,
2044 struct ivi_layout_surface *remsurf)
2045{
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002046 if (ivilayer == NULL || remsurf == NULL) {
2047 weston_log("ivi_layout_layer_remove_surface: invalid argument\n");
2048 return;
2049 }
2050
Ucan, Emre (ADITG/SW1)536d8332016-03-16 13:36:59 +00002051 wl_list_remove(&remsurf->pending.link);
2052 wl_list_init(&remsurf->pending.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002053
Ucan, Emre (ADITG/SW1)38fcf382015-08-20 14:13:29 +00002054 ivilayer->order.dirty = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002055}
2056
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002057static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002058ivi_layout_surface_set_source_rectangle(struct ivi_layout_surface *ivisurf,
2059 int32_t x, int32_t y,
2060 int32_t width, int32_t height)
2061{
2062 struct ivi_layout_surface_properties *prop = NULL;
2063
2064 if (ivisurf == NULL) {
2065 weston_log("ivi_layout_surface_set_source_rectangle: invalid argument\n");
2066 return IVI_FAILED;
2067 }
2068
2069 prop = &ivisurf->pending.prop;
2070 prop->source_x = x;
2071 prop->source_y = y;
2072 prop->source_width = width;
2073 prop->source_height = height;
2074
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09002075 if (ivisurf->prop.source_x != x || ivisurf->prop.source_y != y ||
2076 ivisurf->prop.source_width != width ||
2077 ivisurf->prop.source_height != height)
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00002078 prop->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata5d4a3232015-06-22 15:32:14 +09002079 else
Ucan, Emre (ADITG/SW1)0bd29b62016-03-31 11:08:52 +00002080 prop->event_mask &= ~IVI_NOTIFICATION_SOURCE_RECT;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002081
2082 return IVI_SUCCEEDED;
2083}
2084
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002085int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002086ivi_layout_commit_changes(void)
2087{
2088 struct ivi_layout *layout = get_instance();
2089
2090 commit_surface_list(layout);
2091 commit_layer_list(layout);
2092 commit_screen_list(layout);
2093
2094 commit_transition(layout);
2095
2096 commit_changes(layout);
2097 send_prop(layout);
2098 weston_compositor_schedule_repaint(layout->compositor);
2099
2100 return IVI_SUCCEEDED;
2101}
2102
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002103static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09002104ivi_layout_layer_set_transition(struct ivi_layout_layer *ivilayer,
2105 enum ivi_layout_transition_type type,
2106 uint32_t duration)
2107{
2108 if (ivilayer == NULL) {
2109 weston_log("%s: invalid argument\n", __func__);
2110 return -1;
2111 }
2112
2113 ivilayer->pending.prop.transition_type = type;
2114 ivilayer->pending.prop.transition_duration = duration;
2115
2116 return 0;
2117}
2118
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002119static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09002120ivi_layout_layer_set_fade_info(struct ivi_layout_layer* ivilayer,
2121 uint32_t is_fade_in,
2122 double start_alpha, double end_alpha)
2123{
2124 if (ivilayer == NULL) {
2125 weston_log("%s: invalid argument\n", __func__);
2126 return -1;
2127 }
2128
2129 ivilayer->pending.prop.is_fade_in = is_fade_in;
2130 ivilayer->pending.prop.start_alpha = start_alpha;
2131 ivilayer->pending.prop.end_alpha = end_alpha;
2132
2133 return 0;
2134}
2135
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002136static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09002137ivi_layout_surface_set_transition_duration(struct ivi_layout_surface *ivisurf,
2138 uint32_t duration)
2139{
2140 struct ivi_layout_surface_properties *prop;
2141
2142 if (ivisurf == NULL) {
2143 weston_log("%s: invalid argument\n", __func__);
2144 return -1;
2145 }
2146
2147 prop = &ivisurf->pending.prop;
2148 prop->transition_duration = duration*10;
2149 return 0;
2150}
2151
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002152static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09002153ivi_layout_surface_set_transition(struct ivi_layout_surface *ivisurf,
2154 enum ivi_layout_transition_type type,
2155 uint32_t duration)
2156{
2157 struct ivi_layout_surface_properties *prop;
2158
2159 if (ivisurf == NULL) {
2160 weston_log("%s: invalid argument\n", __func__);
2161 return -1;
2162 }
2163
2164 prop = &ivisurf->pending.prop;
2165 prop->transition_type = type;
2166 prop->transition_duration = duration;
2167 return 0;
2168}
2169
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09002170static int32_t
2171ivi_layout_surface_dump(struct weston_surface *surface,
2172 void *target, size_t size,int32_t x, int32_t y,
2173 int32_t width, int32_t height)
2174{
2175 int result = 0;
2176
2177 if (surface == NULL) {
2178 weston_log("%s: invalid argument\n", __func__);
2179 return IVI_FAILED;
2180 }
2181
2182 result = weston_surface_copy_content(
2183 surface, target, size,
2184 x, y, width, height);
2185
2186 return result == 0 ? IVI_SUCCEEDED : IVI_FAILED;
2187}
2188
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002189/**
2190 * methods of interaction between ivi-shell with ivi-layout
2191 */
2192struct weston_view *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002193ivi_layout_get_weston_view(struct ivi_layout_surface *surface)
2194{
Dawid Gajownik74a635b2015-08-06 17:12:19 -03002195 if (surface == NULL)
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002196 return NULL;
2197
Ucan, Emre (ADITG/SW1)64635ee2015-08-28 12:59:06 +00002198 return get_weston_view(surface);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002199}
2200
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002201void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002202ivi_layout_surface_configure(struct ivi_layout_surface *ivisurf,
2203 int32_t width, int32_t height)
2204{
2205 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002206
Nobuhiko Tanibatae6cc9972015-04-27 16:54:01 +09002207 /* emit callback which is set by ivi-layout api user */
2208 wl_signal_emit(&layout->surface_notification.configure_changed,
2209 ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002210}
2211
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002212struct ivi_layout_surface*
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002213ivi_layout_surface_create(struct weston_surface *wl_surface,
2214 uint32_t id_surface)
2215{
2216 struct ivi_layout *layout = get_instance();
2217 struct ivi_layout_surface *ivisurf = NULL;
2218 struct weston_view *tmpview = NULL;
2219
2220 if (wl_surface == NULL) {
2221 weston_log("ivi_layout_surface_create: invalid argument\n");
2222 return NULL;
2223 }
2224
2225 ivisurf = get_surface(&layout->surface_list, id_surface);
2226 if (ivisurf != NULL) {
2227 if (ivisurf->surface != NULL) {
2228 weston_log("id_surface(%d) is already created\n", id_surface);
2229 return NULL;
2230 }
2231 }
2232
2233 ivisurf = calloc(1, sizeof *ivisurf);
2234 if (ivisurf == NULL) {
2235 weston_log("fails to allocate memory\n");
2236 return NULL;
2237 }
2238
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002239 wl_signal_init(&ivisurf->property_changed);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002240 ivisurf->id_surface = id_surface;
2241 ivisurf->layout = layout;
2242
2243 ivisurf->surface = wl_surface;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002244
2245 tmpview = weston_view_create(wl_surface);
2246 if (tmpview == NULL) {
2247 weston_log("fails to allocate memory\n");
2248 }
2249
2250 ivisurf->surface->width_from_buffer = 0;
2251 ivisurf->surface->height_from_buffer = 0;
2252
Nobuhiko Tanibata21deb282015-07-15 14:05:32 +09002253 weston_matrix_init(&ivisurf->transform.matrix);
2254 wl_list_init(&ivisurf->transform.link);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002255
2256 init_surface_properties(&ivisurf->prop);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002257
2258 ivisurf->pending.prop = ivisurf->prop;
2259 wl_list_init(&ivisurf->pending.link);
2260
2261 wl_list_init(&ivisurf->order.link);
2262 wl_list_init(&ivisurf->order.layer_list);
2263
2264 wl_list_insert(&layout->surface_list, &ivisurf->link);
2265
2266 wl_signal_emit(&layout->surface_notification.created, ivisurf);
2267
2268 return ivisurf;
2269}
2270
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002271void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002272ivi_layout_init_with_compositor(struct weston_compositor *ec)
2273{
2274 struct ivi_layout *layout = get_instance();
2275
2276 layout->compositor = ec;
2277
2278 wl_list_init(&layout->surface_list);
2279 wl_list_init(&layout->layer_list);
2280 wl_list_init(&layout->screen_list);
2281
2282 wl_signal_init(&layout->layer_notification.created);
2283 wl_signal_init(&layout->layer_notification.removed);
2284
2285 wl_signal_init(&layout->surface_notification.created);
2286 wl_signal_init(&layout->surface_notification.removed);
2287 wl_signal_init(&layout->surface_notification.configure_changed);
2288
2289 /* Add layout_layer at the last of weston_compositor.layer_list */
2290 weston_layer_init(&layout->layout_layer, ec->layer_list.prev);
2291
2292 create_screen(ec);
2293
2294 layout->transitions = ivi_layout_transition_set_create(ec);
2295 wl_list_init(&layout->pending_transition_list);
2296}
2297
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002298static struct ivi_layout_interface ivi_layout_interface = {
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002299 /**
2300 * commit all changes
2301 */
2302 .commit_changes = ivi_layout_commit_changes,
2303
2304 /**
2305 * surface controller interfaces
2306 */
2307 .add_notification_create_surface = ivi_layout_add_notification_create_surface,
2308 .remove_notification_create_surface = ivi_layout_remove_notification_create_surface,
2309 .add_notification_remove_surface = ivi_layout_add_notification_remove_surface,
2310 .remove_notification_remove_surface = ivi_layout_remove_notification_remove_surface,
2311 .add_notification_configure_surface = ivi_layout_add_notification_configure_surface,
2312 .remove_notification_configure_surface = ivi_layout_remove_notification_configure_surface,
2313 .get_surfaces = ivi_layout_get_surfaces,
2314 .get_id_of_surface = ivi_layout_get_id_of_surface,
2315 .get_surface_from_id = ivi_layout_get_surface_from_id,
2316 .get_properties_of_surface = ivi_layout_get_properties_of_surface,
2317 .get_surfaces_on_layer = ivi_layout_get_surfaces_on_layer,
2318 .surface_set_visibility = ivi_layout_surface_set_visibility,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002319 .surface_set_opacity = ivi_layout_surface_set_opacity,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002320 .surface_set_source_rectangle = ivi_layout_surface_set_source_rectangle,
2321 .surface_set_destination_rectangle = ivi_layout_surface_set_destination_rectangle,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002322 .surface_set_orientation = ivi_layout_surface_set_orientation,
Ucan, Emre (ADITG/SW1)706cb5a2016-04-04 08:05:03 +00002323 .surface_add_listener = ivi_layout_surface_add_listener,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002324 .surface_get_weston_surface = ivi_layout_surface_get_weston_surface,
2325 .surface_set_transition = ivi_layout_surface_set_transition,
2326 .surface_set_transition_duration = ivi_layout_surface_set_transition_duration,
2327
2328 /**
2329 * layer controller interfaces
2330 */
2331 .add_notification_create_layer = ivi_layout_add_notification_create_layer,
2332 .remove_notification_create_layer = ivi_layout_remove_notification_create_layer,
2333 .add_notification_remove_layer = ivi_layout_add_notification_remove_layer,
2334 .remove_notification_remove_layer = ivi_layout_remove_notification_remove_layer,
2335 .layer_create_with_dimension = ivi_layout_layer_create_with_dimension,
Nobuhiko Tanibata3aa8aed2015-06-22 15:32:23 +09002336 .layer_destroy = ivi_layout_layer_destroy,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002337 .get_layers = ivi_layout_get_layers,
2338 .get_id_of_layer = ivi_layout_get_id_of_layer,
2339 .get_layer_from_id = ivi_layout_get_layer_from_id,
2340 .get_properties_of_layer = ivi_layout_get_properties_of_layer,
2341 .get_layers_under_surface = ivi_layout_get_layers_under_surface,
2342 .get_layers_on_screen = ivi_layout_get_layers_on_screen,
2343 .layer_set_visibility = ivi_layout_layer_set_visibility,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002344 .layer_set_opacity = ivi_layout_layer_set_opacity,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002345 .layer_set_source_rectangle = ivi_layout_layer_set_source_rectangle,
2346 .layer_set_destination_rectangle = ivi_layout_layer_set_destination_rectangle,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002347 .layer_set_orientation = ivi_layout_layer_set_orientation,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002348 .layer_add_surface = ivi_layout_layer_add_surface,
2349 .layer_remove_surface = ivi_layout_layer_remove_surface,
2350 .layer_set_render_order = ivi_layout_layer_set_render_order,
2351 .layer_add_notification = ivi_layout_layer_add_notification,
2352 .layer_remove_notification = ivi_layout_layer_remove_notification,
2353 .layer_set_transition = ivi_layout_layer_set_transition,
2354
2355 /**
Ucan, Emre (ADITG/SW1)6d89b1c2016-03-17 15:30:49 +00002356 * screen controller interfaces
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002357 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002358 .get_screens_under_layer = ivi_layout_get_screens_under_layer,
2359 .screen_add_layer = ivi_layout_screen_add_layer,
2360 .screen_set_render_order = ivi_layout_screen_set_render_order,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002361
2362 /**
2363 * animation
2364 */
2365 .transition_move_layer_cancel = ivi_layout_transition_move_layer_cancel,
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09002366 .layer_set_fade_info = ivi_layout_layer_set_fade_info,
2367
2368 /**
2369 * surface content dumping for debugging
2370 */
2371 .surface_get_size = ivi_layout_surface_get_size,
2372 .surface_dump = ivi_layout_surface_dump,
Nobuhiko Tanibata82051702015-06-22 15:31:26 +09002373
2374 /**
Nobuhiko Tanibatadb8efd12015-06-22 15:31:39 +09002375 * remove notification by callback on property changes of ivi_surface/layer
Nobuhiko Tanibata82051702015-06-22 15:31:26 +09002376 */
Ucan, Emre (ADITG/SW1)d56b90d2016-03-17 15:30:32 +00002377 .layer_remove_notification_by_callback = ivi_layout_layer_remove_notification_by_callback
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002378};
2379
2380int
2381load_controller_modules(struct weston_compositor *compositor, const char *modules,
2382 int *argc, char *argv[])
2383{
2384 const char *p, *end;
2385 char buffer[256];
2386 int (*controller_module_init)(struct weston_compositor *compositor,
2387 int *argc, char *argv[],
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002388 const struct ivi_layout_interface *interface,
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002389 size_t interface_version);
2390
2391 if (modules == NULL)
2392 return 0;
2393
2394 p = modules;
2395 while (*p) {
2396 end = strchrnul(p, ',');
2397 snprintf(buffer, sizeof buffer, "%.*s", (int)(end - p), p);
2398
2399 controller_module_init = weston_load_module(buffer, "controller_module_init");
Pekka Paalanen97246c02015-03-26 15:47:29 +02002400 if (!controller_module_init)
2401 return -1;
2402
2403 if (controller_module_init(compositor, argc, argv,
Ucan, Emre \(ADITG/SW1\)0c0e51e2015-10-15 14:51:41 +00002404 &ivi_layout_interface,
2405 sizeof(struct ivi_layout_interface)) != 0) {
Pekka Paalanen97246c02015-03-26 15:47:29 +02002406 weston_log("ivi-shell: Initialization of controller module fails");
2407 return -1;
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002408 }
2409
2410 p = end;
2411 while (*p == ',')
2412 p++;
2413 }
2414
2415 return 0;
2416}