blob: a7f9e02c1a084dd831c3c58195e30502fd3b2133 [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) {
1082 send_layer_prop(ivilayer);
1083 }
1084
1085 wl_list_for_each_reverse(ivisurf, &layout->surface_list, link) {
1086 send_surface_prop(ivisurf);
1087 }
1088}
1089
1090static void
1091clear_surface_pending_list(struct ivi_layout_layer *ivilayer)
1092{
1093 struct ivi_layout_surface *surface_link = NULL;
1094 struct ivi_layout_surface *surface_next = NULL;
1095
1096 wl_list_for_each_safe(surface_link, surface_next,
1097 &ivilayer->pending.surface_list, pending.link) {
1098 if (!wl_list_empty(&surface_link->pending.link)) {
1099 wl_list_remove(&surface_link->pending.link);
1100 }
1101
1102 wl_list_init(&surface_link->pending.link);
1103 }
1104
1105 ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE;
1106}
1107
1108static void
1109clear_surface_order_list(struct ivi_layout_layer *ivilayer)
1110{
1111 struct ivi_layout_surface *surface_link = NULL;
1112 struct ivi_layout_surface *surface_next = NULL;
1113
1114 wl_list_for_each_safe(surface_link, surface_next,
1115 &ivilayer->order.surface_list, order.link) {
1116 if (!wl_list_empty(&surface_link->order.link)) {
1117 wl_list_remove(&surface_link->order.link);
1118 }
1119
1120 wl_list_init(&surface_link->order.link);
1121 }
1122
1123 ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE;
1124}
1125
1126static void
1127layer_created(struct wl_listener *listener, void *data)
1128{
1129 struct ivi_layout_layer *ivilayer = data;
1130
1131 struct listener_layout_notification *notification =
1132 container_of(listener,
1133 struct listener_layout_notification,
1134 listener);
1135
1136 struct ivi_layout_notification_callback *created_callback =
1137 notification->userdata;
1138
1139 ((layer_create_notification_func)created_callback->callback)
1140 (ivilayer, created_callback->data);
1141}
1142
1143static void
1144layer_removed(struct wl_listener *listener, void *data)
1145{
1146 struct ivi_layout_layer *ivilayer = data;
1147
1148 struct listener_layout_notification *notification =
1149 container_of(listener,
1150 struct listener_layout_notification,
1151 listener);
1152
1153 struct ivi_layout_notification_callback *removed_callback =
1154 notification->userdata;
1155
1156 ((layer_remove_notification_func)removed_callback->callback)
1157 (ivilayer, removed_callback->data);
1158}
1159
1160static void
1161layer_prop_changed(struct wl_listener *listener, void *data)
1162{
1163 struct ivi_layout_layer *ivilayer = data;
1164
1165 struct listener_layout_notification *layout_listener =
1166 container_of(listener,
1167 struct listener_layout_notification,
1168 listener);
1169
1170 struct ivi_layout_notification_callback *prop_callback =
1171 layout_listener->userdata;
1172
1173 ((layer_property_notification_func)prop_callback->callback)
1174 (ivilayer, &ivilayer->prop, ivilayer->event_mask, prop_callback->data);
1175}
1176
1177static void
1178surface_created(struct wl_listener *listener, void *data)
1179{
1180 struct ivi_layout_surface *ivisurface = data;
1181
1182 struct listener_layout_notification *notification =
1183 container_of(listener,
1184 struct listener_layout_notification,
1185 listener);
1186
1187 struct ivi_layout_notification_callback *created_callback =
1188 notification->userdata;
1189
1190 ((surface_create_notification_func)created_callback->callback)
1191 (ivisurface, created_callback->data);
1192}
1193
1194static void
1195surface_removed(struct wl_listener *listener, void *data)
1196{
1197 struct ivi_layout_surface *ivisurface = data;
1198
1199 struct listener_layout_notification *notification =
1200 container_of(listener,
1201 struct listener_layout_notification,
1202 listener);
1203
1204 struct ivi_layout_notification_callback *removed_callback =
1205 notification->userdata;
1206
1207 ((surface_remove_notification_func)removed_callback->callback)
1208 (ivisurface, removed_callback->data);
1209}
1210
1211static void
1212surface_prop_changed(struct wl_listener *listener, void *data)
1213{
1214 struct ivi_layout_surface *ivisurf = data;
1215
1216 struct listener_layout_notification *layout_listener =
1217 container_of(listener,
1218 struct listener_layout_notification,
1219 listener);
1220
1221 struct ivi_layout_notification_callback *prop_callback =
1222 layout_listener->userdata;
1223
1224 ((surface_property_notification_func)prop_callback->callback)
1225 (ivisurf, &ivisurf->prop, ivisurf->event_mask, prop_callback->data);
1226
1227 ivisurf->event_mask = 0;
1228}
1229
1230static void
1231surface_configure_changed(struct wl_listener *listener,
1232 void *data)
1233{
1234 struct ivi_layout_surface *ivisurface = data;
1235
1236 struct listener_layout_notification *notification =
1237 container_of(listener,
1238 struct listener_layout_notification,
1239 listener);
1240
1241 struct ivi_layout_notification_callback *configure_changed_callback =
1242 notification->userdata;
1243
1244 ((surface_configure_notification_func)configure_changed_callback->callback)
1245 (ivisurface, configure_changed_callback->data);
1246}
1247
1248static int32_t
1249add_notification(struct wl_signal *signal,
1250 wl_notify_func_t callback,
1251 void *userdata)
1252{
1253 struct listener_layout_notification *notification = NULL;
1254
1255 notification = malloc(sizeof *notification);
1256 if (notification == NULL) {
1257 weston_log("fails to allocate memory\n");
1258 free(userdata);
1259 return IVI_FAILED;
1260 }
1261
1262 notification->listener.notify = callback;
1263 notification->userdata = userdata;
1264
1265 wl_signal_add(signal, &notification->listener);
1266
1267 return IVI_SUCCEEDED;
1268}
1269
1270static void
1271remove_notification(struct wl_list *listener_list, void *callback, void *userdata)
1272{
1273 struct wl_listener *listener = NULL;
1274 struct wl_listener *next = NULL;
1275
1276 wl_list_for_each_safe(listener, next, listener_list, link) {
1277 struct listener_layout_notification *notification =
1278 container_of(listener,
1279 struct listener_layout_notification,
1280 listener);
1281
1282 struct ivi_layout_notification_callback *notification_callback =
1283 notification->userdata;
1284
1285 if ((notification_callback->callback != callback) ||
1286 (notification_callback->data != userdata)) {
1287 continue;
1288 }
1289
1290 if (!wl_list_empty(&listener->link)) {
1291 wl_list_remove(&listener->link);
1292 }
1293
1294 free(notification->userdata);
1295 free(notification);
1296 }
1297}
1298
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001299/**
1300 * Exported APIs of ivi-layout library are implemented from here.
1301 * Brief of APIs is described in ivi-layout-export.h.
1302 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001303static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001304ivi_layout_add_notification_create_layer(layer_create_notification_func callback,
1305 void *userdata)
1306{
1307 struct ivi_layout *layout = get_instance();
1308 struct ivi_layout_notification_callback *created_callback = NULL;
1309
1310 if (callback == NULL) {
1311 weston_log("ivi_layout_add_notification_create_layer: invalid argument\n");
1312 return IVI_FAILED;
1313 }
1314
1315 created_callback = malloc(sizeof *created_callback);
1316 if (created_callback == NULL) {
1317 weston_log("fails to allocate memory\n");
1318 return IVI_FAILED;
1319 }
1320
1321 created_callback->callback = callback;
1322 created_callback->data = userdata;
1323
1324 return add_notification(&layout->layer_notification.created,
1325 layer_created,
1326 created_callback);
1327}
1328
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001329static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001330ivi_layout_remove_notification_create_layer(layer_create_notification_func callback,
1331 void *userdata)
1332{
1333 struct ivi_layout *layout = get_instance();
1334 remove_notification(&layout->layer_notification.created.listener_list, callback, userdata);
1335}
1336
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001337static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001338ivi_layout_add_notification_remove_layer(layer_remove_notification_func callback,
1339 void *userdata)
1340{
1341 struct ivi_layout *layout = get_instance();
1342 struct ivi_layout_notification_callback *removed_callback = NULL;
1343
1344 if (callback == NULL) {
1345 weston_log("ivi_layout_add_notification_remove_layer: invalid argument\n");
1346 return IVI_FAILED;
1347 }
1348
1349 removed_callback = malloc(sizeof *removed_callback);
1350 if (removed_callback == NULL) {
1351 weston_log("fails to allocate memory\n");
1352 return IVI_FAILED;
1353 }
1354
1355 removed_callback->callback = callback;
1356 removed_callback->data = userdata;
1357 return add_notification(&layout->layer_notification.removed,
1358 layer_removed,
1359 removed_callback);
1360}
1361
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001362static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001363ivi_layout_remove_notification_remove_layer(layer_remove_notification_func callback,
1364 void *userdata)
1365{
1366 struct ivi_layout *layout = get_instance();
1367 remove_notification(&layout->layer_notification.removed.listener_list, callback, userdata);
1368}
1369
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001370static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001371ivi_layout_add_notification_create_surface(surface_create_notification_func callback,
1372 void *userdata)
1373{
1374 struct ivi_layout *layout = get_instance();
1375 struct ivi_layout_notification_callback *created_callback = NULL;
1376
1377 if (callback == NULL) {
1378 weston_log("ivi_layout_add_notification_create_surface: invalid argument\n");
1379 return IVI_FAILED;
1380 }
1381
1382 created_callback = malloc(sizeof *created_callback);
1383 if (created_callback == NULL) {
1384 weston_log("fails to allocate memory\n");
1385 return IVI_FAILED;
1386 }
1387
1388 created_callback->callback = callback;
1389 created_callback->data = userdata;
1390
1391 return add_notification(&layout->surface_notification.created,
1392 surface_created,
1393 created_callback);
1394}
1395
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001396static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001397ivi_layout_remove_notification_create_surface(surface_create_notification_func callback,
1398 void *userdata)
1399{
1400 struct ivi_layout *layout = get_instance();
1401 remove_notification(&layout->surface_notification.created.listener_list, callback, userdata);
1402}
1403
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001404static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001405ivi_layout_add_notification_remove_surface(surface_remove_notification_func callback,
1406 void *userdata)
1407{
1408 struct ivi_layout *layout = get_instance();
1409 struct ivi_layout_notification_callback *removed_callback = NULL;
1410
1411 if (callback == NULL) {
1412 weston_log("ivi_layout_add_notification_remove_surface: invalid argument\n");
1413 return IVI_FAILED;
1414 }
1415
1416 removed_callback = malloc(sizeof *removed_callback);
1417 if (removed_callback == NULL) {
1418 weston_log("fails to allocate memory\n");
1419 return IVI_FAILED;
1420 }
1421
1422 removed_callback->callback = callback;
1423 removed_callback->data = userdata;
1424
1425 return add_notification(&layout->surface_notification.removed,
1426 surface_removed,
1427 removed_callback);
1428}
1429
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001430static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001431ivi_layout_remove_notification_remove_surface(surface_remove_notification_func callback,
1432 void *userdata)
1433{
1434 struct ivi_layout *layout = get_instance();
1435 remove_notification(&layout->surface_notification.removed.listener_list, callback, userdata);
1436}
1437
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001438static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001439ivi_layout_add_notification_configure_surface(surface_configure_notification_func callback,
1440 void *userdata)
1441{
1442 struct ivi_layout *layout = get_instance();
1443 struct ivi_layout_notification_callback *configure_changed_callback = NULL;
1444 if (callback == NULL) {
1445 weston_log("ivi_layout_add_notification_configure_surface: invalid argument\n");
1446 return IVI_FAILED;
1447 }
1448
1449 configure_changed_callback = malloc(sizeof *configure_changed_callback);
1450 if (configure_changed_callback == NULL) {
1451 weston_log("fails to allocate memory\n");
1452 return IVI_FAILED;
1453 }
1454
1455 configure_changed_callback->callback = callback;
1456 configure_changed_callback->data = userdata;
1457
1458 return add_notification(&layout->surface_notification.configure_changed,
1459 surface_configure_changed,
1460 configure_changed_callback);
1461}
1462
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001463static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001464ivi_layout_remove_notification_configure_surface(surface_configure_notification_func callback,
1465 void *userdata)
1466{
1467 struct ivi_layout *layout = get_instance();
1468 remove_notification(&layout->surface_notification.configure_changed.listener_list, callback, userdata);
1469}
1470
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001471uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001472ivi_layout_get_id_of_surface(struct ivi_layout_surface *ivisurf)
1473{
1474 return ivisurf->id_surface;
1475}
1476
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001477static uint32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001478ivi_layout_get_id_of_layer(struct ivi_layout_layer *ivilayer)
1479{
1480 return ivilayer->id_layer;
1481}
1482
Nobuhiko Tanibata4d0116e2015-06-22 15:31:57 +09001483static uint32_t
1484ivi_layout_get_id_of_screen(struct ivi_layout_screen *iviscrn)
1485{
1486 return iviscrn->id_screen;
1487}
1488
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001489static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001490ivi_layout_get_layer_from_id(uint32_t id_layer)
1491{
1492 struct ivi_layout *layout = get_instance();
1493 struct ivi_layout_layer *ivilayer = NULL;
1494
1495 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1496 if (ivilayer->id_layer == id_layer) {
1497 return ivilayer;
1498 }
1499 }
1500
1501 return NULL;
1502}
1503
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001504struct ivi_layout_surface *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001505ivi_layout_get_surface_from_id(uint32_t id_surface)
1506{
1507 struct ivi_layout *layout = get_instance();
1508 struct ivi_layout_surface *ivisurf = NULL;
1509
1510 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1511 if (ivisurf->id_surface == id_surface) {
1512 return ivisurf;
1513 }
1514 }
1515
1516 return NULL;
1517}
1518
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001519static struct ivi_layout_screen *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001520ivi_layout_get_screen_from_id(uint32_t id_screen)
1521{
1522 struct ivi_layout *layout = get_instance();
1523 struct ivi_layout_screen *iviscrn = NULL;
1524
1525 wl_list_for_each(iviscrn, &layout->screen_list, link) {
1526/* FIXME : select iviscrn from screen_list by id_screen */
1527 return iviscrn;
1528 break;
1529 }
1530
1531 return NULL;
1532}
1533
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001534static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001535ivi_layout_get_screen_resolution(struct ivi_layout_screen *iviscrn,
1536 int32_t *pWidth, int32_t *pHeight)
1537{
1538 struct weston_output *output = NULL;
1539
Nobuhiko Tanibata0c217cb2015-06-22 15:30:32 +09001540 if (iviscrn == NULL || pWidth == NULL || pHeight == NULL) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001541 weston_log("ivi_layout_get_screen_resolution: invalid argument\n");
1542 return IVI_FAILED;
1543 }
1544
1545 output = iviscrn->output;
1546 *pWidth = output->current_mode->width;
1547 *pHeight = output->current_mode->height;
1548
1549 return IVI_SUCCEEDED;
1550}
1551
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001552static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001553ivi_layout_surface_add_notification(struct ivi_layout_surface *ivisurf,
1554 surface_property_notification_func callback,
1555 void *userdata)
1556{
1557 struct listener_layout_notification* notification = NULL;
1558 struct ivi_layout_notification_callback *prop_callback = NULL;
1559
1560 if (ivisurf == NULL || callback == NULL) {
1561 weston_log("ivi_layout_surface_add_notification: invalid argument\n");
1562 return IVI_FAILED;
1563 }
1564
1565 notification = malloc(sizeof *notification);
1566 if (notification == NULL) {
1567 weston_log("fails to allocate memory\n");
1568 return IVI_FAILED;
1569 }
1570
1571 prop_callback = malloc(sizeof *prop_callback);
1572 if (prop_callback == NULL) {
1573 weston_log("fails to allocate memory\n");
1574 return IVI_FAILED;
1575 }
1576
1577 prop_callback->callback = callback;
1578 prop_callback->data = userdata;
1579
1580 notification->listener.notify = surface_prop_changed;
1581 notification->userdata = prop_callback;
1582
1583 wl_signal_add(&ivisurf->property_changed, &notification->listener);
1584
1585 return IVI_SUCCEEDED;
1586}
1587
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001588static const struct ivi_layout_layer_properties *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001589ivi_layout_get_properties_of_layer(struct ivi_layout_layer *ivilayer)
1590{
1591 if (ivilayer == NULL) {
1592 weston_log("ivi_layout_get_properties_of_layer: invalid argument\n");
1593 return NULL;
1594 }
1595
1596 return &ivilayer->prop;
1597}
1598
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001599static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001600ivi_layout_get_screens(int32_t *pLength, struct ivi_layout_screen ***ppArray)
1601{
1602 struct ivi_layout *layout = get_instance();
1603 struct ivi_layout_screen *iviscrn = NULL;
1604 int32_t length = 0;
1605 int32_t n = 0;
1606
1607 if (pLength == NULL || ppArray == NULL) {
1608 weston_log("ivi_layout_get_screens: invalid argument\n");
1609 return IVI_FAILED;
1610 }
1611
1612 length = wl_list_length(&layout->screen_list);
1613
1614 if (length != 0){
1615 /* the Array must be free by module which called this function */
1616 *ppArray = calloc(length, sizeof(struct ivi_layout_screen *));
1617 if (*ppArray == NULL) {
1618 weston_log("fails to allocate memory\n");
1619 return IVI_FAILED;
1620 }
1621
1622 wl_list_for_each(iviscrn, &layout->screen_list, link) {
1623 (*ppArray)[n++] = iviscrn;
1624 }
1625 }
1626
1627 *pLength = length;
1628
1629 return IVI_SUCCEEDED;
1630}
1631
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001632static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001633ivi_layout_get_screens_under_layer(struct ivi_layout_layer *ivilayer,
1634 int32_t *pLength,
1635 struct ivi_layout_screen ***ppArray)
1636{
1637 struct link_screen *link_scrn = NULL;
1638 int32_t length = 0;
1639 int32_t n = 0;
1640
1641 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1642 weston_log("ivi_layout_get_screens_under_layer: invalid argument\n");
1643 return IVI_FAILED;
1644 }
1645
1646 length = wl_list_length(&ivilayer->screen_list);
1647
1648 if (length != 0){
1649 /* the Array must be free by module which called this function */
1650 *ppArray = calloc(length, sizeof(struct ivi_layout_screen *));
1651 if (*ppArray == NULL) {
1652 weston_log("fails to allocate memory\n");
1653 return IVI_FAILED;
1654 }
1655
1656 wl_list_for_each(link_scrn, &ivilayer->screen_list, link) {
1657 (*ppArray)[n++] = link_scrn->iviscrn;
1658 }
1659 }
1660
1661 *pLength = length;
1662
1663 return IVI_SUCCEEDED;
1664}
1665
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001666static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001667ivi_layout_get_layers(int32_t *pLength, struct ivi_layout_layer ***ppArray)
1668{
1669 struct ivi_layout *layout = get_instance();
1670 struct ivi_layout_layer *ivilayer = NULL;
1671 int32_t length = 0;
1672 int32_t n = 0;
1673
1674 if (pLength == NULL || ppArray == NULL) {
1675 weston_log("ivi_layout_get_layers: invalid argument\n");
1676 return IVI_FAILED;
1677 }
1678
1679 length = wl_list_length(&layout->layer_list);
1680
1681 if (length != 0){
1682 /* the Array must be free by module which called this function */
1683 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1684 if (*ppArray == NULL) {
1685 weston_log("fails to allocate memory\n");
1686 return IVI_FAILED;
1687 }
1688
1689 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1690 (*ppArray)[n++] = ivilayer;
1691 }
1692 }
1693
1694 *pLength = length;
1695
1696 return IVI_SUCCEEDED;
1697}
1698
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001699static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001700ivi_layout_get_layers_on_screen(struct ivi_layout_screen *iviscrn,
1701 int32_t *pLength,
1702 struct ivi_layout_layer ***ppArray)
1703{
1704 struct ivi_layout_layer *ivilayer = NULL;
1705 int32_t length = 0;
1706 int32_t n = 0;
1707
1708 if (iviscrn == NULL || pLength == NULL || ppArray == NULL) {
1709 weston_log("ivi_layout_get_layers_on_screen: invalid argument\n");
1710 return IVI_FAILED;
1711 }
1712
1713 length = wl_list_length(&iviscrn->order.layer_list);
1714
1715 if (length != 0){
1716 /* the Array must be free by module which called this function */
1717 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1718 if (*ppArray == NULL) {
1719 weston_log("fails to allocate memory\n");
1720 return IVI_FAILED;
1721 }
1722
Nobuhiko Tanibatae2b82142015-06-22 15:30:19 +09001723 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001724 (*ppArray)[n++] = ivilayer;
1725 }
1726 }
1727
1728 *pLength = length;
1729
1730 return IVI_SUCCEEDED;
1731}
1732
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001733static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001734ivi_layout_get_layers_under_surface(struct ivi_layout_surface *ivisurf,
1735 int32_t *pLength,
1736 struct ivi_layout_layer ***ppArray)
1737{
1738 struct link_layer *link_layer = NULL;
1739 int32_t length = 0;
1740 int32_t n = 0;
1741
1742 if (ivisurf == NULL || pLength == NULL || ppArray == NULL) {
1743 weston_log("ivi_layout_getLayers: invalid argument\n");
1744 return IVI_FAILED;
1745 }
1746
1747 length = wl_list_length(&ivisurf->layer_list);
1748
1749 if (length != 0){
1750 /* the Array must be free by module which called this function */
1751 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1752 if (*ppArray == NULL) {
1753 weston_log("fails to allocate memory\n");
1754 return IVI_FAILED;
1755 }
1756
1757 wl_list_for_each(link_layer, &ivisurf->layer_list, link) {
1758 (*ppArray)[n++] = link_layer->ivilayer;
1759 }
1760 }
1761
1762 *pLength = length;
1763
1764 return IVI_SUCCEEDED;
1765}
1766
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001767static
1768int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001769ivi_layout_get_surfaces(int32_t *pLength, struct ivi_layout_surface ***ppArray)
1770{
1771 struct ivi_layout *layout = get_instance();
1772 struct ivi_layout_surface *ivisurf = NULL;
1773 int32_t length = 0;
1774 int32_t n = 0;
1775
1776 if (pLength == NULL || ppArray == NULL) {
1777 weston_log("ivi_layout_get_surfaces: invalid argument\n");
1778 return IVI_FAILED;
1779 }
1780
1781 length = wl_list_length(&layout->surface_list);
1782
1783 if (length != 0){
1784 /* the Array must be free by module which called this function */
1785 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1786 if (*ppArray == NULL) {
1787 weston_log("fails to allocate memory\n");
1788 return IVI_FAILED;
1789 }
1790
1791 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1792 (*ppArray)[n++] = ivisurf;
1793 }
1794 }
1795
1796 *pLength = length;
1797
1798 return IVI_SUCCEEDED;
1799}
1800
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001801static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001802ivi_layout_get_surfaces_on_layer(struct ivi_layout_layer *ivilayer,
1803 int32_t *pLength,
1804 struct ivi_layout_surface ***ppArray)
1805{
1806 struct ivi_layout_surface *ivisurf = NULL;
1807 int32_t length = 0;
1808 int32_t n = 0;
1809
1810 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1811 weston_log("ivi_layout_getSurfaceIDsOnLayer: invalid argument\n");
1812 return IVI_FAILED;
1813 }
1814
1815 length = wl_list_length(&ivilayer->order.surface_list);
1816
1817 if (length != 0) {
1818 /* the Array must be free by module which called this function */
1819 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1820 if (*ppArray == NULL) {
1821 weston_log("fails to allocate memory\n");
1822 return IVI_FAILED;
1823 }
1824
1825 wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) {
1826 (*ppArray)[n++] = ivisurf;
1827 }
1828 }
1829
1830 *pLength = length;
1831
1832 return IVI_SUCCEEDED;
1833}
1834
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001835static struct ivi_layout_layer *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001836ivi_layout_layer_create_with_dimension(uint32_t id_layer,
1837 int32_t width, int32_t height)
1838{
1839 struct ivi_layout *layout = get_instance();
1840 struct ivi_layout_layer *ivilayer = NULL;
1841
1842 ivilayer = get_layer(&layout->layer_list, id_layer);
1843 if (ivilayer != NULL) {
1844 weston_log("id_layer is already created\n");
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001845 ++ivilayer->ref_count;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001846 return ivilayer;
1847 }
1848
1849 ivilayer = calloc(1, sizeof *ivilayer);
1850 if (ivilayer == NULL) {
1851 weston_log("fails to allocate memory\n");
1852 return NULL;
1853 }
1854
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001855 ivilayer->ref_count = 1;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001856 wl_list_init(&ivilayer->link);
1857 wl_signal_init(&ivilayer->property_changed);
1858 wl_list_init(&ivilayer->screen_list);
1859 wl_list_init(&ivilayer->link_to_surface);
1860 ivilayer->layout = layout;
1861 ivilayer->id_layer = id_layer;
1862
1863 init_layer_properties(&ivilayer->prop, width, height);
1864 ivilayer->event_mask = 0;
1865
1866 wl_list_init(&ivilayer->pending.surface_list);
1867 wl_list_init(&ivilayer->pending.link);
1868 ivilayer->pending.prop = ivilayer->prop;
1869
1870 wl_list_init(&ivilayer->order.surface_list);
1871 wl_list_init(&ivilayer->order.link);
1872
1873 wl_list_insert(&layout->layer_list, &ivilayer->link);
1874
1875 wl_signal_emit(&layout->layer_notification.created, ivilayer);
1876
1877 return ivilayer;
1878}
1879
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001880static void
Nobuhiko Tanibataef6c7862014-12-15 13:20:44 +09001881ivi_layout_layer_remove_notification(struct ivi_layout_layer *ivilayer)
1882{
1883 if (ivilayer == NULL) {
1884 weston_log("ivi_layout_layer_remove_notification: invalid argument\n");
1885 return;
1886 }
1887
1888 remove_all_notification(&ivilayer->property_changed.listener_list);
1889}
1890
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001891static void
Nobuhiko Tanibatadb8efd12015-06-22 15:31:39 +09001892ivi_layout_layer_remove_notification_by_callback(struct ivi_layout_layer *ivilayer,
1893 layer_property_notification_func callback,
1894 void *userdata)
1895{
1896 if (ivilayer == NULL) {
1897 weston_log("ivi_layout_layer_remove_notification_by_callback: invalid argument\n");
1898 return;
1899 }
1900
1901 remove_notification(&ivilayer->property_changed.listener_list, callback, userdata);
1902}
1903
1904static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001905ivi_layout_layer_remove(struct ivi_layout_layer *ivilayer)
1906{
1907 struct ivi_layout *layout = get_instance();
1908
1909 if (ivilayer == NULL) {
1910 weston_log("ivi_layout_layer_remove: invalid argument\n");
1911 return;
1912 }
1913
Nobuhiko Tanibata4b601e12015-06-22 15:31:16 +09001914 if (--ivilayer->ref_count > 0)
1915 return;
1916
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001917 wl_signal_emit(&layout->layer_notification.removed, ivilayer);
1918
1919 clear_surface_pending_list(ivilayer);
1920 clear_surface_order_list(ivilayer);
1921
1922 if (!wl_list_empty(&ivilayer->pending.link)) {
1923 wl_list_remove(&ivilayer->pending.link);
1924 }
1925 if (!wl_list_empty(&ivilayer->order.link)) {
1926 wl_list_remove(&ivilayer->order.link);
1927 }
1928 if (!wl_list_empty(&ivilayer->link)) {
1929 wl_list_remove(&ivilayer->link);
1930 }
1931 remove_orderlayer_from_screen(ivilayer);
1932 remove_link_to_surface(ivilayer);
1933 ivi_layout_layer_remove_notification(ivilayer);
1934
1935 free(ivilayer);
1936}
1937
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001938int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001939ivi_layout_layer_set_visibility(struct ivi_layout_layer *ivilayer,
1940 bool newVisibility)
1941{
1942 struct ivi_layout_layer_properties *prop = NULL;
1943
1944 if (ivilayer == NULL) {
1945 weston_log("ivi_layout_layer_set_visibility: invalid argument\n");
1946 return IVI_FAILED;
1947 }
1948
1949 prop = &ivilayer->pending.prop;
1950 prop->visibility = newVisibility;
1951
1952 ivilayer->event_mask |= IVI_NOTIFICATION_VISIBILITY;
1953
1954 return IVI_SUCCEEDED;
1955}
1956
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001957static bool
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001958ivi_layout_layer_get_visibility(struct ivi_layout_layer *ivilayer)
1959{
1960 if (ivilayer == NULL) {
1961 weston_log("ivi_layout_layer_get_visibility: invalid argument\n");
1962 return false;
1963 }
1964
1965 return ivilayer->prop.visibility;
1966}
1967
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001968int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001969ivi_layout_layer_set_opacity(struct ivi_layout_layer *ivilayer,
1970 wl_fixed_t opacity)
1971{
1972 struct ivi_layout_layer_properties *prop = NULL;
1973
Nobuhiko Tanibata7bbacc62015-06-22 15:30:09 +09001974 if (ivilayer == NULL ||
1975 opacity < wl_fixed_from_double(0.0) ||
1976 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001977 weston_log("ivi_layout_layer_set_opacity: invalid argument\n");
1978 return IVI_FAILED;
1979 }
1980
1981 prop = &ivilayer->pending.prop;
1982 prop->opacity = opacity;
1983
1984 ivilayer->event_mask |= IVI_NOTIFICATION_OPACITY;
1985
1986 return IVI_SUCCEEDED;
1987}
1988
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09001989wl_fixed_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001990ivi_layout_layer_get_opacity(struct ivi_layout_layer *ivilayer)
1991{
1992 if (ivilayer == NULL) {
1993 weston_log("ivi_layout_layer_get_opacity: invalid argument\n");
1994 return wl_fixed_from_double(0.0);
1995 }
1996
1997 return ivilayer->prop.opacity;
1998}
1999
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002000static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002001ivi_layout_layer_set_source_rectangle(struct ivi_layout_layer *ivilayer,
2002 int32_t x, int32_t y,
2003 int32_t width, int32_t height)
2004{
2005 struct ivi_layout_layer_properties *prop = NULL;
2006
2007 if (ivilayer == NULL) {
2008 weston_log("ivi_layout_layer_set_source_rectangle: invalid argument\n");
2009 return IVI_FAILED;
2010 }
2011
2012 prop = &ivilayer->pending.prop;
2013 prop->source_x = x;
2014 prop->source_y = y;
2015 prop->source_width = width;
2016 prop->source_height = height;
2017
2018 ivilayer->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
2019
2020 return IVI_SUCCEEDED;
2021}
2022
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002023static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002024ivi_layout_layer_set_destination_rectangle(struct ivi_layout_layer *ivilayer,
2025 int32_t x, int32_t y,
2026 int32_t width, int32_t height)
2027{
2028 struct ivi_layout_layer_properties *prop = NULL;
2029
2030 if (ivilayer == NULL) {
2031 weston_log("ivi_layout_layer_set_destination_rectangle: invalid argument\n");
2032 return IVI_FAILED;
2033 }
2034
2035 prop = &ivilayer->pending.prop;
2036 prop->dest_x = x;
2037 prop->dest_y = y;
2038 prop->dest_width = width;
2039 prop->dest_height = height;
2040
2041 ivilayer->event_mask |= IVI_NOTIFICATION_DEST_RECT;
2042
2043 return IVI_SUCCEEDED;
2044}
2045
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002046static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002047ivi_layout_layer_get_dimension(struct ivi_layout_layer *ivilayer,
2048 int32_t *dest_width, int32_t *dest_height)
2049{
2050 if (ivilayer == NULL || dest_width == NULL || dest_height == NULL) {
2051 weston_log("ivi_layout_layer_get_dimension: invalid argument\n");
2052 return IVI_FAILED;
2053 }
2054
2055 *dest_width = ivilayer->prop.dest_width;
2056 *dest_height = ivilayer->prop.dest_height;
2057
2058 return IVI_SUCCEEDED;
2059}
2060
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002061static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002062ivi_layout_layer_set_dimension(struct ivi_layout_layer *ivilayer,
2063 int32_t dest_width, int32_t dest_height)
2064{
2065 struct ivi_layout_layer_properties *prop = NULL;
2066
2067 if (ivilayer == NULL) {
2068 weston_log("ivi_layout_layer_set_dimension: invalid argument\n");
2069 return IVI_FAILED;
2070 }
2071
2072 prop = &ivilayer->pending.prop;
2073
2074 prop->dest_width = dest_width;
2075 prop->dest_height = dest_height;
2076
2077 ivilayer->event_mask |= IVI_NOTIFICATION_DIMENSION;
2078
2079 return IVI_SUCCEEDED;
2080}
2081
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002082int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002083ivi_layout_layer_get_position(struct ivi_layout_layer *ivilayer,
2084 int32_t *dest_x, int32_t *dest_y)
2085{
2086 if (ivilayer == NULL || dest_x == NULL || dest_y == NULL) {
2087 weston_log("ivi_layout_layer_get_position: invalid argument\n");
2088 return IVI_FAILED;
2089 }
2090
2091 *dest_x = ivilayer->prop.dest_x;
2092 *dest_y = ivilayer->prop.dest_y;
2093
2094 return IVI_SUCCEEDED;
2095}
2096
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002097int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002098ivi_layout_layer_set_position(struct ivi_layout_layer *ivilayer,
2099 int32_t dest_x, int32_t dest_y)
2100{
2101 struct ivi_layout_layer_properties *prop = NULL;
2102
2103 if (ivilayer == NULL) {
2104 weston_log("ivi_layout_layer_set_position: invalid argument\n");
2105 return IVI_FAILED;
2106 }
2107
2108 prop = &ivilayer->pending.prop;
2109 prop->dest_x = dest_x;
2110 prop->dest_y = dest_y;
2111
2112 ivilayer->event_mask |= IVI_NOTIFICATION_POSITION;
2113
2114 return IVI_SUCCEEDED;
2115}
2116
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002117static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002118ivi_layout_layer_set_orientation(struct ivi_layout_layer *ivilayer,
2119 enum wl_output_transform orientation)
2120{
2121 struct ivi_layout_layer_properties *prop = NULL;
2122
2123 if (ivilayer == NULL) {
2124 weston_log("ivi_layout_layer_set_orientation: invalid argument\n");
2125 return IVI_FAILED;
2126 }
2127
2128 prop = &ivilayer->pending.prop;
2129 prop->orientation = orientation;
2130
2131 ivilayer->event_mask |= IVI_NOTIFICATION_ORIENTATION;
2132
2133 return IVI_SUCCEEDED;
2134}
2135
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002136static enum wl_output_transform
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002137ivi_layout_layer_get_orientation(struct ivi_layout_layer *ivilayer)
2138{
2139 if (ivilayer == NULL) {
2140 weston_log("ivi_layout_layer_get_orientation: invalid argument\n");
2141 return 0;
2142 }
2143
2144 return ivilayer->prop.orientation;
2145}
2146
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002147int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002148ivi_layout_layer_set_render_order(struct ivi_layout_layer *ivilayer,
2149 struct ivi_layout_surface **pSurface,
2150 int32_t number)
2151{
2152 struct ivi_layout *layout = get_instance();
2153 struct ivi_layout_surface *ivisurf = NULL;
2154 struct ivi_layout_surface *next = NULL;
2155 uint32_t *id_surface = NULL;
2156 int32_t i = 0;
2157
2158 if (ivilayer == NULL) {
2159 weston_log("ivi_layout_layer_set_render_order: invalid argument\n");
2160 return IVI_FAILED;
2161 }
2162
2163 if (pSurface == NULL) {
2164 wl_list_for_each_safe(ivisurf, next, &ivilayer->pending.surface_list, pending.link) {
2165 if (!wl_list_empty(&ivisurf->pending.link)) {
2166 wl_list_remove(&ivisurf->pending.link);
2167 }
2168
2169 wl_list_init(&ivisurf->pending.link);
2170 }
2171 ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE;
2172 return IVI_SUCCEEDED;
2173 }
2174
2175 for (i = 0; i < number; i++) {
2176 id_surface = &pSurface[i]->id_surface;
2177
2178 wl_list_for_each_safe(ivisurf, next, &layout->surface_list, link) {
2179 if (*id_surface != ivisurf->id_surface) {
2180 continue;
2181 }
2182
2183 if (!wl_list_empty(&ivisurf->pending.link)) {
2184 wl_list_remove(&ivisurf->pending.link);
2185 }
2186 wl_list_init(&ivisurf->pending.link);
2187 wl_list_insert(&ivilayer->pending.surface_list,
2188 &ivisurf->pending.link);
2189 break;
2190 }
2191 }
2192
2193 ivilayer->event_mask |= IVI_NOTIFICATION_ADD;
2194
2195 return IVI_SUCCEEDED;
2196}
2197
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002198int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002199ivi_layout_surface_set_visibility(struct ivi_layout_surface *ivisurf,
2200 bool newVisibility)
2201{
2202 struct ivi_layout_surface_properties *prop = NULL;
2203
2204 if (ivisurf == NULL) {
2205 weston_log("ivi_layout_surface_set_visibility: invalid argument\n");
2206 return IVI_FAILED;
2207 }
2208
2209 prop = &ivisurf->pending.prop;
2210 prop->visibility = newVisibility;
2211
2212 ivisurf->event_mask |= IVI_NOTIFICATION_VISIBILITY;
2213
2214 return IVI_SUCCEEDED;
2215}
2216
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002217bool
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002218ivi_layout_surface_get_visibility(struct ivi_layout_surface *ivisurf)
2219{
2220 if (ivisurf == NULL) {
2221 weston_log("ivi_layout_surface_get_visibility: invalid argument\n");
2222 return false;
2223 }
2224
2225 return ivisurf->prop.visibility;
2226}
2227
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002228int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002229ivi_layout_surface_set_opacity(struct ivi_layout_surface *ivisurf,
2230 wl_fixed_t opacity)
2231{
2232 struct ivi_layout_surface_properties *prop = NULL;
2233
Nobuhiko Tanibataa86226c2015-06-22 15:29:20 +09002234 if (ivisurf == NULL ||
2235 opacity < wl_fixed_from_double(0.0) ||
2236 wl_fixed_from_double(1.0) < opacity) {
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002237 weston_log("ivi_layout_surface_set_opacity: invalid argument\n");
2238 return IVI_FAILED;
2239 }
2240
2241 prop = &ivisurf->pending.prop;
2242 prop->opacity = opacity;
2243
2244 ivisurf->event_mask |= IVI_NOTIFICATION_OPACITY;
2245
2246 return IVI_SUCCEEDED;
2247}
2248
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002249wl_fixed_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002250ivi_layout_surface_get_opacity(struct ivi_layout_surface *ivisurf)
2251{
2252 if (ivisurf == NULL) {
2253 weston_log("ivi_layout_surface_get_opacity: invalid argument\n");
2254 return wl_fixed_from_double(0.0);
2255 }
2256
2257 return ivisurf->prop.opacity;
2258}
2259
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002260int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002261ivi_layout_surface_set_destination_rectangle(struct ivi_layout_surface *ivisurf,
2262 int32_t x, int32_t y,
2263 int32_t width, int32_t height)
2264{
2265 struct ivi_layout_surface_properties *prop = NULL;
2266
2267 if (ivisurf == NULL) {
2268 weston_log("ivi_layout_surface_set_destination_rectangle: invalid argument\n");
2269 return IVI_FAILED;
2270 }
2271
2272 prop = &ivisurf->pending.prop;
2273 prop->start_x = prop->dest_x;
2274 prop->start_y = prop->dest_y;
2275 prop->dest_x = x;
2276 prop->dest_y = y;
2277 prop->start_width = prop->dest_width;
2278 prop->start_height = prop->dest_height;
2279 prop->dest_width = width;
2280 prop->dest_height = height;
2281
2282 ivisurf->event_mask |= IVI_NOTIFICATION_DEST_RECT;
2283
2284 return IVI_SUCCEEDED;
2285}
2286
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002287static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002288ivi_layout_surface_set_dimension(struct ivi_layout_surface *ivisurf,
2289 int32_t dest_width, int32_t dest_height)
2290{
2291 struct ivi_layout_surface_properties *prop = NULL;
2292
2293 if (ivisurf == NULL) {
2294 weston_log("ivi_layout_surface_set_dimension: invalid argument\n");
2295 return IVI_FAILED;
2296 }
2297
2298 prop = &ivisurf->pending.prop;
2299 prop->dest_width = dest_width;
2300 prop->dest_height = dest_height;
2301
2302 ivisurf->event_mask |= IVI_NOTIFICATION_DIMENSION;
2303
2304 return IVI_SUCCEEDED;
2305}
2306
2307int32_t
2308ivi_layout_surface_get_dimension(struct ivi_layout_surface *ivisurf,
2309 int32_t *dest_width, int32_t *dest_height)
2310{
2311 if (ivisurf == NULL || dest_width == NULL || dest_height == NULL) {
2312 weston_log("ivi_layout_surface_get_dimension: invalid argument\n");
2313 return IVI_FAILED;
2314 }
2315
2316 *dest_width = ivisurf->prop.dest_width;
2317 *dest_height = ivisurf->prop.dest_height;
2318
2319 return IVI_SUCCEEDED;
2320}
2321
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002322static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002323ivi_layout_surface_set_position(struct ivi_layout_surface *ivisurf,
2324 int32_t dest_x, int32_t dest_y)
2325{
2326 struct ivi_layout_surface_properties *prop = NULL;
2327
2328 if (ivisurf == NULL) {
2329 weston_log("ivi_layout_surface_set_position: invalid argument\n");
2330 return IVI_FAILED;
2331 }
2332
2333 prop = &ivisurf->pending.prop;
2334 prop->dest_x = dest_x;
2335 prop->dest_y = dest_y;
2336
2337 ivisurf->event_mask |= IVI_NOTIFICATION_POSITION;
2338
2339 return IVI_SUCCEEDED;
2340}
2341
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002342static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002343ivi_layout_surface_get_position(struct ivi_layout_surface *ivisurf,
2344 int32_t *dest_x, int32_t *dest_y)
2345{
2346 if (ivisurf == NULL || dest_x == NULL || dest_y == NULL) {
2347 weston_log("ivi_layout_surface_get_position: invalid argument\n");
2348 return IVI_FAILED;
2349 }
2350
2351 *dest_x = ivisurf->prop.dest_x;
2352 *dest_y = ivisurf->prop.dest_y;
2353
2354 return IVI_SUCCEEDED;
2355}
2356
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002357static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002358ivi_layout_surface_set_orientation(struct ivi_layout_surface *ivisurf,
2359 enum wl_output_transform orientation)
2360{
2361 struct ivi_layout_surface_properties *prop = NULL;
2362
2363 if (ivisurf == NULL) {
2364 weston_log("ivi_layout_surface_set_orientation: invalid argument\n");
2365 return IVI_FAILED;
2366 }
2367
2368 prop = &ivisurf->pending.prop;
2369 prop->orientation = orientation;
2370
2371 ivisurf->event_mask |= IVI_NOTIFICATION_ORIENTATION;
2372
2373 return IVI_SUCCEEDED;
2374}
2375
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002376static enum wl_output_transform
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002377ivi_layout_surface_get_orientation(struct ivi_layout_surface *ivisurf)
2378{
2379 if (ivisurf == NULL) {
2380 weston_log("ivi_layout_surface_get_orientation: invalid argument\n");
2381 return 0;
2382 }
2383
2384 return ivisurf->prop.orientation;
2385}
2386
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002387static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002388ivi_layout_screen_add_layer(struct ivi_layout_screen *iviscrn,
2389 struct ivi_layout_layer *addlayer)
2390{
2391 struct ivi_layout *layout = get_instance();
2392 struct ivi_layout_layer *ivilayer = NULL;
2393 struct ivi_layout_layer *next = NULL;
2394 int is_layer_in_scrn = 0;
2395
2396 if (iviscrn == NULL || addlayer == NULL) {
2397 weston_log("ivi_layout_screen_add_layer: invalid argument\n");
2398 return IVI_FAILED;
2399 }
2400
2401 is_layer_in_scrn = is_layer_in_screen(addlayer, iviscrn);
2402 if (is_layer_in_scrn == 1) {
2403 weston_log("ivi_layout_screen_add_layer: addlayer is already available\n");
2404 return IVI_SUCCEEDED;
2405 }
2406
2407 wl_list_for_each_safe(ivilayer, next, &layout->layer_list, link) {
2408 if (ivilayer->id_layer == addlayer->id_layer) {
2409 if (!wl_list_empty(&ivilayer->pending.link)) {
2410 wl_list_remove(&ivilayer->pending.link);
2411 }
2412 wl_list_init(&ivilayer->pending.link);
2413 wl_list_insert(&iviscrn->pending.layer_list,
2414 &ivilayer->pending.link);
2415 break;
2416 }
2417 }
2418
2419 iviscrn->event_mask |= IVI_NOTIFICATION_ADD;
2420
2421 return IVI_SUCCEEDED;
2422}
2423
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002424static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002425ivi_layout_screen_set_render_order(struct ivi_layout_screen *iviscrn,
2426 struct ivi_layout_layer **pLayer,
2427 const int32_t number)
2428{
2429 struct ivi_layout *layout = get_instance();
2430 struct ivi_layout_layer *ivilayer = NULL;
2431 struct ivi_layout_layer *next = NULL;
2432 uint32_t *id_layer = NULL;
2433 int32_t i = 0;
2434
2435 if (iviscrn == NULL) {
2436 weston_log("ivi_layout_screen_set_render_order: invalid argument\n");
2437 return IVI_FAILED;
2438 }
2439
2440 wl_list_for_each_safe(ivilayer, next,
2441 &iviscrn->pending.layer_list, pending.link) {
2442 wl_list_init(&ivilayer->pending.link);
2443 }
2444
2445 wl_list_init(&iviscrn->pending.layer_list);
2446
2447 if (pLayer == NULL) {
2448 wl_list_for_each_safe(ivilayer, next, &iviscrn->pending.layer_list, pending.link) {
2449 if (!wl_list_empty(&ivilayer->pending.link)) {
2450 wl_list_remove(&ivilayer->pending.link);
2451 }
2452
2453 wl_list_init(&ivilayer->pending.link);
2454 }
2455
2456 iviscrn->event_mask |= IVI_NOTIFICATION_REMOVE;
2457 return IVI_SUCCEEDED;
2458 }
2459
2460 for (i = 0; i < number; i++) {
2461 id_layer = &pLayer[i]->id_layer;
2462 wl_list_for_each(ivilayer, &layout->layer_list, link) {
2463 if (*id_layer != ivilayer->id_layer) {
2464 continue;
2465 }
2466
2467 if (!wl_list_empty(&ivilayer->pending.link)) {
2468 wl_list_remove(&ivilayer->pending.link);
2469 }
2470 wl_list_init(&ivilayer->pending.link);
2471 wl_list_insert(&iviscrn->pending.layer_list,
2472 &ivilayer->pending.link);
2473 break;
2474 }
2475 }
2476
2477 iviscrn->event_mask |= IVI_NOTIFICATION_ADD;
2478
2479 return IVI_SUCCEEDED;
2480}
2481
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002482static struct weston_output *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002483ivi_layout_screen_get_output(struct ivi_layout_screen *iviscrn)
2484{
2485 return iviscrn->output;
2486}
2487
2488/**
2489 * This function is used by the additional ivi-module because of dumping ivi_surface sceenshot.
2490 * The ivi-module, e.g. ivi-controller.so, is in wayland-ivi-extension of Genivi's Layer Management.
2491 * This function is used to get the result of drawing by clients.
2492 */
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002493static struct weston_surface *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002494ivi_layout_surface_get_weston_surface(struct ivi_layout_surface *ivisurf)
2495{
2496 return ivisurf != NULL ? ivisurf->surface : NULL;
2497}
2498
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002499static int32_t
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09002500ivi_layout_surface_get_size(struct ivi_layout_surface *ivisurf,
2501 int32_t *width, int32_t *height,
2502 int32_t *stride)
2503{
2504 int32_t w;
2505 int32_t h;
2506 const size_t bytespp = 4; /* PIXMAN_a8b8g8r8 */
2507
2508 if (ivisurf == NULL || ivisurf->surface == NULL) {
2509 weston_log("%s: invalid argument\n", __func__);
2510 return IVI_FAILED;
2511 }
2512
2513 weston_surface_get_content_size(ivisurf->surface, &w, &h);
2514
2515 if (width != NULL)
2516 *width = w;
2517
2518 if (height != NULL)
2519 *height = h;
2520
2521 if (stride != NULL)
2522 *stride = w * bytespp;
2523
2524 return IVI_SUCCEEDED;
2525}
2526
2527static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002528ivi_layout_layer_add_notification(struct ivi_layout_layer *ivilayer,
2529 layer_property_notification_func callback,
2530 void *userdata)
2531{
2532 struct ivi_layout_notification_callback *prop_callback = NULL;
2533
2534 if (ivilayer == NULL || callback == NULL) {
2535 weston_log("ivi_layout_layer_add_notification: invalid argument\n");
2536 return IVI_FAILED;
2537 }
2538
2539 prop_callback = malloc(sizeof *prop_callback);
2540 if (prop_callback == NULL) {
2541 weston_log("fails to allocate memory\n");
2542 return IVI_FAILED;
2543 }
2544
2545 prop_callback->callback = callback;
2546 prop_callback->data = userdata;
2547
2548 return add_notification(&ivilayer->property_changed,
2549 layer_prop_changed,
2550 prop_callback);
2551}
2552
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002553static const struct ivi_layout_surface_properties *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002554ivi_layout_get_properties_of_surface(struct ivi_layout_surface *ivisurf)
2555{
2556 if (ivisurf == NULL) {
2557 weston_log("ivi_layout_get_properties_of_surface: invalid argument\n");
2558 return NULL;
2559 }
2560
2561 return &ivisurf->prop;
2562}
2563
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002564static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002565ivi_layout_layer_add_surface(struct ivi_layout_layer *ivilayer,
2566 struct ivi_layout_surface *addsurf)
2567{
2568 struct ivi_layout *layout = get_instance();
2569 struct ivi_layout_surface *ivisurf = NULL;
2570 struct ivi_layout_surface *next = NULL;
2571 int is_surf_in_layer = 0;
2572
2573 if (ivilayer == NULL || addsurf == NULL) {
2574 weston_log("ivi_layout_layer_add_surface: invalid argument\n");
2575 return IVI_FAILED;
2576 }
2577
2578 is_surf_in_layer = is_surface_in_layer(addsurf, ivilayer);
2579 if (is_surf_in_layer == 1) {
2580 weston_log("ivi_layout_layer_add_surface: addsurf is already available\n");
2581 return IVI_SUCCEEDED;
2582 }
2583
2584 wl_list_for_each_safe(ivisurf, next, &layout->surface_list, link) {
2585 if (ivisurf->id_surface == addsurf->id_surface) {
2586 if (!wl_list_empty(&ivisurf->pending.link)) {
2587 wl_list_remove(&ivisurf->pending.link);
2588 }
2589 wl_list_init(&ivisurf->pending.link);
2590 wl_list_insert(&ivilayer->pending.surface_list,
2591 &ivisurf->pending.link);
2592 break;
2593 }
2594 }
2595
2596 ivilayer->event_mask |= IVI_NOTIFICATION_ADD;
2597
2598 return IVI_SUCCEEDED;
2599}
2600
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002601static void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002602ivi_layout_layer_remove_surface(struct ivi_layout_layer *ivilayer,
2603 struct ivi_layout_surface *remsurf)
2604{
2605 struct ivi_layout_surface *ivisurf = NULL;
2606 struct ivi_layout_surface *next = NULL;
2607
2608 if (ivilayer == NULL || remsurf == NULL) {
2609 weston_log("ivi_layout_layer_remove_surface: invalid argument\n");
2610 return;
2611 }
2612
2613 wl_list_for_each_safe(ivisurf, next,
2614 &ivilayer->pending.surface_list, pending.link) {
2615 if (ivisurf->id_surface == remsurf->id_surface) {
2616 if (!wl_list_empty(&ivisurf->pending.link)) {
2617 wl_list_remove(&ivisurf->pending.link);
2618 }
2619 wl_list_init(&ivisurf->pending.link);
2620 break;
2621 }
2622 }
2623
2624 remsurf->event_mask |= IVI_NOTIFICATION_REMOVE;
2625}
2626
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002627static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002628ivi_layout_surface_set_source_rectangle(struct ivi_layout_surface *ivisurf,
2629 int32_t x, int32_t y,
2630 int32_t width, int32_t height)
2631{
2632 struct ivi_layout_surface_properties *prop = NULL;
2633
2634 if (ivisurf == NULL) {
2635 weston_log("ivi_layout_surface_set_source_rectangle: invalid argument\n");
2636 return IVI_FAILED;
2637 }
2638
2639 prop = &ivisurf->pending.prop;
2640 prop->source_x = x;
2641 prop->source_y = y;
2642 prop->source_width = width;
2643 prop->source_height = height;
2644
2645 ivisurf->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
2646
2647 return IVI_SUCCEEDED;
2648}
2649
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002650int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002651ivi_layout_commit_changes(void)
2652{
2653 struct ivi_layout *layout = get_instance();
2654
2655 commit_surface_list(layout);
2656 commit_layer_list(layout);
2657 commit_screen_list(layout);
2658
2659 commit_transition(layout);
2660
2661 commit_changes(layout);
2662 send_prop(layout);
2663 weston_compositor_schedule_repaint(layout->compositor);
2664
2665 return IVI_SUCCEEDED;
2666}
2667
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002668static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09002669ivi_layout_layer_set_transition(struct ivi_layout_layer *ivilayer,
2670 enum ivi_layout_transition_type type,
2671 uint32_t duration)
2672{
2673 if (ivilayer == NULL) {
2674 weston_log("%s: invalid argument\n", __func__);
2675 return -1;
2676 }
2677
2678 ivilayer->pending.prop.transition_type = type;
2679 ivilayer->pending.prop.transition_duration = duration;
2680
2681 return 0;
2682}
2683
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002684static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09002685ivi_layout_layer_set_fade_info(struct ivi_layout_layer* ivilayer,
2686 uint32_t is_fade_in,
2687 double start_alpha, double end_alpha)
2688{
2689 if (ivilayer == NULL) {
2690 weston_log("%s: invalid argument\n", __func__);
2691 return -1;
2692 }
2693
2694 ivilayer->pending.prop.is_fade_in = is_fade_in;
2695 ivilayer->pending.prop.start_alpha = start_alpha;
2696 ivilayer->pending.prop.end_alpha = end_alpha;
2697
2698 return 0;
2699}
2700
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002701static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09002702ivi_layout_surface_set_transition_duration(struct ivi_layout_surface *ivisurf,
2703 uint32_t duration)
2704{
2705 struct ivi_layout_surface_properties *prop;
2706
2707 if (ivisurf == NULL) {
2708 weston_log("%s: invalid argument\n", __func__);
2709 return -1;
2710 }
2711
2712 prop = &ivisurf->pending.prop;
2713 prop->transition_duration = duration*10;
2714 return 0;
2715}
2716
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002717static int32_t
Nobuhiko Tanibata3c6796f2014-12-15 13:20:58 +09002718ivi_layout_surface_set_transition(struct ivi_layout_surface *ivisurf,
2719 enum ivi_layout_transition_type type,
2720 uint32_t duration)
2721{
2722 struct ivi_layout_surface_properties *prop;
2723
2724 if (ivisurf == NULL) {
2725 weston_log("%s: invalid argument\n", __func__);
2726 return -1;
2727 }
2728
2729 prop = &ivisurf->pending.prop;
2730 prop->transition_type = type;
2731 prop->transition_duration = duration;
2732 return 0;
2733}
2734
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09002735static int32_t
2736ivi_layout_surface_dump(struct weston_surface *surface,
2737 void *target, size_t size,int32_t x, int32_t y,
2738 int32_t width, int32_t height)
2739{
2740 int result = 0;
2741
2742 if (surface == NULL) {
2743 weston_log("%s: invalid argument\n", __func__);
2744 return IVI_FAILED;
2745 }
2746
2747 result = weston_surface_copy_content(
2748 surface, target, size,
2749 x, y, width, height);
2750
2751 return result == 0 ? IVI_SUCCEEDED : IVI_FAILED;
2752}
2753
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002754/**
2755 * methods of interaction between ivi-shell with ivi-layout
2756 */
2757struct weston_view *
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002758ivi_layout_get_weston_view(struct ivi_layout_surface *surface)
2759{
2760 struct weston_view *tmpview = NULL;
2761
2762 if(surface == NULL)
2763 return NULL;
2764
2765 wl_list_for_each(tmpview, &surface->surface->views, surface_link)
2766 {
2767 if (tmpview != NULL) {
2768 break;
2769 }
2770 }
2771 return tmpview;
2772}
2773
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002774void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002775ivi_layout_surface_configure(struct ivi_layout_surface *ivisurf,
2776 int32_t width, int32_t height)
2777{
2778 struct ivi_layout *layout = get_instance();
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002779
Nobuhiko Tanibatae6cc9972015-04-27 16:54:01 +09002780 /* emit callback which is set by ivi-layout api user */
2781 wl_signal_emit(&layout->surface_notification.configure_changed,
2782 ivisurf);
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002783}
2784
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002785static int32_t
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002786ivi_layout_surface_set_content_observer(struct ivi_layout_surface *ivisurf,
2787 ivi_controller_surface_content_callback callback,
2788 void* userdata)
2789{
2790 int32_t ret = IVI_FAILED;
2791
2792 if (ivisurf != NULL) {
2793 ivisurf->content_observer.callback = callback;
2794 ivisurf->content_observer.userdata = userdata;
2795 ret = IVI_SUCCEEDED;
2796 }
2797 return ret;
2798}
2799
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002800struct ivi_layout_surface*
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002801ivi_layout_surface_create(struct weston_surface *wl_surface,
2802 uint32_t id_surface)
2803{
2804 struct ivi_layout *layout = get_instance();
2805 struct ivi_layout_surface *ivisurf = NULL;
2806 struct weston_view *tmpview = NULL;
2807
2808 if (wl_surface == NULL) {
2809 weston_log("ivi_layout_surface_create: invalid argument\n");
2810 return NULL;
2811 }
2812
2813 ivisurf = get_surface(&layout->surface_list, id_surface);
2814 if (ivisurf != NULL) {
2815 if (ivisurf->surface != NULL) {
2816 weston_log("id_surface(%d) is already created\n", id_surface);
2817 return NULL;
2818 }
2819 }
2820
2821 ivisurf = calloc(1, sizeof *ivisurf);
2822 if (ivisurf == NULL) {
2823 weston_log("fails to allocate memory\n");
2824 return NULL;
2825 }
2826
2827 wl_list_init(&ivisurf->link);
2828 wl_signal_init(&ivisurf->property_changed);
2829 wl_signal_init(&ivisurf->configured);
2830 wl_list_init(&ivisurf->layer_list);
2831 ivisurf->id_surface = id_surface;
2832 ivisurf->layout = layout;
2833
2834 ivisurf->surface = wl_surface;
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002835
2836 tmpview = weston_view_create(wl_surface);
2837 if (tmpview == NULL) {
2838 weston_log("fails to allocate memory\n");
2839 }
2840
2841 ivisurf->surface->width_from_buffer = 0;
2842 ivisurf->surface->height_from_buffer = 0;
2843
2844 weston_matrix_init(&ivisurf->surface_rotation.matrix);
2845 weston_matrix_init(&ivisurf->layer_rotation.matrix);
2846 weston_matrix_init(&ivisurf->surface_pos.matrix);
2847 weston_matrix_init(&ivisurf->layer_pos.matrix);
2848 weston_matrix_init(&ivisurf->scaling.matrix);
2849
2850 wl_list_init(&ivisurf->surface_rotation.link);
2851 wl_list_init(&ivisurf->layer_rotation.link);
2852 wl_list_init(&ivisurf->surface_pos.link);
2853 wl_list_init(&ivisurf->layer_pos.link);
2854 wl_list_init(&ivisurf->scaling.link);
2855
2856 init_surface_properties(&ivisurf->prop);
2857 ivisurf->event_mask = 0;
2858
2859 ivisurf->pending.prop = ivisurf->prop;
2860 wl_list_init(&ivisurf->pending.link);
2861
2862 wl_list_init(&ivisurf->order.link);
2863 wl_list_init(&ivisurf->order.layer_list);
2864
2865 wl_list_insert(&layout->surface_list, &ivisurf->link);
2866
2867 wl_signal_emit(&layout->surface_notification.created, ivisurf);
2868
2869 return ivisurf;
2870}
2871
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002872void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002873ivi_layout_init_with_compositor(struct weston_compositor *ec)
2874{
2875 struct ivi_layout *layout = get_instance();
2876
2877 layout->compositor = ec;
2878
2879 wl_list_init(&layout->surface_list);
2880 wl_list_init(&layout->layer_list);
2881 wl_list_init(&layout->screen_list);
2882
2883 wl_signal_init(&layout->layer_notification.created);
2884 wl_signal_init(&layout->layer_notification.removed);
2885
2886 wl_signal_init(&layout->surface_notification.created);
2887 wl_signal_init(&layout->surface_notification.removed);
2888 wl_signal_init(&layout->surface_notification.configure_changed);
2889
2890 /* Add layout_layer at the last of weston_compositor.layer_list */
2891 weston_layer_init(&layout->layout_layer, ec->layer_list.prev);
2892
2893 create_screen(ec);
2894
2895 layout->transitions = ivi_layout_transition_set_create(ec);
2896 wl_list_init(&layout->pending_transition_list);
2897}
2898
2899
Nobuhiko Tanibata28dc18c2014-12-15 13:22:31 +09002900void
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09002901ivi_layout_surface_add_configured_listener(struct ivi_layout_surface* ivisurf,
2902 struct wl_listener* listener)
2903{
2904 wl_signal_add(&ivisurf->configured, listener);
2905}
2906
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002907static struct ivi_controller_interface ivi_controller_interface = {
2908 /**
2909 * commit all changes
2910 */
2911 .commit_changes = ivi_layout_commit_changes,
2912
2913 /**
2914 * surface controller interfaces
2915 */
2916 .add_notification_create_surface = ivi_layout_add_notification_create_surface,
2917 .remove_notification_create_surface = ivi_layout_remove_notification_create_surface,
2918 .add_notification_remove_surface = ivi_layout_add_notification_remove_surface,
2919 .remove_notification_remove_surface = ivi_layout_remove_notification_remove_surface,
2920 .add_notification_configure_surface = ivi_layout_add_notification_configure_surface,
2921 .remove_notification_configure_surface = ivi_layout_remove_notification_configure_surface,
2922 .get_surfaces = ivi_layout_get_surfaces,
2923 .get_id_of_surface = ivi_layout_get_id_of_surface,
2924 .get_surface_from_id = ivi_layout_get_surface_from_id,
2925 .get_properties_of_surface = ivi_layout_get_properties_of_surface,
2926 .get_surfaces_on_layer = ivi_layout_get_surfaces_on_layer,
2927 .surface_set_visibility = ivi_layout_surface_set_visibility,
2928 .surface_get_visibility = ivi_layout_surface_get_visibility,
2929 .surface_set_opacity = ivi_layout_surface_set_opacity,
2930 .surface_get_opacity = ivi_layout_surface_get_opacity,
2931 .surface_set_source_rectangle = ivi_layout_surface_set_source_rectangle,
2932 .surface_set_destination_rectangle = ivi_layout_surface_set_destination_rectangle,
2933 .surface_set_position = ivi_layout_surface_set_position,
2934 .surface_get_position = ivi_layout_surface_get_position,
2935 .surface_set_dimension = ivi_layout_surface_set_dimension,
2936 .surface_get_dimension = ivi_layout_surface_get_dimension,
2937 .surface_set_orientation = ivi_layout_surface_set_orientation,
2938 .surface_get_orientation = ivi_layout_surface_get_orientation,
2939 .surface_set_content_observer = ivi_layout_surface_set_content_observer,
2940 .surface_add_notification = ivi_layout_surface_add_notification,
2941 .surface_remove_notification = ivi_layout_surface_remove_notification,
2942 .surface_get_weston_surface = ivi_layout_surface_get_weston_surface,
2943 .surface_set_transition = ivi_layout_surface_set_transition,
2944 .surface_set_transition_duration = ivi_layout_surface_set_transition_duration,
2945
2946 /**
2947 * layer controller interfaces
2948 */
2949 .add_notification_create_layer = ivi_layout_add_notification_create_layer,
2950 .remove_notification_create_layer = ivi_layout_remove_notification_create_layer,
2951 .add_notification_remove_layer = ivi_layout_add_notification_remove_layer,
2952 .remove_notification_remove_layer = ivi_layout_remove_notification_remove_layer,
2953 .layer_create_with_dimension = ivi_layout_layer_create_with_dimension,
2954 .layer_remove = ivi_layout_layer_remove,
2955 .get_layers = ivi_layout_get_layers,
2956 .get_id_of_layer = ivi_layout_get_id_of_layer,
2957 .get_layer_from_id = ivi_layout_get_layer_from_id,
2958 .get_properties_of_layer = ivi_layout_get_properties_of_layer,
2959 .get_layers_under_surface = ivi_layout_get_layers_under_surface,
2960 .get_layers_on_screen = ivi_layout_get_layers_on_screen,
2961 .layer_set_visibility = ivi_layout_layer_set_visibility,
2962 .layer_get_visibility = ivi_layout_layer_get_visibility,
2963 .layer_set_opacity = ivi_layout_layer_set_opacity,
2964 .layer_get_opacity = ivi_layout_layer_get_opacity,
2965 .layer_set_source_rectangle = ivi_layout_layer_set_source_rectangle,
2966 .layer_set_destination_rectangle = ivi_layout_layer_set_destination_rectangle,
2967 .layer_set_position = ivi_layout_layer_set_position,
2968 .layer_get_position = ivi_layout_layer_get_position,
2969 .layer_set_dimension = ivi_layout_layer_set_dimension,
2970 .layer_get_dimension = ivi_layout_layer_get_dimension,
2971 .layer_set_orientation = ivi_layout_layer_set_orientation,
2972 .layer_get_orientation = ivi_layout_layer_get_orientation,
2973 .layer_add_surface = ivi_layout_layer_add_surface,
2974 .layer_remove_surface = ivi_layout_layer_remove_surface,
2975 .layer_set_render_order = ivi_layout_layer_set_render_order,
2976 .layer_add_notification = ivi_layout_layer_add_notification,
2977 .layer_remove_notification = ivi_layout_layer_remove_notification,
2978 .layer_set_transition = ivi_layout_layer_set_transition,
2979
2980 /**
Nobuhiko Tanibata4d0116e2015-06-22 15:31:57 +09002981 * screen controller interfaces part1
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09002982 */
2983 .get_screen_from_id = ivi_layout_get_screen_from_id,
2984 .get_screen_resolution = ivi_layout_get_screen_resolution,
2985 .get_screens = ivi_layout_get_screens,
2986 .get_screens_under_layer = ivi_layout_get_screens_under_layer,
2987 .screen_add_layer = ivi_layout_screen_add_layer,
2988 .screen_set_render_order = ivi_layout_screen_set_render_order,
2989 .screen_get_output = ivi_layout_screen_get_output,
2990
2991 /**
2992 * animation
2993 */
2994 .transition_move_layer_cancel = ivi_layout_transition_move_layer_cancel,
Nobuhiko Tanibatac3fd6242015-04-21 02:13:15 +09002995 .layer_set_fade_info = ivi_layout_layer_set_fade_info,
2996
2997 /**
2998 * surface content dumping for debugging
2999 */
3000 .surface_get_size = ivi_layout_surface_get_size,
3001 .surface_dump = ivi_layout_surface_dump,
Nobuhiko Tanibata82051702015-06-22 15:31:26 +09003002
3003 /**
Nobuhiko Tanibatadb8efd12015-06-22 15:31:39 +09003004 * remove notification by callback on property changes of ivi_surface/layer
Nobuhiko Tanibata82051702015-06-22 15:31:26 +09003005 */
Nobuhiko Tanibatadb8efd12015-06-22 15:31:39 +09003006 .surface_remove_notification_by_callback = ivi_layout_surface_remove_notification_by_callback,
Nobuhiko Tanibata4d0116e2015-06-22 15:31:57 +09003007 .layer_remove_notification_by_callback = ivi_layout_layer_remove_notification_by_callback,
3008
3009 /**
3010 * screen controller interfaces part2
3011 */
3012 .get_id_of_screen = ivi_layout_get_id_of_screen
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09003013};
3014
3015int
3016load_controller_modules(struct weston_compositor *compositor, const char *modules,
3017 int *argc, char *argv[])
3018{
3019 const char *p, *end;
3020 char buffer[256];
3021 int (*controller_module_init)(struct weston_compositor *compositor,
3022 int *argc, char *argv[],
3023 const struct ivi_controller_interface *interface,
3024 size_t interface_version);
3025
3026 if (modules == NULL)
3027 return 0;
3028
3029 p = modules;
3030 while (*p) {
3031 end = strchrnul(p, ',');
3032 snprintf(buffer, sizeof buffer, "%.*s", (int)(end - p), p);
3033
3034 controller_module_init = weston_load_module(buffer, "controller_module_init");
Pekka Paalanen97246c02015-03-26 15:47:29 +02003035 if (!controller_module_init)
3036 return -1;
3037
3038 if (controller_module_init(compositor, argc, argv,
3039 &ivi_controller_interface,
3040 sizeof(struct ivi_controller_interface)) != 0) {
3041 weston_log("ivi-shell: Initialization of controller module fails");
3042 return -1;
Nobuhiko Tanibataee8e5832014-12-15 13:25:39 +09003043 }
3044
3045 p = end;
3046 while (*p == ',')
3047 p++;
3048 }
3049
3050 return 0;
3051}