• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2013 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  *
23  */
24 
25 #ifndef OVERLAY_H
26 #define OVERLAY_H
27 
28 #include"config.h"
29 
30 #include <cairo.h>
31 
32 enum position {
33 	POS_UNSET = -1,
34 
35 	POS_LEFT = 0,
36 	POS_CENTRE = 1,
37 	POS_RIGHT = 2,
38 
39 	POS_TOP = 0 << 4,
40 	POS_MIDDLE = 1 << 4,
41 	POS_BOTTOM = 2 << 4,
42 
43 	POS_TOP_LEFT = POS_TOP | POS_LEFT,
44 	POS_TOP_CENTRE = POS_TOP | POS_CENTRE,
45 	POS_TOP_RIGHT = POS_TOP | POS_RIGHT,
46 
47 	POS_MIDDLE_LEFT = POS_MIDDLE | POS_LEFT,
48 	POS_MIDDLE_CENTRE = POS_MIDDLE | POS_CENTRE,
49 	POS_MIDDLE_RIGHT = POS_MIDDLE | POS_RIGHT,
50 
51 	POS_BOTTOM_LEFT = POS_BOTTOM | POS_LEFT,
52 	POS_BOTTOM_CENTRE = POS_BOTTOM | POS_CENTRE,
53 	POS_BOTTOM_RIGHT = POS_BOTTOM | POS_RIGHT,
54 };
55 
56 struct overlay {
57 	cairo_surface_t *surface;
58 	void (*show)(struct overlay *);
59 	void (*hide)(struct overlay *);
60 };
61 
62 extern const cairo_user_data_key_t overlay_key;
63 
64 struct config {
65 	struct config_section {
66 		struct config_section *next;
67 		struct config_value {
68 			struct config_value *next;
69 			char *name;
70 			char *value;
71 		} *values;
72 		char name[0];
73 	} *sections;
74 };
75 
76 void config_init(struct config *config);
77 void config_parse_string(struct config *config, const char *str);
78 void config_set_value(struct config *config,
79 		      const char *section,
80 		      const char *name,
81 		      const char *value);
82 const char *config_get_value(struct config *config,
83 			     const char *section,
84 			     const char *name);
85 
86 #ifdef HAVE_OVERLAY_XVLIB
87 cairo_surface_t *x11_overlay_create(struct config *config, int *width, int *height);
88 void x11_overlay_stop(void);
89 #else
x11_overlay_create(struct config * config,int * width,int * height)90 static inline cairo_surface_t *x11_overlay_create(struct config *config, int *width, int *height) { return NULL; }
x11_overlay_stop(void)91 static inline void x11_overlay_stop(void) { }
92 #endif
93 
94 #ifdef HAVE_OVERLAY_XLIB
95 cairo_surface_t *x11_window_create(struct config *config, int *width, int *height);
96 #else
x11_window_create(struct config * config,int * width,int * height)97 static inline cairo_surface_t *x11_window_create(struct config *config, int *width, int *height) { return NULL; }
98 #endif
99 
100 cairo_surface_t *kms_overlay_create(struct config *config, int *width, int *height);
101 
102 #endif /* OVERLAY_H */
103