blob: 196b115d153812dbcbb153397603f1b0570511aa [file] [log] [blame]
Nobuhiko Tanibata6f9df652014-11-27 13:22:00 +09001/*
2 * Copyright (C) 2013 DENSO CORPORATION
3 *
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.
13 *
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.
21 */
22
23/**
24 * The ivi-layout library supports API set of controlling properties of
25 * surface and layer which groups surfaces. An unique ID whose type is integer
26 * is required to create surface and layer. With the unique ID, surface and
27 * layer are identified to control them. The API set consists of APIs to control
28 * properties of surface and layers about followings,
29 * - visibility.
30 * - opacity.
31 * - clipping (x,y,width,height).
32 * - position and size of it to be displayed.
33 * - orientation per 90 degree.
34 * - add or remove surfaces to a layer.
35 * - order of surfaces/layers in layer/screen to be displayed.
36 * - commit to apply property changes.
37 * - notifications of property change.
38 *
39 * Management of surfaces and layers grouping these surfaces are common
40 * way in In-Vehicle Infotainment system, which integrate several domains
41 * in one system. A layer is allocated to a domain in order to control
42 * application surfaces grouped to the layer all together.
43 *
44 * This API and ABI follow following specifications.
45 * http://projects.genivi.org/wayland-ivi-extension/layer-manager-apis
46 */
47
48#ifndef _IVI_LAYOUT_EXPORT_H_
49#define _IVI_LAYOUT_EXPORT_H_
50
51#ifdef __cplusplus
52extern "C" {
53#endif /* __cplusplus */
54
55#include "stdbool.h"
56#include "compositor.h"
57
58#define IVI_SUCCEEDED (0)
59#define IVI_FAILED (-1)
60
61struct ivi_layout_layer;
62struct ivi_layout_screen;
63struct ivi_layout_surface;
64
65struct ivi_layout_surface_properties
66{
67 wl_fixed_t opacity;
68 int32_t source_x;
69 int32_t source_y;
70 int32_t source_width;
71 int32_t source_height;
72 int32_t start_x;
73 int32_t start_y;
74 int32_t start_width;
75 int32_t start_height;
76 int32_t dest_x;
77 int32_t dest_y;
78 int32_t dest_width;
79 int32_t dest_height;
80 enum wl_output_transform orientation;
81 bool visibility;
82 int32_t transition_type;
83 uint32_t transition_duration;
84};
85
86struct ivi_layout_layer_properties
87{
88 wl_fixed_t opacity;
89 int32_t source_x;
90 int32_t source_y;
91 int32_t source_width;
92 int32_t source_height;
93 int32_t dest_x;
94 int32_t dest_y;
95 int32_t dest_width;
96 int32_t dest_height;
97 enum wl_output_transform orientation;
98 uint32_t visibility;
99 int32_t transition_type;
100 uint32_t transition_duration;
101 double start_alpha;
102 double end_alpha;
103 uint32_t is_fade_in;
104};
105
106enum ivi_layout_notification_mask {
107 IVI_NOTIFICATION_NONE = 0,
108 IVI_NOTIFICATION_OPACITY = (1 << 1),
109 IVI_NOTIFICATION_SOURCE_RECT = (1 << 2),
110 IVI_NOTIFICATION_DEST_RECT = (1 << 3),
111 IVI_NOTIFICATION_DIMENSION = (1 << 4),
112 IVI_NOTIFICATION_POSITION = (1 << 5),
113 IVI_NOTIFICATION_ORIENTATION = (1 << 6),
114 IVI_NOTIFICATION_VISIBILITY = (1 << 7),
115 IVI_NOTIFICATION_PIXELFORMAT = (1 << 8),
116 IVI_NOTIFICATION_ADD = (1 << 9),
117 IVI_NOTIFICATION_REMOVE = (1 << 10),
118 IVI_NOTIFICATION_CONFIGURE = (1 << 11),
119 IVI_NOTIFICATION_ALL = 0xFFFF
120};
121
122enum ivi_layout_transition_type{
123 IVI_LAYOUT_TRANSITION_NONE,
124 IVI_LAYOUT_TRANSITION_VIEW_DEFAULT,
125 IVI_LAYOUT_TRANSITION_VIEW_DEST_RECT_ONLY,
126 IVI_LAYOUT_TRANSITION_VIEW_FADE_ONLY,
127 IVI_LAYOUT_TRANSITION_LAYER_FADE,
128 IVI_LAYOUT_TRANSITION_LAYER_MOVE,
129 IVI_LAYOUT_TRANSITION_LAYER_VIEW_ORDER,
130 IVI_LAYOUT_TRANSITION_VIEW_MOVE_RESIZE,
131 IVI_LAYOUT_TRANSITION_VIEW_RESIZE,
132 IVI_LAYOUT_TRANSITION_VIEW_FADE,
133 IVI_LAYOUT_TRANSITION_MAX,
134};
135
136typedef void (*layer_property_notification_func)(
137 struct ivi_layout_layer *ivilayer,
138 const struct ivi_layout_layer_properties *,
139 enum ivi_layout_notification_mask mask,
140 void *userdata);
141
142typedef void (*surface_property_notification_func)(
143 struct ivi_layout_surface *ivisurf,
144 const struct ivi_layout_surface_properties *,
145 enum ivi_layout_notification_mask mask,
146 void *userdata);
147
148typedef void (*layer_create_notification_func)(
149 struct ivi_layout_layer *ivilayer,
150 void *userdata);
151
152typedef void (*layer_remove_notification_func)(
153 struct ivi_layout_layer *ivilayer,
154 void *userdata);
155
156typedef void (*surface_create_notification_func)(
157 struct ivi_layout_surface *ivisurf,
158 void *userdata);
159
160typedef void (*surface_remove_notification_func)(
161 struct ivi_layout_surface *ivisurf,
162 void *userdata);
163
164typedef void (*surface_configure_notification_func)(
165 struct ivi_layout_surface *ivisurf,
166 void *userdata);
167
168typedef void (*ivi_controller_surface_content_callback)(
169 struct ivi_layout_surface *ivisurf,
170 int32_t content,
171 void *userdata);
172
173/**
174 * \brief register for notification when layer is created
175 */
176int32_t
177ivi_layout_add_notification_create_layer(
178 layer_create_notification_func callback,
179 void *userdata);
180
181void
182ivi_layout_remove_notification_create_layer(
183 layer_create_notification_func callback,
184 void *userdata);
185
186/**
187 * \brief register for notification when layer is removed
188 */
189int32_t
190ivi_layout_add_notification_remove_layer(
191 layer_remove_notification_func callback,
192 void *userdata);
193
194void
195ivi_layout_remove_notification_remove_layer(
196 layer_remove_notification_func callback,
197 void *userdata);
198
199/**
200 * \brief register for notification when surface is created
201 */
202int32_t
203ivi_layout_add_notification_create_surface(
204 surface_create_notification_func callback,
205 void *userdata);
206
207void
208ivi_layout_remove_notification_create_surface(
209 surface_create_notification_func callback,
210 void *userdata);
211
212/**
213 * \brief register for notification when surface is removed
214 */
215int32_t
216ivi_layout_add_notification_remove_surface(
217 surface_remove_notification_func callback,
218 void *userdata);
219
220void
221ivi_layout_remove_notification_remove_surface(
222 surface_remove_notification_func callback,
223 void *userdata);
224
225/**
226 * \brief register for notification when surface is configured
227 */
228int32_t
229ivi_layout_add_notification_configure_surface(
230 surface_configure_notification_func callback,
231 void *userdata);
232
233void
234ivi_layout_remove_notification_configure_surface(
235 surface_configure_notification_func callback,
236 void *userdata);
237
238/**
239 * \brief get id of surface from ivi_layout_surface
240 *
241 * \return id of surface
242 */
243uint32_t
244ivi_layout_get_id_of_surface(struct ivi_layout_surface *ivisurf);
245
246/**
247 * \brief get id of layer from ivi_layout_layer
248 *
249 *
250 * \return id of layer
251 */
252uint32_t
253ivi_layout_get_id_of_layer(struct ivi_layout_layer *ivilayer);
254
255/**
256 * \brief get ivi_layout_surface from id of surface
257 *
258 * \return (struct ivi_layout_surface *)
259 * if the method call was successful
260 * \return NULL if the method call was failed
261 */
262struct ivi_layout_surface *
263ivi_layout_get_surface_from_id(uint32_t id_surface);
264
265/**
266 * \brief get ivi_layout_screen from id of screen
267 *
268 * \return (struct ivi_layout_screen *)
269 * if the method call was successful
270 * \return NULL if the method call was failed
271 */
272struct ivi_layout_screen *
273ivi_layout_get_screen_from_id(uint32_t id_screen);
274
275/**
276 * \brief Get the screen resolution of a specific screen
277 *
278 * \return IVI_SUCCEEDED if the method call was successful
279 * \return IVI_FAILED if the method call was failed
280 */
281int32_t
282ivi_layout_get_screen_resolution(struct ivi_layout_screen *iviscrn,
283 int32_t *pWidth,
284 int32_t *pHeight);
285
286/**
287 * \brief Set an observer callback for surface content status change.
288 *
289 * \return IVI_SUCCEEDED if the method call was successful
290 * \return IVI_FAILED if the method call was failed
291 */
292int32_t
293ivi_layout_surface_set_content_observer(
294 struct ivi_layout_surface *ivisurf,
295 ivi_controller_surface_content_callback callback,
296 void* userdata);
297
298/**
299 * \brief Get the layer properties
300 *
301 * \return (const struct ivi_layout_layer_properties *)
302 * if the method call was successful
303 * \return NULL if the method call was failed
304 */
305const struct ivi_layout_layer_properties *
306ivi_layout_get_properties_of_layer(struct ivi_layout_layer *ivilayer);
307
308/**
309 * \brief Get the screens
310 *
311 * \return IVI_SUCCEEDED if the method call was successful
312 * \return IVI_FAILED if the method call was failed
313 */
314int32_t
315ivi_layout_get_screens(int32_t *pLength, struct ivi_layout_screen ***ppArray);
316
317/**
318 * \brief Get the screens under the given layer
319 *
320 * \return IVI_SUCCEEDED if the method call was successful
321 * \return IVI_FAILED if the method call was failed
322 */
323int32_t
324ivi_layout_get_screens_under_layer(struct ivi_layout_layer *ivilayer,
325 int32_t *pLength,
326 struct ivi_layout_screen ***ppArray);
327
328/**
329 * \brief Get all Layers which are currently registered and managed
330 * by the services
331 *
332 * \return IVI_SUCCEEDED if the method call was successful
333 * \return IVI_FAILED if the method call was failed
334 */
335int32_t
336ivi_layout_get_layers(int32_t *pLength, struct ivi_layout_layer ***ppArray);
337
338/**
339 * \brief Get all Layers under the given surface
340 *
341 * \return IVI_SUCCEEDED if the method call was successful
342 * \return IVI_FAILED if the method call was failed
343 */
344int32_t
345ivi_layout_get_layers_under_surface(struct ivi_layout_surface *ivisurf,
346 int32_t *pLength,
347 struct ivi_layout_layer ***ppArray);
348
349/**
350 * \brief Get all Surfaces which are currently registered and managed
351 * by the services
352 *
353 * \return IVI_SUCCEEDED if the method call was successful
354 * \return IVI_FAILED if the method call was failed
355 */
356int32_t
357ivi_layout_get_surfaces(int32_t *pLength, struct ivi_layout_surface ***ppArray);
358
359/**
360 * \brief Create a layer which should be managed by the service
361 *
362 * \return (struct ivi_layout_layer *)
363 * if the method call was successful
364 * \return NULL if the method call was failed
365 */
366struct ivi_layout_layer *
367ivi_layout_layer_create_with_dimension(uint32_t id_layer,
368 int32_t width, int32_t height);
369
370/**
371 * \brief Removes a layer which is currently managed by the service
372 */
373void
374ivi_layout_layer_remove(struct ivi_layout_layer *ivilayer);
375
376/**
377 * \brief Set the visibility of a layer. If a layer is not visible, the
378 * layer and its surfaces will not be rendered.
379 *
380 * \return IVI_SUCCEEDED if the method call was successful
381 * \return IVI_FAILED if the method call was failed
382 */
383int32_t
384ivi_layout_layer_set_visibility(struct ivi_layout_layer *ivilayer,
385 bool newVisibility);
386
387/**
388 * \brief Set the opacity of a layer.
389 *
390 * \return IVI_SUCCEEDED if the method call was successful
391 * \return IVI_FAILED if the method call was failed
392 */
393int32_t
394ivi_layout_layer_set_opacity(struct ivi_layout_layer *ivilayer,
395 wl_fixed_t opacity);
396
397/**
398 * \brief Get the opacity of a layer.
399 *
400 * \return opacity if the method call was successful
401 * \return wl_fixed_from_double(0.0) if the method call was failed
402 */
403wl_fixed_t
404ivi_layout_layer_get_opacity(struct ivi_layout_layer *ivilayer);
405
406/**
407 * \brief Set the area of a layer which should be used for the rendering.
408 *
409 * Only this part will be visible.
410 *
411 * \return IVI_SUCCEEDED if the method call was successful
412 * \return IVI_FAILED if the method call was failed
413 */
414int32_t
415ivi_layout_layer_set_source_rectangle(struct ivi_layout_layer *ivilayer,
416 int32_t x, int32_t y,
417 int32_t width, int32_t height);
418
419/**
420 * \brief Set the destination area on the display for a layer.
421 *
422 * The layer will be scaled and positioned to this rectangle
423 * for rendering
424 *
425 * \return IVI_SUCCEEDED if the method call was successful
426 * \return IVI_FAILED if the method call was failed
427 */
428int32_t
429ivi_layout_layer_set_destination_rectangle(struct ivi_layout_layer *ivilayer,
430 int32_t x, int32_t y,
431 int32_t width, int32_t height);
432
433/**
434 * \brief Get the horizontal and vertical position of the layer.
435 *
436 * \return IVI_SUCCEEDED if the method call was successful
437 * \return IVI_FAILED if the method call was failed
438 */
439int32_t
440ivi_layout_layer_get_position(struct ivi_layout_layer *ivilayer,
441 int32_t *dest_x, int32_t *dest_y);
442
443/**
444 * \brief Sets the horizontal and vertical position of the layer.
445 *
446 * \return IVI_SUCCEEDED if the method call was successful
447 * \return IVI_FAILED if the method call was failed
448 */
449int32_t
450ivi_layout_layer_set_position(struct ivi_layout_layer *ivilayer,
451 int32_t dest_x, int32_t dest_y);
452
453/**
454 * \brief Sets the orientation of a layer.
455 *
456 * \return IVI_SUCCEEDED if the method call was successful
457 * \return IVI_FAILED if the method call was failed
458 */
459int32_t
460ivi_layout_layer_set_orientation(struct ivi_layout_layer *ivilayer,
461 enum wl_output_transform orientation);
462
463/**
464 * \brief Sets render order of surfaces within one layer
465 *
466 * \return IVI_SUCCEEDED if the method call was successful
467 * \return IVI_FAILED if the method call was failed
468 */
469int32_t
470ivi_layout_layer_set_render_order(struct ivi_layout_layer *ivilayer,
471 struct ivi_layout_surface **pSurface,
472 int32_t number);
473
474/**
475 * \brief Set the visibility of a surface.
476 *
477 * If a surface is not visible it will not be rendered.
478 *
479 * \return IVI_SUCCEEDED if the method call was successful
480 * \return IVI_FAILED if the method call was failed
481 */
482int32_t
483ivi_layout_surface_set_visibility(struct ivi_layout_surface *ivisurf,
484 bool newVisibility);
485
486/**
487 * \brief Get the visibility of a surface.
488 *
489 * If a surface is not visible it will not be rendered.
490 *
491 * \return true if surface is visible
492 * \return false if surface is invisible or the method call was failed
493 */
494bool
495ivi_layout_surface_get_visibility(struct ivi_layout_surface *ivisurf);
496
497/**
498 * \brief Set the opacity of a surface.
499 *
500 * \return IVI_SUCCEEDED if the method call was successful
501 * \return IVI_FAILED if the method call was failed
502 */
503int32_t
504ivi_layout_surface_set_opacity(struct ivi_layout_surface *ivisurf,
505 wl_fixed_t opacity);
506
507/**
508 * \brief Get the opacity of a surface.
509 *
510 * \return opacity if the method call was successful
511 * \return wl_fixed_from_double(0.0) if the method call was failed
512 */
513wl_fixed_t
514ivi_layout_surface_get_opacity(struct ivi_layout_surface *ivisurf);
515
516/**
517 * \brief Set the destination area of a surface within a layer for rendering.
518 *
519 * The surface will be scaled to this rectangle for rendering.
520 *
521 * \return IVI_SUCCEEDED if the method call was successful
522 * \return IVI_FAILED if the method call was failed
523 */
524int32_t
525ivi_layout_surface_set_destination_rectangle(struct ivi_layout_surface *ivisurf,
526 int32_t x, int32_t y,
527 int32_t width, int32_t height);
528
529/**
530 * \brief Sets the orientation of a surface.
531 *
532 * \return IVI_SUCCEEDED if the method call was successful
533 * \return IVI_FAILED if the method call was failed
534 */
535int32_t
536ivi_layout_surface_set_orientation(struct ivi_layout_surface *ivisurf,
537 enum wl_output_transform orientation);
538
539/**
540 * \brief Add a layer to a screen which is currently managed by the service
541 *
542 * \return IVI_SUCCEEDED if the method call was successful
543 * \return IVI_FAILED if the method call was failed
544 */
545int32_t
546ivi_layout_screen_add_layer(struct ivi_layout_screen *iviscrn,
547 struct ivi_layout_layer *addlayer);
548
549/**
550 * \brief Sets render order of layers on a display
551 *
552 * \return IVI_SUCCEEDED if the method call was successful
553 * \return IVI_FAILED if the method call was failed
554 */
555int32_t
556ivi_layout_screen_set_render_order(struct ivi_layout_screen *iviscrn,
557 struct ivi_layout_layer **pLayer,
558 const int32_t number);
559
560/**
561 * \brief register for notification on property changes of layer
562 *
563 * \return IVI_SUCCEEDED if the method call was successful
564 * \return IVI_FAILED if the method call was failed
565 */
566int32_t
567ivi_layout_layer_add_notification(struct ivi_layout_layer *ivilayer,
568 layer_property_notification_func callback,
569 void *userdata);
570
571/**
572 * \brief remove notification on property changes of layer
573 */
574void
575ivi_layout_layer_remove_notification(struct ivi_layout_layer *ivilayer);
576
577/**
578 * \brief register for notification on property changes of surface
579 *
580 * \return IVI_SUCCEEDED if the method call was successful
581 * \return IVI_FAILED if the method call was failed
582 */
583int32_t
584ivi_layout_surface_add_notification(struct ivi_layout_surface *ivisurf,
585 surface_property_notification_func callback,
586 void *userdata);
587
588/**
589 * \brief remove notification on property changes of surface
590 */
591void
592ivi_layout_surface_remove_notification(struct ivi_layout_surface *ivisurf);
593
594/**
595 * \brief Get the surface properties
596 *
597 * \return (const struct ivi_surface_layer_properties *)
598 * if the method call was successful
599 * \return NULL if the method call was failed
600 */
601const struct ivi_layout_surface_properties *
602ivi_layout_get_properties_of_surface(struct ivi_layout_surface *ivisurf);
603
604/**
605 * \brief Add a surface to a layer which is currently managed by the service
606 *
607 * \return IVI_SUCCEEDED if the method call was successful
608 * \return IVI_FAILED if the method call was failed
609 */
610int32_t
611ivi_layout_layer_add_surface(struct ivi_layout_layer *ivilayer,
612 struct ivi_layout_surface *addsurf);
613
614/**
615 * \brief Removes a surface from a layer which is currently managed by the service
616 */
617void
618ivi_layout_layer_remove_surface(struct ivi_layout_layer *ivilayer,
619 struct ivi_layout_surface *remsurf);
620
621/**
622 * \brief Set the area of a surface which should be used for the rendering.
623 *
624 * \return IVI_SUCCEEDED if the method call was successful
625 * \return IVI_FAILED if the method call was failed
626 */
627int32_t
628ivi_layout_surface_set_source_rectangle(struct ivi_layout_surface *ivisurf,
629 int32_t x, int32_t y,
630 int32_t width, int32_t height);
631
632/**
633 * \brief get weston_output from ivi_layout_screen.
634 *
635 * \return (struct weston_output *)
636 * if the method call was successful
637 * \return NULL if the method call was failed
638 */
639struct weston_output *
640ivi_layout_screen_get_output(struct ivi_layout_screen *);
641
642struct weston_surface *
643ivi_layout_surface_get_weston_surface(struct ivi_layout_surface *ivisurf);
644
645int32_t
646ivi_layout_layer_set_transition(struct ivi_layout_layer *ivilayer,
647 enum ivi_layout_transition_type type,
648 uint32_t duration);
649
650int32_t
651ivi_layout_layer_set_fade_info(struct ivi_layout_layer* layer,
652 uint32_t is_fade_in,
653 double start_alpha, double end_alpha);
654
655int32_t
656ivi_layout_surface_set_transition(struct ivi_layout_surface *ivisurf,
657 enum ivi_layout_transition_type type,
658 uint32_t duration);
659
660void
661ivi_layout_transition_layer_render_order(struct ivi_layout_layer* layer,
662 struct ivi_layout_surface** new_order,
663 uint32_t surface_num,
664 uint32_t duration);
665
666void
667ivi_layout_transition_move_layer_cancel(struct ivi_layout_layer* layer);
668
669/**
670 * \brief Commit all changes and execute all enqueued commands since
671 * last commit.
672 *
673 * \return IVI_SUCCEEDED if the method call was successful
674 * \return IVI_FAILED if the method call was failed
675 */
676int32_t
677ivi_layout_commit_changes(void);
678
679#ifdef __cplusplus
680}
681#endif /* __cplusplus */
682
683#endif /* _IVI_LAYOUT_EXPORT_H_ */