John Kåre Alsaker | 30d2b1f | 2012-11-13 19:10:28 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2012 John Kåre Alsaker |
| 3 | * |
Bryce Harrington | a0bbfea | 2015-06-11 15:35:43 -0700 | [diff] [blame] | 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: |
John Kåre Alsaker | 30d2b1f | 2012-11-13 19:10:28 +0100 | [diff] [blame] | 11 | * |
Bryce Harrington | a0bbfea | 2015-06-11 15:35:43 -0700 | [diff] [blame] | 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. |
John Kåre Alsaker | 30d2b1f | 2012-11-13 19:10:28 +0100 | [diff] [blame] | 24 | */ |
| 25 | |
Daniel Stone | c228e23 | 2013-05-22 18:03:19 +0300 | [diff] [blame] | 26 | #include "config.h" |
| 27 | |
Jussi Kukkonen | 649bbce | 2016-07-19 14:16:27 +0300 | [diff] [blame] | 28 | #include <stdint.h> |
| 29 | |
Daniel Stone | c228e23 | 2013-05-22 18:03:19 +0300 | [diff] [blame] | 30 | #include "compositor.h" |
John Kåre Alsaker | 30d2b1f | 2012-11-13 19:10:28 +0100 | [diff] [blame] | 31 | |
Vasily Khoruzhick | 1bfe2e6 | 2013-01-08 19:09:02 +0300 | [diff] [blame] | 32 | #ifdef ENABLE_EGL |
| 33 | |
John Kåre Alsaker | 30d2b1f | 2012-11-13 19:10:28 +0100 | [diff] [blame] | 34 | #include <EGL/egl.h> |
Jonny Lamb | 62185f4 | 2015-03-24 13:12:00 +0100 | [diff] [blame] | 35 | #include <EGL/eglext.h> |
John Kåre Alsaker | 30d2b1f | 2012-11-13 19:10:28 +0100 | [diff] [blame] | 36 | |
Vasily Khoruzhick | 1bfe2e6 | 2013-01-08 19:09:02 +0300 | [diff] [blame] | 37 | #else |
| 38 | |
| 39 | typedef int EGLint; |
Jonny Lamb | 445fb69 | 2015-03-24 13:12:01 +0100 | [diff] [blame] | 40 | typedef int EGLenum; |
Vasily Khoruzhick | 26def5c | 2013-01-11 13:50:45 +0300 | [diff] [blame] | 41 | typedef void *EGLDisplay; |
| 42 | typedef void *EGLSurface; |
Jonny Lamb | f1ec506 | 2015-03-24 13:12:05 +0100 | [diff] [blame] | 43 | typedef void *EGLConfig; |
Vasily Khoruzhick | 26def5c | 2013-01-11 13:50:45 +0300 | [diff] [blame] | 44 | typedef intptr_t EGLNativeDisplayType; |
| 45 | typedef intptr_t EGLNativeWindowType; |
Pekka Paalanen | e47d0d9 | 2013-12-04 15:34:45 +0200 | [diff] [blame] | 46 | #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0) |
Vasily Khoruzhick | 1bfe2e6 | 2013-01-08 19:09:02 +0300 | [diff] [blame] | 47 | |
Jonny Lamb | a3e6a4a | 2015-03-24 13:12:02 +0100 | [diff] [blame] | 48 | #endif /* ENABLE_EGL */ |
| 49 | |
Jonny Lamb | 74eed31 | 2015-03-24 13:12:04 +0100 | [diff] [blame] | 50 | #define NO_EGL_PLATFORM 0 |
| 51 | |
Jason Ekstrand | 0b61bf4 | 2013-10-27 22:24:54 -0500 | [diff] [blame] | 52 | enum gl_renderer_border_side { |
| 53 | GL_RENDERER_BORDER_TOP = 0, |
| 54 | GL_RENDERER_BORDER_LEFT = 1, |
| 55 | GL_RENDERER_BORDER_RIGHT = 2, |
| 56 | GL_RENDERER_BORDER_BOTTOM = 3, |
| 57 | }; |
| 58 | |
Ander Conselvan de Oliveira | 97f2952 | 2013-10-14 15:57:11 +0300 | [diff] [blame] | 59 | struct gl_renderer_interface { |
| 60 | const EGLint *opaque_attribs; |
| 61 | const EGLint *alpha_attribs; |
| 62 | |
Miguel A. Vico | dddc670 | 2016-05-18 17:41:07 +0200 | [diff] [blame] | 63 | int (*display_create)(struct weston_compositor *ec, |
| 64 | EGLenum platform, |
| 65 | void *native_window, |
Miguel A. Vico | 4057cd9 | 2016-05-18 17:44:22 +0200 | [diff] [blame^] | 66 | const EGLint *config_attribs, |
Miguel A. Vico | dddc670 | 2016-05-18 17:41:07 +0200 | [diff] [blame] | 67 | const EGLint *visual_id, |
| 68 | const int n_ids); |
Ander Conselvan de Oliveira | 97f2952 | 2013-10-14 15:57:11 +0300 | [diff] [blame] | 69 | |
| 70 | EGLDisplay (*display)(struct weston_compositor *ec); |
| 71 | |
Miguel A. Vico | c095cde | 2016-05-18 17:43:00 +0200 | [diff] [blame] | 72 | int (*output_window_create)(struct weston_output *output, |
| 73 | EGLNativeWindowType window_for_legacy, |
| 74 | void *window_for_platform, |
Miguel A. Vico | 4057cd9 | 2016-05-18 17:44:22 +0200 | [diff] [blame^] | 75 | const EGLint *config_attribs, |
Miguel A. Vico | c095cde | 2016-05-18 17:43:00 +0200 | [diff] [blame] | 76 | const EGLint *visual_id, |
| 77 | const int n_ids); |
Ander Conselvan de Oliveira | 97f2952 | 2013-10-14 15:57:11 +0300 | [diff] [blame] | 78 | |
| 79 | void (*output_destroy)(struct weston_output *output); |
| 80 | |
| 81 | EGLSurface (*output_surface)(struct weston_output *output); |
| 82 | |
Jason Ekstrand | 0b61bf4 | 2013-10-27 22:24:54 -0500 | [diff] [blame] | 83 | /* Sets the output border. |
| 84 | * |
| 85 | * The side specifies the side for which we are setting the border. |
| 86 | * The width and height are the width and height of the border. |
| 87 | * The tex_width patemeter specifies the width of the actual |
| 88 | * texture; this may be larger than width if the data is not |
| 89 | * tightly packed. |
| 90 | * |
| 91 | * The top and bottom textures will extend over the sides to the |
Jason Ekstrand | c107306 | 2014-04-11 03:42:59 -0500 | [diff] [blame] | 92 | * full width of the bordered window. The right and left edges, |
| 93 | * however, will extend only to the top and bottom of the |
Jason Ekstrand | 0b61bf4 | 2013-10-27 22:24:54 -0500 | [diff] [blame] | 94 | * compositor surface. This is demonstrated by the picture below: |
| 95 | * |
| 96 | * +-----------------------+ |
| 97 | * | TOP | |
| 98 | * +-+-------------------+-+ |
| 99 | * | | | | |
| 100 | * |L| |R| |
| 101 | * |E| |I| |
| 102 | * |F| |G| |
| 103 | * |T| |H| |
| 104 | * | | |T| |
| 105 | * | | | | |
| 106 | * +-+-------------------+-+ |
| 107 | * | BOTTOM | |
| 108 | * +-----------------------+ |
| 109 | */ |
| 110 | void (*output_set_border)(struct weston_output *output, |
| 111 | enum gl_renderer_border_side side, |
| 112 | int32_t width, int32_t height, |
| 113 | int32_t tex_width, unsigned char *data); |
| 114 | |
Ander Conselvan de Oliveira | 97f2952 | 2013-10-14 15:57:11 +0300 | [diff] [blame] | 115 | void (*print_egl_error_state)(void); |
| 116 | }; |
| 117 | |