blob: 71f6b46e49e108445616f74da716cb711cdbabcc [file] [log] [blame]
John Kåre Alsaker30d2b1f2012-11-13 19:10:28 +01001/*
2 * Copyright © 2012 John Kåre Alsaker
3 *
Bryce Harringtona0bbfea2015-06-11 15:35:43 -07004 * 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 Alsaker30d2b1f2012-11-13 19:10:28 +010011 *
Bryce Harringtona0bbfea2015-06-11 15:35:43 -070012 * 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 Alsaker30d2b1f2012-11-13 19:10:28 +010024 */
25
Daniel Stonec228e232013-05-22 18:03:19 +030026#include "config.h"
27
28#include "compositor.h"
John Kåre Alsaker30d2b1f2012-11-13 19:10:28 +010029
Vasily Khoruzhick1bfe2e62013-01-08 19:09:02 +030030#ifdef ENABLE_EGL
31
John Kåre Alsaker30d2b1f2012-11-13 19:10:28 +010032#include <EGL/egl.h>
Jonny Lamb62185f42015-03-24 13:12:00 +010033#include <EGL/eglext.h>
John Kåre Alsaker30d2b1f2012-11-13 19:10:28 +010034
Vasily Khoruzhick1bfe2e62013-01-08 19:09:02 +030035#else
36
37typedef int EGLint;
Jonny Lamb445fb692015-03-24 13:12:01 +010038typedef int EGLenum;
Vasily Khoruzhick26def5c2013-01-11 13:50:45 +030039typedef void *EGLDisplay;
40typedef void *EGLSurface;
Jonny Lambf1ec5062015-03-24 13:12:05 +010041typedef void *EGLConfig;
Vasily Khoruzhick26def5c2013-01-11 13:50:45 +030042typedef intptr_t EGLNativeDisplayType;
43typedef intptr_t EGLNativeWindowType;
Pekka Paalanene47d0d92013-12-04 15:34:45 +020044#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
Vasily Khoruzhick1bfe2e62013-01-08 19:09:02 +030045
Jonny Lamba3e6a4a2015-03-24 13:12:02 +010046#endif /* ENABLE_EGL */
47
Jonny Lambf1ec5062015-03-24 13:12:05 +010048#ifndef EGL_EXT_platform_base
49typedef EGLDisplay (*PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list);
50typedef EGLSurface (*PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list);
51#endif
52
Jonny Lamba3e6a4a2015-03-24 13:12:02 +010053#ifndef EGL_PLATFORM_GBM_KHR
54#define EGL_PLATFORM_GBM_KHR 0x31D7
55#endif
56
57#ifndef EGL_PLATFORM_WAYLAND_KHR
58#define EGL_PLATFORM_WAYLAND_KHR 0x31D8
59#endif
60
61#ifndef EGL_PLATFORM_X11_KHR
62#define EGL_PLATFORM_X11_KHR 0x31D5
Vasily Khoruzhick1bfe2e62013-01-08 19:09:02 +030063#endif
Ander Conselvan de Oliveira97f29522013-10-14 15:57:11 +030064
Jonny Lamb74eed312015-03-24 13:12:04 +010065#define NO_EGL_PLATFORM 0
66
Jason Ekstrand0b61bf42013-10-27 22:24:54 -050067enum gl_renderer_border_side {
68 GL_RENDERER_BORDER_TOP = 0,
69 GL_RENDERER_BORDER_LEFT = 1,
70 GL_RENDERER_BORDER_RIGHT = 2,
71 GL_RENDERER_BORDER_BOTTOM = 3,
72};
73
Ander Conselvan de Oliveira97f29522013-10-14 15:57:11 +030074struct gl_renderer_interface {
75 const EGLint *opaque_attribs;
76 const EGLint *alpha_attribs;
77
78 int (*create)(struct weston_compositor *ec,
Jonny Lamb70eba3f2015-03-20 15:26:50 +010079 EGLenum platform,
80 void *native_window,
Ander Conselvan de Oliveira97f29522013-10-14 15:57:11 +030081 const EGLint *attribs,
Derek Foremane76f1852015-05-15 12:12:39 -050082 const EGLint *visual_id,
83 const int n_ids);
Ander Conselvan de Oliveira97f29522013-10-14 15:57:11 +030084
85 EGLDisplay (*display)(struct weston_compositor *ec);
86
87 int (*output_create)(struct weston_output *output,
Jonny Lamb671148f2015-03-20 15:26:52 +010088 EGLNativeWindowType window_for_legacy,
89 void *window_for_platform,
Neil Roberts77c1a5b2014-03-07 18:05:50 +000090 const EGLint *attribs,
Derek Foremane76f1852015-05-15 12:12:39 -050091 const EGLint *visual_id,
92 const int n_ids);
Ander Conselvan de Oliveira97f29522013-10-14 15:57:11 +030093
94 void (*output_destroy)(struct weston_output *output);
95
96 EGLSurface (*output_surface)(struct weston_output *output);
97
Jason Ekstrand0b61bf42013-10-27 22:24:54 -050098 /* Sets the output border.
99 *
100 * The side specifies the side for which we are setting the border.
101 * The width and height are the width and height of the border.
102 * The tex_width patemeter specifies the width of the actual
103 * texture; this may be larger than width if the data is not
104 * tightly packed.
105 *
106 * The top and bottom textures will extend over the sides to the
Jason Ekstrandc1073062014-04-11 03:42:59 -0500107 * full width of the bordered window. The right and left edges,
108 * however, will extend only to the top and bottom of the
Jason Ekstrand0b61bf42013-10-27 22:24:54 -0500109 * compositor surface. This is demonstrated by the picture below:
110 *
111 * +-----------------------+
112 * | TOP |
113 * +-+-------------------+-+
114 * | | | |
115 * |L| |R|
116 * |E| |I|
117 * |F| |G|
118 * |T| |H|
119 * | | |T|
120 * | | | |
121 * +-+-------------------+-+
122 * | BOTTOM |
123 * +-----------------------+
124 */
125 void (*output_set_border)(struct weston_output *output,
126 enum gl_renderer_border_side side,
127 int32_t width, int32_t height,
128 int32_t tex_width, unsigned char *data);
129
Ander Conselvan de Oliveira97f29522013-10-14 15:57:11 +0300130 void (*print_egl_error_state)(void);
131};
132