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};
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_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;
890 wl_list_for_each(iviscrn, &layout->screen_list, link) {
891 if (iviscrn->event_mask & IVI_NOTIFICATION_REMOVE) {
892 wl_list_for_each_safe(ivilayer, next,
893 &iviscrn->order.layer_list, order.link) {
894 remove_orderlayer_from_screen(ivilayer);
896 if (!wl_list_empty(&ivilayer->order.link)) {
897 wl_list_remove(&ivilayer->order.link);
900 wl_list_init(&ivilayer->order.link);
901 ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE;
905 if (iviscrn->event_mask & IVI_NOTIFICATION_ADD) {
906 wl_list_for_each_safe(ivilayer, next,
907 &iviscrn->order.layer_list, order.link) {
908 remove_orderlayer_from_screen(ivilayer);
910 if (!wl_list_empty(&ivilayer->order.link)) {
911 wl_list_remove(&ivilayer->order.link);
914 wl_list_init(&ivilayer->order.link);
917 wl_list_init(&iviscrn->order.layer_list);
918 wl_list_for_each(ivilayer, &iviscrn->pending.layer_list,
920 wl_list_insert(&iviscrn->order.layer_list,
921 &ivilayer->order.link);
922 add_orderlayer_to_screen(ivilayer, iviscrn);
923 ivilayer->event_mask |= IVI_NOTIFICATION_ADD;
927 iviscrn->event_mask = 0;
929 /* Clear view list of layout ivi_layer */
930 wl_list_init(&layout->layout_layer.view_list.link);
932 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, order.link) {
933 if (ivilayer->prop.visibility == false)
936 wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) {
937 struct weston_view *tmpview = NULL;
938 wl_list_for_each(tmpview, &ivisurf->surface->views, surface_link) {
939 if (tmpview != NULL) {
944 if (ivisurf->prop.visibility == false)
946 if (ivisurf->surface == NULL || tmpview == NULL)
949 weston_layer_entry_insert(&layout->layout_layer.view_list,
950 &tmpview->layer_link);
952 ivisurf->surface->output = iviscrn->output;
961 commit_transition(struct ivi_layout* layout)
963 if(wl_list_empty(&layout->pending_transition_list)){
967 wl_list_insert_list(&layout->transitions->transition_list,
968 &layout->pending_transition_list);
970 wl_list_init(&layout->pending_transition_list);
972 wl_event_source_timer_update(layout->transitions->event_source, 1);
976 send_surface_prop(struct ivi_layout_surface *ivisurf)
978 wl_signal_emit(&ivisurf->property_changed, ivisurf);
979 ivisurf->event_mask = 0;
983 send_layer_prop(struct ivi_layout_layer *ivilayer)
985 wl_signal_emit(&ivilayer->property_changed, ivilayer);
986 ivilayer->event_mask = 0;
990 send_prop(struct ivi_layout *layout)
992 struct ivi_layout_layer *ivilayer = NULL;
993 struct ivi_layout_surface *ivisurf = NULL;
995 wl_list_for_each_reverse(ivilayer, &layout->layer_list, link) {
996 send_layer_prop(ivilayer);
999 wl_list_for_each_reverse(ivisurf, &layout->surface_list, link) {
1000 send_surface_prop(ivisurf);
1005 clear_surface_pending_list(struct ivi_layout_layer *ivilayer)
1007 struct ivi_layout_surface *surface_link = NULL;
1008 struct ivi_layout_surface *surface_next = NULL;
1010 wl_list_for_each_safe(surface_link, surface_next,
1011 &ivilayer->pending.surface_list, pending.link) {
1012 if (!wl_list_empty(&surface_link->pending.link)) {
1013 wl_list_remove(&surface_link->pending.link);
1016 wl_list_init(&surface_link->pending.link);
1019 ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE;
1023 clear_surface_order_list(struct ivi_layout_layer *ivilayer)
1025 struct ivi_layout_surface *surface_link = NULL;
1026 struct ivi_layout_surface *surface_next = NULL;
1028 wl_list_for_each_safe(surface_link, surface_next,
1029 &ivilayer->order.surface_list, order.link) {
1030 if (!wl_list_empty(&surface_link->order.link)) {
1031 wl_list_remove(&surface_link->order.link);
1034 wl_list_init(&surface_link->order.link);
1037 ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE;
1041 layer_created(struct wl_listener *listener, void *data)
1043 struct ivi_layout_layer *ivilayer = data;
1045 struct listener_layout_notification *notification =
1046 container_of(listener,
1047 struct listener_layout_notification,
1050 struct ivi_layout_notification_callback *created_callback =
1051 notification->userdata;
1053 ((layer_create_notification_func)created_callback->callback)
1054 (ivilayer, created_callback->data);
1058 layer_removed(struct wl_listener *listener, void *data)
1060 struct ivi_layout_layer *ivilayer = data;
1062 struct listener_layout_notification *notification =
1063 container_of(listener,
1064 struct listener_layout_notification,
1067 struct ivi_layout_notification_callback *removed_callback =
1068 notification->userdata;
1070 ((layer_remove_notification_func)removed_callback->callback)
1071 (ivilayer, removed_callback->data);
1075 layer_prop_changed(struct wl_listener *listener, void *data)
1077 struct ivi_layout_layer *ivilayer = data;
1079 struct listener_layout_notification *layout_listener =
1080 container_of(listener,
1081 struct listener_layout_notification,
1084 struct ivi_layout_notification_callback *prop_callback =
1085 layout_listener->userdata;
1087 ((layer_property_notification_func)prop_callback->callback)
1088 (ivilayer, &ivilayer->prop, ivilayer->event_mask, prop_callback->data);
1092 surface_created(struct wl_listener *listener, void *data)
1094 struct ivi_layout_surface *ivisurface = data;
1096 struct listener_layout_notification *notification =
1097 container_of(listener,
1098 struct listener_layout_notification,
1101 struct ivi_layout_notification_callback *created_callback =
1102 notification->userdata;
1104 ((surface_create_notification_func)created_callback->callback)
1105 (ivisurface, created_callback->data);
1109 surface_removed(struct wl_listener *listener, void *data)
1111 struct ivi_layout_surface *ivisurface = data;
1113 struct listener_layout_notification *notification =
1114 container_of(listener,
1115 struct listener_layout_notification,
1118 struct ivi_layout_notification_callback *removed_callback =
1119 notification->userdata;
1121 ((surface_remove_notification_func)removed_callback->callback)
1122 (ivisurface, removed_callback->data);
1126 surface_prop_changed(struct wl_listener *listener, void *data)
1128 struct ivi_layout_surface *ivisurf = data;
1130 struct listener_layout_notification *layout_listener =
1131 container_of(listener,
1132 struct listener_layout_notification,
1135 struct ivi_layout_notification_callback *prop_callback =
1136 layout_listener->userdata;
1138 ((surface_property_notification_func)prop_callback->callback)
1139 (ivisurf, &ivisurf->prop, ivisurf->event_mask, prop_callback->data);
1141 ivisurf->event_mask = 0;
1145 surface_configure_changed(struct wl_listener *listener,
1148 struct ivi_layout_surface *ivisurface = data;
1150 struct listener_layout_notification *notification =
1151 container_of(listener,
1152 struct listener_layout_notification,
1155 struct ivi_layout_notification_callback *configure_changed_callback =
1156 notification->userdata;
1158 ((surface_configure_notification_func)configure_changed_callback->callback)
1159 (ivisurface, configure_changed_callback->data);
1163 add_notification(struct wl_signal *signal,
1164 wl_notify_func_t callback,
1167 struct listener_layout_notification *notification = NULL;
1169 notification = malloc(sizeof *notification);
1170 if (notification == NULL) {
1171 weston_log("fails to allocate memory\n");
1176 notification->listener.notify = callback;
1177 notification->userdata = userdata;
1179 wl_signal_add(signal, ¬ification->listener);
1181 return IVI_SUCCEEDED;
1185 remove_notification(struct wl_list *listener_list, void *callback, void *userdata)
1187 struct wl_listener *listener = NULL;
1188 struct wl_listener *next = NULL;
1190 wl_list_for_each_safe(listener, next, listener_list, link) {
1191 struct listener_layout_notification *notification =
1192 container_of(listener,
1193 struct listener_layout_notification,
1196 struct ivi_layout_notification_callback *notification_callback =
1197 notification->userdata;
1199 if ((notification_callback->callback != callback) ||
1200 (notification_callback->data != userdata)) {
1204 if (!wl_list_empty(&listener->link)) {
1205 wl_list_remove(&listener->link);
1208 free(notification->userdata);
1214 remove_all_notification(struct wl_list *listener_list)
1216 struct wl_listener *listener = NULL;
1217 struct wl_listener *next = NULL;
1219 wl_list_for_each_safe(listener, next, listener_list, link) {
1220 struct listener_layout_notification *notification = NULL;
1221 if (!wl_list_empty(&listener->link)) {
1222 wl_list_remove(&listener->link);
1226 container_of(listener,
1227 struct listener_layout_notification,
1230 free(notification->userdata);
1236 * Exported APIs of ivi-layout library are implemented from here.
1237 * Brief of APIs is described in ivi-layout-export.h.
1240 ivi_layout_add_notification_create_layer(layer_create_notification_func callback,
1243 struct ivi_layout *layout = get_instance();
1244 struct ivi_layout_notification_callback *created_callback = NULL;
1246 if (callback == NULL) {
1247 weston_log("ivi_layout_add_notification_create_layer: invalid argument\n");
1251 created_callback = malloc(sizeof *created_callback);
1252 if (created_callback == NULL) {
1253 weston_log("fails to allocate memory\n");
1257 created_callback->callback = callback;
1258 created_callback->data = userdata;
1260 return add_notification(&layout->layer_notification.created,
1266 ivi_layout_remove_notification_create_layer(layer_create_notification_func callback,
1269 struct ivi_layout *layout = get_instance();
1270 remove_notification(&layout->layer_notification.created.listener_list, callback, userdata);
1274 ivi_layout_add_notification_remove_layer(layer_remove_notification_func callback,
1277 struct ivi_layout *layout = get_instance();
1278 struct ivi_layout_notification_callback *removed_callback = NULL;
1280 if (callback == NULL) {
1281 weston_log("ivi_layout_add_notification_remove_layer: invalid argument\n");
1285 removed_callback = malloc(sizeof *removed_callback);
1286 if (removed_callback == NULL) {
1287 weston_log("fails to allocate memory\n");
1291 removed_callback->callback = callback;
1292 removed_callback->data = userdata;
1293 return add_notification(&layout->layer_notification.removed,
1299 ivi_layout_remove_notification_remove_layer(layer_remove_notification_func callback,
1302 struct ivi_layout *layout = get_instance();
1303 remove_notification(&layout->layer_notification.removed.listener_list, callback, userdata);
1307 ivi_layout_add_notification_create_surface(surface_create_notification_func callback,
1310 struct ivi_layout *layout = get_instance();
1311 struct ivi_layout_notification_callback *created_callback = NULL;
1313 if (callback == NULL) {
1314 weston_log("ivi_layout_add_notification_create_surface: invalid argument\n");
1318 created_callback = malloc(sizeof *created_callback);
1319 if (created_callback == NULL) {
1320 weston_log("fails to allocate memory\n");
1324 created_callback->callback = callback;
1325 created_callback->data = userdata;
1327 return add_notification(&layout->surface_notification.created,
1333 ivi_layout_remove_notification_create_surface(surface_create_notification_func callback,
1336 struct ivi_layout *layout = get_instance();
1337 remove_notification(&layout->surface_notification.created.listener_list, callback, userdata);
1341 ivi_layout_add_notification_remove_surface(surface_remove_notification_func callback,
1344 struct ivi_layout *layout = get_instance();
1345 struct ivi_layout_notification_callback *removed_callback = NULL;
1347 if (callback == NULL) {
1348 weston_log("ivi_layout_add_notification_remove_surface: invalid argument\n");
1352 removed_callback = malloc(sizeof *removed_callback);
1353 if (removed_callback == NULL) {
1354 weston_log("fails to allocate memory\n");
1358 removed_callback->callback = callback;
1359 removed_callback->data = userdata;
1361 return add_notification(&layout->surface_notification.removed,
1367 ivi_layout_remove_notification_remove_surface(surface_remove_notification_func callback,
1370 struct ivi_layout *layout = get_instance();
1371 remove_notification(&layout->surface_notification.removed.listener_list, callback, userdata);
1375 ivi_layout_add_notification_configure_surface(surface_configure_notification_func callback,
1378 struct ivi_layout *layout = get_instance();
1379 struct ivi_layout_notification_callback *configure_changed_callback = NULL;
1380 if (callback == NULL) {
1381 weston_log("ivi_layout_add_notification_configure_surface: invalid argument\n");
1385 configure_changed_callback = malloc(sizeof *configure_changed_callback);
1386 if (configure_changed_callback == NULL) {
1387 weston_log("fails to allocate memory\n");
1391 configure_changed_callback->callback = callback;
1392 configure_changed_callback->data = userdata;
1394 return add_notification(&layout->surface_notification.configure_changed,
1395 surface_configure_changed,
1396 configure_changed_callback);
1400 ivi_layout_remove_notification_configure_surface(surface_configure_notification_func callback,
1403 struct ivi_layout *layout = get_instance();
1404 remove_notification(&layout->surface_notification.configure_changed.listener_list, callback, userdata);
1408 ivi_layout_get_id_of_surface(struct ivi_layout_surface *ivisurf)
1410 return ivisurf->id_surface;
1414 ivi_layout_get_id_of_layer(struct ivi_layout_layer *ivilayer)
1416 return ivilayer->id_layer;
1419 struct ivi_layout_layer *
1420 ivi_layout_get_layer_from_id(uint32_t id_layer)
1422 struct ivi_layout *layout = get_instance();
1423 struct ivi_layout_layer *ivilayer = NULL;
1425 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1426 if (ivilayer->id_layer == id_layer) {
1434 WL_EXPORT struct ivi_layout_surface *
1435 ivi_layout_get_surface_from_id(uint32_t id_surface)
1437 struct ivi_layout *layout = get_instance();
1438 struct ivi_layout_surface *ivisurf = NULL;
1440 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1441 if (ivisurf->id_surface == id_surface) {
1449 WL_EXPORT struct ivi_layout_screen *
1450 ivi_layout_get_screen_from_id(uint32_t id_screen)
1452 struct ivi_layout *layout = get_instance();
1453 struct ivi_layout_screen *iviscrn = NULL;
1455 wl_list_for_each(iviscrn, &layout->screen_list, link) {
1456 /* FIXME : select iviscrn from screen_list by id_screen */
1465 ivi_layout_get_screen_resolution(struct ivi_layout_screen *iviscrn,
1466 int32_t *pWidth, int32_t *pHeight)
1468 struct weston_output *output = NULL;
1470 if (pWidth == NULL || pHeight == NULL) {
1471 weston_log("ivi_layout_get_screen_resolution: invalid argument\n");
1475 output = iviscrn->output;
1476 *pWidth = output->current_mode->width;
1477 *pHeight = output->current_mode->height;
1479 return IVI_SUCCEEDED;
1483 ivi_layout_surface_add_notification(struct ivi_layout_surface *ivisurf,
1484 surface_property_notification_func callback,
1487 struct listener_layout_notification* notification = NULL;
1488 struct ivi_layout_notification_callback *prop_callback = NULL;
1490 if (ivisurf == NULL || callback == NULL) {
1491 weston_log("ivi_layout_surface_add_notification: invalid argument\n");
1495 notification = malloc(sizeof *notification);
1496 if (notification == NULL) {
1497 weston_log("fails to allocate memory\n");
1501 prop_callback = malloc(sizeof *prop_callback);
1502 if (prop_callback == NULL) {
1503 weston_log("fails to allocate memory\n");
1507 prop_callback->callback = callback;
1508 prop_callback->data = userdata;
1510 notification->listener.notify = surface_prop_changed;
1511 notification->userdata = prop_callback;
1513 wl_signal_add(&ivisurf->property_changed, ¬ification->listener);
1515 return IVI_SUCCEEDED;
1519 ivi_layout_surface_remove_notification(struct ivi_layout_surface *ivisurf)
1521 if (ivisurf == NULL) {
1522 weston_log("ivi_layout_surface_remove_notification: invalid argument\n");
1526 remove_all_notification(&ivisurf->property_changed.listener_list);
1530 remove_configured_listener(struct ivi_layout_surface *ivisurf)
1532 struct wl_listener *link = NULL;
1533 struct wl_listener *next = NULL;
1535 wl_list_for_each_safe(link, next, &ivisurf->configured.listener_list, link) {
1536 wl_list_remove(&link->link);
1541 ivi_layout_surface_remove(struct ivi_layout_surface *ivisurf)
1543 struct ivi_layout *layout = get_instance();
1545 if (ivisurf == NULL) {
1546 weston_log("ivi_layout_surface_remove: invalid argument\n");
1550 if (!wl_list_empty(&ivisurf->pending.link)) {
1551 wl_list_remove(&ivisurf->pending.link);
1553 if (!wl_list_empty(&ivisurf->order.link)) {
1554 wl_list_remove(&ivisurf->order.link);
1556 if (!wl_list_empty(&ivisurf->link)) {
1557 wl_list_remove(&ivisurf->link);
1559 remove_ordersurface_from_layer(ivisurf);
1561 wl_signal_emit(&layout->surface_notification.removed, ivisurf);
1563 remove_configured_listener(ivisurf);
1565 ivi_layout_surface_remove_notification(ivisurf);
1570 WL_EXPORT const struct ivi_layout_layer_properties *
1571 ivi_layout_get_properties_of_layer(struct ivi_layout_layer *ivilayer)
1573 if (ivilayer == NULL) {
1574 weston_log("ivi_layout_get_properties_of_layer: invalid argument\n");
1578 return &ivilayer->prop;
1582 ivi_layout_get_screens(int32_t *pLength, struct ivi_layout_screen ***ppArray)
1584 struct ivi_layout *layout = get_instance();
1585 struct ivi_layout_screen *iviscrn = NULL;
1589 if (pLength == NULL || ppArray == NULL) {
1590 weston_log("ivi_layout_get_screens: invalid argument\n");
1594 length = wl_list_length(&layout->screen_list);
1597 /* the Array must be free by module which called this function */
1598 *ppArray = calloc(length, sizeof(struct ivi_layout_screen *));
1599 if (*ppArray == NULL) {
1600 weston_log("fails to allocate memory\n");
1604 wl_list_for_each(iviscrn, &layout->screen_list, link) {
1605 (*ppArray)[n++] = iviscrn;
1611 return IVI_SUCCEEDED;
1615 ivi_layout_get_screens_under_layer(struct ivi_layout_layer *ivilayer,
1617 struct ivi_layout_screen ***ppArray)
1619 struct link_screen *link_scrn = NULL;
1623 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1624 weston_log("ivi_layout_get_screens_under_layer: invalid argument\n");
1628 length = wl_list_length(&ivilayer->screen_list);
1631 /* the Array must be free by module which called this function */
1632 *ppArray = calloc(length, sizeof(struct ivi_layout_screen *));
1633 if (*ppArray == NULL) {
1634 weston_log("fails to allocate memory\n");
1638 wl_list_for_each(link_scrn, &ivilayer->screen_list, link) {
1639 (*ppArray)[n++] = link_scrn->iviscrn;
1645 return IVI_SUCCEEDED;
1649 ivi_layout_get_layers(int32_t *pLength, struct ivi_layout_layer ***ppArray)
1651 struct ivi_layout *layout = get_instance();
1652 struct ivi_layout_layer *ivilayer = NULL;
1656 if (pLength == NULL || ppArray == NULL) {
1657 weston_log("ivi_layout_get_layers: invalid argument\n");
1661 length = wl_list_length(&layout->layer_list);
1664 /* the Array must be free by module which called this function */
1665 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1666 if (*ppArray == NULL) {
1667 weston_log("fails to allocate memory\n");
1671 wl_list_for_each(ivilayer, &layout->layer_list, link) {
1672 (*ppArray)[n++] = ivilayer;
1678 return IVI_SUCCEEDED;
1682 ivi_layout_get_layers_on_screen(struct ivi_layout_screen *iviscrn,
1684 struct ivi_layout_layer ***ppArray)
1686 struct ivi_layout_layer *ivilayer = NULL;
1690 if (iviscrn == NULL || pLength == NULL || ppArray == NULL) {
1691 weston_log("ivi_layout_get_layers_on_screen: invalid argument\n");
1695 length = wl_list_length(&iviscrn->order.layer_list);
1698 /* the Array must be free by module which called this function */
1699 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1700 if (*ppArray == NULL) {
1701 weston_log("fails to allocate memory\n");
1705 wl_list_for_each(ivilayer, &iviscrn->order.layer_list, link) {
1706 (*ppArray)[n++] = ivilayer;
1712 return IVI_SUCCEEDED;
1716 ivi_layout_get_layers_under_surface(struct ivi_layout_surface *ivisurf,
1718 struct ivi_layout_layer ***ppArray)
1720 struct link_layer *link_layer = NULL;
1724 if (ivisurf == NULL || pLength == NULL || ppArray == NULL) {
1725 weston_log("ivi_layout_getLayers: invalid argument\n");
1729 length = wl_list_length(&ivisurf->layer_list);
1732 /* the Array must be free by module which called this function */
1733 *ppArray = calloc(length, sizeof(struct ivi_layout_layer *));
1734 if (*ppArray == NULL) {
1735 weston_log("fails to allocate memory\n");
1739 wl_list_for_each(link_layer, &ivisurf->layer_list, link) {
1740 (*ppArray)[n++] = link_layer->ivilayer;
1746 return IVI_SUCCEEDED;
1750 ivi_layout_get_surfaces(int32_t *pLength, struct ivi_layout_surface ***ppArray)
1752 struct ivi_layout *layout = get_instance();
1753 struct ivi_layout_surface *ivisurf = NULL;
1757 if (pLength == NULL || ppArray == NULL) {
1758 weston_log("ivi_layout_get_surfaces: invalid argument\n");
1762 length = wl_list_length(&layout->surface_list);
1765 /* the Array must be free by module which called this function */
1766 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1767 if (*ppArray == NULL) {
1768 weston_log("fails to allocate memory\n");
1772 wl_list_for_each(ivisurf, &layout->surface_list, link) {
1773 (*ppArray)[n++] = ivisurf;
1779 return IVI_SUCCEEDED;
1783 ivi_layout_get_surfaces_on_layer(struct ivi_layout_layer *ivilayer,
1785 struct ivi_layout_surface ***ppArray)
1787 struct ivi_layout_surface *ivisurf = NULL;
1791 if (ivilayer == NULL || pLength == NULL || ppArray == NULL) {
1792 weston_log("ivi_layout_getSurfaceIDsOnLayer: invalid argument\n");
1796 length = wl_list_length(&ivilayer->order.surface_list);
1799 /* the Array must be free by module which called this function */
1800 *ppArray = calloc(length, sizeof(struct ivi_layout_surface *));
1801 if (*ppArray == NULL) {
1802 weston_log("fails to allocate memory\n");
1806 wl_list_for_each(ivisurf, &ivilayer->order.surface_list, order.link) {
1807 (*ppArray)[n++] = ivisurf;
1813 return IVI_SUCCEEDED;
1816 WL_EXPORT struct ivi_layout_layer *
1817 ivi_layout_layer_create_with_dimension(uint32_t id_layer,
1818 int32_t width, int32_t height)
1820 struct ivi_layout *layout = get_instance();
1821 struct ivi_layout_layer *ivilayer = NULL;
1823 ivilayer = get_layer(&layout->layer_list, id_layer);
1824 if (ivilayer != NULL) {
1825 weston_log("id_layer is already created\n");
1829 ivilayer = calloc(1, sizeof *ivilayer);
1830 if (ivilayer == NULL) {
1831 weston_log("fails to allocate memory\n");
1835 wl_list_init(&ivilayer->link);
1836 wl_signal_init(&ivilayer->property_changed);
1837 wl_list_init(&ivilayer->screen_list);
1838 wl_list_init(&ivilayer->link_to_surface);
1839 ivilayer->layout = layout;
1840 ivilayer->id_layer = id_layer;
1842 init_layer_properties(&ivilayer->prop, width, height);
1843 ivilayer->event_mask = 0;
1845 wl_list_init(&ivilayer->pending.surface_list);
1846 wl_list_init(&ivilayer->pending.link);
1847 ivilayer->pending.prop = ivilayer->prop;
1849 wl_list_init(&ivilayer->order.surface_list);
1850 wl_list_init(&ivilayer->order.link);
1852 wl_list_insert(&layout->layer_list, &ivilayer->link);
1854 wl_signal_emit(&layout->layer_notification.created, ivilayer);
1860 ivi_layout_layer_remove(struct ivi_layout_layer *ivilayer)
1862 struct ivi_layout *layout = get_instance();
1864 if (ivilayer == NULL) {
1865 weston_log("ivi_layout_layer_remove: invalid argument\n");
1869 wl_signal_emit(&layout->layer_notification.removed, ivilayer);
1871 clear_surface_pending_list(ivilayer);
1872 clear_surface_order_list(ivilayer);
1874 if (!wl_list_empty(&ivilayer->pending.link)) {
1875 wl_list_remove(&ivilayer->pending.link);
1877 if (!wl_list_empty(&ivilayer->order.link)) {
1878 wl_list_remove(&ivilayer->order.link);
1880 if (!wl_list_empty(&ivilayer->link)) {
1881 wl_list_remove(&ivilayer->link);
1883 remove_orderlayer_from_screen(ivilayer);
1884 remove_link_to_surface(ivilayer);
1885 ivi_layout_layer_remove_notification(ivilayer);
1891 ivi_layout_layer_set_visibility(struct ivi_layout_layer *ivilayer,
1894 struct ivi_layout_layer_properties *prop = NULL;
1896 if (ivilayer == NULL) {
1897 weston_log("ivi_layout_layer_set_visibility: invalid argument\n");
1901 prop = &ivilayer->pending.prop;
1902 prop->visibility = newVisibility;
1904 ivilayer->event_mask |= IVI_NOTIFICATION_VISIBILITY;
1906 return IVI_SUCCEEDED;
1910 ivi_layout_layer_get_visibility(struct ivi_layout_layer *ivilayer)
1912 if (ivilayer == NULL) {
1913 weston_log("ivi_layout_layer_get_visibility: invalid argument\n");
1917 return ivilayer->prop.visibility;
1921 ivi_layout_layer_set_opacity(struct ivi_layout_layer *ivilayer,
1924 struct ivi_layout_layer_properties *prop = NULL;
1926 if (ivilayer == NULL) {
1927 weston_log("ivi_layout_layer_set_opacity: invalid argument\n");
1931 prop = &ivilayer->pending.prop;
1932 prop->opacity = opacity;
1934 ivilayer->event_mask |= IVI_NOTIFICATION_OPACITY;
1936 return IVI_SUCCEEDED;
1939 WL_EXPORT wl_fixed_t
1940 ivi_layout_layer_get_opacity(struct ivi_layout_layer *ivilayer)
1942 if (ivilayer == NULL) {
1943 weston_log("ivi_layout_layer_get_opacity: invalid argument\n");
1944 return wl_fixed_from_double(0.0);
1947 return ivilayer->prop.opacity;
1951 ivi_layout_layer_set_source_rectangle(struct ivi_layout_layer *ivilayer,
1952 int32_t x, int32_t y,
1953 int32_t width, int32_t height)
1955 struct ivi_layout_layer_properties *prop = NULL;
1957 if (ivilayer == NULL) {
1958 weston_log("ivi_layout_layer_set_source_rectangle: invalid argument\n");
1962 prop = &ivilayer->pending.prop;
1965 prop->source_width = width;
1966 prop->source_height = height;
1968 ivilayer->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
1970 return IVI_SUCCEEDED;
1974 ivi_layout_layer_set_destination_rectangle(struct ivi_layout_layer *ivilayer,
1975 int32_t x, int32_t y,
1976 int32_t width, int32_t height)
1978 struct ivi_layout_layer_properties *prop = NULL;
1980 if (ivilayer == NULL) {
1981 weston_log("ivi_layout_layer_set_destination_rectangle: invalid argument\n");
1985 prop = &ivilayer->pending.prop;
1988 prop->dest_width = width;
1989 prop->dest_height = height;
1991 ivilayer->event_mask |= IVI_NOTIFICATION_DEST_RECT;
1993 return IVI_SUCCEEDED;
1997 ivi_layout_layer_get_dimension(struct ivi_layout_layer *ivilayer,
1998 int32_t *dest_width, int32_t *dest_height)
2000 if (ivilayer == NULL || dest_width == NULL || dest_height == NULL) {
2001 weston_log("ivi_layout_layer_get_dimension: invalid argument\n");
2005 *dest_width = ivilayer->prop.dest_width;
2006 *dest_height = ivilayer->prop.dest_height;
2008 return IVI_SUCCEEDED;
2012 ivi_layout_layer_set_dimension(struct ivi_layout_layer *ivilayer,
2013 int32_t dest_width, int32_t dest_height)
2015 struct ivi_layout_layer_properties *prop = NULL;
2017 if (ivilayer == NULL) {
2018 weston_log("ivi_layout_layer_set_dimension: invalid argument\n");
2022 prop = &ivilayer->pending.prop;
2024 prop->dest_width = dest_width;
2025 prop->dest_height = dest_height;
2027 ivilayer->event_mask |= IVI_NOTIFICATION_DIMENSION;
2029 return IVI_SUCCEEDED;
2033 ivi_layout_layer_get_position(struct ivi_layout_layer *ivilayer,
2034 int32_t *dest_x, int32_t *dest_y)
2036 if (ivilayer == NULL || dest_x == NULL || dest_y == NULL) {
2037 weston_log("ivi_layout_layer_get_position: invalid argument\n");
2041 *dest_x = ivilayer->prop.dest_x;
2042 *dest_y = ivilayer->prop.dest_y;
2044 return IVI_SUCCEEDED;
2048 ivi_layout_layer_set_position(struct ivi_layout_layer *ivilayer,
2049 int32_t dest_x, int32_t dest_y)
2051 struct ivi_layout_layer_properties *prop = NULL;
2053 if (ivilayer == NULL) {
2054 weston_log("ivi_layout_layer_set_position: invalid argument\n");
2058 prop = &ivilayer->pending.prop;
2059 prop->dest_x = dest_x;
2060 prop->dest_y = dest_y;
2062 ivilayer->event_mask |= IVI_NOTIFICATION_POSITION;
2064 return IVI_SUCCEEDED;
2068 ivi_layout_layer_set_orientation(struct ivi_layout_layer *ivilayer,
2069 enum wl_output_transform orientation)
2071 struct ivi_layout_layer_properties *prop = NULL;
2073 if (ivilayer == NULL) {
2074 weston_log("ivi_layout_layer_set_orientation: invalid argument\n");
2078 prop = &ivilayer->pending.prop;
2079 prop->orientation = orientation;
2081 ivilayer->event_mask |= IVI_NOTIFICATION_ORIENTATION;
2083 return IVI_SUCCEEDED;
2086 enum wl_output_transform
2087 ivi_layout_layer_get_orientation(struct ivi_layout_layer *ivilayer)
2089 if (ivilayer == NULL) {
2090 weston_log("ivi_layout_layer_get_orientation: invalid argument\n");
2094 return ivilayer->prop.orientation;
2098 ivi_layout_layer_set_render_order(struct ivi_layout_layer *ivilayer,
2099 struct ivi_layout_surface **pSurface,
2102 struct ivi_layout *layout = get_instance();
2103 struct ivi_layout_surface *ivisurf = NULL;
2104 struct ivi_layout_surface *next = NULL;
2105 uint32_t *id_surface = NULL;
2108 if (ivilayer == NULL) {
2109 weston_log("ivi_layout_layer_set_render_order: invalid argument\n");
2113 if (pSurface == NULL) {
2114 wl_list_for_each_safe(ivisurf, next, &ivilayer->pending.surface_list, pending.link) {
2115 if (!wl_list_empty(&ivisurf->pending.link)) {
2116 wl_list_remove(&ivisurf->pending.link);
2119 wl_list_init(&ivisurf->pending.link);
2121 ivilayer->event_mask |= IVI_NOTIFICATION_REMOVE;
2122 return IVI_SUCCEEDED;
2125 for (i = 0; i < number; i++) {
2126 id_surface = &pSurface[i]->id_surface;
2128 wl_list_for_each_safe(ivisurf, next, &layout->surface_list, link) {
2129 if (*id_surface != ivisurf->id_surface) {
2133 if (!wl_list_empty(&ivisurf->pending.link)) {
2134 wl_list_remove(&ivisurf->pending.link);
2136 wl_list_init(&ivisurf->pending.link);
2137 wl_list_insert(&ivilayer->pending.surface_list,
2138 &ivisurf->pending.link);
2143 ivilayer->event_mask |= IVI_NOTIFICATION_ADD;
2145 return IVI_SUCCEEDED;
2149 ivi_layout_surface_set_visibility(struct ivi_layout_surface *ivisurf,
2152 struct ivi_layout_surface_properties *prop = NULL;
2154 if (ivisurf == NULL) {
2155 weston_log("ivi_layout_surface_set_visibility: invalid argument\n");
2159 prop = &ivisurf->pending.prop;
2160 prop->visibility = newVisibility;
2162 ivisurf->event_mask |= IVI_NOTIFICATION_VISIBILITY;
2164 return IVI_SUCCEEDED;
2168 ivi_layout_surface_get_visibility(struct ivi_layout_surface *ivisurf)
2170 if (ivisurf == NULL) {
2171 weston_log("ivi_layout_surface_get_visibility: invalid argument\n");
2175 return ivisurf->prop.visibility;
2179 ivi_layout_surface_set_opacity(struct ivi_layout_surface *ivisurf,
2182 struct ivi_layout_surface_properties *prop = NULL;
2184 if (ivisurf == NULL) {
2185 weston_log("ivi_layout_surface_set_opacity: invalid argument\n");
2189 prop = &ivisurf->pending.prop;
2190 prop->opacity = opacity;
2192 ivisurf->event_mask |= IVI_NOTIFICATION_OPACITY;
2194 return IVI_SUCCEEDED;
2197 WL_EXPORT wl_fixed_t
2198 ivi_layout_surface_get_opacity(struct ivi_layout_surface *ivisurf)
2200 if (ivisurf == NULL) {
2201 weston_log("ivi_layout_surface_get_opacity: invalid argument\n");
2202 return wl_fixed_from_double(0.0);
2205 return ivisurf->prop.opacity;
2209 ivi_layout_surface_set_destination_rectangle(struct ivi_layout_surface *ivisurf,
2210 int32_t x, int32_t y,
2211 int32_t width, int32_t height)
2213 struct ivi_layout_surface_properties *prop = NULL;
2215 if (ivisurf == NULL) {
2216 weston_log("ivi_layout_surface_set_destination_rectangle: invalid argument\n");
2220 prop = &ivisurf->pending.prop;
2221 prop->start_x = prop->dest_x;
2222 prop->start_y = prop->dest_y;
2225 prop->start_width = prop->dest_width;
2226 prop->start_height = prop->dest_height;
2227 prop->dest_width = width;
2228 prop->dest_height = height;
2230 ivisurf->event_mask |= IVI_NOTIFICATION_DEST_RECT;
2232 return IVI_SUCCEEDED;
2236 ivi_layout_surface_set_dimension(struct ivi_layout_surface *ivisurf,
2237 int32_t dest_width, int32_t dest_height)
2239 struct ivi_layout_surface_properties *prop = NULL;
2241 if (ivisurf == NULL) {
2242 weston_log("ivi_layout_surface_set_dimension: invalid argument\n");
2246 prop = &ivisurf->pending.prop;
2247 prop->dest_width = dest_width;
2248 prop->dest_height = dest_height;
2250 ivisurf->event_mask |= IVI_NOTIFICATION_DIMENSION;
2252 return IVI_SUCCEEDED;
2256 ivi_layout_surface_get_dimension(struct ivi_layout_surface *ivisurf,
2257 int32_t *dest_width, int32_t *dest_height)
2259 if (ivisurf == NULL || dest_width == NULL || dest_height == NULL) {
2260 weston_log("ivi_layout_surface_get_dimension: invalid argument\n");
2264 *dest_width = ivisurf->prop.dest_width;
2265 *dest_height = ivisurf->prop.dest_height;
2267 return IVI_SUCCEEDED;
2271 ivi_layout_surface_set_position(struct ivi_layout_surface *ivisurf,
2272 int32_t dest_x, int32_t dest_y)
2274 struct ivi_layout_surface_properties *prop = NULL;
2276 if (ivisurf == NULL) {
2277 weston_log("ivi_layout_surface_set_position: invalid argument\n");
2281 prop = &ivisurf->pending.prop;
2282 prop->dest_x = dest_x;
2283 prop->dest_y = dest_y;
2285 ivisurf->event_mask |= IVI_NOTIFICATION_POSITION;
2287 return IVI_SUCCEEDED;
2291 ivi_layout_surface_get_position(struct ivi_layout_surface *ivisurf,
2292 int32_t *dest_x, int32_t *dest_y)
2294 if (ivisurf == NULL || dest_x == NULL || dest_y == NULL) {
2295 weston_log("ivi_layout_surface_get_position: invalid argument\n");
2299 *dest_x = ivisurf->prop.dest_x;
2300 *dest_y = ivisurf->prop.dest_y;
2302 return IVI_SUCCEEDED;
2306 ivi_layout_surface_set_orientation(struct ivi_layout_surface *ivisurf,
2307 enum wl_output_transform orientation)
2309 struct ivi_layout_surface_properties *prop = NULL;
2311 if (ivisurf == NULL) {
2312 weston_log("ivi_layout_surface_set_orientation: invalid argument\n");
2316 prop = &ivisurf->pending.prop;
2317 prop->orientation = orientation;
2319 ivisurf->event_mask |= IVI_NOTIFICATION_ORIENTATION;
2321 return IVI_SUCCEEDED;
2324 enum wl_output_transform
2325 ivi_layout_surface_get_orientation(struct ivi_layout_surface *ivisurf)
2327 if (ivisurf == NULL) {
2328 weston_log("ivi_layout_surface_get_orientation: invalid argument\n");
2332 return ivisurf->prop.orientation;
2336 ivi_layout_screen_add_layer(struct ivi_layout_screen *iviscrn,
2337 struct ivi_layout_layer *addlayer)
2339 struct ivi_layout *layout = get_instance();
2340 struct ivi_layout_layer *ivilayer = NULL;
2341 struct ivi_layout_layer *next = NULL;
2342 int is_layer_in_scrn = 0;
2344 if (iviscrn == NULL || addlayer == NULL) {
2345 weston_log("ivi_layout_screen_add_layer: invalid argument\n");
2349 is_layer_in_scrn = is_layer_in_screen(addlayer, iviscrn);
2350 if (is_layer_in_scrn == 1) {
2351 weston_log("ivi_layout_screen_add_layer: addlayer is already available\n");
2352 return IVI_SUCCEEDED;
2355 wl_list_for_each_safe(ivilayer, next, &layout->layer_list, link) {
2356 if (ivilayer->id_layer == addlayer->id_layer) {
2357 if (!wl_list_empty(&ivilayer->pending.link)) {
2358 wl_list_remove(&ivilayer->pending.link);
2360 wl_list_init(&ivilayer->pending.link);
2361 wl_list_insert(&iviscrn->pending.layer_list,
2362 &ivilayer->pending.link);
2367 iviscrn->event_mask |= IVI_NOTIFICATION_ADD;
2369 return IVI_SUCCEEDED;
2373 ivi_layout_screen_set_render_order(struct ivi_layout_screen *iviscrn,
2374 struct ivi_layout_layer **pLayer,
2375 const int32_t number)
2377 struct ivi_layout *layout = get_instance();
2378 struct ivi_layout_layer *ivilayer = NULL;
2379 struct ivi_layout_layer *next = NULL;
2380 uint32_t *id_layer = NULL;
2383 if (iviscrn == NULL) {
2384 weston_log("ivi_layout_screen_set_render_order: invalid argument\n");
2388 wl_list_for_each_safe(ivilayer, next,
2389 &iviscrn->pending.layer_list, pending.link) {
2390 wl_list_init(&ivilayer->pending.link);
2393 wl_list_init(&iviscrn->pending.layer_list);
2395 if (pLayer == NULL) {
2396 wl_list_for_each_safe(ivilayer, next, &iviscrn->pending.layer_list, pending.link) {
2397 if (!wl_list_empty(&ivilayer->pending.link)) {
2398 wl_list_remove(&ivilayer->pending.link);
2401 wl_list_init(&ivilayer->pending.link);
2404 iviscrn->event_mask |= IVI_NOTIFICATION_REMOVE;
2405 return IVI_SUCCEEDED;
2408 for (i = 0; i < number; i++) {
2409 id_layer = &pLayer[i]->id_layer;
2410 wl_list_for_each(ivilayer, &layout->layer_list, link) {
2411 if (*id_layer != ivilayer->id_layer) {
2415 if (!wl_list_empty(&ivilayer->pending.link)) {
2416 wl_list_remove(&ivilayer->pending.link);
2418 wl_list_init(&ivilayer->pending.link);
2419 wl_list_insert(&iviscrn->pending.layer_list,
2420 &ivilayer->pending.link);
2425 iviscrn->event_mask |= IVI_NOTIFICATION_ADD;
2427 return IVI_SUCCEEDED;
2430 WL_EXPORT struct weston_output *
2431 ivi_layout_screen_get_output(struct ivi_layout_screen *iviscrn)
2433 return iviscrn->output;
2437 * This function is used by the additional ivi-module because of dumping ivi_surface sceenshot.
2438 * The ivi-module, e.g. ivi-controller.so, is in wayland-ivi-extension of Genivi's Layer Management.
2439 * This function is used to get the result of drawing by clients.
2441 WL_EXPORT struct weston_surface *
2442 ivi_layout_surface_get_weston_surface(struct ivi_layout_surface *ivisurf)
2444 return ivisurf != NULL ? ivisurf->surface : NULL;
2448 ivi_layout_layer_add_notification(struct ivi_layout_layer *ivilayer,
2449 layer_property_notification_func callback,
2452 struct ivi_layout_notification_callback *prop_callback = NULL;
2454 if (ivilayer == NULL || callback == NULL) {
2455 weston_log("ivi_layout_layer_add_notification: invalid argument\n");
2459 prop_callback = malloc(sizeof *prop_callback);
2460 if (prop_callback == NULL) {
2461 weston_log("fails to allocate memory\n");
2465 prop_callback->callback = callback;
2466 prop_callback->data = userdata;
2468 return add_notification(&ivilayer->property_changed,
2474 ivi_layout_layer_remove_notification(struct ivi_layout_layer *ivilayer)
2476 if (ivilayer == NULL) {
2477 weston_log("ivi_layout_layer_remove_notification: invalid argument\n");
2481 remove_all_notification(&ivilayer->property_changed.listener_list);
2484 WL_EXPORT const struct ivi_layout_surface_properties *
2485 ivi_layout_get_properties_of_surface(struct ivi_layout_surface *ivisurf)
2487 if (ivisurf == NULL) {
2488 weston_log("ivi_layout_get_properties_of_surface: invalid argument\n");
2492 return &ivisurf->prop;
2496 ivi_layout_layer_add_surface(struct ivi_layout_layer *ivilayer,
2497 struct ivi_layout_surface *addsurf)
2499 struct ivi_layout *layout = get_instance();
2500 struct ivi_layout_surface *ivisurf = NULL;
2501 struct ivi_layout_surface *next = NULL;
2502 int is_surf_in_layer = 0;
2504 if (ivilayer == NULL || addsurf == NULL) {
2505 weston_log("ivi_layout_layer_add_surface: invalid argument\n");
2509 is_surf_in_layer = is_surface_in_layer(addsurf, ivilayer);
2510 if (is_surf_in_layer == 1) {
2511 weston_log("ivi_layout_layer_add_surface: addsurf is already available\n");
2512 return IVI_SUCCEEDED;
2515 wl_list_for_each_safe(ivisurf, next, &layout->surface_list, link) {
2516 if (ivisurf->id_surface == addsurf->id_surface) {
2517 if (!wl_list_empty(&ivisurf->pending.link)) {
2518 wl_list_remove(&ivisurf->pending.link);
2520 wl_list_init(&ivisurf->pending.link);
2521 wl_list_insert(&ivilayer->pending.surface_list,
2522 &ivisurf->pending.link);
2527 ivilayer->event_mask |= IVI_NOTIFICATION_ADD;
2529 return IVI_SUCCEEDED;
2533 ivi_layout_layer_remove_surface(struct ivi_layout_layer *ivilayer,
2534 struct ivi_layout_surface *remsurf)
2536 struct ivi_layout_surface *ivisurf = NULL;
2537 struct ivi_layout_surface *next = NULL;
2539 if (ivilayer == NULL || remsurf == NULL) {
2540 weston_log("ivi_layout_layer_remove_surface: invalid argument\n");
2544 wl_list_for_each_safe(ivisurf, next,
2545 &ivilayer->pending.surface_list, pending.link) {
2546 if (ivisurf->id_surface == remsurf->id_surface) {
2547 if (!wl_list_empty(&ivisurf->pending.link)) {
2548 wl_list_remove(&ivisurf->pending.link);
2550 wl_list_init(&ivisurf->pending.link);
2555 remsurf->event_mask |= IVI_NOTIFICATION_REMOVE;
2559 ivi_layout_surface_set_source_rectangle(struct ivi_layout_surface *ivisurf,
2560 int32_t x, int32_t y,
2561 int32_t width, int32_t height)
2563 struct ivi_layout_surface_properties *prop = NULL;
2565 if (ivisurf == NULL) {
2566 weston_log("ivi_layout_surface_set_source_rectangle: invalid argument\n");
2570 prop = &ivisurf->pending.prop;
2573 prop->source_width = width;
2574 prop->source_height = height;
2576 ivisurf->event_mask |= IVI_NOTIFICATION_SOURCE_RECT;
2578 return IVI_SUCCEEDED;
2582 ivi_layout_commit_changes(void)
2584 struct ivi_layout *layout = get_instance();
2586 commit_surface_list(layout);
2587 commit_layer_list(layout);
2588 commit_screen_list(layout);
2590 commit_transition(layout);
2592 commit_changes(layout);
2594 weston_compositor_schedule_repaint(layout->compositor);
2596 return IVI_SUCCEEDED;
2599 /***called from ivi-shell**/
2600 static struct weston_view *
2601 ivi_layout_get_weston_view(struct ivi_layout_surface *surface)
2603 struct weston_view *tmpview = NULL;
2608 wl_list_for_each(tmpview, &surface->surface->views, surface_link)
2610 if (tmpview != NULL) {
2618 ivi_layout_surface_configure(struct ivi_layout_surface *ivisurf,
2619 int32_t width, int32_t height)
2621 struct ivi_layout *layout = get_instance();
2622 int32_t in_init = 0;
2623 ivisurf->surface->width_from_buffer = width;
2624 ivisurf->surface->height_from_buffer = height;
2626 if (ivisurf->prop.source_width == 0 || ivisurf->prop.source_height == 0) {
2630 /* FIXME: when sourceHeight/Width is used as clipping range in image buffer */
2631 /* if (ivisurf->prop.sourceWidth == 0 || ivisurf->prop.sourceHeight == 0) { */
2632 ivisurf->pending.prop.source_width = width;
2633 ivisurf->pending.prop.source_height = height;
2634 ivisurf->prop.source_width = width;
2635 ivisurf->prop.source_height = height;
2638 ivisurf->event_mask |= IVI_NOTIFICATION_CONFIGURE;
2641 wl_signal_emit(&layout->surface_notification.configure_changed, ivisurf);
2643 ivi_layout_commit_changes();
2648 ivi_layout_surface_set_content_observer(struct ivi_layout_surface *ivisurf,
2649 ivi_controller_surface_content_callback callback,
2652 int32_t ret = IVI_FAILED;
2654 if (ivisurf != NULL) {
2655 ivisurf->content_observer.callback = callback;
2656 ivisurf->content_observer.userdata = userdata;
2657 ret = IVI_SUCCEEDED;
2662 static struct ivi_layout_surface*
2663 ivi_layout_surface_create(struct weston_surface *wl_surface,
2664 uint32_t id_surface)
2666 struct ivi_layout *layout = get_instance();
2667 struct ivi_layout_surface *ivisurf = NULL;
2668 struct weston_view *tmpview = NULL;
2670 if (wl_surface == NULL) {
2671 weston_log("ivi_layout_surface_create: invalid argument\n");
2675 ivisurf = get_surface(&layout->surface_list, id_surface);
2676 if (ivisurf != NULL) {
2677 if (ivisurf->surface != NULL) {
2678 weston_log("id_surface(%d) is already created\n", id_surface);
2683 ivisurf = calloc(1, sizeof *ivisurf);
2684 if (ivisurf == NULL) {
2685 weston_log("fails to allocate memory\n");
2689 wl_list_init(&ivisurf->link);
2690 wl_signal_init(&ivisurf->property_changed);
2691 wl_signal_init(&ivisurf->configured);
2692 wl_list_init(&ivisurf->layer_list);
2693 ivisurf->id_surface = id_surface;
2694 ivisurf->layout = layout;
2696 ivisurf->surface = wl_surface;
2697 ivisurf->surface_destroy_listener.notify =
2698 westonsurface_destroy_from_ivisurface;
2699 wl_resource_add_destroy_listener(wl_surface->resource,
2700 &ivisurf->surface_destroy_listener);
2702 tmpview = weston_view_create(wl_surface);
2703 if (tmpview == NULL) {
2704 weston_log("fails to allocate memory\n");
2707 ivisurf->surface->width_from_buffer = 0;
2708 ivisurf->surface->height_from_buffer = 0;
2710 weston_matrix_init(&ivisurf->surface_rotation.matrix);
2711 weston_matrix_init(&ivisurf->layer_rotation.matrix);
2712 weston_matrix_init(&ivisurf->surface_pos.matrix);
2713 weston_matrix_init(&ivisurf->layer_pos.matrix);
2714 weston_matrix_init(&ivisurf->scaling.matrix);
2716 wl_list_init(&ivisurf->surface_rotation.link);
2717 wl_list_init(&ivisurf->layer_rotation.link);
2718 wl_list_init(&ivisurf->surface_pos.link);
2719 wl_list_init(&ivisurf->layer_pos.link);
2720 wl_list_init(&ivisurf->scaling.link);
2722 init_surface_properties(&ivisurf->prop);
2723 ivisurf->event_mask = 0;
2725 ivisurf->pending.prop = ivisurf->prop;
2726 wl_list_init(&ivisurf->pending.link);
2728 wl_list_init(&ivisurf->order.link);
2729 wl_list_init(&ivisurf->order.layer_list);
2731 wl_list_insert(&layout->surface_list, &ivisurf->link);
2733 wl_signal_emit(&layout->surface_notification.created, ivisurf);
2739 ivi_layout_init_with_compositor(struct weston_compositor *ec)
2741 struct ivi_layout *layout = get_instance();
2743 layout->compositor = ec;
2745 wl_list_init(&layout->surface_list);
2746 wl_list_init(&layout->layer_list);
2747 wl_list_init(&layout->screen_list);
2749 wl_signal_init(&layout->layer_notification.created);
2750 wl_signal_init(&layout->layer_notification.removed);
2752 wl_signal_init(&layout->surface_notification.created);
2753 wl_signal_init(&layout->surface_notification.removed);
2754 wl_signal_init(&layout->surface_notification.configure_changed);
2756 /* Add layout_layer at the last of weston_compositor.layer_list */
2757 weston_layer_init(&layout->layout_layer, ec->layer_list.prev);
2761 layout->transitions = ivi_layout_transition_set_create(ec);
2762 wl_list_init(&layout->pending_transition_list);
2767 ivi_layout_surface_add_configured_listener(struct ivi_layout_surface* ivisurf,
2768 struct wl_listener* listener)
2770 wl_signal_add(&ivisurf->configured, listener);
2773 WL_EXPORT struct ivi_layout_interface ivi_layout_interface = {
2774 .get_weston_view = ivi_layout_get_weston_view,
2775 .surface_configure = ivi_layout_surface_configure,
2776 .surface_create = ivi_layout_surface_create,
2777 .init_with_compositor = ivi_layout_init_with_compositor,
2778 .get_surface_dimension = ivi_layout_surface_get_dimension,
2779 .add_surface_configured_listener = ivi_layout_surface_add_configured_listener