blob: c39e751bab993400177df9bbd354a3007f76008f [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>
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090061
62#include "compositor.h"
63#include "ivi-layout-export.h"
64#include "ivi-layout-private.h"
65
Jon Cruz867d50e2015-06-15 15:37:10 -070066#include "shared/helpers.h"
Jon Cruz4678bab2015-06-15 15:37:07 -070067#include "shared/os-compatibility.h"
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +090068
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +090069struct link_layer {
70 struct ivi_layout_layer *ivilayer;
71 struct wl_list link;
72 struct wl_list link_to_layer;
73};
74
75struct link_screen {
76 struct ivi_layout_screen *iviscrn;
77 struct wl_list link;
78 struct wl_list link_to_screen;
79};
80
81struct listener_layout_notification {
82 void *userdata;
83 struct wl_listener listener;
84};
85
86struct ivi_layout;
87
88struct ivi_layout_screen {
89 struct wl_list link;
90 struct wl_list link_to_layer;
91 uint32_t id_screen;
92
93 struct ivi_layout *layout;
94 struct weston_output *output;
95
96 uint32_t event_mask;
97
98 struct {
99 struct wl_list layer_list;
100 struct wl_list link;
101 } pending;
102
103 struct {
104 struct wl_list layer_list;
105 struct wl_list link;
106 } order;
107};
108
109struct ivi_layout_notification_callback {
110 void *callback;
111 void *data;
112};
113
Nobuhiko Tanibata82051702015-06-22 15:31:26 +0900114static void
115remove_notification(struct wl_list *listener_list, void *callback, void *userdata);
116
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900117static struct ivi_layout ivilayout = {0};
118
119struct ivi_layout *
120get_instance(void)
121{
122 return &ivilayout;
123}
124
125/**
126 * Internal API to add/remove a link to ivi_surface from ivi_layer.
127 */
128static void
129add_link_to_surface(struct ivi_layout_layer *ivilayer,
130 struct link_layer *link_layer)
131{
132 struct link_layer *link = NULL;
133
134 wl_list_for_each(link, &ivilayer->link_to_surface, link_to_layer) {
135 if (link == link_layer)
136 return;
137 }
138
139 wl_list_insert(&ivilayer->link_to_surface, &link_layer->link_to_layer);
140}
141
142static void
143remove_link_to_surface(struct ivi_layout_layer *ivilayer)
144{
145 struct link_layer *link = NULL;
146 struct link_layer *next = NULL;
147
148 wl_list_for_each_safe(link, next, &ivilayer->link_to_surface, link_to_layer) {
149 if (!wl_list_empty(&link->link_to_layer)) {
150 wl_list_remove(&link->link_to_layer);
151 }
152 if (!wl_list_empty(&link->link)) {
153 wl_list_remove(&link->link);
154 }
155 free(link);
156 }
157
158 wl_list_init(&ivilayer->link_to_surface);
159}
160
161/**
162 * Internal API to add a link to ivi_layer from ivi_screen.
163 */
164static void
165add_link_to_layer(struct ivi_layout_screen *iviscrn,
166 struct link_screen *link_screen)
167{
168 wl_list_init(&link_screen->link_to_screen);
169 wl_list_insert(&iviscrn->link_to_layer, &link_screen->link_to_screen);
170}
171
172/**
173 * Internal API to add/remove a ivi_surface from ivi_layer.
174 */
175static void
176add_ordersurface_to_layer(struct ivi_layout_surface *ivisurf,
177 struct ivi_layout_layer *ivilayer)
178{
179 struct link_layer *link_layer = NULL;
180
181 link_layer = malloc(sizeof *link_layer);
182 if (link_layer == NULL) {
183 weston_log("fails to allocate memory\n");
184 return;
185 }
186
187 link_layer->ivilayer = ivilayer;
188 wl_list_init(&link_layer->link);
189 wl_list_insert(&ivisurf->layer_list, &link_layer->link);
190 add_link_to_surface(ivilayer, link_layer);
191}
192
193static void
194remove_ordersurface_from_layer(struct ivi_layout_surface *ivisurf)
195{
196 struct link_layer *link_layer = NULL;
197 struct link_layer *next = NULL;
198
199 wl_list_for_each_safe(link_layer, next, &ivisurf->layer_list, link) {
200 if (!wl_list_empty(&link_layer->link)) {
201 wl_list_remove(&link_layer->link);
202 }
203 if (!wl_list_empty(&link_layer->link_to_layer)) {
204 wl_list_remove(&link_layer->link_to_layer);
205 }
206 free(link_layer);
207 }
208 wl_list_init(&ivisurf->layer_list);
209}
210
211/**
212 * Internal API to add/remove a ivi_layer to/from ivi_screen.
213 */
214static void
215add_orderlayer_to_screen(struct ivi_layout_layer *ivilayer,
216 struct ivi_layout_screen *iviscrn)
217{
218 struct link_screen *link_scrn = NULL;
219
220 link_scrn = malloc(sizeof *link_scrn);
221 if (link_scrn == NULL) {
222 weston_log("fails to allocate memory\n");
223 return;
224 }
225
226 link_scrn->iviscrn = iviscrn;
227 wl_list_init(&link_scrn->link);
228 wl_list_insert(&ivilayer->screen_list, &link_scrn->link);
229 add_link_to_layer(iviscrn, link_scrn);
230}
231
232static void
233remove_orderlayer_from_screen(struct ivi_layout_layer *ivilayer)
234{
235 struct link_screen *link_scrn = NULL;
236 struct link_screen *next = NULL;
237
238 wl_list_for_each_safe(link_scrn, next, &ivilayer->screen_list, link) {
239 if (!wl_list_empty(&link_scrn->link)) {
240 wl_list_remove(&link_scrn->link);
241 }
242 if (!wl_list_empty(&link_scrn->link_to_screen)) {
243 wl_list_remove(&link_scrn->link_to_screen);
244 }
245 free(link_scrn);
246 }
247 wl_list_init(&ivilayer->screen_list);
248}
249
250/**
251 * Internal API to add/remove a ivi_layer to/from ivi_screen.
252 */
253static struct ivi_layout_surface *
254get_surface(struct wl_list *surf_list, uint32_t id_surface)
255{
256 struct ivi_layout_surface *ivisurf;
257
258 wl_list_for_each(ivisurf, surf_list, link) {
259 if (ivisurf->id_surface == id_surface) {
260 return ivisurf;
261 }
262 }
263
264 return NULL;
265}
266
267static struct ivi_layout_layer *
268get_layer(struct wl_list *layer_list, uint32_t id_layer)
269{
270 struct ivi_layout_layer *ivilayer;
271
272 wl_list_for_each(ivilayer, layer_list, link) {
273 if (ivilayer->id_layer == id_layer) {
274 return ivilayer;
275 }
276 }
277
278 return NULL;
279}
280
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900281static void
282remove_configured_listener(struct ivi_layout_surface *ivisurf)
283{
284 struct wl_listener *link = NULL;
285 struct wl_listener *next = NULL;
286
287 wl_list_for_each_safe(link, next, &ivisurf->configured.listener_list, link) {
288 wl_list_remove(&link->link);
289 }
290}
291
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900292static void
293remove_all_notification(struct wl_list *listener_list)
294{
295 struct wl_listener *listener = NULL;
296 struct wl_listener *next = NULL;
297
298 wl_list_for_each_safe(listener, next, listener_list, link) {
299 struct listener_layout_notification *notification = NULL;
300 if (!wl_list_empty(&listener->link)) {
301 wl_list_remove(&listener->link);
302 }
303
304 notification =
305 container_of(listener,
306 struct listener_layout_notification,
307 listener);
308
309 free(notification->userdata);
310 free(notification);
311 }
312}
313
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900314static void
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900315ivi_layout_surface_remove_notification(struct ivi_layout_surface *ivisurf)
316{
317 if (ivisurf == NULL) {
318 weston_log("ivi_layout_surface_remove_notification: invalid argument\n");
319 return;
320 }
321
322 remove_all_notification(&ivisurf->property_changed.listener_list);
323}
324
Nobuhiko Tanibata82051702015-06-22 15:31:26 +0900325static void
326ivi_layout_surface_remove_notification_by_callback(struct ivi_layout_surface *ivisurf,
327 surface_property_notification_func callback,
328 void *userdata)
329{
330 if (ivisurf == NULL) {
331 weston_log("ivi_layout_surface_remove_notification_by_callback: invalid argument\n");
332 return;
333 }
334
335 remove_notification(&ivisurf->property_changed.listener_list, callback, userdata);
336}
337
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900338/**
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900339 * Called at destruction of wl_surface/ivi_surface
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +0900340 */
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900341void
342ivi_layout_surface_destroy(struct ivi_layout_surface *ivisurf)
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900343{
344 struct ivi_layout *layout = get_instance();
345
346 if (ivisurf == NULL) {
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900347 weston_log("%s: invalid argument\n", __func__);
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900348 return;
349 }
350
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900351 wl_list_remove(&ivisurf->surface_rotation.link);
352 wl_list_remove(&ivisurf->layer_rotation.link);
353 wl_list_remove(&ivisurf->surface_pos.link);
354 wl_list_remove(&ivisurf->layer_pos.link);
355 wl_list_remove(&ivisurf->scaling.link);
356
357 wl_list_remove(&ivisurf->pending.link);
358 wl_list_remove(&ivisurf->order.link);
359 wl_list_remove(&ivisurf->link);
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +0900360 remove_ordersurface_from_layer(ivisurf);
361
362 wl_signal_emit(&layout->surface_notification.removed, ivisurf);
363
364 remove_configured_listener(ivisurf);
365
366 ivi_layout_surface_remove_notification(ivisurf);
367
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900368 ivisurf->surface = NULL;
Nobuhiko Tanibata6f6c9382015-06-22 15:30:53 +0900369
370 free(ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900371}
372
373/**
374 * Internal API to check ivi_layer/ivi_surface already added in ivi_layer/ivi_screen.
375 * Called by ivi_layout_layer_add_surface/ivi_layout_screenAddLayer
376 */
377static int
378is_surface_in_layer(struct ivi_layout_surface *ivisurf,
379 struct ivi_layout_layer *ivilayer)
380{
381 struct ivi_layout_surface *surf = NULL;
382
383 wl_list_for_each(surf, &ivilayer->pending.surface_list, pending.link) {
384 if (surf->id_surface == ivisurf->id_surface) {
385 return 1;
386 }
387 }
388
389 return 0;
390}
391
392static int
393is_layer_in_screen(struct ivi_layout_layer *ivilayer,
394 struct ivi_layout_screen *iviscrn)
395{
396 struct ivi_layout_layer *layer = NULL;
397
398 wl_list_for_each(layer, &iviscrn->pending.layer_list, pending.link) {
399 if (layer->id_layer == ivilayer->id_layer) {
400 return 1;
401 }
402 }
403
404 return 0;
405}
406
407/**
408 * Internal API to initialize ivi_screens found from output_list of weston_compositor.
409 * Called by ivi_layout_init_with_compositor.
410 */
411static void
412create_screen(struct weston_compositor *ec)
413{
414 struct ivi_layout *layout = get_instance();
415 struct ivi_layout_screen *iviscrn = NULL;
416 struct weston_output *output = NULL;
417 int32_t count = 0;
418
419 wl_list_for_each(output, &ec->output_list, link) {
420 iviscrn = calloc(1, sizeof *iviscrn);
421 if (iviscrn == NULL) {
422 weston_log("fails to allocate memory\n");
423 continue;
424 }
425
426 wl_list_init(&iviscrn->link);
427 iviscrn->layout = layout;
428
429 iviscrn->id_screen = count;
430 count++;
431
432 iviscrn->output = output;
433 iviscrn->event_mask = 0;
434
435 wl_list_init(&iviscrn->pending.layer_list);
436 wl_list_init(&iviscrn->pending.link);
437
438 wl_list_init(&iviscrn->order.layer_list);
439 wl_list_init(&iviscrn->order.link);
440
441 wl_list_init(&iviscrn->link_to_layer);
442
443 wl_list_insert(&layout->screen_list, &iviscrn->link);
444 }
445}
446
447/**
448 * Internal APIs to initialize properties of ivi_surface/ivi_layer when they are created.
449 */
450static void
451init_layer_properties(struct ivi_layout_layer_properties *prop,
452 int32_t width, int32_t height)
453{
454 memset(prop, 0, sizeof *prop);
455 prop->opacity = wl_fixed_from_double(1.0);
456 prop->source_width = width;
457 prop->source_height = height;
458 prop->dest_width = width;
459 prop->dest_height = height;
460}
461
462static void
463init_surface_properties(struct ivi_layout_surface_properties *prop)
464{
465 memset(prop, 0, sizeof *prop);
466 prop->opacity = wl_fixed_from_double(1.0);
Nobuhiko Tanibatae259a7a2015-04-27 17:02:54 +0900467 /*
468 * FIXME: this shall be finxed by ivi-layout-transition.
469 */
470 prop->dest_width = 1;
471 prop->dest_height = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900472}
473
474/**
475 * Internal APIs to be called from ivi_layout_commit_changes.
476 */
477static void
478update_opacity(struct ivi_layout_layer *ivilayer,
479 struct ivi_layout_surface *ivisurf)
480{
481 double layer_alpha = wl_fixed_to_double(ivilayer->prop.opacity);
482 double surf_alpha = wl_fixed_to_double(ivisurf->prop.opacity);
483
484 if ((ivilayer->event_mask & IVI_NOTIFICATION_OPACITY) ||
485 (ivisurf->event_mask & IVI_NOTIFICATION_OPACITY)) {
486 struct weston_view *tmpview = NULL;
487 wl_list_for_each(tmpview, &ivisurf->surface->views, surface_link) {
488 if (tmpview == NULL) {
489 continue;
490 }
491 tmpview->alpha = layer_alpha * surf_alpha;
492 }
493 }
494}
495
496static void
497update_surface_orientation(struct ivi_layout_layer *ivilayer,
498 struct ivi_layout_surface *ivisurf)
499{
500 struct weston_view *view;
501 struct weston_matrix *matrix = &ivisurf->surface_rotation.matrix;
502 float width = 0.0f;
503 float height = 0.0f;
504 float v_sin = 0.0f;
505 float v_cos = 0.0f;
506 float cx = 0.0f;
507 float cy = 0.0f;
508 float sx = 1.0f;
509 float sy = 1.0f;
510
511 wl_list_for_each(view, &ivisurf->surface->views, surface_link) {
512 if (view != NULL) {
513 break;
514 }
515 }
516
517 if (view == NULL) {
518 return;
519 }
520
521 if ((ivilayer->prop.dest_width == 0) ||
522 (ivilayer->prop.dest_height == 0)) {
523 return;
524 }
525 width = (float)ivilayer->prop.dest_width;
526 height = (float)ivilayer->prop.dest_height;
527
528 switch (ivisurf->prop.orientation) {
529 case WL_OUTPUT_TRANSFORM_NORMAL:
530 v_sin = 0.0f;
531 v_cos = 1.0f;
532 break;
533 case WL_OUTPUT_TRANSFORM_90:
534 v_sin = 1.0f;
535 v_cos = 0.0f;
536 sx = width / height;
537 sy = height / width;
538 break;
539 case WL_OUTPUT_TRANSFORM_180:
540 v_sin = 0.0f;
541 v_cos = -1.0f;
542 break;
543 case WL_OUTPUT_TRANSFORM_270:
544 default:
545 v_sin = -1.0f;
546 v_cos = 0.0f;
547 sx = width / height;
548 sy = height / width;
549 break;
550 }
551 wl_list_remove(&ivisurf->surface_rotation.link);
552 weston_view_geometry_dirty(view);
553
554 weston_matrix_init(matrix);
555 cx = 0.5f * width;
556 cy = 0.5f * height;
557 weston_matrix_translate(matrix, -cx, -cy, 0.0f);
558 weston_matrix_rotate_xy(matrix, v_cos, v_sin);
559 weston_matrix_scale(matrix, sx, sy, 1.0);
560 weston_matrix_translate(matrix, cx, cy, 0.0f);
561 wl_list_insert(&view->geometry.transformation_list,
562 &ivisurf->surface_rotation.link);
563
564 weston_view_set_transform_parent(view, NULL);
565 weston_view_update_transform(view);
566}
567
568static void
569update_layer_orientation(struct ivi_layout_layer *ivilayer,
570 struct ivi_layout_surface *ivisurf)
571{
572 struct weston_surface *es = ivisurf->surface;
573 struct weston_view *view;
574 struct weston_matrix *matrix = &ivisurf->layer_rotation.matrix;
575 struct weston_output *output = NULL;
576 float width = 0.0f;
577 float height = 0.0f;
578 float v_sin = 0.0f;
579 float v_cos = 0.0f;
580 float cx = 0.0f;
581 float cy = 0.0f;
582 float sx = 1.0f;
583 float sy = 1.0f;
584
585 wl_list_for_each(view, &ivisurf->surface->views, surface_link) {
586 if (view != NULL) {
587 break;
588 }
589 }
590
591 if (es == NULL || view == NULL) {
592 return;
593 }
594
595 output = es->output;
596 if (output == NULL) {
597 return;
598 }
599 if ((output->width == 0) || (output->height == 0)) {
600 return;
601 }
602 width = (float)output->width;
603 height = (float)output->height;
604
605 switch (ivilayer->prop.orientation) {
606 case WL_OUTPUT_TRANSFORM_NORMAL:
607 v_sin = 0.0f;
608 v_cos = 1.0f;
609 break;
610 case WL_OUTPUT_TRANSFORM_90:
611 v_sin = 1.0f;
612 v_cos = 0.0f;
613 sx = width / height;
614 sy = height / width;
615 break;
616 case WL_OUTPUT_TRANSFORM_180:
617 v_sin = 0.0f;
618 v_cos = -1.0f;
619 break;
620 case WL_OUTPUT_TRANSFORM_270:
621 default:
622 v_sin = -1.0f;
623 v_cos = 0.0f;
624 sx = width / height;
625 sy = height / width;
626 break;
627 }
628 wl_list_remove(&ivisurf->layer_rotation.link);
629 weston_view_geometry_dirty(view);
630
631 weston_matrix_init(matrix);
632 cx = 0.5f * width;
633 cy = 0.5f * height;
634 weston_matrix_translate(matrix, -cx, -cy, 0.0f);
635 weston_matrix_rotate_xy(matrix, v_cos, v_sin);
636 weston_matrix_scale(matrix, sx, sy, 1.0);
637 weston_matrix_translate(matrix, cx, cy, 0.0f);
638 wl_list_insert(&view->geometry.transformation_list,
639 &ivisurf->layer_rotation.link);
640
641 weston_view_set_transform_parent(view, NULL);
642 weston_view_update_transform(view);
643}
644
645static void
646update_surface_position(struct ivi_layout_surface *ivisurf)
647{
648 struct weston_view *view;
649 float tx = (float)ivisurf->prop.dest_x;
650 float ty = (float)ivisurf->prop.dest_y;
651 struct weston_matrix *matrix = &ivisurf->surface_pos.matrix;
652
653 wl_list_for_each(view, &ivisurf->surface->views, surface_link) {
654 if (view != NULL) {
655 break;
656 }
657 }
658
659 if (view == NULL) {
660 return;
661 }
662
663 wl_list_remove(&ivisurf->surface_pos.link);
664
665 weston_matrix_init(matrix);
666 weston_matrix_translate(matrix, tx, ty, 0.0f);
667 wl_list_insert(&view->geometry.transformation_list,
668 &ivisurf->surface_pos.link);
669
670 weston_view_set_transform_parent(view, NULL);
671 weston_view_update_transform(view);
672}
673
674static void
675update_layer_position(struct ivi_layout_layer *ivilayer,
676 struct ivi_layout_surface *ivisurf)
677{
678 struct weston_view *view;
679 struct weston_matrix *matrix = &ivisurf->layer_pos.matrix;
680 float tx = (float)ivilayer->prop.dest_x;
681 float ty = (float)ivilayer->prop.dest_y;
682
683 wl_list_for_each(view, &ivisurf->surface->views, surface_link) {
684 if (view != NULL) {
685 break;
686 }
687 }
688
689 if (view == NULL) {
690 return;
691 }
692
693 wl_list_remove(&ivisurf->layer_pos.link);
694
695 weston_matrix_init(matrix);
696 weston_matrix_translate(matrix, tx, ty, 0.0f);
697 wl_list_insert(&view->geometry.transformation_list,
698 &ivisurf->layer_pos.link);
699
700 weston_view_set_transform_parent(view, NULL);
701 weston_view_update_transform(view);
702}
703
704static void
705update_scale(struct ivi_layout_layer *ivilayer,
706 struct ivi_layout_surface *ivisurf)
707{
708 struct weston_view *view;
709 struct weston_matrix *matrix = &ivisurf->scaling.matrix;
710 float sx = 0.0f;
711 float sy = 0.0f;
712 float lw = 0.0f;
713 float sw = 0.0f;
714 float lh = 0.0f;
715 float sh = 0.0f;
716
717 wl_list_for_each(view, &ivisurf->surface->views, surface_link) {
718 if (view != NULL) {
719 break;
720 }
721 }
722
723 if (view == NULL) {
724 return;
725 }
726
Nobuhiko Tanibatabcff6322015-04-27 16:57:26 +0900727 if (ivisurf->prop.source_width == 0 || ivisurf->prop.source_height == 0) {
728 weston_log("ivi-shell: source rectangle is not yet set by ivi_layout_surface_set_source_rectangle\n");
729 return;
730 }
731
732 if (ivisurf->prop.dest_width == 0 || ivisurf->prop.dest_height == 0) {
733 weston_log("ivi-shell: destination rectangle is not yet set by ivi_layout_surface_set_destination_rectangle\n");
734 return;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +0900735 }
736
737 lw = ((float)ivilayer->prop.dest_width / (float)ivilayer->prop.source_width );
738 sw = ((float)ivisurf->prop.dest_width / (float)ivisurf->prop.source_width );
739 lh = ((float)ivilayer->prop.dest_height / (float)ivilayer->prop.source_height);
740 sh = ((float)ivisurf->prop.dest_height / (float)ivisurf->prop.source_height );
741 sx = sw * lw;
742 sy = sh * lh;
743
744 wl_list_remove(&ivisurf->scaling.link);
745 weston_matrix_init(matrix);
746 weston_matrix_scale(matrix, sx, sy, 1.0f);
747
748 wl_list_insert(&view->geometry.transformation_list,
749 &ivisurf->scaling.link);
750
751 weston_view_set_transform_parent(view, NULL);
752 weston_view_update_transform(view);
753}
754
755static void
756update_prop(struct ivi_layout_layer *ivilayer,
757 struct ivi_layout_surface *ivisurf)
758{
759 if (ivilayer->event_mask | ivisurf->event_mask) {
760 struct weston_view *tmpview;
761 update_opacity(ivilayer, ivisurf);
762 update_layer_orientation(ivilayer, ivisurf);
763 update_layer_position(ivilayer, ivisurf);
764 update_surface_position(ivisurf);
765 update_surface_orientation(ivilayer, ivisurf);
766 update_scale(ivilayer, ivisurf);
767
768 ivisurf->update_count++;
769
770 wl_list_for_each(tmpview, &ivisurf->surface->views, surface_link) {
771 if (tmpview != NULL) {
772 break;
773 }
774 }
775
776 if (tmpview != NULL) {
777 weston_view_geometry_dirty(tmpview);
778 }
779
780 if (ivisurf->surface != NULL) {
781 weston_surface_damage(ivisurf->surface);
782 }
783 }
784}
785
786static void
787commit_changes(struct ivi_layout *layout)
788{
789 struct ivi_layout_screen *iviscrn = NULL;
790 struct ivi_layout_layer *ivilayer = NULL;
791 struct ivi_layout_surface *ivisurf = NULL;
792
793 wl_list_for_each(iviscrn, &layout->screen_list, link) {
794 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
795 wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) {
796 update_prop(ivilayer, ivisurf);
797 }
798 }
799 }
800}
801
802static void
803commit_surface_list(struct ivi_layout *layout)
804{
805 struct ivi_layout_surface *ivisurf = NULL;
806 int32_t dest_x = 0;
807 int32_t dest_y = 0;
808 int32_t dest_width = 0;
809 int32_t dest_height = 0;
810 int32_t configured = 0;
811
812 wl_list_for_each(ivisurf, &layout->surface_list, link) {
813 if(ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEFAULT) {
814 dest_x = ivisurf->prop.dest_x;
815 dest_y = ivisurf->prop.dest_y;
816 dest_width = ivisurf->prop.dest_width;
817 dest_height = ivisurf->prop.dest_height;
818
819 ivi_layout_transition_move_resize_view(ivisurf,
820 ivisurf->pending.prop.dest_x,
821 ivisurf->pending.prop.dest_y,
822 ivisurf->pending.prop.dest_width,
823 ivisurf->pending.prop.dest_height,
824 ivisurf->pending.prop.transition_duration);
825
826 if(ivisurf->pending.prop.visibility) {
827 ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration);
828 } else {
829 ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration);
830 }
831
832 ivisurf->prop = ivisurf->pending.prop;
833 ivisurf->prop.dest_x = dest_x;
834 ivisurf->prop.dest_y = dest_y;
835 ivisurf->prop.dest_width = dest_width;
836 ivisurf->prop.dest_height = dest_height;
837 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
838 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
839
840 } else if(ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEST_RECT_ONLY){
841 dest_x = ivisurf->prop.dest_x;
842 dest_y = ivisurf->prop.dest_y;
843 dest_width = ivisurf->prop.dest_width;
844 dest_height = ivisurf->prop.dest_height;
845
846 ivi_layout_transition_move_resize_view(ivisurf,
847 ivisurf->pending.prop.dest_x,
848 ivisurf->pending.prop.dest_y,
849 ivisurf->pending.prop.dest_width,
850 ivisurf->pending.prop.dest_height,
851 ivisurf->pending.prop.transition_duration);
852
853 ivisurf->prop = ivisurf->pending.prop;
854 ivisurf->prop.dest_x = dest_x;
855 ivisurf->prop.dest_y = dest_y;
856 ivisurf->prop.dest_width = dest_width;
857 ivisurf->prop.dest_height = dest_height;
858
859 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
860 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
861
862 } else if(ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY){
863 configured = 0;
864 if(ivisurf->pending.prop.visibility) {
865 ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration);
866 } else {
867 ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration);
868 }
869
870 if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width ||
871 ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) {
872 configured = 1;
873 }
874
875 ivisurf->prop = ivisurf->pending.prop;
876 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
877 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
878
879 if (configured && !is_surface_transition(ivisurf))
880 wl_signal_emit(&ivisurf->configured, ivisurf);
881 } else {
882 configured = 0;
883 if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width ||
884 ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) {
885 configured = 1;
886 }
887
888 ivisurf->prop = ivisurf->pending.prop;
889 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
890 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
891
892 if (configured && !is_surface_transition(ivisurf))
893 wl_signal_emit(&ivisurf->configured, ivisurf);
894 }
895 }
896}
897
898static void
899commit_layer_list(struct ivi_layout *layout)
900{
901 struct ivi_layout_layer *ivilayer = NULL;
902 struct ivi_layout_surface *ivisurf = NULL;
903 struct ivi_layout_surface *next = NULL;
904
905 wl_list_for_each(ivilayer, &layout->layer_list, link) {
906 if(ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_MOVE) {
907 ivi_layout_transition_move_layer(ivilayer, ivilayer->pending.prop.dest_x, ivilayer->pending.prop.dest_y, ivilayer->pending.prop.transition_duration);
908 } else if(ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_FADE) {
909 ivi_layout_transition_fade_layer(ivilayer,ivilayer->pending.prop.is_fade_in,
910 ivilayer->pending.prop.start_alpha,ivilayer->pending.prop.end_alpha,
911 NULL, NULL,
912 ivilayer->pending.prop.transition_duration);
913 }
914 ivilayer->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
915
916 ivilayer->prop = ivilayer->pending.prop;
917
918 if (!(ivilayer->event_mask &
919 (IVI_NOTIFICATION_ADD | IVI_NOTIFICATION_REMOVE)) ) {
920 continue;
921 }
922
923 if (ivilayer->event_mask & IVI_NOTIFICATION_REMOVE) {
924 wl_list_for_each_safe(ivisurf, next,
925 &ivilayer->order.surface_list, order.link) {
926 remove_ordersurface_from_layer(ivisurf);
927
928 if (!wl_list_empty(&ivisurf->order.link)) {
929 wl_list_remove(&ivisurf->order.link);
930 }
931
932 wl_list_init(&ivisurf->order.link);
933 ivisurf->event_mask |= IVI_NOTIFICATION_REMOVE;
934 }
935
936 wl_list_init(&ivilayer->order.surface_list);
937 }
938
939 if (ivilayer->event_mask & IVI_NOTIFICATION_ADD) {
940 wl_list_for_each_safe(ivisurf, next,
941 &ivilayer->order.surface_list, order.link) {
942 remove_ordersurface_from_layer(ivisurf);
943
944 if (!wl_list_empty(&ivisurf->order.link)) {
945 wl_list_remove(&ivisurf->order.link);
946 }
947
948 wl_list_init(&ivisurf->order.link);
949 }
950
951 wl_list_init(&ivilayer->order.surface_list);
952 wl_list_for_each(ivisurf, &ivilayer->pending.surface_list,
953 pending.link) {
954 if(!wl_list_empty(&ivisurf->order.link)){
955 wl_list_remove(&ivisurf->order.link);
956 wl_list_init(&ivisurf->order.link);
957 }
958
959 wl_list_insert(&ivilayer->order.surface_list,
960 &ivisurf->order.link);
961 add_ordersurface_to_layer(ivisurf, ivilayer);
962 ivisurf->event_mask |= IVI_NOTIFICATION_ADD;
963 }
964 }
965 }
966}
967
968static void
969commit_screen_list(struct ivi_layout *layout)
970{
971 struct ivi_layout_screen *iviscrn = NULL;
972 struct ivi_layout_layer *ivilayer = NULL;
973 struct ivi_layout_layer *next = NULL;
974 struct ivi_layout_surface *ivisurf = NULL;
975
976 wl_list_for_each(iviscrn, &layout->screen_list, link) {
977 if (iviscrn->event_mask & IVI_NOTIFICATION_REMOVE) {
978 wl_list_for_each_safe(ivilayer, next,
979 &iviscrn->order.layer_list, order.link) {
980 remove_orderlayer_from_screen(ivilayer);
981
982 if (!wl_list_empty(&ivilayer->order.link)) {
983 wl_list_remove(&ivilayer->order.link);
984 }
985
986 wl_list_init(&ivilayer->order.link);
987 ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE;
988 }
989 }
990
991 if (iviscrn->event_mask & IVI_NOTIFICATION_ADD) {
992 wl_list_for_each_safe(ivilayer, next,
993 &iviscrn->order.layer_list, order.link) {
994 remove_orderlayer_from_screen(ivilayer);
995
996 if (!wl_list_empty(&ivilayer->order.link)) {
997 wl_list_remove(&ivilayer->order.link);
998 }
999
1000 wl_list_init(&ivilayer->order.link);
1001 }
1002
1003 wl_list_init(&iviscrn->order.layer_list);
1004 wl_list_for_each(ivilayer, &iviscrn->pending.layer_list,
1005 pending.link) {
1006 wl_list_insert(&iviscrn->order.layer_list,
1007 &ivilayer->order.link);
1008 add_orderlayer_to_screen(ivilayer, iviscrn);
1009 ivilayer->event_mask |= IVI_NOTIFICATION_ADD;
1010 }
1011 }
1012
1013 iviscrn->event_mask = 0;
1014
1015 /* Clear view list of layout ivi_layer */
1016 wl_list_init(&layout->layout_layer.view_list.link);
1017
1018 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
1019 if (ivilayer->prop.visibility == false)
1020 continue;
1021
1022 wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) {
1023 struct weston_view *tmpview = NULL;
1024 wl_list_for_each(tmpview, &ivisurf->surface->views, surface_link) {
1025 if (tmpview != NULL) {
1026 break;
1027 }
1028 }
1029
1030 if (ivisurf->prop.visibility == false)
1031 continue;
1032 if (ivisurf->surface == NULL || tmpview == NULL)
1033 continue;
1034
1035 weston_layer_entry_insert(&layout->layout_layer.view_list,
1036 &tmpview->layer_link);
1037
1038 ivisurf->surface->output = iviscrn->output;
1039 }
1040 }
1041
1042 break;
1043 }
1044}
1045
1046static void
1047commit_transition(struct ivi_layout* layout)
1048{
1049 if(wl_list_empty(&layout->pending_transition_list)){
1050 return;
1051 }
1052
1053 wl_list_insert_list(&layout->transitions->transition_list,
1054 &layout->pending_transition_list);
1055
1056 wl_list_init(&layout->pending_transition_list);
1057
1058 wl_event_source_timer_update(layout->transitions->event_source, 1);
1059}
1060
1061static void
1062send_surface_prop(struct ivi_layout_surface *ivisurf)
1063{
1064 wl_signal_emit(&ivisurf->property_changed, ivisurf);
1065 ivisurf->event_mask = 0;
1066}
1067
1068static void
1069send_layer_prop(struct ivi_layout_layer *ivilayer)
1070{
1071 wl_signal_emit(&ivilayer->property_changed, ivilayer);
1072 ivilayer->event_mask = 0;
1073}
1074
1075static void
1076send_prop(struct ivi_layout *layout)
1077{
1078 struct ivi_layout_layer *ivilayer = NULL;
1079 struct ivi_layout_surface *ivisurf = NULL;
1080
1081 wl_list_for_each_reverse(ivilayer, &layout->layer_list, link) {
Nobuhiko Tanibata6ce3ef82015-06-22 15:32:06 +09001082 if (ivilayer->event_mask)
1083 send_layer_prop(ivilayer);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001084 }
1085
1086 wl_list_for_each_reverse(ivisurf, &layout->surface_list, link) {
Nobuhiko Tanibata6ce3ef82015-06-22 15:32:06 +09001087 if (ivisurf->event_mask)
1088 send_surface_prop(ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001089 }
1090}
1091
1092static void
1093clear_surface_pending_list(struct ivi_layout_layer *ivilayer)
1094{
1095 struct ivi_layout_surface *surface_link = NULL;
1096 struct ivi_layout_surface *surface_next = NULL;
1097
1098 wl_list_for_each_safe(surface_link, surface_next,
1099 &ivilayer->pending.surface_list, pending.link) {
1100 if (!wl_list_empty(&surface_link->pending.link)) {
1101 wl_list_remove(&surface_link->pending.link);
1102 }
1103
1104 wl_list_init(&surface_link->pending.link);
1105 }
1106
1107 ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE;
1108}
1109
1110static void
1111clear_surface_order_list(struct ivi_layout_layer *ivilayer)
1112{
1113 struct ivi_layout_surface *surface_link = NULL;
1114 struct ivi_layout_surface *surface_next = NULL;
1115
1116 wl_list_for_each_safe(surface_link, surface_next,
1117 &ivilayer->order.surface_list, order.link) {
1118 if (!wl_list_empty(&surface_link->order.link)) {
1119 wl_list_remove(&surface_link->order.link);
1120 }
1121
1122 wl_list_init(&surface_link->order.link);
1123 }
1124
1125 ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE;
1126}
1127
1128static void
1129layer_created(struct wl_listener *listener, void *data)
1130{
1131 struct ivi_layout_layer *ivilayer = data;
1132
1133 struct listener_layout_notification *notification =
1134 container_of(listener,
1135 struct listener_layout_notification,
1136 listener);
1137
1138 struct ivi_layout_notification_callback *created_callback =
1139 notification->userdata;
1140
1141 ((layer_create_notification_func)created_callback->callback)
1142 (ivilayer, created_callback->data);
1143}
1144
1145static void
1146layer_removed(struct wl_listener *listener, void *data)
1147{
1148 struct ivi_layout_layer *ivilayer = data;
1149
1150 struct listener_layout_notification *notification =
1151 container_of(listener,
1152 struct listener_layout_notification,
1153 listener);
1154
1155 struct ivi_layout_notification_callback *removed_callback =
1156 notification->userdata;
1157
1158 ((layer_remove_notification_func)removed_callback->callback)
1159 (ivilayer, removed_callback->data);
1160}
1161
1162static void
1163layer_prop_changed(struct wl_listener *listener, void *data)
1164{
1165 struct ivi_layout_layer *ivilayer = data;
1166
1167 struct listener_layout_notification *layout_listener =
1168 container_of(listener,
1169 struct listener_layout_notification,
1170 listener);
1171
1172 struct ivi_layout_notification_callback *prop_callback =
1173 layout_listener->userdata;
1174
1175 ((layer_property_notification_func)prop_callback->callback)
1176 (ivilayer, &ivilayer->prop, ivilayer->event_mask, prop_callback->data);
1177}
1178
1179static void
1180surface_created(struct wl_listener *listener, void *data)
1181{
1182 struct ivi_layout_surface *ivisurface = data;
1183
1184 struct listener_layout_notification *notification =
1185 container_of(listener,
1186 struct listener_layout_notification,
1187 listener);
1188
1189 struct ivi_layout_notification_callback *created_callback =
1190 notification->userdata;
1191
1192 ((surface_create_notification_func)created_callback->callback)
1193 (ivisurface, created_callback->data);
1194}
1195
1196static void
1197surface_removed(struct wl_listener *listener, void *data)
1198{
1199 struct ivi_layout_surface *ivisurface = data;
1200
1201 struct listener_layout_notification *notification =
1202 container_of(listener,
1203 struct listener_layout_notification,
1204 listener);
1205
1206 struct ivi_layout_notification_callback *removed_callback =
1207 notification->userdata;
1208
1209 ((surface_remove_notification_func)removed_callback->callback)
1210 (ivisurface, removed_callback->data);
1211}
1212
1213static void
1214surface_prop_changed(struct wl_listener *listener, void *data)
1215{
1216 struct ivi_layout_surface *ivisurf = data;
1217
1218 struct listener_layout_notification *layout_listener =
1219 container_of(listener,
1220 struct listener_layout_notification,
1221 listener);
1222
1223 struct ivi_layout_notification_callback *prop_callback =
1224 layout_listener->userdata;
1225
1226 ((surface_property_notification_func)prop_callback->callback)
1227 (ivisurf, &ivisurf->prop, ivisurf->event_mask, prop_callback->data);
1228
1229 ivisurf->event_mask = 0;
1230}
1231
1232static void
1233surface_configure_changed(struct wl_listener *listener,
1234 void *data)
1235{
1236 struct ivi_layout_surface *ivisurface = data;
1237
1238 struct listener_layout_notification *notification =
1239 container_of(listener,
1240 struct listener_layout_notification,
1241 listener);
1242
1243 struct ivi_layout_notification_callback *configure_changed_callback =
1244 notification->userdata;
1245
1246 ((surface_configure_notification_func)configure_changed_callback->callback)
1247 (ivisurface, configure_changed_callback->data);
1248}
1249
1250static int32_t
1251add_notification(struct wl_signal *signal,
1252 wl_notify_func_t callback,
1253 void *userdata)
1254{
1255 struct listener_layout_notification *notification = NULL;
1256
1257 notification = malloc(sizeof *notification);
1258 if (notification == NULL) {
1259 weston_log("fails to allocate memory\n");
1260 free(userdata);
1261 return IVI_FAILED;
1262 }
1263
1264 notification->listener.notify = callback;
1265 notification->userdata = userdata;
1266
1267 wl_signal_add(signal, &notification->listener);
1268
1269 return IVI_SUCCEEDED;
1270}
1271
1272static void
1273remove_notification(struct wl_list *listener_list, void *callback, void *userdata)
1274{
1275 struct wl_listener *listener = NULL;
1276 struct wl_listener *next = NULL;
1277
1278 wl_list_for_each_safe(listener, next, listener_list, link) {
1279 struct listener_layout_notification *notification =
1280 container_of(listener,
1281 struct listener_layout_notification,
1282 listener);
1283
1284 struct ivi_layout_notification_callback *notification_callback =
1285 notification->userdata;
1286
1287 if ((notification_callback->callback != callback) ||
1288 (notification_callback->data != userdata)) {
1289 continue;
1290 }
1291
1292 if (!wl_list_empty(&listener->link)) {
1293 wl_list_remove(&listener->link);
1294 }
1295
1296 free(notification->userdata);
1297 free(notification);
1298 }
1299}
1300
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001301/**
1302 * Exported APIs of ivi-layout library are implemented from here.
1303 * Brief of APIs is described in ivi-layout-export.h.
1304 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001305static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001306ivi_layout_add_notification_create_layer(layer_create_notification_func callback,
1307 void *userdata)
1308{
1309 struct ivi_layout *layout = get_instance();
1310 struct ivi_layout_notification_callback *created_callback = NULL;
1311
1312 if (callback == NULL) {
1313 weston_log("ivi_layout_add_notification_create_layer: invalid argument\n");
1314 return IVI_FAILED;
1315 }
1316
1317 created_callback = malloc(sizeof *created_callback);
1318 if (created_callback == NULL) {
1319 weston_log("fails to allocate memory\n");
1320 return IVI_FAILED;
1321 }
1322
1323 created_callback->callback = callback;
1324 created_callback->data = userdata;
1325
1326 return add_notification(&layout->layer_notification.created,
1327 layer_created,
1328 created_callback);
1329}
1330
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001331static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001332ivi_layout_remove_notification_create_layer(layer_create_notification_func callback,
1333 void *userdata)
1334{
1335 struct ivi_layout *layout = get_instance();
1336 remove_notification(&layout->layer_notification.created.listener_list, callback, userdata);
1337}
1338
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001339static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001340ivi_layout_add_notification_remove_layer(layer_remove_notification_func callback,
1341 void *userdata)
1342{
1343 struct ivi_layout *layout = get_instance();
1344 struct ivi_layout_notification_callback *removed_callback = NULL;
1345
1346 if (callback == NULL) {
1347 weston_log("ivi_layout_add_notification_remove_layer: invalid argument\n");
1348 return IVI_FAILED;
1349 }
1350
1351 removed_callback = malloc(sizeof *removed_callback);
1352 if (removed_callback == NULL) {
1353 weston_log("fails to allocate memory\n");
1354 return IVI_FAILED;
1355 }
1356
1357 removed_callback->callback = callback;
1358 removed_callback->data = userdata;
1359 return add_notification(&layout->layer_notification.removed,
1360 layer_removed,
1361 removed_callback);
1362}
1363
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001364static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001365ivi_layout_remove_notification_remove_layer(layer_remove_notification_func callback,
1366 void *userdata)
1367{
1368 struct ivi_layout *layout = get_instance();
1369 remove_notification(&layout->layer_notification.removed.listener_list, callback, userdata);
1370}
1371
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001372static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001373ivi_layout_add_notification_create_surface(surface_create_notification_func callback,
1374 void *userdata)
1375{
1376 struct ivi_layout *layout = get_instance();
1377 struct ivi_layout_notification_callback *created_callback = NULL;
1378
1379 if (callback == NULL) {
1380 weston_log("ivi_layout_add_notification_create_surface: invalid argument\n");
1381 return IVI_FAILED;
1382 }
1383
1384 created_callback = malloc(sizeof *created_callback);
1385 if (created_callback == NULL) {
1386 weston_log("fails to allocate memory\n");
1387 return IVI_FAILED;
1388 }
1389
1390 created_callback->callback = callback;
1391 created_callback->data = userdata;
1392
1393 return add_notification(&layout->surface_notification.created,
1394 surface_created,
1395 created_callback);
1396}
1397
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001398static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001399ivi_layout_remove_notification_create_surface(surface_create_notification_func callback,
1400 void *userdata)
1401{
1402 struct ivi_layout *layout = get_instance();
1403 remove_notification(&layout->surface_notification.created.listener_list, callback, userdata);
1404}
1405
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001406static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001407ivi_layout_add_notification_remove_surface(surface_remove_notification_func callback,
1408 void *userdata)
1409{
1410 struct ivi_layout *layout = get_instance();
1411 struct ivi_layout_notification_callback *removed_callback = NULL;
1412
1413 if (callback == NULL) {
1414 weston_log("ivi_layout_add_notification_remove_surface: invalid argument\n");
1415 return IVI_FAILED;
1416 }
1417
1418 removed_callback = malloc(sizeof *removed_callback);
1419 if (removed_callback == NULL) {
1420 weston_log("fails to allocate memory\n");
1421 return IVI_FAILED;
1422 }
1423
1424 removed_callback->callback = callback;
1425 removed_callback->data = userdata;
1426
1427 return add_notification(&layout->surface_notification.removed,
1428 surface_removed,
1429 removed_callback);
1430}
1431
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001432static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001433ivi_layout_remove_notification_remove_surface(surface_remove_notification_func callback,
1434 void *userdata)
1435{
1436 struct ivi_layout *layout = get_instance();
1437 remove_notification(&layout->surface_notification.removed.listener_list, callback, userdata);
1438}
1439
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001440static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001441ivi_layout_add_notification_configure_surface(surface_configure_notification_func callback,
1442 void *userdata)
1443{
1444 struct ivi_layout *layout = get_instance();
1445 struct ivi_layout_notification_callback *configure_changed_callback = NULL;
1446 if (callback == NULL) {
1447 weston_log("ivi_layout_add_notification_configure_surface: invalid argument\n");
1448 return IVI_FAILED;
1449 }
1450
1451 configure_changed_callback = malloc(sizeof *configure_changed_callback);
1452 if (configure_changed_callback == NULL) {
1453 weston_log("fails to allocate memory\n");
1454 return IVI_FAILED;
1455 }
1456
1457 configure_changed_callback->callback = callback;
1458 configure_changed_callback->data = userdata;
1459
1460 return add_notification(&layout->surface_notification.configure_changed,
1461 surface_configure_changed,
1462 configure_changed_callback);
1463}
1464
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001465static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001466ivi_layout_remove_notification_configure_surface(surface_configure_notification_func callback,
1467 void *userdata)
1468{
1469 struct ivi_layout *layout = get_instance();
1470 remove_notification(&layout->surface_notification.configure_changed.listener_list, callback, userdata);
1471}
1472
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001473uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001474ivi_layout_get_id_of_surface(struct ivi_layout_surface *ivisurf)
1475{
1476 return ivisurf->id_surface;
1477}
1478
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001479static uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001480ivi_layout_get_id_of_layer(struct ivi_layout_layer *ivilayer)
1481{
1482 return ivilayer->id_layer;
1483}
1484
Nobuhiko Tanibata4d0116e2015-06-22 15:31:57 +09001485static uint32_t
1486ivi_layout_get_id_of_screen(struct ivi_layout_screen *iviscrn)
1487{
1488 return iviscrn->id_screen;
1489}
1490
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001491static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001492ivi_layout_get_layer_from_id(uint32_t id_layer)
1493{
1494 struct ivi_layout *layout = get_instance();
1495 struct ivi_layout_layer *ivilayer = NULL;
1496
1497 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1498 if (ivilayer->id_layer == id_layer) {
1499 return ivilayer;
1500 }
1501 }
1502
1503 return NULL;
1504}
1505
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001506struct ivi_layout_surface *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001507ivi_layout_get_surface_from_id(uint32_t id_surface)
1508{
1509 struct ivi_layout *layout = get_instance();
1510 struct ivi_layout_surface *ivisurf = NULL;
1511
1512 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1513 if (ivisurf->id_surface == id_surface) {
1514 return ivisurf;
1515 }
1516 }
1517
1518 return NULL;
1519}
1520
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001521static struct ivi_layout_screen *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001522ivi_layout_get_screen_from_id(uint32_t id_screen)
1523{
1524 struct ivi_layout *layout = get_instance();
1525 struct ivi_layout_screen *iviscrn = NULL;
1526
1527 wl_list_for_each(iviscrn, &layout->screen_list, link) {
1528/* FIXME : select iviscrn from screen_list by id_screen */
1529 return iviscrn;
1530 break;
1531 }
1532
1533 return NULL;
1534}
1535
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001536static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001537ivi_layout_get_screen_resolution(struct ivi_layout_screen *iviscrn,
1538 int32_t *pWidth, int32_t *pHeight)
1539{
1540 struct weston_output *output = NULL;
1541
Nobuhiko Tanibata0c217cb2015-06-22 15:30:32 +09001542 if (iviscrn == NULL || pWidth == NULL || pHeight == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001543 weston_log("ivi_layout_get_screen_resolution: invalid argument\n");
1544 return IVI_FAILED;
1545 }
1546
1547 output = iviscrn->output;
1548 *pWidth = output->current_mode->width;
1549 *pHeight = output->current_mode->height;
1550
1551 return IVI_SUCCEEDED;
1552}
1553
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001554static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001555ivi_layout_surface_add_notification(struct ivi_layout_surface *ivisurf,
1556 surface_property_notification_func callback,
1557 void *userdata)
1558{
1559 struct listener_layout_notification* notification = NULL;
1560 struct ivi_layout_notification_callback *prop_callback = NULL;
1561
1562 if (ivisurf == NULL || callback == NULL) {
1563 weston_log("ivi_layout_surface_add_notification: invalid argument\n");
1564 return IVI_FAILED;
1565 }
1566
1567 notification = malloc(sizeof *notification);
1568 if (notification == NULL) {
1569 weston_log("fails to allocate memory\n");
1570 return IVI_FAILED;
1571 }
1572
1573 prop_callback = malloc(sizeof *prop_callback);
1574 if (prop_callback == NULL) {
1575 weston_log("fails to allocate memory\n");
1576 return IVI_FAILED;
1577 }
1578
1579 prop_callback->callback = callback;
1580 prop_callback->data = userdata;
1581
1582 notification->listener.notify = surface_prop_changed;
1583 notification->userdata = prop_callback;
1584
1585 wl_signal_add(&ivisurf->property_changed, &notification->listener);
1586
1587 return IVI_SUCCEEDED;
1588}
1589
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001590static const struct ivi_layout_layer_properties *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001591ivi_layout_get_properties_of_layer(struct ivi_layout_layer *ivilayer)
1592{
1593 if (ivilayer == NULL) {
1594 weston_log("ivi_layout_get_properties_of_layer: invalid argument\n");
1595 return NULL;
1596 }
1597
1598 return &ivilayer->prop;
1599}
1600
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001601static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001602ivi_layout_get_screens(int32_t *pLength, struct ivi_layout_screen ***ppArray)
1603{
1604 struct ivi_layout *layout = get_instance();
1605 struct ivi_layout_screen *iviscrn = NULL;
1606 int32_t length = 0;
1607 int32_t n = 0;
1608
1609 if (pLength == NULL || ppArray == NULL) {
1610 weston_log("ivi_layout_get_screens: invalid argument\n");
1611 return IVI_FAILED;
1612 }
1613
1614 length = wl_list_length(&layout->screen_list);
1615
1616 if (length != 0){
1617 /* the Array must be free by module which called this function */
1618 *ppArray = calloc(length, sizeof(struct ivi_layout_screen *));
1619 if (*ppArray == NULL) {
1620 weston_log("fails to allocate memory\n");
1621 return IVI_FAILED;
1622 }
1623
1624 wl_list_for_each(iviscrn, &layout->screen_list, link) {
1625 (*ppArray)[n++] = iviscrn;
1626 }
1627 }
1628
1629 *pLength = length;
1630
1631 return IVI_SUCCEEDED;
1632}
1633
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001634static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001635ivi_layout_get_screens_under_layer(struct ivi_layout_layer *ivilayer,
1636 int32_t *pLength,
1637 struct ivi_layout_screen ***ppArray)
1638{
1639 struct link_screen *link_scrn = NULL;
1640 int32_t length = 0;
1641 int32_t n = 0;
1642
1643 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1644 weston_log("ivi_layout_get_screens_under_layer: invalid argument\n");
1645 return IVI_FAILED;
1646 }
1647
1648 length = wl_list_length(&ivilayer->screen_list);
1649
1650 if (length != 0){
1651 /* the Array must be free by module which called this function */
1652 *ppArray = calloc(length, sizeof(struct ivi_layout_screen *));
1653 if (*ppArray == NULL) {
1654 weston_log("fails to allocate memory\n");
1655 return IVI_FAILED;
1656 }
1657
1658 wl_list_for_each(link_scrn, &ivilayer->screen_list, link) {
1659 (*ppArray)[n++] = link_scrn->iviscrn;
1660 }
1661 }
1662
1663 *pLength = length;
1664
1665 return IVI_SUCCEEDED;
1666}
1667
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001668static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001669ivi_layout_get_layers(int32_t *pLength, struct ivi_layout_layer ***ppArray)
1670{
1671 struct ivi_layout *layout = get_instance();
1672 struct ivi_layout_layer *ivilayer = NULL;
1673 int32_t length = 0;
1674 int32_t n = 0;
1675
1676 if (pLength == NULL || ppArray == NULL) {
1677 weston_log("ivi_layout_get_layers: invalid argument\n");
1678 return IVI_FAILED;
1679 }
1680
1681 length = wl_list_length(&layout->layer_list);
1682
1683 if (length != 0){
1684 /* the Array must be free by module which called this function */
1685 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1686 if (*ppArray == NULL) {
1687 weston_log("fails to allocate memory\n");
1688 return IVI_FAILED;
1689 }
1690
1691 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1692 (*ppArray)[n++] = ivilayer;
1693 }
1694 }
1695
1696 *pLength = length;
1697
1698 return IVI_SUCCEEDED;
1699}
1700
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001701static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001702ivi_layout_get_layers_on_screen(struct ivi_layout_screen *iviscrn,
1703 int32_t *pLength,
1704 struct ivi_layout_layer ***ppArray)
1705{
1706 struct ivi_layout_layer *ivilayer = NULL;
1707 int32_t length = 0;
1708 int32_t n = 0;
1709
1710 if (iviscrn == NULL || pLength == NULL || ppArray == NULL) {
1711 weston_log("ivi_layout_get_layers_on_screen: invalid argument\n");
1712 return IVI_FAILED;
1713 }
1714
1715 length = wl_list_length(&iviscrn->order.layer_list);
1716
1717 if (length != 0){
1718 /* the Array must be free by module which called this function */
1719 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1720 if (*ppArray == NULL) {
1721 weston_log("fails to allocate memory\n");
1722 return IVI_FAILED;
1723 }
1724
Nobuhiko Tanibatae2b82142015-06-22 15:30:19 +09001725 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001726 (*ppArray)[n++] = ivilayer;
1727 }
1728 }
1729
1730 *pLength = length;
1731
1732 return IVI_SUCCEEDED;
1733}
1734
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001735static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001736ivi_layout_get_layers_under_surface(struct ivi_layout_surface *ivisurf,
1737 int32_t *pLength,
1738 struct ivi_layout_layer ***ppArray)
1739{
1740 struct link_layer *link_layer = NULL;
1741 int32_t length = 0;
1742 int32_t n = 0;
1743
1744 if (ivisurf == NULL || pLength == NULL || ppArray == NULL) {
1745 weston_log("ivi_layout_getLayers: invalid argument\n");
1746 return IVI_FAILED;
1747 }
1748
1749 length = wl_list_length(&ivisurf->layer_list);
1750
1751 if (length != 0){
1752 /* the Array must be free by module which called this function */
1753 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1754 if (*ppArray == NULL) {
1755 weston_log("fails to allocate memory\n");
1756 return IVI_FAILED;
1757 }
1758
1759 wl_list_for_each(link_layer, &ivisurf->layer_list, link) {
1760 (*ppArray)[n++] = link_layer->ivilayer;
1761 }
1762 }
1763
1764 *pLength = length;
1765
1766 return IVI_SUCCEEDED;
1767}
1768
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001769static
1770int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001771ivi_layout_get_surfaces(int32_t *pLength, struct ivi_layout_surface ***ppArray)
1772{
1773 struct ivi_layout *layout = get_instance();
1774 struct ivi_layout_surface *ivisurf = NULL;
1775 int32_t length = 0;
1776 int32_t n = 0;
1777
1778 if (pLength == NULL || ppArray == NULL) {
1779 weston_log("ivi_layout_get_surfaces: invalid argument\n");
1780 return IVI_FAILED;
1781 }
1782
1783 length = wl_list_length(&layout->surface_list);
1784
1785 if (length != 0){
1786 /* the Array must be free by module which called this function */
1787 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1788 if (*ppArray == NULL) {
1789 weston_log("fails to allocate memory\n");
1790 return IVI_FAILED;
1791 }
1792
1793 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1794 (*ppArray)[n++] = ivisurf;
1795 }
1796 }
1797
1798 *pLength = length;
1799
1800 return IVI_SUCCEEDED;
1801}
1802
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001803static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001804ivi_layout_get_surfaces_on_layer(struct ivi_layout_layer *ivilayer,
1805 int32_t *pLength,
1806 struct ivi_layout_surface ***ppArray)
1807{
1808 struct ivi_layout_surface *ivisurf = NULL;
1809 int32_t length = 0;
1810 int32_t n = 0;
1811
1812 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1813 weston_log("ivi_layout_getSurfaceIDsOnLayer: invalid argument\n");
1814 return IVI_FAILED;
1815 }
1816
1817 length = wl_list_length(&ivilayer->order.surface_list);
1818
1819 if (length != 0) {
1820 /* the Array must be free by module which called this function */
1821 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1822 if (*ppArray == NULL) {
1823 weston_log("fails to allocate memory\n");
1824 return IVI_FAILED;
1825 }
1826
1827 wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) {
1828 (*ppArray)[n++] = ivisurf;
1829 }
1830 }
1831
1832 *pLength = length;
1833
1834 return IVI_SUCCEEDED;
1835}
1836
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001837static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001838ivi_layout_layer_create_with_dimension(uint32_t id_layer,
1839 int32_t width, int32_t height)
1840{
1841 struct ivi_layout *layout = get_instance();
1842 struct ivi_layout_layer *ivilayer = NULL;
1843
1844 ivilayer = get_layer(&layout->layer_list, id_layer);
1845 if (ivilayer != NULL) {
1846 weston_log("id_layer is already created\n");
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001847 ++ivilayer->ref_count;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001848 return ivilayer;
1849 }
1850
1851 ivilayer = calloc(1, sizeof *ivilayer);
1852 if (ivilayer == NULL) {
1853 weston_log("fails to allocate memory\n");
1854 return NULL;
1855 }
1856
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001857 ivilayer->ref_count = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001858 wl_list_init(&ivilayer->link);
1859 wl_signal_init(&ivilayer->property_changed);
1860 wl_list_init(&ivilayer->screen_list);
1861 wl_list_init(&ivilayer->link_to_surface);
1862 ivilayer->layout = layout;
1863 ivilayer->id_layer = id_layer;
1864
1865 init_layer_properties(&ivilayer->prop, width, height);
1866 ivilayer->event_mask = 0;
1867
1868 wl_list_init(&ivilayer->pending.surface_list);
1869 wl_list_init(&ivilayer->pending.link);
1870 ivilayer->pending.prop = ivilayer->prop;
1871
1872 wl_list_init(&ivilayer->order.surface_list);
1873 wl_list_init(&ivilayer->order.link);
1874
1875 wl_list_insert(&layout->layer_list, &ivilayer->link);
1876
1877 wl_signal_emit(&layout->layer_notification.created, ivilayer);
1878
1879 return ivilayer;
1880}
1881
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001882static void
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +09001883ivi_layout_layer_remove_notification(struct ivi_layout_layer *ivilayer)
1884{
1885 if (ivilayer == NULL) {
1886 weston_log("ivi_layout_layer_remove_notification: invalid argument\n");
1887 return;
1888 }
1889
1890 remove_all_notification(&ivilayer->property_changed.listener_list);
1891}
1892
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001893static void
Nobuhiko Tanibatadb8efd12015-06-22 15:31:39 +09001894ivi_layout_layer_remove_notification_by_callback(struct ivi_layout_layer *ivilayer,
1895 layer_property_notification_func callback,
1896 void *userdata)
1897{
1898 if (ivilayer == NULL) {
1899 weston_log("ivi_layout_layer_remove_notification_by_callback: invalid argument\n");
1900 return;
1901 }
1902
1903 remove_notification(&ivilayer->property_changed.listener_list, callback, userdata);
1904}
1905
1906static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001907ivi_layout_layer_remove(struct ivi_layout_layer *ivilayer)
1908{
1909 struct ivi_layout *layout = get_instance();
1910
1911 if (ivilayer == NULL) {
1912 weston_log("ivi_layout_layer_remove: invalid argument\n");
1913 return;
1914 }
1915
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001916 if (--ivilayer->ref_count > 0)
1917 return;
1918
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001919 wl_signal_emit(&layout->layer_notification.removed, ivilayer);
1920
1921 clear_surface_pending_list(ivilayer);
1922 clear_surface_order_list(ivilayer);
1923
1924 if (!wl_list_empty(&ivilayer->pending.link)) {
1925 wl_list_remove(&ivilayer->pending.link);
1926 }
1927 if (!wl_list_empty(&ivilayer->order.link)) {
1928 wl_list_remove(&ivilayer->order.link);
1929 }
1930 if (!wl_list_empty(&ivilayer->link)) {
1931 wl_list_remove(&ivilayer->link);
1932 }
1933 remove_orderlayer_from_screen(ivilayer);
1934 remove_link_to_surface(ivilayer);
1935 ivi_layout_layer_remove_notification(ivilayer);
1936
1937 free(ivilayer);
1938}
1939
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001940int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001941ivi_layout_layer_set_visibility(struct ivi_layout_layer *ivilayer,
1942 bool newVisibility)
1943{
1944 struct ivi_layout_layer_properties *prop = NULL;
1945
1946 if (ivilayer == NULL) {
1947 weston_log("ivi_layout_layer_set_visibility: invalid argument\n");
1948 return IVI_FAILED;
1949 }
1950
1951 prop = &ivilayer->pending.prop;
1952 prop->visibility = newVisibility;
1953
1954 ivilayer->event_mask |= IVI_NOTIFICATION_VISIBILITY;
1955
1956 return IVI_SUCCEEDED;
1957}
1958
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001959static bool
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001960ivi_layout_layer_get_visibility(struct ivi_layout_layer *ivilayer)
1961{
1962 if (ivilayer == NULL) {
1963 weston_log("ivi_layout_layer_get_visibility: invalid argument\n");
1964 return false;
1965 }
1966
1967 return ivilayer->prop.visibility;
1968}
1969
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001970int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001971ivi_layout_layer_set_opacity(struct ivi_layout_layer *ivilayer,
1972 wl_fixed_t opacity)
1973{
1974 struct ivi_layout_layer_properties *prop = NULL;
1975
Nobuhiko Tanibata7bbacc62015-06-22 15:30:09 +09001976 if (ivilayer == NULL ||
1977 opacity < wl_fixed_from_double(0.0) ||
1978 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001979 weston_log("ivi_layout_layer_set_opacity: invalid argument\n");
1980 return IVI_FAILED;
1981 }
1982
1983 prop = &ivilayer->pending.prop;
1984 prop->opacity = opacity;
1985
1986 ivilayer->event_mask |= IVI_NOTIFICATION_OPACITY;
1987
1988 return IVI_SUCCEEDED;
1989}
1990
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001991wl_fixed_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001992ivi_layout_layer_get_opacity(struct ivi_layout_layer *ivilayer)
1993{
1994 if (ivilayer == NULL) {
1995 weston_log("ivi_layout_layer_get_opacity: invalid argument\n");
1996 return wl_fixed_from_double(0.0);
1997 }
1998
1999 return ivilayer->prop.opacity;
2000}
2001
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002002static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002003ivi_layout_layer_set_source_rectangle(struct ivi_layout_layer *ivilayer,
2004 int32_t x, int32_t y,
2005 int32_t width, int32_t height)
2006{
2007 struct ivi_layout_layer_properties *prop = NULL;
2008
2009 if (ivilayer == NULL) {
2010 weston_log("ivi_layout_layer_set_source_rectangle: invalid argument\n");
2011 return IVI_FAILED;
2012 }
2013
2014 prop = &ivilayer->pending.prop;
2015 prop->source_x = x;
2016 prop->source_y = y;
2017 prop->source_width = width;
2018 prop->source_height = height;
2019
2020 ivilayer->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
2021
2022 return IVI_SUCCEEDED;
2023}
2024
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002025static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002026ivi_layout_layer_set_destination_rectangle(struct ivi_layout_layer *ivilayer,
2027 int32_t x, int32_t y,
2028 int32_t width, int32_t height)
2029{
2030 struct ivi_layout_layer_properties *prop = NULL;
2031
2032 if (ivilayer == NULL) {
2033 weston_log("ivi_layout_layer_set_destination_rectangle: invalid argument\n");
2034 return IVI_FAILED;
2035 }
2036
2037 prop = &ivilayer->pending.prop;
2038 prop->dest_x = x;
2039 prop->dest_y = y;
2040 prop->dest_width = width;
2041 prop->dest_height = height;
2042
2043 ivilayer->event_mask |= IVI_NOTIFICATION_DEST_RECT;
2044
2045 return IVI_SUCCEEDED;
2046}
2047
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002048static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002049ivi_layout_layer_get_dimension(struct ivi_layout_layer *ivilayer,
2050 int32_t *dest_width, int32_t *dest_height)
2051{
2052 if (ivilayer == NULL || dest_width == NULL || dest_height == NULL) {
2053 weston_log("ivi_layout_layer_get_dimension: invalid argument\n");
2054 return IVI_FAILED;
2055 }
2056
2057 *dest_width = ivilayer->prop.dest_width;
2058 *dest_height = ivilayer->prop.dest_height;
2059
2060 return IVI_SUCCEEDED;
2061}
2062
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002063static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002064ivi_layout_layer_set_dimension(struct ivi_layout_layer *ivilayer,
2065 int32_t dest_width, int32_t dest_height)
2066{
2067 struct ivi_layout_layer_properties *prop = NULL;
2068
2069 if (ivilayer == NULL) {
2070 weston_log("ivi_layout_layer_set_dimension: invalid argument\n");
2071 return IVI_FAILED;
2072 }
2073
2074 prop = &ivilayer->pending.prop;
2075
2076 prop->dest_width = dest_width;
2077 prop->dest_height = dest_height;
2078
2079 ivilayer->event_mask |= IVI_NOTIFICATION_DIMENSION;
2080
2081 return IVI_SUCCEEDED;
2082}
2083
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002084int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002085ivi_layout_layer_get_position(struct ivi_layout_layer *ivilayer,
2086 int32_t *dest_x, int32_t *dest_y)
2087{
2088 if (ivilayer == NULL || dest_x == NULL || dest_y == NULL) {
2089 weston_log("ivi_layout_layer_get_position: invalid argument\n");
2090 return IVI_FAILED;
2091 }
2092
2093 *dest_x = ivilayer->prop.dest_x;
2094 *dest_y = ivilayer->prop.dest_y;
2095
2096 return IVI_SUCCEEDED;
2097}
2098
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002099int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002100ivi_layout_layer_set_position(struct ivi_layout_layer *ivilayer,
2101 int32_t dest_x, int32_t dest_y)
2102{
2103 struct ivi_layout_layer_properties *prop = NULL;
2104
2105 if (ivilayer == NULL) {
2106 weston_log("ivi_layout_layer_set_position: invalid argument\n");
2107 return IVI_FAILED;
2108 }
2109
2110 prop = &ivilayer->pending.prop;
2111 prop->dest_x = dest_x;
2112 prop->dest_y = dest_y;
2113
2114 ivilayer->event_mask |= IVI_NOTIFICATION_POSITION;
2115
2116 return IVI_SUCCEEDED;
2117}
2118
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002119static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002120ivi_layout_layer_set_orientation(struct ivi_layout_layer *ivilayer,
2121 enum wl_output_transform orientation)
2122{
2123 struct ivi_layout_layer_properties *prop = NULL;
2124
2125 if (ivilayer == NULL) {
2126 weston_log("ivi_layout_layer_set_orientation: invalid argument\n");
2127 return IVI_FAILED;
2128 }
2129
2130 prop = &ivilayer->pending.prop;
2131 prop->orientation = orientation;
2132
2133 ivilayer->event_mask |= IVI_NOTIFICATION_ORIENTATION;
2134
2135 return IVI_SUCCEEDED;
2136}
2137
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002138static enum wl_output_transform
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002139ivi_layout_layer_get_orientation(struct ivi_layout_layer *ivilayer)
2140{
2141 if (ivilayer == NULL) {
2142 weston_log("ivi_layout_layer_get_orientation: invalid argument\n");
2143 return 0;
2144 }
2145
2146 return ivilayer->prop.orientation;
2147}
2148
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002149int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002150ivi_layout_layer_set_render_order(struct ivi_layout_layer *ivilayer,
2151 struct ivi_layout_surface **pSurface,
2152 int32_t number)
2153{
2154 struct ivi_layout *layout = get_instance();
2155 struct ivi_layout_surface *ivisurf = NULL;
2156 struct ivi_layout_surface *next = NULL;
2157 uint32_t *id_surface = NULL;
2158 int32_t i = 0;
2159
2160 if (ivilayer == NULL) {
2161 weston_log("ivi_layout_layer_set_render_order: invalid argument\n");
2162 return IVI_FAILED;
2163 }
2164
2165 if (pSurface == NULL) {
2166 wl_list_for_each_safe(ivisurf, next, &ivilayer->pending.surface_list, pending.link) {
2167 if (!wl_list_empty(&ivisurf->pending.link)) {
2168 wl_list_remove(&ivisurf->pending.link);
2169 }
2170
2171 wl_list_init(&ivisurf->pending.link);
2172 }
2173 ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE;
2174 return IVI_SUCCEEDED;
2175 }
2176
2177 for (i = 0; i < number; i++) {
2178 id_surface = &pSurface[i]->id_surface;
2179
2180 wl_list_for_each_safe(ivisurf, next, &layout->surface_list, link) {
2181 if (*id_surface != ivisurf->id_surface) {
2182 continue;
2183 }
2184
2185 if (!wl_list_empty(&ivisurf->pending.link)) {
2186 wl_list_remove(&ivisurf->pending.link);
2187 }
2188 wl_list_init(&ivisurf->pending.link);
2189 wl_list_insert(&ivilayer->pending.surface_list,
2190 &ivisurf->pending.link);
2191 break;
2192 }
2193 }
2194
2195 ivilayer->event_mask |= IVI_NOTIFICATION_ADD;
2196
2197 return IVI_SUCCEEDED;
2198}
2199
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002200int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002201ivi_layout_surface_set_visibility(struct ivi_layout_surface *ivisurf,
2202 bool newVisibility)
2203{
2204 struct ivi_layout_surface_properties *prop = NULL;
2205
2206 if (ivisurf == NULL) {
2207 weston_log("ivi_layout_surface_set_visibility: invalid argument\n");
2208 return IVI_FAILED;
2209 }
2210
2211 prop = &ivisurf->pending.prop;
2212 prop->visibility = newVisibility;
2213
2214 ivisurf->event_mask |= IVI_NOTIFICATION_VISIBILITY;
2215
2216 return IVI_SUCCEEDED;
2217}
2218
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002219bool
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002220ivi_layout_surface_get_visibility(struct ivi_layout_surface *ivisurf)
2221{
2222 if (ivisurf == NULL) {
2223 weston_log("ivi_layout_surface_get_visibility: invalid argument\n");
2224 return false;
2225 }
2226
2227 return ivisurf->prop.visibility;
2228}
2229
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002230int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002231ivi_layout_surface_set_opacity(struct ivi_layout_surface *ivisurf,
2232 wl_fixed_t opacity)
2233{
2234 struct ivi_layout_surface_properties *prop = NULL;
2235
Nobuhiko Tanibataa86226c2015-06-22 15:29:20 +09002236 if (ivisurf == NULL ||
2237 opacity < wl_fixed_from_double(0.0) ||
2238 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002239 weston_log("ivi_layout_surface_set_opacity: invalid argument\n");
2240 return IVI_FAILED;
2241 }
2242
2243 prop = &ivisurf->pending.prop;
2244 prop->opacity = opacity;
2245
2246 ivisurf->event_mask |= IVI_NOTIFICATION_OPACITY;
2247
2248 return IVI_SUCCEEDED;
2249}
2250
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002251wl_fixed_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002252ivi_layout_surface_get_opacity(struct ivi_layout_surface *ivisurf)
2253{
2254 if (ivisurf == NULL) {
2255 weston_log("ivi_layout_surface_get_opacity: invalid argument\n");
2256 return wl_fixed_from_double(0.0);
2257 }
2258
2259 return ivisurf->prop.opacity;
2260}
2261
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002262int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002263ivi_layout_surface_set_destination_rectangle(struct ivi_layout_surface *ivisurf,
2264 int32_t x, int32_t y,
2265 int32_t width, int32_t height)
2266{
2267 struct ivi_layout_surface_properties *prop = NULL;
2268
2269 if (ivisurf == NULL) {
2270 weston_log("ivi_layout_surface_set_destination_rectangle: invalid argument\n");
2271 return IVI_FAILED;
2272 }
2273
2274 prop = &ivisurf->pending.prop;
2275 prop->start_x = prop->dest_x;
2276 prop->start_y = prop->dest_y;
2277 prop->dest_x = x;
2278 prop->dest_y = y;
2279 prop->start_width = prop->dest_width;
2280 prop->start_height = prop->dest_height;
2281 prop->dest_width = width;
2282 prop->dest_height = height;
2283
2284 ivisurf->event_mask |= IVI_NOTIFICATION_DEST_RECT;
2285
2286 return IVI_SUCCEEDED;
2287}
2288
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002289static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002290ivi_layout_surface_set_dimension(struct ivi_layout_surface *ivisurf,
2291 int32_t dest_width, int32_t dest_height)
2292{
2293 struct ivi_layout_surface_properties *prop = NULL;
2294
2295 if (ivisurf == NULL) {
2296 weston_log("ivi_layout_surface_set_dimension: invalid argument\n");
2297 return IVI_FAILED;
2298 }
2299
2300 prop = &ivisurf->pending.prop;
2301 prop->dest_width = dest_width;
2302 prop->dest_height = dest_height;
2303
2304 ivisurf->event_mask |= IVI_NOTIFICATION_DIMENSION;
2305
2306 return IVI_SUCCEEDED;
2307}
2308
2309int32_t
2310ivi_layout_surface_get_dimension(struct ivi_layout_surface *ivisurf,
2311 int32_t *dest_width, int32_t *dest_height)
2312{
2313 if (ivisurf == NULL || dest_width == NULL || dest_height == NULL) {
2314 weston_log("ivi_layout_surface_get_dimension: invalid argument\n");
2315 return IVI_FAILED;
2316 }
2317
2318 *dest_width = ivisurf->prop.dest_width;
2319 *dest_height = ivisurf->prop.dest_height;
2320
2321 return IVI_SUCCEEDED;
2322}
2323
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002324static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002325ivi_layout_surface_set_position(struct ivi_layout_surface *ivisurf,
2326 int32_t dest_x, int32_t dest_y)
2327{
2328 struct ivi_layout_surface_properties *prop = NULL;
2329
2330 if (ivisurf == NULL) {
2331 weston_log("ivi_layout_surface_set_position: invalid argument\n");
2332 return IVI_FAILED;
2333 }
2334
2335 prop = &ivisurf->pending.prop;
2336 prop->dest_x = dest_x;
2337 prop->dest_y = dest_y;
2338
2339 ivisurf->event_mask |= IVI_NOTIFICATION_POSITION;
2340
2341 return IVI_SUCCEEDED;
2342}
2343
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002344static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002345ivi_layout_surface_get_position(struct ivi_layout_surface *ivisurf,
2346 int32_t *dest_x, int32_t *dest_y)
2347{
2348 if (ivisurf == NULL || dest_x == NULL || dest_y == NULL) {
2349 weston_log("ivi_layout_surface_get_position: invalid argument\n");
2350 return IVI_FAILED;
2351 }
2352
2353 *dest_x = ivisurf->prop.dest_x;
2354 *dest_y = ivisurf->prop.dest_y;
2355
2356 return IVI_SUCCEEDED;
2357}
2358
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002359static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002360ivi_layout_surface_set_orientation(struct ivi_layout_surface *ivisurf,
2361 enum wl_output_transform orientation)
2362{
2363 struct ivi_layout_surface_properties *prop = NULL;
2364
2365 if (ivisurf == NULL) {
2366 weston_log("ivi_layout_surface_set_orientation: invalid argument\n");
2367 return IVI_FAILED;
2368 }
2369
2370 prop = &ivisurf->pending.prop;
2371 prop->orientation = orientation;
2372
2373 ivisurf->event_mask |= IVI_NOTIFICATION_ORIENTATION;
2374
2375 return IVI_SUCCEEDED;
2376}
2377
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002378static enum wl_output_transform
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002379ivi_layout_surface_get_orientation(struct ivi_layout_surface *ivisurf)
2380{
2381 if (ivisurf == NULL) {
2382 weston_log("ivi_layout_surface_get_orientation: invalid argument\n");
2383 return 0;
2384 }
2385
2386 return ivisurf->prop.orientation;
2387}
2388
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002389static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002390ivi_layout_screen_add_layer(struct ivi_layout_screen *iviscrn,
2391 struct ivi_layout_layer *addlayer)
2392{
2393 struct ivi_layout *layout = get_instance();
2394 struct ivi_layout_layer *ivilayer = NULL;
2395 struct ivi_layout_layer *next = NULL;
2396 int is_layer_in_scrn = 0;
2397
2398 if (iviscrn == NULL || addlayer == NULL) {
2399 weston_log("ivi_layout_screen_add_layer: invalid argument\n");
2400 return IVI_FAILED;
2401 }
2402
2403 is_layer_in_scrn = is_layer_in_screen(addlayer, iviscrn);
2404 if (is_layer_in_scrn == 1) {
2405 weston_log("ivi_layout_screen_add_layer: addlayer is already available\n");
2406 return IVI_SUCCEEDED;
2407 }
2408
2409 wl_list_for_each_safe(ivilayer, next, &layout->layer_list, link) {
2410 if (ivilayer->id_layer == addlayer->id_layer) {
2411 if (!wl_list_empty(&ivilayer->pending.link)) {
2412 wl_list_remove(&ivilayer->pending.link);
2413 }
2414 wl_list_init(&ivilayer->pending.link);
2415 wl_list_insert(&iviscrn->pending.layer_list,
2416 &ivilayer->pending.link);
2417 break;
2418 }
2419 }
2420
2421 iviscrn->event_mask |= IVI_NOTIFICATION_ADD;
2422
2423 return IVI_SUCCEEDED;
2424}
2425
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002426static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002427ivi_layout_screen_set_render_order(struct ivi_layout_screen *iviscrn,
2428 struct ivi_layout_layer **pLayer,
2429 const int32_t number)
2430{
2431 struct ivi_layout *layout = get_instance();
2432 struct ivi_layout_layer *ivilayer = NULL;
2433 struct ivi_layout_layer *next = NULL;
2434 uint32_t *id_layer = NULL;
2435 int32_t i = 0;
2436
2437 if (iviscrn == NULL) {
2438 weston_log("ivi_layout_screen_set_render_order: invalid argument\n");
2439 return IVI_FAILED;
2440 }
2441
2442 wl_list_for_each_safe(ivilayer, next,
2443 &iviscrn->pending.layer_list, pending.link) {
2444 wl_list_init(&ivilayer->pending.link);
2445 }
2446
2447 wl_list_init(&iviscrn->pending.layer_list);
2448
2449 if (pLayer == NULL) {
2450 wl_list_for_each_safe(ivilayer, next, &iviscrn->pending.layer_list, pending.link) {
2451 if (!wl_list_empty(&ivilayer->pending.link)) {
2452 wl_list_remove(&ivilayer->pending.link);
2453 }
2454
2455 wl_list_init(&ivilayer->pending.link);
2456 }
2457
2458 iviscrn->event_mask |= IVI_NOTIFICATION_REMOVE;
2459 return IVI_SUCCEEDED;
2460 }
2461
2462 for (i = 0; i < number; i++) {
2463 id_layer = &pLayer[i]->id_layer;
2464 wl_list_for_each(ivilayer, &layout->layer_list, link) {
2465 if (*id_layer != ivilayer->id_layer) {
2466 continue;
2467 }
2468
2469 if (!wl_list_empty(&ivilayer->pending.link)) {
2470 wl_list_remove(&ivilayer->pending.link);
2471 }
2472 wl_list_init(&ivilayer->pending.link);
2473 wl_list_insert(&iviscrn->pending.layer_list,
2474 &ivilayer->pending.link);
2475 break;
2476 }
2477 }
2478
2479 iviscrn->event_mask |= IVI_NOTIFICATION_ADD;
2480
2481 return IVI_SUCCEEDED;
2482}
2483
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002484static struct weston_output *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002485ivi_layout_screen_get_output(struct ivi_layout_screen *iviscrn)
2486{
2487 return iviscrn->output;
2488}
2489
2490/**
2491 * This function is used by the additional ivi-module because of dumping ivi_surface sceenshot.
2492 * The ivi-module, e.g. ivi-controller.so, is in wayland-ivi-extension of Genivi's Layer Management.
2493 * This function is used to get the result of drawing by clients.
2494 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002495static struct weston_surface *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002496ivi_layout_surface_get_weston_surface(struct ivi_layout_surface *ivisurf)
2497{
2498 return ivisurf != NULL ? ivisurf->surface : NULL;
2499}
2500
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002501static int32_t
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09002502ivi_layout_surface_get_size(struct ivi_layout_surface *ivisurf,
2503 int32_t *width, int32_t *height,
2504 int32_t *stride)
2505{
2506 int32_t w;
2507 int32_t h;
2508 const size_t bytespp = 4; /* PIXMAN_a8b8g8r8 */
2509
2510 if (ivisurf == NULL || ivisurf->surface == NULL) {
2511 weston_log("%s: invalid argument\n", __func__);
2512 return IVI_FAILED;
2513 }
2514
2515 weston_surface_get_content_size(ivisurf->surface, &w, &h);
2516
2517 if (width != NULL)
2518 *width = w;
2519
2520 if (height != NULL)
2521 *height = h;
2522
2523 if (stride != NULL)
2524 *stride = w * bytespp;
2525
2526 return IVI_SUCCEEDED;
2527}
2528
2529static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002530ivi_layout_layer_add_notification(struct ivi_layout_layer *ivilayer,
2531 layer_property_notification_func callback,
2532 void *userdata)
2533{
2534 struct ivi_layout_notification_callback *prop_callback = NULL;
2535
2536 if (ivilayer == NULL || callback == NULL) {
2537 weston_log("ivi_layout_layer_add_notification: invalid argument\n");
2538 return IVI_FAILED;
2539 }
2540
2541 prop_callback = malloc(sizeof *prop_callback);
2542 if (prop_callback == NULL) {
2543 weston_log("fails to allocate memory\n");
2544 return IVI_FAILED;
2545 }
2546
2547 prop_callback->callback = callback;
2548 prop_callback->data = userdata;
2549
2550 return add_notification(&ivilayer->property_changed,
2551 layer_prop_changed,
2552 prop_callback);
2553}
2554
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002555static const struct ivi_layout_surface_properties *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002556ivi_layout_get_properties_of_surface(struct ivi_layout_surface *ivisurf)
2557{
2558 if (ivisurf == NULL) {
2559 weston_log("ivi_layout_get_properties_of_surface: invalid argument\n");
2560 return NULL;
2561 }
2562
2563 return &ivisurf->prop;
2564}
2565
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002566static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002567ivi_layout_layer_add_surface(struct ivi_layout_layer *ivilayer,
2568 struct ivi_layout_surface *addsurf)
2569{
2570 struct ivi_layout *layout = get_instance();
2571 struct ivi_layout_surface *ivisurf = NULL;
2572 struct ivi_layout_surface *next = NULL;
2573 int is_surf_in_layer = 0;
2574
2575 if (ivilayer == NULL || addsurf == NULL) {
2576 weston_log("ivi_layout_layer_add_surface: invalid argument\n");
2577 return IVI_FAILED;
2578 }
2579
2580 is_surf_in_layer = is_surface_in_layer(addsurf, ivilayer);
2581 if (is_surf_in_layer == 1) {
2582 weston_log("ivi_layout_layer_add_surface: addsurf is already available\n");
2583 return IVI_SUCCEEDED;
2584 }
2585
2586 wl_list_for_each_safe(ivisurf, next, &layout->surface_list, link) {
2587 if (ivisurf->id_surface == addsurf->id_surface) {
2588 if (!wl_list_empty(&ivisurf->pending.link)) {
2589 wl_list_remove(&ivisurf->pending.link);
2590 }
2591 wl_list_init(&ivisurf->pending.link);
2592 wl_list_insert(&ivilayer->pending.surface_list,
2593 &ivisurf->pending.link);
2594 break;
2595 }
2596 }
2597
2598 ivilayer->event_mask |= IVI_NOTIFICATION_ADD;
2599
2600 return IVI_SUCCEEDED;
2601}
2602
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002603static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002604ivi_layout_layer_remove_surface(struct ivi_layout_layer *ivilayer,
2605 struct ivi_layout_surface *remsurf)
2606{
2607 struct ivi_layout_surface *ivisurf = NULL;
2608 struct ivi_layout_surface *next = NULL;
2609
2610 if (ivilayer == NULL || remsurf == NULL) {
2611 weston_log("ivi_layout_layer_remove_surface: invalid argument\n");
2612 return;
2613 }
2614
2615 wl_list_for_each_safe(ivisurf, next,
2616 &ivilayer->pending.surface_list, pending.link) {
2617 if (ivisurf->id_surface == remsurf->id_surface) {
2618 if (!wl_list_empty(&ivisurf->pending.link)) {
2619 wl_list_remove(&ivisurf->pending.link);
2620 }
2621 wl_list_init(&ivisurf->pending.link);
2622 break;
2623 }
2624 }
2625
2626 remsurf->event_mask |= IVI_NOTIFICATION_REMOVE;
2627}
2628
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002629static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002630ivi_layout_surface_set_source_rectangle(struct ivi_layout_surface *ivisurf,
2631 int32_t x, int32_t y,
2632 int32_t width, int32_t height)
2633{
2634 struct ivi_layout_surface_properties *prop = NULL;
2635
2636 if (ivisurf == NULL) {
2637 weston_log("ivi_layout_surface_set_source_rectangle: invalid argument\n");
2638 return IVI_FAILED;
2639 }
2640
2641 prop = &ivisurf->pending.prop;
2642 prop->source_x = x;
2643 prop->source_y = y;
2644 prop->source_width = width;
2645 prop->source_height = height;
2646
2647 ivisurf->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
2648
2649 return IVI_SUCCEEDED;
2650}
2651
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002652int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002653ivi_layout_commit_changes(void)
2654{
2655 struct ivi_layout *layout = get_instance();
2656
2657 commit_surface_list(layout);
2658 commit_layer_list(layout);
2659 commit_screen_list(layout);
2660
2661 commit_transition(layout);
2662
2663 commit_changes(layout);
2664 send_prop(layout);
2665 weston_compositor_schedule_repaint(layout->compositor);
2666
2667 return IVI_SUCCEEDED;
2668}
2669
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002670static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09002671ivi_layout_layer_set_transition(struct ivi_layout_layer *ivilayer,
2672 enum ivi_layout_transition_type type,
2673 uint32_t duration)
2674{
2675 if (ivilayer == NULL) {
2676 weston_log("%s: invalid argument\n", __func__);
2677 return -1;
2678 }
2679
2680 ivilayer->pending.prop.transition_type = type;
2681 ivilayer->pending.prop.transition_duration = duration;
2682
2683 return 0;
2684}
2685
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002686static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09002687ivi_layout_layer_set_fade_info(struct ivi_layout_layer* ivilayer,
2688 uint32_t is_fade_in,
2689 double start_alpha, double end_alpha)
2690{
2691 if (ivilayer == NULL) {
2692 weston_log("%s: invalid argument\n", __func__);
2693 return -1;
2694 }
2695
2696 ivilayer->pending.prop.is_fade_in = is_fade_in;
2697 ivilayer->pending.prop.start_alpha = start_alpha;
2698 ivilayer->pending.prop.end_alpha = end_alpha;
2699
2700 return 0;
2701}
2702
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002703static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09002704ivi_layout_surface_set_transition_duration(struct ivi_layout_surface *ivisurf,
2705 uint32_t duration)
2706{
2707 struct ivi_layout_surface_properties *prop;
2708
2709 if (ivisurf == NULL) {
2710 weston_log("%s: invalid argument\n", __func__);
2711 return -1;
2712 }
2713
2714 prop = &ivisurf->pending.prop;
2715 prop->transition_duration = duration*10;
2716 return 0;
2717}
2718
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002719static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09002720ivi_layout_surface_set_transition(struct ivi_layout_surface *ivisurf,
2721 enum ivi_layout_transition_type type,
2722 uint32_t duration)
2723{
2724 struct ivi_layout_surface_properties *prop;
2725
2726 if (ivisurf == NULL) {
2727 weston_log("%s: invalid argument\n", __func__);
2728 return -1;
2729 }
2730
2731 prop = &ivisurf->pending.prop;
2732 prop->transition_type = type;
2733 prop->transition_duration = duration;
2734 return 0;
2735}
2736
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09002737static int32_t
2738ivi_layout_surface_dump(struct weston_surface *surface,
2739 void *target, size_t size,int32_t x, int32_t y,
2740 int32_t width, int32_t height)
2741{
2742 int result = 0;
2743
2744 if (surface == NULL) {
2745 weston_log("%s: invalid argument\n", __func__);
2746 return IVI_FAILED;
2747 }
2748
2749 result = weston_surface_copy_content(
2750 surface, target, size,
2751 x, y, width, height);
2752
2753 return result == 0 ? IVI_SUCCEEDED : IVI_FAILED;
2754}
2755
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002756/**
2757 * methods of interaction between ivi-shell with ivi-layout
2758 */
2759struct weston_view *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002760ivi_layout_get_weston_view(struct ivi_layout_surface *surface)
2761{
2762 struct weston_view *tmpview = NULL;
2763
2764 if(surface == NULL)
2765 return NULL;
2766
2767 wl_list_for_each(tmpview, &surface->surface->views, surface_link)
2768 {
2769 if (tmpview != NULL) {
2770 break;
2771 }
2772 }
2773 return tmpview;
2774}
2775
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002776void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002777ivi_layout_surface_configure(struct ivi_layout_surface *ivisurf,
2778 int32_t width, int32_t height)
2779{
2780 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002781
Nobuhiko Tanibatae6cc9972015-04-27 16:54:01 +09002782 /* emit callback which is set by ivi-layout api user */
2783 wl_signal_emit(&layout->surface_notification.configure_changed,
2784 ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002785}
2786
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002787static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002788ivi_layout_surface_set_content_observer(struct ivi_layout_surface *ivisurf,
2789 ivi_controller_surface_content_callback callback,
2790 void* userdata)
2791{
2792 int32_t ret = IVI_FAILED;
2793
2794 if (ivisurf != NULL) {
2795 ivisurf->content_observer.callback = callback;
2796 ivisurf->content_observer.userdata = userdata;
2797 ret = IVI_SUCCEEDED;
2798 }
2799 return ret;
2800}
2801
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002802struct ivi_layout_surface*
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002803ivi_layout_surface_create(struct weston_surface *wl_surface,
2804 uint32_t id_surface)
2805{
2806 struct ivi_layout *layout = get_instance();
2807 struct ivi_layout_surface *ivisurf = NULL;
2808 struct weston_view *tmpview = NULL;
2809
2810 if (wl_surface == NULL) {
2811 weston_log("ivi_layout_surface_create: invalid argument\n");
2812 return NULL;
2813 }
2814
2815 ivisurf = get_surface(&layout->surface_list, id_surface);
2816 if (ivisurf != NULL) {
2817 if (ivisurf->surface != NULL) {
2818 weston_log("id_surface(%d) is already created\n", id_surface);
2819 return NULL;
2820 }
2821 }
2822
2823 ivisurf = calloc(1, sizeof *ivisurf);
2824 if (ivisurf == NULL) {
2825 weston_log("fails to allocate memory\n");
2826 return NULL;
2827 }
2828
2829 wl_list_init(&ivisurf->link);
2830 wl_signal_init(&ivisurf->property_changed);
2831 wl_signal_init(&ivisurf->configured);
2832 wl_list_init(&ivisurf->layer_list);
2833 ivisurf->id_surface = id_surface;
2834 ivisurf->layout = layout;
2835
2836 ivisurf->surface = wl_surface;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002837
2838 tmpview = weston_view_create(wl_surface);
2839 if (tmpview == NULL) {
2840 weston_log("fails to allocate memory\n");
2841 }
2842
2843 ivisurf->surface->width_from_buffer = 0;
2844 ivisurf->surface->height_from_buffer = 0;
2845
2846 weston_matrix_init(&ivisurf->surface_rotation.matrix);
2847 weston_matrix_init(&ivisurf->layer_rotation.matrix);
2848 weston_matrix_init(&ivisurf->surface_pos.matrix);
2849 weston_matrix_init(&ivisurf->layer_pos.matrix);
2850 weston_matrix_init(&ivisurf->scaling.matrix);
2851
2852 wl_list_init(&ivisurf->surface_rotation.link);
2853 wl_list_init(&ivisurf->layer_rotation.link);
2854 wl_list_init(&ivisurf->surface_pos.link);
2855 wl_list_init(&ivisurf->layer_pos.link);
2856 wl_list_init(&ivisurf->scaling.link);
2857
2858 init_surface_properties(&ivisurf->prop);
2859 ivisurf->event_mask = 0;
2860
2861 ivisurf->pending.prop = ivisurf->prop;
2862 wl_list_init(&ivisurf->pending.link);
2863
2864 wl_list_init(&ivisurf->order.link);
2865 wl_list_init(&ivisurf->order.layer_list);
2866
2867 wl_list_insert(&layout->surface_list, &ivisurf->link);
2868
2869 wl_signal_emit(&layout->surface_notification.created, ivisurf);
2870
2871 return ivisurf;
2872}
2873
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002874void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002875ivi_layout_init_with_compositor(struct weston_compositor *ec)
2876{
2877 struct ivi_layout *layout = get_instance();
2878
2879 layout->compositor = ec;
2880
2881 wl_list_init(&layout->surface_list);
2882 wl_list_init(&layout->layer_list);
2883 wl_list_init(&layout->screen_list);
2884
2885 wl_signal_init(&layout->layer_notification.created);
2886 wl_signal_init(&layout->layer_notification.removed);
2887
2888 wl_signal_init(&layout->surface_notification.created);
2889 wl_signal_init(&layout->surface_notification.removed);
2890 wl_signal_init(&layout->surface_notification.configure_changed);
2891
2892 /* Add layout_layer at the last of weston_compositor.layer_list */
2893 weston_layer_init(&layout->layout_layer, ec->layer_list.prev);
2894
2895 create_screen(ec);
2896
2897 layout->transitions = ivi_layout_transition_set_create(ec);
2898 wl_list_init(&layout->pending_transition_list);
2899}
2900
2901
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002902void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002903ivi_layout_surface_add_configured_listener(struct ivi_layout_surface* ivisurf,
2904 struct wl_listener* listener)
2905{
2906 wl_signal_add(&ivisurf->configured, listener);
2907}
2908
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002909static struct ivi_controller_interface ivi_controller_interface = {
2910 /**
2911 * commit all changes
2912 */
2913 .commit_changes = ivi_layout_commit_changes,
2914
2915 /**
2916 * surface controller interfaces
2917 */
2918 .add_notification_create_surface = ivi_layout_add_notification_create_surface,
2919 .remove_notification_create_surface = ivi_layout_remove_notification_create_surface,
2920 .add_notification_remove_surface = ivi_layout_add_notification_remove_surface,
2921 .remove_notification_remove_surface = ivi_layout_remove_notification_remove_surface,
2922 .add_notification_configure_surface = ivi_layout_add_notification_configure_surface,
2923 .remove_notification_configure_surface = ivi_layout_remove_notification_configure_surface,
2924 .get_surfaces = ivi_layout_get_surfaces,
2925 .get_id_of_surface = ivi_layout_get_id_of_surface,
2926 .get_surface_from_id = ivi_layout_get_surface_from_id,
2927 .get_properties_of_surface = ivi_layout_get_properties_of_surface,
2928 .get_surfaces_on_layer = ivi_layout_get_surfaces_on_layer,
2929 .surface_set_visibility = ivi_layout_surface_set_visibility,
2930 .surface_get_visibility = ivi_layout_surface_get_visibility,
2931 .surface_set_opacity = ivi_layout_surface_set_opacity,
2932 .surface_get_opacity = ivi_layout_surface_get_opacity,
2933 .surface_set_source_rectangle = ivi_layout_surface_set_source_rectangle,
2934 .surface_set_destination_rectangle = ivi_layout_surface_set_destination_rectangle,
2935 .surface_set_position = ivi_layout_surface_set_position,
2936 .surface_get_position = ivi_layout_surface_get_position,
2937 .surface_set_dimension = ivi_layout_surface_set_dimension,
2938 .surface_get_dimension = ivi_layout_surface_get_dimension,
2939 .surface_set_orientation = ivi_layout_surface_set_orientation,
2940 .surface_get_orientation = ivi_layout_surface_get_orientation,
2941 .surface_set_content_observer = ivi_layout_surface_set_content_observer,
2942 .surface_add_notification = ivi_layout_surface_add_notification,
2943 .surface_remove_notification = ivi_layout_surface_remove_notification,
2944 .surface_get_weston_surface = ivi_layout_surface_get_weston_surface,
2945 .surface_set_transition = ivi_layout_surface_set_transition,
2946 .surface_set_transition_duration = ivi_layout_surface_set_transition_duration,
2947
2948 /**
2949 * layer controller interfaces
2950 */
2951 .add_notification_create_layer = ivi_layout_add_notification_create_layer,
2952 .remove_notification_create_layer = ivi_layout_remove_notification_create_layer,
2953 .add_notification_remove_layer = ivi_layout_add_notification_remove_layer,
2954 .remove_notification_remove_layer = ivi_layout_remove_notification_remove_layer,
2955 .layer_create_with_dimension = ivi_layout_layer_create_with_dimension,
2956 .layer_remove = ivi_layout_layer_remove,
2957 .get_layers = ivi_layout_get_layers,
2958 .get_id_of_layer = ivi_layout_get_id_of_layer,
2959 .get_layer_from_id = ivi_layout_get_layer_from_id,
2960 .get_properties_of_layer = ivi_layout_get_properties_of_layer,
2961 .get_layers_under_surface = ivi_layout_get_layers_under_surface,
2962 .get_layers_on_screen = ivi_layout_get_layers_on_screen,
2963 .layer_set_visibility = ivi_layout_layer_set_visibility,
2964 .layer_get_visibility = ivi_layout_layer_get_visibility,
2965 .layer_set_opacity = ivi_layout_layer_set_opacity,
2966 .layer_get_opacity = ivi_layout_layer_get_opacity,
2967 .layer_set_source_rectangle = ivi_layout_layer_set_source_rectangle,
2968 .layer_set_destination_rectangle = ivi_layout_layer_set_destination_rectangle,
2969 .layer_set_position = ivi_layout_layer_set_position,
2970 .layer_get_position = ivi_layout_layer_get_position,
2971 .layer_set_dimension = ivi_layout_layer_set_dimension,
2972 .layer_get_dimension = ivi_layout_layer_get_dimension,
2973 .layer_set_orientation = ivi_layout_layer_set_orientation,
2974 .layer_get_orientation = ivi_layout_layer_get_orientation,
2975 .layer_add_surface = ivi_layout_layer_add_surface,
2976 .layer_remove_surface = ivi_layout_layer_remove_surface,
2977 .layer_set_render_order = ivi_layout_layer_set_render_order,
2978 .layer_add_notification = ivi_layout_layer_add_notification,
2979 .layer_remove_notification = ivi_layout_layer_remove_notification,
2980 .layer_set_transition = ivi_layout_layer_set_transition,
2981
2982 /**
Nobuhiko Tanibata4d0116e2015-06-22 15:31:57 +09002983 * screen controller interfaces part1
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002984 */
2985 .get_screen_from_id = ivi_layout_get_screen_from_id,
2986 .get_screen_resolution = ivi_layout_get_screen_resolution,
2987 .get_screens = ivi_layout_get_screens,
2988 .get_screens_under_layer = ivi_layout_get_screens_under_layer,
2989 .screen_add_layer = ivi_layout_screen_add_layer,
2990 .screen_set_render_order = ivi_layout_screen_set_render_order,
2991 .screen_get_output = ivi_layout_screen_get_output,
2992
2993 /**
2994 * animation
2995 */
2996 .transition_move_layer_cancel = ivi_layout_transition_move_layer_cancel,
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09002997 .layer_set_fade_info = ivi_layout_layer_set_fade_info,
2998
2999 /**
3000 * surface content dumping for debugging
3001 */
3002 .surface_get_size = ivi_layout_surface_get_size,
3003 .surface_dump = ivi_layout_surface_dump,
Nobuhiko Tanibata82051702015-06-22 15:31:26 +09003004
3005 /**
Nobuhiko Tanibatadb8efd12015-06-22 15:31:39 +09003006 * remove notification by callback on property changes of ivi_surface/layer
Nobuhiko Tanibata82051702015-06-22 15:31:26 +09003007 */
Nobuhiko Tanibatadb8efd12015-06-22 15:31:39 +09003008 .surface_remove_notification_by_callback = ivi_layout_surface_remove_notification_by_callback,
Nobuhiko Tanibata4d0116e2015-06-22 15:31:57 +09003009 .layer_remove_notification_by_callback = ivi_layout_layer_remove_notification_by_callback,
3010
3011 /**
3012 * screen controller interfaces part2
3013 */
3014 .get_id_of_screen = ivi_layout_get_id_of_screen
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09003015};
3016
3017int
3018load_controller_modules(struct weston_compositor *compositor, const char *modules,
3019 int *argc, char *argv[])
3020{
3021 const char *p, *end;
3022 char buffer[256];
3023 int (*controller_module_init)(struct weston_compositor *compositor,
3024 int *argc, char *argv[],
3025 const struct ivi_controller_interface *interface,
3026 size_t interface_version);
3027
3028 if (modules == NULL)
3029 return 0;
3030
3031 p = modules;
3032 while (*p) {
3033 end = strchrnul(p, ',');
3034 snprintf(buffer, sizeof buffer, "%.*s", (int)(end - p), p);
3035
3036 controller_module_init = weston_load_module(buffer, "controller_module_init");
Pekka Paalanen97246c02015-03-26 15:47:29 +02003037 if (!controller_module_init)
3038 return -1;
3039
3040 if (controller_module_init(compositor, argc, argv,
3041 &ivi_controller_interface,
3042 sizeof(struct ivi_controller_interface)) != 0) {
3043 weston_log("ivi-shell: Initialization of controller module fails");
3044 return -1;
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09003045 }
3046
3047 p = end;
3048 while (*p == ',')
3049 p++;
3050 }
3051
3052 return 0;
3053}