2 * Copyright (C) 2013 DENSO CORPORATION
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the copyright holders not be used in
9 * advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. The copyright holders make
11 * no representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 * Implementation of ivi-layout library. The actual view on ivi_screen is
25 * not updated till calling ivi_layout_commit_changes. A overview from
26 * calling API for updating properties of ivi_surface/ivi_layer to asking
27 * compositor to compose them by using weston_compositor_schedule_repaint,
28 * 0/ initialize this library by ivi_layout_init_with_compositor
29 * with (struct weston_compositor *ec) from ivi-shell.
30 * 1/ When a API for updating properties of ivi_surface/ivi_layer, it updates
31 * pending prop of ivi_surface/ivi_layer/ivi_screen which are structure to
33 * 2/ Before calling commitChanges, in case of calling a API to get a property,
34 * return current property, not pending property.
35 * 3/ At the timing of calling ivi_layout_commitChanges, pending properties
36 * are applied to properties.
38 * *) ivi_layout_commitChanges is also called by transition animation
39 * per each frame. See ivi-layout-transition.c in details. Transition
40 * animation interpolates frames between previous properties of ivi_surface
42 * For example, when a property of ivi_surface is changed from invisibility
43 * to visibility, it behaves like fade-in. When ivi_layout_commitChange is
44 * called during transition animation, it cancels the transition and
45 * re-start transition to new properties from current properties of final
46 * frame just before the the cancellation.
48 * 4/ According properties, set transformation by using weston_matrix and
49 * weston_view per ivi_surfaces and ivi_layers in while loop.
50 * 5/ Set damage and trigger transform by using weston_view_geometry_dirty.
51 * 6/ Notify update of properties.
52 * 7/ Trigger composition by weston_compositor_schedule_repaint.
61 #include <linux/input.h>
63 #include "compositor.h"
64 #include "ivi-layout-export.h"
65 #include "ivi-layout-private.h"
68 struct ivi_layout_layer *ivilayer;
70 struct wl_list link_to_layer;
74 struct ivi_layout_screen *iviscrn;
76 struct wl_list link_to_screen;
79 struct listener_layout_notification {
81 struct wl_listener listener;
86 struct ivi_layout_screen {
88 struct wl_list link_to_layer;
91 struct ivi_layout *layout;
92 struct weston_output *output;
97 struct wl_list layer_list;
102 struct wl_list layer_list;
107 struct ivi_layout_notification_callback {
112 static struct ivi_layout ivilayout = {0};
115 get_layout_instance(void)
121 * Internal API to add/remove a link to ivi_surface from ivi_layer.
124 add_link_to_surface(struct ivi_layout_layer *ivilayer,
125 struct link_layer *link_layer)
127 struct link_layer *link = NULL;
129 wl_list_for_each(link, &ivilayer->link_to_surface, link_to_layer) {
130 if (link == link_layer)
134 wl_list_insert(&ivilayer->link_to_surface, &link_layer->link_to_layer);
138 remove_link_to_surface(struct ivi_layout_layer *ivilayer)
140 struct link_layer *link = NULL;
141 struct link_layer *next = NULL;
143 wl_list_for_each_safe(link, next, &ivilayer->link_to_surface, link_to_layer) {
144 if (!wl_list_empty(&link->link_to_layer)) {
145 wl_list_remove(&link->link_to_layer);
147 if (!wl_list_empty(&link->link)) {
148 wl_list_remove(&link->link);
153 wl_list_init(&ivilayer->link_to_surface);
157 * Internal API to add a link to ivi_layer from ivi_screen.
160 add_link_to_layer(struct ivi_layout_screen *iviscrn,
161 struct link_screen *link_screen)
163 wl_list_init(&link_screen->link_to_screen);
164 wl_list_insert(&iviscrn->link_to_layer, &link_screen->link_to_screen);
168 * Internal API to add/remove a ivi_surface from ivi_layer.
171 add_ordersurface_to_layer(struct ivi_layout_surface *ivisurf,
172 struct ivi_layout_layer *ivilayer)
174 struct link_layer *link_layer = NULL;
176 link_layer = malloc(sizeof *link_layer);
177 if (link_layer == NULL) {
178 weston_log("fails to allocate memory\n");
182 link_layer->ivilayer = ivilayer;
183 wl_list_init(&link_layer->link);
184 wl_list_insert(&ivisurf->layer_list, &link_layer->link);
185 add_link_to_surface(ivilayer, link_layer);
189 remove_ordersurface_from_layer(struct ivi_layout_surface *ivisurf)
191 struct link_layer *link_layer = NULL;
192 struct link_layer *next = NULL;
194 wl_list_for_each_safe(link_layer, next, &ivisurf->layer_list, link) {
195 if (!wl_list_empty(&link_layer->link)) {
196 wl_list_remove(&link_layer->link);
198 if (!wl_list_empty(&link_layer->link_to_layer)) {
199 wl_list_remove(&link_layer->link_to_layer);
203 wl_list_init(&ivisurf->layer_list);
207 * Internal API to add/remove a ivi_layer to/from ivi_screen.
210 add_orderlayer_to_screen(struct ivi_layout_layer *ivilayer,
211 struct ivi_layout_screen *iviscrn)
213 struct link_screen *link_scrn = NULL;
215 link_scrn = malloc(sizeof *link_scrn);
216 if (link_scrn == NULL) {
217 weston_log("fails to allocate memory\n");
221 link_scrn->iviscrn = iviscrn;
222 wl_list_init(&link_scrn->link);
223 wl_list_insert(&ivilayer->screen_list, &link_scrn->link);
224 add_link_to_layer(iviscrn, link_scrn);
228 remove_orderlayer_from_screen(struct ivi_layout_layer *ivilayer)
230 struct link_screen *link_scrn = NULL;
231 struct link_screen *next = NULL;
233 wl_list_for_each_safe(link_scrn, next, &ivilayer->screen_list, link) {
234 if (!wl_list_empty(&link_scrn->link)) {
235 wl_list_remove(&link_scrn->link);
237 if (!wl_list_empty(&link_scrn->link_to_screen)) {
238 wl_list_remove(&link_scrn->link_to_screen);
242 wl_list_init(&ivilayer->screen_list);
246 * Internal API to add/remove a ivi_layer to/from ivi_screen.
248 static struct ivi_layout_surface *
249 get_surface(struct wl_list *surf_list, uint32_t id_surface)
251 struct ivi_layout_surface *ivisurf;
253 wl_list_for_each(ivisurf, surf_list, link) {
254 if (ivisurf->id_surface == id_surface) {
262 static struct ivi_layout_layer *
263 get_layer(struct wl_list *layer_list, uint32_t id_layer)
265 struct ivi_layout_layer *ivilayer;
267 wl_list_for_each(ivilayer, layer_list, link) {
268 if (ivilayer->id_layer == id_layer) {
277 * Called at destruction of ivi_surface
280 westonsurface_destroy_from_ivisurface(struct wl_listener *listener, void *data)
282 struct ivi_layout_surface *ivisurf = NULL;
284 ivisurf = container_of(listener, struct ivi_layout_surface,
285 surface_destroy_listener);
287 wl_list_remove(&ivisurf->surface_rotation.link);
288 wl_list_remove(&ivisurf->layer_rotation.link);
289 wl_list_remove(&ivisurf->surface_pos.link);
290 wl_list_remove(&ivisurf->layer_pos.link);
291 wl_list_remove(&ivisurf->scaling.link);
293 ivisurf->surface = NULL;
294 ivi_layout_surface_remove(ivisurf);
298 * Internal API to check ivi_layer/ivi_surface already added in ivi_layer/ivi_screen.
299 * Called by ivi_layout_layer_add_surface/ivi_layout_screenAddLayer
302 is_surface_in_layer(struct ivi_layout_surface *ivisurf,
303 struct ivi_layout_layer *ivilayer)
305 struct ivi_layout_surface *surf = NULL;
307 wl_list_for_each(surf, &ivilayer->pending.surface_list, pending.link) {
308 if (surf->id_surface == ivisurf->id_surface) {
317 is_layer_in_screen(struct ivi_layout_layer *ivilayer,
318 struct ivi_layout_screen *iviscrn)
320 struct ivi_layout_layer *layer = NULL;
322 wl_list_for_each(layer, &iviscrn->pending.layer_list, pending.link) {
323 if (layer->id_layer == ivilayer->id_layer) {
332 * Internal API to initialize ivi_screens found from output_list of weston_compositor.
333 * Called by ivi_layout_init_with_compositor.
336 create_screen(struct weston_compositor *ec)
338 struct ivi_layout *layout = get_layout_instance();
339 struct ivi_layout_screen *iviscrn = NULL;
340 struct weston_output *output = NULL;
343 wl_list_for_each(output, &ec->output_list, link) {
344 iviscrn = calloc(1, sizeof *iviscrn);
345 if (iviscrn == NULL) {
346 weston_log("fails to allocate memory\n");
350 wl_list_init(&iviscrn->link);
351 iviscrn->layout = layout;
353 iviscrn->id_screen = count;
356 iviscrn->output = output;
357 iviscrn->event_mask = 0;
359 wl_list_init(&iviscrn->pending.layer_list);
360 wl_list_init(&iviscrn->pending.link);
362 wl_list_init(&iviscrn->order.layer_list);
363 wl_list_init(&iviscrn->order.link);
365 wl_list_init(&iviscrn->link_to_layer);
367 wl_list_insert(&layout->screen_list, &iviscrn->link);
372 * Internal APIs to initialize properties of ivi_surface/ivi_layer when they are created.
375 init_layer_properties(struct ivi_layout_layer_properties *prop,
376 int32_t width, int32_t height)
378 memset(prop, 0, sizeof *prop);
379 prop->opacity = wl_fixed_from_double(1.0);
380 prop->source_width = width;
381 prop->source_height = height;
382 prop->dest_width = width;
383 prop->dest_height = height;
387 init_surface_properties(struct ivi_layout_surface_properties *prop)
389 memset(prop, 0, sizeof *prop);
390 prop->opacity = wl_fixed_from_double(1.0);
394 * Internal APIs to be called from ivi_layout_commit_changes.
397 update_opacity(struct ivi_layout_layer *ivilayer,
398 struct ivi_layout_surface *ivisurf)
400 double layer_alpha = wl_fixed_to_double(ivilayer->prop.opacity);
401 double surf_alpha = wl_fixed_to_double(ivisurf->prop.opacity);
403 if ((ivilayer->event_mask & IVI_NOTIFICATION_OPACITY) ||
404 (ivisurf->event_mask & IVI_NOTIFICATION_OPACITY)) {
405 struct weston_view *tmpview = NULL;
406 wl_list_for_each(tmpview, &ivisurf->surface->views, surface_link) {
407 if (tmpview == NULL) {
410 tmpview->alpha = layer_alpha * surf_alpha;
416 update_surface_orientation(struct ivi_layout_layer *ivilayer,
417 struct ivi_layout_surface *ivisurf)
419 struct weston_view *view;
420 struct weston_matrix *matrix = &ivisurf->surface_rotation.matrix;
430 wl_list_for_each(view, &ivisurf->surface->views, surface_link) {
440 if ((ivilayer->prop.dest_width == 0) ||
441 (ivilayer->prop.dest_height == 0)) {
444 width = (float)ivilayer->prop.dest_width;
445 height = (float)ivilayer->prop.dest_height;
447 switch (ivisurf->prop.orientation) {
448 case WL_OUTPUT_TRANSFORM_NORMAL:
452 case WL_OUTPUT_TRANSFORM_90:
458 case WL_OUTPUT_TRANSFORM_180:
462 case WL_OUTPUT_TRANSFORM_270:
470 wl_list_remove(&ivisurf->surface_rotation.link);
471 weston_view_geometry_dirty(view);
473 weston_matrix_init(matrix);
476 weston_matrix_translate(matrix, -cx, -cy, 0.0f);
477 weston_matrix_rotate_xy(matrix, v_cos, v_sin);
478 weston_matrix_scale(matrix, sx, sy, 1.0);
479 weston_matrix_translate(matrix, cx, cy, 0.0f);
480 wl_list_insert(&view->geometry.transformation_list,
481 &ivisurf->surface_rotation.link);
483 weston_view_set_transform_parent(view, NULL);
484 weston_view_update_transform(view);
488 update_layer_orientation(struct ivi_layout_layer *ivilayer,
489 struct ivi_layout_surface *ivisurf)
491 struct weston_surface *es = ivisurf->surface;
492 struct weston_view *view;
493 struct weston_matrix *matrix = &ivisurf->layer_rotation.matrix;
494 struct weston_output *output = NULL;
504 wl_list_for_each(view, &ivisurf->surface->views, surface_link) {
510 if (es == NULL || view == NULL) {
515 if (output == NULL) {
518 if ((output->width == 0) || (output->height == 0)) {
521 width = (float)output->width;
522 height = (float)output->height;
524 switch (ivilayer->prop.orientation) {
525 case WL_OUTPUT_TRANSFORM_NORMAL:
529 case WL_OUTPUT_TRANSFORM_90:
535 case WL_OUTPUT_TRANSFORM_180:
539 case WL_OUTPUT_TRANSFORM_270:
547 wl_list_remove(&ivisurf->layer_rotation.link);
548 weston_view_geometry_dirty(view);
550 weston_matrix_init(matrix);
553 weston_matrix_translate(matrix, -cx, -cy, 0.0f);
554 weston_matrix_rotate_xy(matrix, v_cos, v_sin);
555 weston_matrix_scale(matrix, sx, sy, 1.0);
556 weston_matrix_translate(matrix, cx, cy, 0.0f);
557 wl_list_insert(&view->geometry.transformation_list,
558 &ivisurf->layer_rotation.link);
560 weston_view_set_transform_parent(view, NULL);
561 weston_view_update_transform(view);
565 update_surface_position(struct ivi_layout_surface *ivisurf)
567 struct weston_view *view;
568 float tx = (float)ivisurf->prop.dest_x;
569 float ty = (float)ivisurf->prop.dest_y;
570 struct weston_matrix *matrix = &ivisurf->surface_pos.matrix;
572 wl_list_for_each(view, &ivisurf->surface->views, surface_link) {
582 wl_list_remove(&ivisurf->surface_pos.link);
584 weston_matrix_init(matrix);
585 weston_matrix_translate(matrix, tx, ty, 0.0f);
586 wl_list_insert(&view->geometry.transformation_list,
587 &ivisurf->surface_pos.link);
589 weston_view_set_transform_parent(view, NULL);
590 weston_view_update_transform(view);
594 update_layer_position(struct ivi_layout_layer *ivilayer,
595 struct ivi_layout_surface *ivisurf)
597 struct weston_view *view;
598 struct weston_matrix *matrix = &ivisurf->layer_pos.matrix;
599 float tx = (float)ivilayer->prop.dest_x;
600 float ty = (float)ivilayer->prop.dest_y;
602 wl_list_for_each(view, &ivisurf->surface->views, surface_link) {
612 wl_list_remove(&ivisurf->layer_pos.link);
614 weston_matrix_init(matrix);
615 weston_matrix_translate(matrix, tx, ty, 0.0f);
616 wl_list_insert(&view->geometry.transformation_list,
617 &ivisurf->layer_pos.link);
619 weston_view_set_transform_parent(view, NULL);
620 weston_view_update_transform(view);
624 update_scale(struct ivi_layout_layer *ivilayer,
625 struct ivi_layout_surface *ivisurf)
627 struct weston_view *view;
628 struct weston_matrix *matrix = &ivisurf->scaling.matrix;
636 wl_list_for_each(view, &ivisurf->surface->views, surface_link) {
646 if (ivisurf->prop.dest_width == 0 && ivisurf->prop.dest_height == 0) {
647 ivisurf->prop.dest_width = ivisurf->surface->width_from_buffer;
648 ivisurf->prop.dest_height = ivisurf->surface->height_from_buffer;
651 lw = ((float)ivilayer->prop.dest_width / (float)ivilayer->prop.source_width );
652 sw = ((float)ivisurf->prop.dest_width / (float)ivisurf->prop.source_width );
653 lh = ((float)ivilayer->prop.dest_height / (float)ivilayer->prop.source_height);
654 sh = ((float)ivisurf->prop.dest_height / (float)ivisurf->prop.source_height );
658 wl_list_remove(&ivisurf->scaling.link);
659 weston_matrix_init(matrix);
660 weston_matrix_scale(matrix, sx, sy, 1.0f);
662 wl_list_insert(&view->geometry.transformation_list,
663 &ivisurf->scaling.link);
665 weston_view_set_transform_parent(view, NULL);
666 weston_view_update_transform(view);
670 update_prop(struct ivi_layout_layer *ivilayer,
671 struct ivi_layout_surface *ivisurf)
673 if (ivilayer->event_mask | ivisurf->event_mask) {
674 struct weston_view *tmpview;
675 update_opacity(ivilayer, ivisurf);
676 update_layer_orientation(ivilayer, ivisurf);
677 update_layer_position(ivilayer, ivisurf);
678 update_surface_position(ivisurf);
679 update_surface_orientation(ivilayer, ivisurf);
680 update_scale(ivilayer, ivisurf);
682 ivisurf->update_count++;
684 wl_list_for_each(tmpview, &ivisurf->surface->views, surface_link) {
685 if (tmpview != NULL) {
690 if (tmpview != NULL) {
691 weston_view_geometry_dirty(tmpview);
694 if (ivisurf->surface != NULL) {
695 weston_surface_damage(ivisurf->surface);
701 commit_changes(struct ivi_layout *layout)
703 struct ivi_layout_screen *iviscrn = NULL;
704 struct ivi_layout_layer *ivilayer = NULL;
705 struct ivi_layout_surface *ivisurf = NULL;
707 wl_list_for_each(iviscrn, &layout->screen_list, link) {
708 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
709 wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) {
710 update_prop(ivilayer, ivisurf);
717 commit_surface_list(struct ivi_layout *layout)
719 struct ivi_layout_surface *ivisurf = NULL;
722 int32_t dest_width = 0;
723 int32_t dest_height = 0;
724 int32_t configured = 0;
726 wl_list_for_each(ivisurf, &layout->surface_list, link) {
727 if(ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEFAULT) {
728 dest_x = ivisurf->prop.dest_x;
729 dest_y = ivisurf->prop.dest_y;
730 dest_width = ivisurf->prop.dest_width;
731 dest_height = ivisurf->prop.dest_height;
733 ivi_layout_transition_move_resize_view(ivisurf,
734 ivisurf->pending.prop.dest_x,
735 ivisurf->pending.prop.dest_y,
736 ivisurf->pending.prop.dest_width,
737 ivisurf->pending.prop.dest_height,
738 ivisurf->pending.prop.transition_duration);
740 if(ivisurf->pending.prop.visibility) {
741 ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration);
743 ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration);
746 ivisurf->prop = ivisurf->pending.prop;
747 ivisurf->prop.dest_x = dest_x;
748 ivisurf->prop.dest_y = dest_y;
749 ivisurf->prop.dest_width = dest_width;
750 ivisurf->prop.dest_height = dest_height;
751 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
752 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
754 } else if(ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_DEST_RECT_ONLY){
755 dest_x = ivisurf->prop.dest_x;
756 dest_y = ivisurf->prop.dest_y;
757 dest_width = ivisurf->prop.dest_width;
758 dest_height = ivisurf->prop.dest_height;
760 ivi_layout_transition_move_resize_view(ivisurf,
761 ivisurf->pending.prop.dest_x,
762 ivisurf->pending.prop.dest_y,
763 ivisurf->pending.prop.dest_width,
764 ivisurf->pending.prop.dest_height,
765 ivisurf->pending.prop.transition_duration);
767 ivisurf->prop = ivisurf->pending.prop;
768 ivisurf->prop.dest_x = dest_x;
769 ivisurf->prop.dest_y = dest_y;
770 ivisurf->prop.dest_width = dest_width;
771 ivisurf->prop.dest_height = dest_height;
773 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
774 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
776 } else if(ivisurf->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY){
778 if(ivisurf->pending.prop.visibility) {
779 ivi_layout_transition_visibility_on(ivisurf, ivisurf->pending.prop.transition_duration);
781 ivi_layout_transition_visibility_off(ivisurf, ivisurf->pending.prop.transition_duration);
784 if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width ||
785 ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) {
789 ivisurf->prop = ivisurf->pending.prop;
790 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
791 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
793 if (configured && !is_surface_transition(ivisurf))
794 wl_signal_emit(&ivisurf->configured, ivisurf);
797 if (ivisurf->prop.dest_width != ivisurf->pending.prop.dest_width ||
798 ivisurf->prop.dest_height != ivisurf->pending.prop.dest_height) {
802 ivisurf->prop = ivisurf->pending.prop;
803 ivisurf->prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
804 ivisurf->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
806 if (configured && !is_surface_transition(ivisurf))
807 wl_signal_emit(&ivisurf->configured, ivisurf);
813 commit_layer_list(struct ivi_layout *layout)
815 struct ivi_layout_layer *ivilayer = NULL;
816 struct ivi_layout_surface *ivisurf = NULL;
817 struct ivi_layout_surface *next = NULL;
819 wl_list_for_each(ivilayer, &layout->layer_list, link) {
820 if(ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_MOVE) {
821 ivi_layout_transition_move_layer(ivilayer, ivilayer->pending.prop.dest_x, ivilayer->pending.prop.dest_y, ivilayer->pending.prop.transition_duration);
822 } else if(ivilayer->pending.prop.transition_type == IVI_LAYOUT_TRANSITION_LAYER_FADE) {
823 ivi_layout_transition_fade_layer(ivilayer,ivilayer->pending.prop.is_fade_in,
824 ivilayer->pending.prop.start_alpha,ivilayer->pending.prop.end_alpha,
826 ivilayer->pending.prop.transition_duration);
828 ivilayer->pending.prop.transition_type = IVI_LAYOUT_TRANSITION_NONE;
830 ivilayer->prop = ivilayer->pending.prop;
832 if (!(ivilayer->event_mask &
833 (IVI_NOTIFICATION_ADD | IVI_NOTIFICATION_REMOVE)) ) {
837 if (ivilayer->event_mask & IVI_NOTIFICATION_REMOVE) {
838 wl_list_for_each_safe(ivisurf, next,
839 &ivilayer->order.surface_list, order.link) {
840 remove_ordersurface_from_layer(ivisurf);
842 if (!wl_list_empty(&ivisurf->order.link)) {
843 wl_list_remove(&ivisurf->order.link);
846 wl_list_init(&ivisurf->order.link);
847 ivisurf->event_mask |= IVI_NOTIFICATION_REMOVE;
850 wl_list_init(&ivilayer->order.surface_list);
853 if (ivilayer->event_mask & IVI_NOTIFICATION_ADD) {
854 wl_list_for_each_safe(ivisurf, next,
855 &ivilayer->order.surface_list, order.link) {
856 remove_ordersurface_from_layer(ivisurf);
858 if (!wl_list_empty(&ivisurf->order.link)) {
859 wl_list_remove(&ivisurf->order.link);
862 wl_list_init(&ivisurf->order.link);
865 wl_list_init(&ivilayer->order.surface_list);
866 wl_list_for_each(ivisurf, &ivilayer->pending.surface_list,
868 if(!wl_list_empty(&ivisurf->order.link)){
869 wl_list_remove(&ivisurf->order.link);
870 wl_list_init(&ivisurf->order.link);
873 wl_list_insert(&ivilayer->order.surface_list,
874 &ivisurf->order.link);
875 add_ordersurface_to_layer(ivisurf, ivilayer);
876 ivisurf->event_mask |= IVI_NOTIFICATION_ADD;
883 commit_screen_list(struct ivi_layout *layout)
885 struct ivi_layout_screen *iviscrn = NULL;
886 struct ivi_layout_layer *ivilayer = NULL;
887 struct ivi_layout_layer *next = NULL;
888 struct ivi_layout_surface *ivisurf = NULL;
889 struct weston_view *view, *n;
891 /* clear view list of layout layer */
892 wl_list_for_each_safe(view, n, &layout->layout_layer.view_list.link, layer_link.link) {
893 weston_layer_entry_remove(&view->layer_link);
897 wl_list_for_each(iviscrn, &layout->screen_list, link) {
898 if (iviscrn->event_mask & IVI_NOTIFICATION_REMOVE) {
899 wl_list_for_each_safe(ivilayer, next,
900 &iviscrn->order.layer_list, order.link) {
901 remove_orderlayer_from_screen(ivilayer);
903 if (!wl_list_empty(&ivilayer->order.link)) {
904 wl_list_remove(&ivilayer->order.link);
907 wl_list_init(&ivilayer->order.link);
908 ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE;
912 if (iviscrn->event_mask & IVI_NOTIFICATION_ADD) {
913 wl_list_for_each_safe(ivilayer, next,
914 &iviscrn->order.layer_list, order.link) {
915 remove_orderlayer_from_screen(ivilayer);
917 if (!wl_list_empty(&ivilayer->order.link)) {
918 wl_list_remove(&ivilayer->order.link);
921 wl_list_init(&ivilayer->order.link);
924 wl_list_init(&iviscrn->order.layer_list);
925 wl_list_for_each(ivilayer, &iviscrn->pending.layer_list,
927 wl_list_insert(&iviscrn->order.layer_list,
928 &ivilayer->order.link);
929 add_orderlayer_to_screen(ivilayer, iviscrn);
930 ivilayer->event_mask |= IVI_NOTIFICATION_ADD;
934 iviscrn->event_mask = 0;
936 /* rebuild view list of layout layer */
937 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
938 if (ivilayer->prop.visibility == false)
941 wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) {
942 struct weston_view *tmpview = NULL;
943 wl_list_for_each(tmpview, &ivisurf->surface->views, surface_link) {
944 if (tmpview != NULL) {
949 if (ivisurf->prop.visibility == false)
951 if (ivisurf->surface == NULL || tmpview == NULL)
954 weston_layer_entry_insert(&layout->layout_layer.view_list,
955 &tmpview->layer_link);
957 ivisurf->surface->output = iviscrn->output;
966 commit_transition(struct ivi_layout* layout)
968 if(wl_list_empty(&layout->pending_transition_list)){
972 wl_list_insert_list(&layout->transitions->transition_list,
973 &layout->pending_transition_list);
975 wl_list_init(&layout->pending_transition_list);
977 wl_event_source_timer_update(layout->transitions->event_source, 1);
981 send_surface_prop(struct ivi_layout_surface *ivisurf)
983 wl_signal_emit(&ivisurf->property_changed, ivisurf);
984 ivisurf->event_mask = 0;
988 send_layer_prop(struct ivi_layout_layer *ivilayer)
990 wl_signal_emit(&ivilayer->property_changed, ivilayer);
991 ivilayer->event_mask = 0;
995 send_prop(struct ivi_layout *layout)
997 struct ivi_layout_layer *ivilayer = NULL;
998 struct ivi_layout_surface *ivisurf = NULL;
1000 wl_list_for_each_reverse(ivilayer, &layout->layer_list, link) {
1001 send_layer_prop(ivilayer);
1004 wl_list_for_each_reverse(ivisurf, &layout->surface_list, link) {
1005 send_surface_prop(ivisurf);
1010 clear_surface_pending_list(struct ivi_layout_layer *ivilayer)
1012 struct ivi_layout_surface *surface_link = NULL;
1013 struct ivi_layout_surface *surface_next = NULL;
1015 wl_list_for_each_safe(surface_link, surface_next,
1016 &ivilayer->pending.surface_list, pending.link) {
1017 if (!wl_list_empty(&surface_link->pending.link)) {
1018 wl_list_remove(&surface_link->pending.link);
1021 wl_list_init(&surface_link->pending.link);
1024 ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE;
1028 clear_surface_order_list(struct ivi_layout_layer *ivilayer)
1030 struct ivi_layout_surface *surface_link = NULL;
1031 struct ivi_layout_surface *surface_next = NULL;
1033 wl_list_for_each_safe(surface_link, surface_next,
1034 &ivilayer->order.surface_list, order.link) {
1035 if (!wl_list_empty(&surface_link->order.link)) {
1036 wl_list_remove(&surface_link->order.link);
1039 wl_list_init(&surface_link->order.link);
1042 ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE;
1046 layer_created(struct wl_listener *listener, void *data)
1048 struct ivi_layout_layer *ivilayer = data;
1050 struct listener_layout_notification *notification =
1051 container_of(listener,
1052 struct listener_layout_notification,
1055 struct ivi_layout_notification_callback *created_callback =
1056 notification->userdata;
1058 ((layer_create_notification_func)created_callback->callback)
1059 (ivilayer, created_callback->data);
1063 layer_removed(struct wl_listener *listener, void *data)
1065 struct ivi_layout_layer *ivilayer = data;
1067 struct listener_layout_notification *notification =
1068 container_of(listener,
1069 struct listener_layout_notification,
1072 struct ivi_layout_notification_callback *removed_callback =
1073 notification->userdata;
1075 ((layer_remove_notification_func)removed_callback->callback)
1076 (ivilayer, removed_callback->data);
1080 layer_prop_changed(struct wl_listener *listener, void *data)
1082 struct ivi_layout_layer *ivilayer = data;
1084 struct listener_layout_notification *layout_listener =
1085 container_of(listener,
1086 struct listener_layout_notification,
1089 struct ivi_layout_notification_callback *prop_callback =
1090 layout_listener->userdata;
1092 ((layer_property_notification_func)prop_callback->callback)
1093 (ivilayer, &ivilayer->prop, ivilayer->event_mask, prop_callback->data);
1097 surface_created(struct wl_listener *listener, void *data)
1099 struct ivi_layout_surface *ivisurface = data;
1101 struct listener_layout_notification *notification =
1102 container_of(listener,
1103 struct listener_layout_notification,
1106 struct ivi_layout_notification_callback *created_callback =
1107 notification->userdata;
1109 ((surface_create_notification_func)created_callback->callback)
1110 (ivisurface, created_callback->data);
1114 surface_removed(struct wl_listener *listener, void *data)
1116 struct ivi_layout_surface *ivisurface = data;
1118 struct listener_layout_notification *notification =
1119 container_of(listener,
1120 struct listener_layout_notification,
1123 struct ivi_layout_notification_callback *removed_callback =
1124 notification->userdata;
1126 ((surface_remove_notification_func)removed_callback->callback)
1127 (ivisurface, removed_callback->data);
1131 surface_prop_changed(struct wl_listener *listener, void *data)
1133 struct ivi_layout_surface *ivisurf = data;
1135 struct listener_layout_notification *layout_listener =
1136 container_of(listener,
1137 struct listener_layout_notification,
1140 struct ivi_layout_notification_callback *prop_callback =
1141 layout_listener->userdata;
1143 ((surface_property_notification_func)prop_callback->callback)
1144 (ivisurf, &ivisurf->prop, ivisurf->event_mask, prop_callback->data);
1146 ivisurf->event_mask = 0;
1150 surface_configure_changed(struct wl_listener *listener,
1153 struct ivi_layout_surface *ivisurface = data;
1155 struct listener_layout_notification *notification =
1156 container_of(listener,
1157 struct listener_layout_notification,
1160 struct ivi_layout_notification_callback *configure_changed_callback =
1161 notification->userdata;
1163 ((surface_configure_notification_func)configure_changed_callback->callback)
1164 (ivisurface, configure_changed_callback->data);
1168 add_notification(struct wl_signal *signal,
1169 wl_notify_func_t callback,
1172 struct listener_layout_notification *notification = NULL;
1174 notification = malloc(sizeof *notification);
1175 if (notification == NULL) {
1176 weston_log("fails to allocate memory\n");
1181 notification->listener.notify = callback;
1182 notification->userdata = userdata;
1184 wl_signal_add(signal, ¬ification->listener);
1186 return IVI_SUCCEEDED;
1190 remove_notification(struct wl_list *listener_list, void *callback, void *userdata)
1192 struct wl_listener *listener = NULL;
1193 struct wl_listener *next = NULL;
1195 wl_list_for_each_safe(listener, next, listener_list, link) {
1196 struct listener_layout_notification *notification =
1197 container_of(listener,
1198 struct listener_layout_notification,
1201 struct ivi_layout_notification_callback *notification_callback =
1202 notification->userdata;
1204 if ((notification_callback->callback != callback) ||
1205 (notification_callback->data != userdata)) {
1209 if (!wl_list_empty(&listener->link)) {
1210 wl_list_remove(&listener->link);
1213 free(notification->userdata);
1219 remove_all_notification(struct wl_list *listener_list)
1221 struct wl_listener *listener = NULL;
1222 struct wl_listener *next = NULL;
1224 wl_list_for_each_safe(listener, next, listener_list, link) {
1225 struct listener_layout_notification *notification = NULL;
1226 if (!wl_list_empty(&listener->link)) {
1227 wl_list_remove(&listener->link);
1231 container_of(listener,
1232 struct listener_layout_notification,
1235 free(notification->userdata);
1241 * Exported APIs of ivi-layout library are implemented from here.
1242 * Brief of APIs is described in ivi-layout-export.h.
1245 ivi_layout_add_notification_create_layer(layer_create_notification_func callback,
1248 struct ivi_layout *layout = get_layout_instance();
1249 struct ivi_layout_notification_callback *created_callback = NULL;
1251 if (callback == NULL) {
1252 weston_log("ivi_layout_add_notification_create_layer: invalid argument\n");
1256 created_callback = malloc(sizeof *created_callback);
1257 if (created_callback == NULL) {
1258 weston_log("fails to allocate memory\n");
1262 created_callback->callback = callback;
1263 created_callback->data = userdata;
1265 return add_notification(&layout->layer_notification.created,
1271 ivi_layout_remove_notification_create_layer(layer_create_notification_func callback,
1274 struct ivi_layout *layout = get_layout_instance();
1275 remove_notification(&layout->layer_notification.created.listener_list, callback, userdata);
1279 ivi_layout_add_notification_remove_layer(layer_remove_notification_func callback,
1282 struct ivi_layout *layout = get_layout_instance();
1283 struct ivi_layout_notification_callback *removed_callback = NULL;
1285 if (callback == NULL) {
1286 weston_log("ivi_layout_add_notification_remove_layer: invalid argument\n");
1290 removed_callback = malloc(sizeof *removed_callback);
1291 if (removed_callback == NULL) {
1292 weston_log("fails to allocate memory\n");
1296 removed_callback->callback = callback;
1297 removed_callback->data = userdata;
1298 return add_notification(&layout->layer_notification.removed,
1304 ivi_layout_remove_notification_remove_layer(layer_remove_notification_func callback,
1307 struct ivi_layout *layout = get_layout_instance();
1308 remove_notification(&layout->layer_notification.removed.listener_list, callback, userdata);
1312 ivi_layout_add_notification_create_surface(surface_create_notification_func callback,
1315 struct ivi_layout *layout = get_layout_instance();
1316 struct ivi_layout_notification_callback *created_callback = NULL;
1318 if (callback == NULL) {
1319 weston_log("ivi_layout_add_notification_create_surface: invalid argument\n");
1323 created_callback = malloc(sizeof *created_callback);
1324 if (created_callback == NULL) {
1325 weston_log("fails to allocate memory\n");
1329 created_callback->callback = callback;
1330 created_callback->data = userdata;
1332 return add_notification(&layout->surface_notification.created,
1338 ivi_layout_remove_notification_create_surface(surface_create_notification_func callback,
1341 struct ivi_layout *layout = get_layout_instance();
1342 remove_notification(&layout->surface_notification.created.listener_list, callback, userdata);
1346 ivi_layout_add_notification_remove_surface(surface_remove_notification_func callback,
1349 struct ivi_layout *layout = get_layout_instance();
1350 struct ivi_layout_notification_callback *removed_callback = NULL;
1352 if (callback == NULL) {
1353 weston_log("ivi_layout_add_notification_remove_surface: invalid argument\n");
1357 removed_callback = malloc(sizeof *removed_callback);
1358 if (removed_callback == NULL) {
1359 weston_log("fails to allocate memory\n");
1363 removed_callback->callback = callback;
1364 removed_callback->data = userdata;
1366 return add_notification(&layout->surface_notification.removed,
1372 ivi_layout_remove_notification_remove_surface(surface_remove_notification_func callback,
1375 struct ivi_layout *layout = get_layout_instance();
1376 remove_notification(&layout->surface_notification.removed.listener_list, callback, userdata);
1380 ivi_layout_add_notification_configure_surface(surface_configure_notification_func callback,
1383 struct ivi_layout *layout = get_layout_instance();
1384 struct ivi_layout_notification_callback *configure_changed_callback = NULL;
1385 if (callback == NULL) {
1386 weston_log("ivi_layout_add_notification_configure_surface: invalid argument\n");
1390 configure_changed_callback = malloc(sizeof *configure_changed_callback);
1391 if (configure_changed_callback == NULL) {
1392 weston_log("fails to allocate memory\n");
1396 configure_changed_callback->callback = callback;
1397 configure_changed_callback->data = userdata;
1399 return add_notification(&layout->surface_notification.configure_changed,
1400 surface_configure_changed,
1401 configure_changed_callback);
1405 ivi_layout_remove_notification_configure_surface(surface_configure_notification_func callback,
1408 struct ivi_layout *layout = get_layout_instance();
1409 remove_notification(&layout->surface_notification.configure_changed.listener_list, callback, userdata);
1413 ivi_layout_get_id_of_surface(struct ivi_layout_surface *ivisurf)
1415 return ivisurf->id_surface;
1419 ivi_layout_get_id_of_layer(struct ivi_layout_layer *ivilayer)
1421 return ivilayer->id_layer;
1424 struct ivi_layout_layer *
1425 ivi_layout_get_layer_from_id(uint32_t id_layer)
1427 struct ivi_layout *layout = get_layout_instance();
1428 struct ivi_layout_layer *ivilayer = NULL;
1430 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1431 if (ivilayer->id_layer == id_layer) {
1439 WL_EXPORT struct ivi_layout_surface *
1440 ivi_layout_get_surface_from_id(uint32_t id_surface)
1442 struct ivi_layout *layout = get_layout_instance();
1443 struct ivi_layout_surface *ivisurf = NULL;
1445 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1446 if (ivisurf->id_surface == id_surface) {
1454 WL_EXPORT struct ivi_layout_screen *
1455 ivi_layout_get_screen_from_id(uint32_t id_screen)
1457 struct ivi_layout *layout = get_layout_instance();
1458 struct ivi_layout_screen *iviscrn = NULL;
1460 wl_list_for_each(iviscrn, &layout->screen_list, link) {
1461 /* FIXME : select iviscrn from screen_list by id_screen */
1470 ivi_layout_get_screen_resolution(struct ivi_layout_screen *iviscrn,
1471 int32_t *pWidth, int32_t *pHeight)
1473 struct weston_output *output = NULL;
1475 if (pWidth == NULL || pHeight == NULL) {
1476 weston_log("ivi_layout_get_screen_resolution: invalid argument\n");
1480 output = iviscrn->output;
1481 *pWidth = output->current_mode->width;
1482 *pHeight = output->current_mode->height;
1484 return IVI_SUCCEEDED;
1488 ivi_layout_surface_add_notification(struct ivi_layout_surface *ivisurf,
1489 surface_property_notification_func callback,
1492 struct listener_layout_notification* notification = NULL;
1493 struct ivi_layout_notification_callback *prop_callback = NULL;
1495 if (ivisurf == NULL || callback == NULL) {
1496 weston_log("ivi_layout_surface_add_notification: invalid argument\n");
1500 notification = malloc(sizeof *notification);
1501 if (notification == NULL) {
1502 weston_log("fails to allocate memory\n");
1506 prop_callback = malloc(sizeof *prop_callback);
1507 if (prop_callback == NULL) {
1508 weston_log("fails to allocate memory\n");
1512 prop_callback->callback = callback;
1513 prop_callback->data = userdata;
1515 notification->listener.notify = surface_prop_changed;
1516 notification->userdata = prop_callback;
1518 wl_signal_add(&ivisurf->property_changed, ¬ification->listener);
1520 return IVI_SUCCEEDED;
1524 ivi_layout_surface_remove_notification(struct ivi_layout_surface *ivisurf)
1526 if (ivisurf == NULL) {
1527 weston_log("ivi_layout_surface_remove_notification: invalid argument\n");
1531 remove_all_notification(&ivisurf->property_changed.listener_list);
1535 remove_configured_listener(struct ivi_layout_surface *ivisurf)
1537 struct wl_listener *link = NULL;
1538 struct wl_listener *next = NULL;
1540 wl_list_for_each_safe(link, next, &ivisurf->configured.listener_list, link) {
1541 wl_list_remove(&link->link);
1546 ivi_layout_surface_remove(struct ivi_layout_surface *ivisurf)
1548 struct ivi_layout *layout = get_layout_instance();
1550 if (ivisurf == NULL) {
1551 weston_log("ivi_layout_surface_remove: invalid argument\n");
1555 if (!wl_list_empty(&ivisurf->pending.link)) {
1556 wl_list_remove(&ivisurf->pending.link);
1558 if (!wl_list_empty(&ivisurf->order.link)) {
1559 wl_list_remove(&ivisurf->order.link);
1561 if (!wl_list_empty(&ivisurf->link)) {
1562 wl_list_remove(&ivisurf->link);
1564 remove_ordersurface_from_layer(ivisurf);
1566 wl_signal_emit(&layout->surface_notification.removed, ivisurf);
1568 remove_configured_listener(ivisurf);
1570 ivi_layout_surface_remove_notification(ivisurf);
1575 WL_EXPORT const struct ivi_layout_layer_properties *
1576 ivi_layout_get_properties_of_layer(struct ivi_layout_layer *ivilayer)
1578 if (ivilayer == NULL) {
1579 weston_log("ivi_layout_get_properties_of_layer: invalid argument\n");
1583 return &ivilayer->prop;
1587 ivi_layout_get_screens(int32_t *pLength, struct ivi_layout_screen ***ppArray)
1589 struct ivi_layout *layout = get_layout_instance();
1590 struct ivi_layout_screen *iviscrn = NULL;
1594 if (pLength == NULL || ppArray == NULL) {
1595 weston_log("ivi_layout_get_screens: invalid argument\n");
1599 length = wl_list_length(&layout->screen_list);
1602 /* the Array must be free by module which called this function */
1603 *ppArray = calloc(length, sizeof(struct ivi_layout_screen *));
1604 if (*ppArray == NULL) {
1605 weston_log("fails to allocate memory\n");
1609 wl_list_for_each(iviscrn, &layout->screen_list, link) {
1610 (*ppArray)[n++] = iviscrn;
1616 return IVI_SUCCEEDED;
1620 ivi_layout_get_screens_under_layer(struct ivi_layout_layer *ivilayer,
1622 struct ivi_layout_screen ***ppArray)
1624 struct link_screen *link_scrn = NULL;
1628 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1629 weston_log("ivi_layout_get_screens_under_layer: invalid argument\n");
1633 length = wl_list_length(&ivilayer->screen_list);
1636 /* the Array must be free by module which called this function */
1637 *ppArray = calloc(length, sizeof(struct ivi_layout_screen *));
1638 if (*ppArray == NULL) {
1639 weston_log("fails to allocate memory\n");
1643 wl_list_for_each(link_scrn, &ivilayer->screen_list, link) {
1644 (*ppArray)[n++] = link_scrn->iviscrn;
1650 return IVI_SUCCEEDED;
1654 ivi_layout_get_layers(int32_t *pLength, struct ivi_layout_layer ***ppArray)
1656 struct ivi_layout *layout = get_layout_instance();
1657 struct ivi_layout_layer *ivilayer = NULL;
1661 if (pLength == NULL || ppArray == NULL) {
1662 weston_log("ivi_layout_get_layers: invalid argument\n");
1666 length = wl_list_length(&layout->layer_list);
1669 /* the Array must be free by module which called this function */
1670 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1671 if (*ppArray == NULL) {
1672 weston_log("fails to allocate memory\n");
1676 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1677 (*ppArray)[n++] = ivilayer;
1683 return IVI_SUCCEEDED;
1687 ivi_layout_get_layers_on_screen(struct ivi_layout_screen *iviscrn,
1689 struct ivi_layout_layer ***ppArray)
1691 struct ivi_layout_layer *ivilayer = NULL;
1695 if (iviscrn == NULL || pLength == NULL || ppArray == NULL) {
1696 weston_log("ivi_layout_get_layers_on_screen: invalid argument\n");
1700 length = wl_list_length(&iviscrn->order.layer_list);
1703 /* the Array must be free by module which called this function */
1704 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1705 if (*ppArray == NULL) {
1706 weston_log("fails to allocate memory\n");
1710 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, link) {
1711 (*ppArray)[n++] = ivilayer;
1717 return IVI_SUCCEEDED;
1721 ivi_layout_get_layers_under_surface(struct ivi_layout_surface *ivisurf,
1723 struct ivi_layout_layer ***ppArray)
1725 struct link_layer *link_layer = NULL;
1729 if (ivisurf == NULL || pLength == NULL || ppArray == NULL) {
1730 weston_log("ivi_layout_getLayers: invalid argument\n");
1734 length = wl_list_length(&ivisurf->layer_list);
1737 /* the Array must be free by module which called this function */
1738 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1739 if (*ppArray == NULL) {
1740 weston_log("fails to allocate memory\n");
1744 wl_list_for_each(link_layer, &ivisurf->layer_list, link) {
1745 (*ppArray)[n++] = link_layer->ivilayer;
1751 return IVI_SUCCEEDED;
1755 ivi_layout_get_surfaces(int32_t *pLength, struct ivi_layout_surface ***ppArray)
1757 struct ivi_layout *layout = get_layout_instance();
1758 struct ivi_layout_surface *ivisurf = NULL;
1762 if (pLength == NULL || ppArray == NULL) {
1763 weston_log("ivi_layout_get_surfaces: invalid argument\n");
1767 length = wl_list_length(&layout->surface_list);
1770 /* the Array must be free by module which called this function */
1771 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1772 if (*ppArray == NULL) {
1773 weston_log("fails to allocate memory\n");
1777 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1778 (*ppArray)[n++] = ivisurf;
1784 return IVI_SUCCEEDED;
1788 ivi_layout_get_surfaces_on_layer(struct ivi_layout_layer *ivilayer,
1790 struct ivi_layout_surface ***ppArray)
1792 struct ivi_layout_surface *ivisurf = NULL;
1796 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1797 weston_log("ivi_layout_getSurfaceIDsOnLayer: invalid argument\n");
1801 length = wl_list_length(&ivilayer->order.surface_list);
1804 /* the Array must be free by module which called this function */
1805 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1806 if (*ppArray == NULL) {
1807 weston_log("fails to allocate memory\n");
1811 wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) {
1812 (*ppArray)[n++] = ivisurf;
1818 return IVI_SUCCEEDED;
1821 WL_EXPORT struct ivi_layout_layer *
1822 ivi_layout_layer_create_with_dimension(uint32_t id_layer,
1823 int32_t width, int32_t height)
1825 struct ivi_layout *layout = get_layout_instance();
1826 struct ivi_layout_layer *ivilayer = NULL;
1828 ivilayer = get_layer(&layout->layer_list, id_layer);
1829 if (ivilayer != NULL) {
1830 weston_log("id_layer is already created\n");
1834 ivilayer = calloc(1, sizeof *ivilayer);
1835 if (ivilayer == NULL) {
1836 weston_log("fails to allocate memory\n");
1840 wl_list_init(&ivilayer->link);
1841 wl_signal_init(&ivilayer->property_changed);
1842 wl_list_init(&ivilayer->screen_list);
1843 wl_list_init(&ivilayer->link_to_surface);
1844 ivilayer->layout = layout;
1845 ivilayer->id_layer = id_layer;
1847 init_layer_properties(&ivilayer->prop, width, height);
1848 ivilayer->event_mask = 0;
1850 wl_list_init(&ivilayer->pending.surface_list);
1851 wl_list_init(&ivilayer->pending.link);
1852 ivilayer->pending.prop = ivilayer->prop;
1854 wl_list_init(&ivilayer->order.surface_list);
1855 wl_list_init(&ivilayer->order.link);
1857 wl_list_insert(&layout->layer_list, &ivilayer->link);
1859 wl_signal_emit(&layout->layer_notification.created, ivilayer);
1865 ivi_layout_layer_remove(struct ivi_layout_layer *ivilayer)
1867 struct ivi_layout *layout = get_layout_instance();
1869 if (ivilayer == NULL) {
1870 weston_log("ivi_layout_layer_remove: invalid argument\n");
1874 wl_signal_emit(&layout->layer_notification.removed, ivilayer);
1876 clear_surface_pending_list(ivilayer);
1877 clear_surface_order_list(ivilayer);
1879 if (!wl_list_empty(&ivilayer->pending.link)) {
1880 wl_list_remove(&ivilayer->pending.link);
1882 if (!wl_list_empty(&ivilayer->order.link)) {
1883 wl_list_remove(&ivilayer->order.link);
1885 if (!wl_list_empty(&ivilayer->link)) {
1886 wl_list_remove(&ivilayer->link);
1888 remove_orderlayer_from_screen(ivilayer);
1889 remove_link_to_surface(ivilayer);
1890 ivi_layout_layer_remove_notification(ivilayer);
1896 ivi_layout_layer_set_visibility(struct ivi_layout_layer *ivilayer,
1899 struct ivi_layout_layer_properties *prop = NULL;
1901 if (ivilayer == NULL) {
1902 weston_log("ivi_layout_layer_set_visibility: invalid argument\n");
1906 prop = &ivilayer->pending.prop;
1907 prop->visibility = newVisibility;
1909 ivilayer->event_mask |= IVI_NOTIFICATION_VISIBILITY;
1911 return IVI_SUCCEEDED;
1915 ivi_layout_layer_get_visibility(struct ivi_layout_layer *ivilayer)
1917 if (ivilayer == NULL) {
1918 weston_log("ivi_layout_layer_get_visibility: invalid argument\n");
1922 return ivilayer->prop.visibility;
1926 ivi_layout_layer_set_opacity(struct ivi_layout_layer *ivilayer,
1929 struct ivi_layout_layer_properties *prop = NULL;
1931 if (ivilayer == NULL) {
1932 weston_log("ivi_layout_layer_set_opacity: invalid argument\n");
1936 prop = &ivilayer->pending.prop;
1937 prop->opacity = opacity;
1939 ivilayer->event_mask |= IVI_NOTIFICATION_OPACITY;
1941 return IVI_SUCCEEDED;
1944 WL_EXPORT wl_fixed_t
1945 ivi_layout_layer_get_opacity(struct ivi_layout_layer *ivilayer)
1947 if (ivilayer == NULL) {
1948 weston_log("ivi_layout_layer_get_opacity: invalid argument\n");
1949 return wl_fixed_from_double(0.0);
1952 return ivilayer->prop.opacity;
1956 ivi_layout_layer_set_source_rectangle(struct ivi_layout_layer *ivilayer,
1957 int32_t x, int32_t y,
1958 int32_t width, int32_t height)
1960 struct ivi_layout_layer_properties *prop = NULL;
1962 if (ivilayer == NULL) {
1963 weston_log("ivi_layout_layer_set_source_rectangle: invalid argument\n");
1967 prop = &ivilayer->pending.prop;
1970 prop->source_width = width;
1971 prop->source_height = height;
1973 ivilayer->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
1975 return IVI_SUCCEEDED;
1979 ivi_layout_layer_set_destination_rectangle(struct ivi_layout_layer *ivilayer,
1980 int32_t x, int32_t y,
1981 int32_t width, int32_t height)
1983 struct ivi_layout_layer_properties *prop = NULL;
1985 if (ivilayer == NULL) {
1986 weston_log("ivi_layout_layer_set_destination_rectangle: invalid argument\n");
1990 prop = &ivilayer->pending.prop;
1993 prop->dest_width = width;
1994 prop->dest_height = height;
1996 ivilayer->event_mask |= IVI_NOTIFICATION_DEST_RECT;
1998 return IVI_SUCCEEDED;
2002 ivi_layout_layer_get_dimension(struct ivi_layout_layer *ivilayer,
2003 int32_t *dest_width, int32_t *dest_height)
2005 if (ivilayer == NULL || dest_width == NULL || dest_height == NULL) {
2006 weston_log("ivi_layout_layer_get_dimension: invalid argument\n");
2010 *dest_width = ivilayer->prop.dest_width;
2011 *dest_height = ivilayer->prop.dest_height;
2013 return IVI_SUCCEEDED;
2017 ivi_layout_layer_set_dimension(struct ivi_layout_layer *ivilayer,
2018 int32_t dest_width, int32_t dest_height)
2020 struct ivi_layout_layer_properties *prop = NULL;
2022 if (ivilayer == NULL) {
2023 weston_log("ivi_layout_layer_set_dimension: invalid argument\n");
2027 prop = &ivilayer->pending.prop;
2029 prop->dest_width = dest_width;
2030 prop->dest_height = dest_height;
2032 ivilayer->event_mask |= IVI_NOTIFICATION_DIMENSION;
2034 return IVI_SUCCEEDED;
2038 ivi_layout_layer_get_position(struct ivi_layout_layer *ivilayer,
2039 int32_t *dest_x, int32_t *dest_y)
2041 if (ivilayer == NULL || dest_x == NULL || dest_y == NULL) {
2042 weston_log("ivi_layout_layer_get_position: invalid argument\n");
2046 *dest_x = ivilayer->prop.dest_x;
2047 *dest_y = ivilayer->prop.dest_y;
2049 return IVI_SUCCEEDED;
2053 ivi_layout_layer_set_position(struct ivi_layout_layer *ivilayer,
2054 int32_t dest_x, int32_t dest_y)
2056 struct ivi_layout_layer_properties *prop = NULL;
2058 if (ivilayer == NULL) {
2059 weston_log("ivi_layout_layer_set_position: invalid argument\n");
2063 prop = &ivilayer->pending.prop;
2064 prop->dest_x = dest_x;
2065 prop->dest_y = dest_y;
2067 ivilayer->event_mask |= IVI_NOTIFICATION_POSITION;
2069 return IVI_SUCCEEDED;
2073 ivi_layout_layer_set_orientation(struct ivi_layout_layer *ivilayer,
2074 enum wl_output_transform orientation)
2076 struct ivi_layout_layer_properties *prop = NULL;
2078 if (ivilayer == NULL) {
2079 weston_log("ivi_layout_layer_set_orientation: invalid argument\n");
2083 prop = &ivilayer->pending.prop;
2084 prop->orientation = orientation;
2086 ivilayer->event_mask |= IVI_NOTIFICATION_ORIENTATION;
2088 return IVI_SUCCEEDED;
2091 enum wl_output_transform
2092 ivi_layout_layer_get_orientation(struct ivi_layout_layer *ivilayer)
2094 if (ivilayer == NULL) {
2095 weston_log("ivi_layout_layer_get_orientation: invalid argument\n");
2099 return ivilayer->prop.orientation;
2103 ivi_layout_layer_set_render_order(struct ivi_layout_layer *ivilayer,
2104 struct ivi_layout_surface **pSurface,
2107 struct ivi_layout *layout = get_layout_instance();
2108 struct ivi_layout_surface *ivisurf = NULL;
2109 struct ivi_layout_surface *next = NULL;
2110 uint32_t *id_surface = NULL;
2113 if (ivilayer == NULL) {
2114 weston_log("ivi_layout_layer_set_render_order: invalid argument\n");
2118 if (pSurface == NULL) {
2119 wl_list_for_each_safe(ivisurf, next, &ivilayer->pending.surface_list, pending.link) {
2120 if (!wl_list_empty(&ivisurf->pending.link)) {
2121 wl_list_remove(&ivisurf->pending.link);
2124 wl_list_init(&ivisurf->pending.link);
2126 ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE;
2127 return IVI_SUCCEEDED;
2130 for (i = 0; i < number; i++) {
2131 id_surface = &pSurface[i]->id_surface;
2133 wl_list_for_each_safe(ivisurf, next, &layout->surface_list, link) {
2134 if (*id_surface != ivisurf->id_surface) {
2138 if (!wl_list_empty(&ivisurf->pending.link)) {
2139 wl_list_remove(&ivisurf->pending.link);
2141 wl_list_init(&ivisurf->pending.link);
2142 wl_list_insert(&ivilayer->pending.surface_list,
2143 &ivisurf->pending.link);
2148 ivilayer->event_mask |= IVI_NOTIFICATION_ADD;
2150 return IVI_SUCCEEDED;
2154 ivi_layout_surface_set_visibility(struct ivi_layout_surface *ivisurf,
2157 struct ivi_layout_surface_properties *prop = NULL;
2159 if (ivisurf == NULL) {
2160 weston_log("ivi_layout_surface_set_visibility: invalid argument\n");
2164 prop = &ivisurf->pending.prop;
2165 prop->visibility = newVisibility;
2167 ivisurf->event_mask |= IVI_NOTIFICATION_VISIBILITY;
2169 return IVI_SUCCEEDED;
2173 ivi_layout_surface_get_visibility(struct ivi_layout_surface *ivisurf)
2175 if (ivisurf == NULL) {
2176 weston_log("ivi_layout_surface_get_visibility: invalid argument\n");
2180 return ivisurf->prop.visibility;
2184 ivi_layout_surface_set_opacity(struct ivi_layout_surface *ivisurf,
2187 struct ivi_layout_surface_properties *prop = NULL;
2189 if (ivisurf == NULL) {
2190 weston_log("ivi_layout_surface_set_opacity: invalid argument\n");
2194 prop = &ivisurf->pending.prop;
2195 prop->opacity = opacity;
2197 ivisurf->event_mask |= IVI_NOTIFICATION_OPACITY;
2199 return IVI_SUCCEEDED;
2202 WL_EXPORT wl_fixed_t
2203 ivi_layout_surface_get_opacity(struct ivi_layout_surface *ivisurf)
2205 if (ivisurf == NULL) {
2206 weston_log("ivi_layout_surface_get_opacity: invalid argument\n");
2207 return wl_fixed_from_double(0.0);
2210 return ivisurf->prop.opacity;
2214 ivi_layout_surface_set_destination_rectangle(struct ivi_layout_surface *ivisurf,
2215 int32_t x, int32_t y,
2216 int32_t width, int32_t height)
2218 struct ivi_layout_surface_properties *prop = NULL;
2220 if (ivisurf == NULL) {
2221 weston_log("ivi_layout_surface_set_destination_rectangle: invalid argument\n");
2225 prop = &ivisurf->pending.prop;
2226 prop->start_x = prop->dest_x;
2227 prop->start_y = prop->dest_y;
2230 prop->start_width = prop->dest_width;
2231 prop->start_height = prop->dest_height;
2232 prop->dest_width = width;
2233 prop->dest_height = height;
2235 ivisurf->event_mask |= IVI_NOTIFICATION_DEST_RECT;
2237 return IVI_SUCCEEDED;
2241 ivi_layout_surface_set_dimension(struct ivi_layout_surface *ivisurf,
2242 int32_t dest_width, int32_t dest_height)
2244 struct ivi_layout_surface_properties *prop = NULL;
2246 if (ivisurf == NULL) {
2247 weston_log("ivi_layout_surface_set_dimension: invalid argument\n");
2251 prop = &ivisurf->pending.prop;
2252 prop->dest_width = dest_width;
2253 prop->dest_height = dest_height;
2255 ivisurf->event_mask |= IVI_NOTIFICATION_DIMENSION;
2257 return IVI_SUCCEEDED;
2261 ivi_layout_surface_get_dimension(struct ivi_layout_surface *ivisurf,
2262 int32_t *dest_width, int32_t *dest_height)
2264 if (ivisurf == NULL || dest_width == NULL || dest_height == NULL) {
2265 weston_log("ivi_layout_surface_get_dimension: invalid argument\n");
2269 *dest_width = ivisurf->prop.dest_width;
2270 *dest_height = ivisurf->prop.dest_height;
2272 return IVI_SUCCEEDED;
2276 ivi_layout_surface_set_position(struct ivi_layout_surface *ivisurf,
2277 int32_t dest_x, int32_t dest_y)
2279 struct ivi_layout_surface_properties *prop = NULL;
2281 if (ivisurf == NULL) {
2282 weston_log("ivi_layout_surface_set_position: invalid argument\n");
2286 prop = &ivisurf->pending.prop;
2287 prop->dest_x = dest_x;
2288 prop->dest_y = dest_y;
2290 ivisurf->event_mask |= IVI_NOTIFICATION_POSITION;
2292 return IVI_SUCCEEDED;
2296 ivi_layout_surface_get_position(struct ivi_layout_surface *ivisurf,
2297 int32_t *dest_x, int32_t *dest_y)
2299 if (ivisurf == NULL || dest_x == NULL || dest_y == NULL) {
2300 weston_log("ivi_layout_surface_get_position: invalid argument\n");
2304 *dest_x = ivisurf->prop.dest_x;
2305 *dest_y = ivisurf->prop.dest_y;
2307 return IVI_SUCCEEDED;
2311 ivi_layout_surface_set_orientation(struct ivi_layout_surface *ivisurf,
2312 enum wl_output_transform orientation)
2314 struct ivi_layout_surface_properties *prop = NULL;
2316 if (ivisurf == NULL) {
2317 weston_log("ivi_layout_surface_set_orientation: invalid argument\n");
2321 prop = &ivisurf->pending.prop;
2322 prop->orientation = orientation;
2324 ivisurf->event_mask |= IVI_NOTIFICATION_ORIENTATION;
2326 return IVI_SUCCEEDED;
2329 enum wl_output_transform
2330 ivi_layout_surface_get_orientation(struct ivi_layout_surface *ivisurf)
2332 if (ivisurf == NULL) {
2333 weston_log("ivi_layout_surface_get_orientation: invalid argument\n");
2337 return ivisurf->prop.orientation;
2341 ivi_layout_screen_add_layer(struct ivi_layout_screen *iviscrn,
2342 struct ivi_layout_layer *addlayer)
2344 struct ivi_layout *layout = get_layout_instance();
2345 struct ivi_layout_layer *ivilayer = NULL;
2346 struct ivi_layout_layer *next = NULL;
2347 int is_layer_in_scrn = 0;
2349 if (iviscrn == NULL || addlayer == NULL) {
2350 weston_log("ivi_layout_screen_add_layer: invalid argument\n");
2354 is_layer_in_scrn = is_layer_in_screen(addlayer, iviscrn);
2355 if (is_layer_in_scrn == 1) {
2356 weston_log("ivi_layout_screen_add_layer: addlayer is already available\n");
2357 return IVI_SUCCEEDED;
2360 wl_list_for_each_safe(ivilayer, next, &layout->layer_list, link) {
2361 if (ivilayer->id_layer == addlayer->id_layer) {
2362 if (!wl_list_empty(&ivilayer->pending.link)) {
2363 wl_list_remove(&ivilayer->pending.link);
2365 wl_list_init(&ivilayer->pending.link);
2366 wl_list_insert(&iviscrn->pending.layer_list,
2367 &ivilayer->pending.link);
2372 iviscrn->event_mask |= IVI_NOTIFICATION_ADD;
2374 return IVI_SUCCEEDED;
2378 ivi_layout_screen_set_render_order(struct ivi_layout_screen *iviscrn,
2379 struct ivi_layout_layer **pLayer,
2380 const int32_t number)
2382 struct ivi_layout *layout = get_layout_instance();
2383 struct ivi_layout_layer *ivilayer = NULL;
2384 struct ivi_layout_layer *next = NULL;
2385 uint32_t *id_layer = NULL;
2388 if (iviscrn == NULL) {
2389 weston_log("ivi_layout_screen_set_render_order: invalid argument\n");
2393 wl_list_for_each_safe(ivilayer, next,
2394 &iviscrn->pending.layer_list, pending.link) {
2395 wl_list_init(&ivilayer->pending.link);
2398 wl_list_init(&iviscrn->pending.layer_list);
2400 if (pLayer == NULL) {
2401 wl_list_for_each_safe(ivilayer, next, &iviscrn->pending.layer_list, pending.link) {
2402 if (!wl_list_empty(&ivilayer->pending.link)) {
2403 wl_list_remove(&ivilayer->pending.link);
2406 wl_list_init(&ivilayer->pending.link);
2409 iviscrn->event_mask |= IVI_NOTIFICATION_REMOVE;
2410 return IVI_SUCCEEDED;
2413 for (i = 0; i < number; i++) {
2414 id_layer = &pLayer[i]->id_layer;
2415 wl_list_for_each(ivilayer, &layout->layer_list, link) {
2416 if (*id_layer != ivilayer->id_layer) {
2420 if (!wl_list_empty(&ivilayer->pending.link)) {
2421 wl_list_remove(&ivilayer->pending.link);
2423 wl_list_init(&ivilayer->pending.link);
2424 wl_list_insert(&iviscrn->pending.layer_list,
2425 &ivilayer->pending.link);
2430 iviscrn->event_mask |= IVI_NOTIFICATION_ADD;
2432 return IVI_SUCCEEDED;
2435 WL_EXPORT struct weston_output *
2436 ivi_layout_screen_get_output(struct ivi_layout_screen *iviscrn)
2438 return iviscrn->output;
2442 * This function is used by the additional ivi-module because of dumping ivi_surface sceenshot.
2443 * The ivi-module, e.g. ivi-controller.so, is in wayland-ivi-extension of Genivi's Layer Management.
2444 * This function is used to get the result of drawing by clients.
2446 WL_EXPORT struct weston_surface *
2447 ivi_layout_surface_get_weston_surface(struct ivi_layout_surface *ivisurf)
2449 return ivisurf != NULL ? ivisurf->surface : NULL;
2453 * This function is used by the additional ivi-module because of dumping ivi_surface sceenshot.
2454 * The ivi-module, e.g. ivi-controller.so, is in wayland-ivi-extension of GENIVI's Layer Management.
2455 * This function is used to get the region and the stride.
2458 ivi_layout_surface_get_size(struct ivi_layout_surface *ivisurf,
2463 if (ivisurf == NULL) {
2467 if (width != NULL) {
2468 *width = ivisurf->prop.source_width;
2471 if (height != NULL) {
2472 *height = ivisurf->prop.source_height;
2475 if (stride != NULL &&
2476 ivisurf->surface->buffer_ref.buffer != NULL &&
2477 ivisurf->surface->buffer_ref.buffer->shm_buffer != NULL) {
2478 *stride = wl_shm_buffer_get_stride(ivisurf->surface->buffer_ref.buffer->shm_buffer);
2481 return IVI_SUCCEEDED;
2485 ivi_layout_layer_add_notification(struct ivi_layout_layer *ivilayer,
2486 layer_property_notification_func callback,
2489 struct ivi_layout_notification_callback *prop_callback = NULL;
2491 if (ivilayer == NULL || callback == NULL) {
2492 weston_log("ivi_layout_layer_add_notification: invalid argument\n");
2496 prop_callback = malloc(sizeof *prop_callback);
2497 if (prop_callback == NULL) {
2498 weston_log("fails to allocate memory\n");
2502 prop_callback->callback = callback;
2503 prop_callback->data = userdata;
2505 return add_notification(&ivilayer->property_changed,
2511 ivi_layout_layer_remove_notification(struct ivi_layout_layer *ivilayer)
2513 if (ivilayer == NULL) {
2514 weston_log("ivi_layout_layer_remove_notification: invalid argument\n");
2518 remove_all_notification(&ivilayer->property_changed.listener_list);
2521 WL_EXPORT const struct ivi_layout_surface_properties *
2522 ivi_layout_get_properties_of_surface(struct ivi_layout_surface *ivisurf)
2524 if (ivisurf == NULL) {
2525 weston_log("ivi_layout_get_properties_of_surface: invalid argument\n");
2529 return &ivisurf->prop;
2533 ivi_layout_layer_add_surface(struct ivi_layout_layer *ivilayer,
2534 struct ivi_layout_surface *addsurf)
2536 struct ivi_layout *layout = get_layout_instance();
2537 struct ivi_layout_surface *ivisurf = NULL;
2538 struct ivi_layout_surface *next = NULL;
2539 int is_surf_in_layer = 0;
2541 if (ivilayer == NULL || addsurf == NULL) {
2542 weston_log("ivi_layout_layer_add_surface: invalid argument\n");
2546 is_surf_in_layer = is_surface_in_layer(addsurf, ivilayer);
2547 if (is_surf_in_layer == 1) {
2548 weston_log("ivi_layout_layer_add_surface: addsurf is already available\n");
2549 return IVI_SUCCEEDED;
2552 wl_list_for_each_safe(ivisurf, next, &layout->surface_list, link) {
2553 if (ivisurf->id_surface == addsurf->id_surface) {
2554 if (!wl_list_empty(&ivisurf->pending.link)) {
2555 wl_list_remove(&ivisurf->pending.link);
2557 wl_list_init(&ivisurf->pending.link);
2558 wl_list_insert(&ivilayer->pending.surface_list,
2559 &ivisurf->pending.link);
2564 ivilayer->event_mask |= IVI_NOTIFICATION_ADD;
2566 return IVI_SUCCEEDED;
2570 ivi_layout_layer_remove_surface(struct ivi_layout_layer *ivilayer,
2571 struct ivi_layout_surface *remsurf)
2573 struct ivi_layout_surface *ivisurf = NULL;
2574 struct ivi_layout_surface *next = NULL;
2576 if (ivilayer == NULL || remsurf == NULL) {
2577 weston_log("ivi_layout_layer_remove_surface: invalid argument\n");
2581 wl_list_for_each_safe(ivisurf, next,
2582 &ivilayer->pending.surface_list, pending.link) {
2583 if (ivisurf->id_surface == remsurf->id_surface) {
2584 if (!wl_list_empty(&ivisurf->pending.link)) {
2585 wl_list_remove(&ivisurf->pending.link);
2587 wl_list_init(&ivisurf->pending.link);
2592 remsurf->event_mask |= IVI_NOTIFICATION_REMOVE;
2596 ivi_layout_surface_set_source_rectangle(struct ivi_layout_surface *ivisurf,
2597 int32_t x, int32_t y,
2598 int32_t width, int32_t height)
2600 struct ivi_layout_surface_properties *prop = NULL;
2602 if (ivisurf == NULL) {
2603 weston_log("ivi_layout_surface_set_source_rectangle: invalid argument\n");
2607 prop = &ivisurf->pending.prop;
2610 prop->source_width = width;
2611 prop->source_height = height;
2613 ivisurf->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
2615 return IVI_SUCCEEDED;
2619 ivi_layout_commit_changes(void)
2621 struct ivi_layout *layout = get_layout_instance();
2623 commit_surface_list(layout);
2624 commit_layer_list(layout);
2625 commit_screen_list(layout);
2627 commit_transition(layout);
2629 commit_changes(layout);
2631 weston_compositor_schedule_repaint(layout->compositor);
2633 return IVI_SUCCEEDED;
2636 /***called from ivi-shell**/
2637 static struct weston_surface *
2638 ivi_layout_get_weston_surface(struct ivi_layout_surface *surface)
2640 return (surface != NULL) ? surface->surface : NULL;
2643 static struct weston_view *
2644 ivi_layout_get_weston_view(struct ivi_layout_surface *surface)
2646 struct weston_view *tmpview = NULL;
2651 wl_list_for_each(tmpview, &surface->surface->views, surface_link)
2653 if (tmpview != NULL) {
2661 ivi_layout_surface_configure(struct ivi_layout_surface *ivisurf,
2662 int32_t width, int32_t height)
2664 struct ivi_layout *layout = get_layout_instance();
2665 int32_t in_init = 0;
2667 ivisurf->surface->width_from_buffer = width;
2668 ivisurf->surface->height_from_buffer = height;
2670 if (ivisurf->prop.source_width == 0 || ivisurf->prop.source_height == 0) {
2674 /* FIXME: when sourceHeight/Width is used as clipping range in image buffer */
2675 /* if (ivisurf->prop.sourceWidth == 0 || ivisurf->prop.sourceHeight == 0) { */
2676 ivisurf->pending.prop.source_width = width;
2677 ivisurf->pending.prop.source_height = height;
2678 ivisurf->prop.source_width = width;
2679 ivisurf->prop.source_height = height;
2682 ivisurf->event_mask |= IVI_NOTIFICATION_CONFIGURE;
2685 wl_signal_emit(&layout->surface_notification.configure_changed, ivisurf);
2687 ivi_layout_commit_changes();
2692 ivi_layout_surface_set_content_observer(struct ivi_layout_surface *ivisurf,
2693 ivi_controller_surface_content_callback callback,
2696 int32_t ret = IVI_FAILED;
2698 if (ivisurf != NULL) {
2699 ivisurf->content_observer.callback = callback;
2700 ivisurf->content_observer.userdata = userdata;
2701 ret = IVI_SUCCEEDED;
2706 static struct ivi_layout_surface*
2707 ivi_layout_surface_create(struct weston_surface *wl_surface,
2708 uint32_t id_surface)
2710 struct ivi_layout *layout = get_layout_instance();
2711 struct ivi_layout_surface *ivisurf = NULL;
2712 struct weston_view *tmpview = NULL;
2714 if (wl_surface == NULL) {
2715 weston_log("ivi_layout_surface_create: invalid argument\n");
2719 ivisurf = get_surface(&layout->surface_list, id_surface);
2720 if (ivisurf != NULL) {
2721 if (ivisurf->surface != NULL) {
2722 weston_log("id_surface(%d) is already created\n", id_surface);
2727 ivisurf = calloc(1, sizeof *ivisurf);
2728 if (ivisurf == NULL) {
2729 weston_log("fails to allocate memory\n");
2733 wl_list_init(&ivisurf->link);
2734 wl_signal_init(&ivisurf->property_changed);
2735 wl_signal_init(&ivisurf->configured);
2736 wl_list_init(&ivisurf->layer_list);
2737 ivisurf->id_surface = id_surface;
2738 ivisurf->layout = layout;
2740 ivisurf->surface = wl_surface;
2741 ivisurf->surface_destroy_listener.notify =
2742 westonsurface_destroy_from_ivisurface;
2743 wl_resource_add_destroy_listener(wl_surface->resource,
2744 &ivisurf->surface_destroy_listener);
2746 tmpview = weston_view_create(wl_surface);
2747 if (tmpview == NULL) {
2748 weston_log("fails to allocate memory\n");
2751 ivisurf->surface->width_from_buffer = 0;
2752 ivisurf->surface->height_from_buffer = 0;
2754 weston_matrix_init(&ivisurf->surface_rotation.matrix);
2755 weston_matrix_init(&ivisurf->layer_rotation.matrix);
2756 weston_matrix_init(&ivisurf->surface_pos.matrix);
2757 weston_matrix_init(&ivisurf->layer_pos.matrix);
2758 weston_matrix_init(&ivisurf->scaling.matrix);
2760 wl_list_init(&ivisurf->surface_rotation.link);
2761 wl_list_init(&ivisurf->layer_rotation.link);
2762 wl_list_init(&ivisurf->surface_pos.link);
2763 wl_list_init(&ivisurf->layer_pos.link);
2764 wl_list_init(&ivisurf->scaling.link);
2766 init_surface_properties(&ivisurf->prop);
2767 ivisurf->event_mask = 0;
2769 ivisurf->pending.prop = ivisurf->prop;
2770 wl_list_init(&ivisurf->pending.link);
2772 wl_list_init(&ivisurf->order.link);
2773 wl_list_init(&ivisurf->order.layer_list);
2775 wl_list_insert(&layout->surface_list, &ivisurf->link);
2777 wl_signal_emit(&layout->surface_notification.created, ivisurf);
2783 ivi_layout_init_with_compositor(struct weston_compositor *ec)
2785 struct ivi_layout *layout = get_layout_instance();
2787 layout->compositor = ec;
2789 wl_list_init(&layout->surface_list);
2790 wl_list_init(&layout->layer_list);
2791 wl_list_init(&layout->screen_list);
2793 wl_signal_init(&layout->layer_notification.created);
2794 wl_signal_init(&layout->layer_notification.removed);
2796 wl_signal_init(&layout->surface_notification.created);
2797 wl_signal_init(&layout->surface_notification.removed);
2798 wl_signal_init(&layout->surface_notification.configure_changed);
2800 /* Add layout_layer at the last of weston_compositor.layer_list */
2801 weston_layer_init(&layout->layout_layer, ec->layer_list.prev);
2805 layout->transitions = ivi_layout_transition_set_create(ec);
2806 wl_list_init(&layout->pending_transition_list);
2811 ivi_layout_surface_add_configured_listener(struct ivi_layout_surface* ivisurf,
2812 struct wl_listener* listener)
2814 wl_signal_add(&ivisurf->configured, listener);
2818 WL_EXPORT struct ivi_layout_interface ivi_layout_interface = {
2819 .get_weston_surface = ivi_layout_get_weston_surface,
2820 .get_weston_view = ivi_layout_get_weston_view,
2821 .surface_configure = ivi_layout_surface_configure,
2822 .surface_create = ivi_layout_surface_create,
2823 .init_with_compositor = ivi_layout_init_with_compositor,
2824 .get_surface_dimension = ivi_layout_surface_get_dimension,
2825 .add_surface_configured_listener = ivi_layout_surface_add_configured_listener