Chris Wilson | b98bade | 2013-08-20 21:39:27 +0100 | [diff] [blame] | 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 | |
Chris Wilson | 34e4780 | 2013-08-18 21:10:26 +0100 | [diff] [blame] | 28 | #include"config.h" |
Chris Wilson | 34e4780 | 2013-08-18 21:10:26 +0100 | [diff] [blame] | 29 | |
Chris Wilson | f9a50de | 2013-08-17 11:12:07 +0100 | [diff] [blame] | 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 *); |
Chris Wilson | f9a50de | 2013-08-17 11:12:07 +0100 | [diff] [blame] | 59 | void (*hide)(struct overlay *); |
| 60 | }; |
| 61 | |
| 62 | extern const cairo_user_data_key_t overlay_key; |
| 63 | |
Chris Wilson | 7c52a3c | 2013-08-22 15:07:48 +0100 | [diff] [blame] | 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 | |
Chris Wilson | 34e4780 | 2013-08-18 21:10:26 +0100 | [diff] [blame] | 86 | #ifdef HAVE_OVERLAY_XVLIB |
Chris Wilson | 7c52a3c | 2013-08-22 15:07:48 +0100 | [diff] [blame] | 87 | cairo_surface_t *x11_overlay_create(struct config *config, int *width, int *height); |
Chris Wilson | f9a50de | 2013-08-17 11:12:07 +0100 | [diff] [blame] | 88 | void x11_overlay_stop(void); |
Chris Wilson | 34e4780 | 2013-08-18 21:10:26 +0100 | [diff] [blame] | 89 | #else |
Chris Wilson | 7c52a3c | 2013-08-22 15:07:48 +0100 | [diff] [blame] | 90 | static inline cairo_surface_t *x11_overlay_create(struct config *config, int *width, int *height) { return NULL; } |
Chris Wilson | 34e4780 | 2013-08-18 21:10:26 +0100 | [diff] [blame] | 91 | static inline void x11_overlay_stop(void) { } |
| 92 | #endif |
| 93 | |
| 94 | #ifdef HAVE_OVERLAY_XLIB |
Chris Wilson | 7c52a3c | 2013-08-22 15:07:48 +0100 | [diff] [blame] | 95 | cairo_surface_t *x11_window_create(struct config *config, int *width, int *height); |
Chris Wilson | 34e4780 | 2013-08-18 21:10:26 +0100 | [diff] [blame] | 96 | #else |
Chris Wilson | 7c52a3c | 2013-08-22 15:07:48 +0100 | [diff] [blame] | 97 | static inline cairo_surface_t *x11_window_create(struct config *config, int *width, int *height) { return NULL; } |
Chris Wilson | 34e4780 | 2013-08-18 21:10:26 +0100 | [diff] [blame] | 98 | #endif |
Chris Wilson | b98bade | 2013-08-20 21:39:27 +0100 | [diff] [blame] | 99 | |
Chris Wilson | d929102 | 2013-08-25 13:15:55 +0100 | [diff] [blame] | 100 | cairo_surface_t *kms_overlay_create(struct config *config, int *width, int *height); |
| 101 | |
Chris Wilson | b98bade | 2013-08-20 21:39:27 +0100 | [diff] [blame] | 102 | #endif /* OVERLAY_H */ |