1 /*
2  * Copyright (C) 2014 DENSO CORPORATION
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining
5  * a copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sublicense, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial
14  * portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23  * SOFTWARE.
24  */
25 
26 #ifndef _ivi_layout_PRIVATE_H_
27 #define _ivi_layout_PRIVATE_H_
28 
29 #include <stdint.h>
30 
31 #include <libweston/libweston.h>
32 #include "ivi-layout-export.h"
33 #include <libweston-desktop/libweston-desktop.h>
34 
35 struct ivi_layout_view {
36 	struct wl_list link;	/* ivi_layout::view_list */
37 	struct wl_list surf_link;	/*ivi_layout_surface::view_list */
38 	struct wl_list pending_link;	/* ivi_layout_layer::pending.view_list */
39 	struct wl_list order_link;	/* ivi_layout_layer::order.view_list */
40 
41 	struct weston_view *view;
42 	struct weston_transform transform;
43 
44 	struct ivi_layout_surface *ivisurf;
45 	struct ivi_layout_layer *on_layer;
46 };
47 
48 struct ivi_layout_surface {
49 	struct wl_list link;	/* ivi_layout::surface_list */
50 	struct wl_signal property_changed;
51 	int32_t update_count;
52 	uint32_t id_surface;
53 
54 	struct ivi_layout *layout;
55 	struct weston_surface *surface;
56 	struct weston_desktop_surface *weston_desktop_surface;
57 
58 	struct ivi_layout_surface_properties prop;
59 
60 	struct {
61 		struct ivi_layout_surface_properties prop;
62 	} pending;
63 
64 	struct wl_list view_list;	/* ivi_layout_view::surf_link */
65 };
66 
67 struct ivi_layout_layer {
68 	struct wl_list link;	/* ivi_layout::layer_list */
69 	struct wl_signal property_changed;
70 	uint32_t id_layer;
71 
72 	struct ivi_layout *layout;
73 	struct ivi_layout_screen *on_screen;
74 
75 	struct ivi_layout_layer_properties prop;
76 
77 	struct {
78 		struct ivi_layout_layer_properties prop;
79 		struct wl_list view_list;	/* ivi_layout_view::pending_link */
80 		struct wl_list link;	/* ivi_layout_screen::pending.layer_list */
81 	} pending;
82 
83 	struct {
84 		int dirty;
85 		struct wl_list view_list;	/* ivi_layout_view::order_link */
86 		struct wl_list link;	/* ivi_layout_screen::order.layer_list */
87 	} order;
88 
89 	int32_t ref_count;
90 };
91 
92 struct ivi_layout {
93 	struct weston_compositor *compositor;
94 
95 	struct wl_list surface_list;	/* ivi_layout_surface::link */
96 	struct wl_list layer_list;	/* ivi_layout_layer::link */
97 	struct wl_list screen_list;	/* ivi_layout_screen::link */
98 	struct wl_list view_list;	/* ivi_layout_view::link */
99 
100 	struct {
101 		struct wl_signal created;
102 		struct wl_signal removed;
103 	} layer_notification;
104 
105 	struct {
106 		struct wl_signal created;
107 		struct wl_signal removed;
108 		struct wl_signal configure_changed;
109 		struct wl_signal configure_desktop_changed;
110 	} surface_notification;
111 
112 	struct weston_layer layout_layer;
113 
114 	struct ivi_layout_transition_set *transitions;
115 	struct wl_list pending_transition_list;	/* transition_node::link */
116 };
117 
118 struct ivi_layout *get_instance(void);
119 
120 struct ivi_layout_transition;
121 
122 struct ivi_layout_transition_set {
123 	struct wl_event_source  *event_source;
124 	struct wl_list          transition_list;
125 };
126 
127 typedef void (*ivi_layout_transition_destroy_user_func)(void *user_data);
128 
129 struct ivi_layout_transition_set *
130 ivi_layout_transition_set_create(struct weston_compositor *ec);
131 
132 void
133 ivi_layout_transition_move_resize_view(struct ivi_layout_surface *surface,
134 				       int32_t dest_x, int32_t dest_y,
135 				       int32_t dest_width, int32_t dest_height,
136 				       uint32_t duration);
137 
138 void
139 ivi_layout_transition_visibility_on(struct ivi_layout_surface *surface,
140 				    uint32_t duration);
141 
142 void
143 ivi_layout_transition_visibility_off(struct ivi_layout_surface *surface,
144 				     uint32_t duration);
145 
146 
147 void
148 ivi_layout_transition_move_layer(struct ivi_layout_layer *layer,
149 				 int32_t dest_x, int32_t dest_y,
150 				 uint32_t duration);
151 
152 void
153 ivi_layout_transition_fade_layer(struct ivi_layout_layer *layer,
154 				 uint32_t is_fade_in,
155 				 double start_alpha, double end_alpha,
156 				 void *user_data,
157 				 ivi_layout_transition_destroy_user_func destroy_func,
158 				 uint32_t duration);
159 
160 int32_t
161 is_surface_transition(struct ivi_layout_surface *surface);
162 
163 void
164 ivi_layout_remove_all_surface_transitions(struct ivi_layout_surface *surface);
165 
166 /**
167  * methods of interaction between transition animation with ivi-layout
168  */
169 int32_t
170 ivi_layout_commit_changes(void);
171 uint32_t
172 ivi_layout_get_id_of_surface(struct ivi_layout_surface *ivisurf);
173 int32_t
174 ivi_layout_surface_set_destination_rectangle(struct ivi_layout_surface *ivisurf,
175 					     int32_t x, int32_t y,
176 					     int32_t width, int32_t height);
177 int32_t
178 ivi_layout_surface_set_opacity(struct ivi_layout_surface *ivisurf,
179 			       wl_fixed_t opacity);
180 int32_t
181 ivi_layout_surface_set_visibility(struct ivi_layout_surface *ivisurf,
182 				  bool newVisibility);
183 void
184 ivi_layout_surface_set_size(struct ivi_layout_surface *ivisurf,
185 			    int32_t width, int32_t height);
186 struct ivi_layout_surface *
187 ivi_layout_get_surface_from_id(uint32_t id_surface);
188 int32_t
189 ivi_layout_layer_set_opacity(struct ivi_layout_layer *ivilayer,
190 			     wl_fixed_t opacity);
191 int32_t
192 ivi_layout_layer_set_visibility(struct ivi_layout_layer *ivilayer,
193 				bool newVisibility);
194 int32_t
195 ivi_layout_layer_set_destination_rectangle(struct ivi_layout_layer *ivilayer,
196 					   int32_t x, int32_t y,
197 					   int32_t width, int32_t height);
198 int32_t
199 ivi_layout_layer_set_render_order(struct ivi_layout_layer *ivilayer,
200 				  struct ivi_layout_surface **pSurface,
201 				  int32_t number);
202 void
203 ivi_layout_transition_move_layer_cancel(struct ivi_layout_layer *layer);
204 
205 #endif
206