1 From 453353a221de9c64479f4372565d2cd8591b36cc Mon Sep 17 00:00:00 2001
2 From: Frank Binns <frank.binns@imgtec.com>
3 Date: Fri, 29 Jun 2012 11:26:04 +0100
4 Subject: [PATCH 5/9] Fix build when EGL_MESA_screen_surface extension isn't
7 The EGL demos won't build against EGL implementations that don't support
8 the EGL_MESA_screen_surface extension. Fix this, in most cases, by
9 wrapping relevant bits of code in #ifdef EGL_MESA_screen_surface.
11 Signed-off-by: Frank Binns <frank.binns@imgtec.com>
13 Applied and fixed up in Yocto by...
15 Integrated-by: Tom Zanussi <tom.zanussi@linux.intel.com>
17 Upstream-Status: Pending
19 src/egl/eglut/eglut.c | 9 +++++++--
20 src/egl/eglut/eglut_screen.c | 14 ++++++++++++++
21 src/egl/opengl/demo1.c | 2 ++
22 src/egl/opengl/demo2.c | 7 ++++++-
23 src/egl/opengl/demo3.c | 7 ++++++-
24 5 files changed, 35 insertions(+), 4 deletions(-)
26 diff --git a/src/egl/eglut/eglut.c b/src/egl/eglut/eglut.c
27 index 2ee6f15..f6a2ad4 100644
28 --- a/src/egl/eglut/eglut.c
29 +++ b/src/egl/eglut/eglut.c
30 @@ -76,8 +76,9 @@ _eglutNow(void)
32 _eglutDestroyWindow(struct eglut_window *win)
34 - if (_eglut->surface_type != EGL_PBUFFER_BIT &&
35 - _eglut->surface_type != EGL_SCREEN_BIT_MESA)
37 + if (_eglut->surface_type == EGL_WINDOW_BIT ||
38 + _eglut->surface_type == EGL_PIXMAP_BIT)
39 eglDestroySurface(_eglut->dpy, win->surface);
41 _eglutNativeFiniWindow(win);
42 @@ -175,7 +176,9 @@ _eglutCreateWindow(const char *title, int x, int y, int w, int h)
43 win->config, win->native.u.pixmap, NULL);
46 +#ifdef EGL_MESA_screen_surface
47 case EGL_SCREEN_BIT_MESA:
49 win->surface = win->native.u.surface;
52 @@ -289,8 +292,10 @@ eglutDestroyWindow(int win)
53 if (window->index != win)
56 +#ifdef EGL_MESA_screen_surface
57 /* XXX it causes some bug in st/egl KMS backend */
58 if ( _eglut->surface_type != EGL_SCREEN_BIT_MESA)
60 eglMakeCurrent(_eglut->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
62 _eglutDestroyWindow(_eglut->current);
63 diff --git a/src/egl/eglut/eglut_screen.c b/src/egl/eglut/eglut_screen.c
64 index 021a8f1..094a4e2 100644
65 --- a/src/egl/eglut/eglut_screen.c
66 +++ b/src/egl/eglut/eglut_screen.c
71 +#ifdef EGL_MESA_screen_surface
72 static EGLScreenMESA kms_screen;
73 static EGLModeMESA kms_mode;
74 static EGLint kms_width, kms_height;
78 _eglutNativeInitDisplay(void)
80 +#ifdef EGL_MESA_screen_surface
81 _eglut->native_dpy = EGL_DEFAULT_DISPLAY;
82 _eglut->surface_type = EGL_SCREEN_BIT_MESA;
87 _eglutNativeFiniDisplay(void)
89 +#ifdef EGL_MESA_screen_surface
97 +#ifdef EGL_MESA_screen_surface
101 @@ -94,19 +101,23 @@ init_kms(void)
108 _eglutNativeInitWindow(struct eglut_window *win, const char *title,
109 int x, int y, int w, int h)
111 +#ifdef EGL_MESA_screen_surface
112 EGLint surf_attribs[16];
117 exts = eglQueryString(_eglut->dpy, EGL_EXTENSIONS);
118 if (!exts || !strstr(exts, "EGL_MESA_screen_surface"))
119 _eglutFatal("EGL_MESA_screen_surface is not supported\n");
121 +#ifdef EGL_MESA_screen_surface
125 @@ -128,14 +139,17 @@ _eglutNativeInitWindow(struct eglut_window *win, const char *title,
127 win->native.width = kms_width;
128 win->native.height = kms_height;
133 _eglutNativeFiniWindow(struct eglut_window *win)
135 +#ifdef EGL_MESA_screen_surface
136 eglShowScreenSurfaceMESA(_eglut->dpy,
137 kms_screen, EGL_NO_SURFACE, 0);
138 eglDestroySurface(_eglut->dpy, win->native.u.surface);
143 diff --git a/src/egl/opengl/demo1.c b/src/egl/opengl/demo1.c
144 index d892734..3a3564c 100644
145 --- a/src/egl/opengl/demo1.c
146 +++ b/src/egl/opengl/demo1.c
149 TestScreens(EGLDisplay dpy)
151 +#ifdef EGL_MESA_screen_surface
153 EGLScreenMESA screens[MAX];
155 @@ -28,6 +29,7 @@ TestScreens(EGLDisplay dpy)
156 for (i = 0; i < numScreens; i++) {
157 printf(" Screen %d handle: %d\n", i, (int) screens[i]);
163 diff --git a/src/egl/opengl/demo2.c b/src/egl/opengl/demo2.c
164 index 505b474..bfef59e 100644
165 --- a/src/egl/opengl/demo2.c
166 +++ b/src/egl/opengl/demo2.c
169 /*#define FRONTBUFFER*/
171 +#ifdef EGL_MESA_screen_surface
172 static void _subset_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,
173 GLfloat r, GLfloat g, GLfloat b)
175 @@ -95,12 +96,13 @@ TestScreens(EGLDisplay dpy)
176 printf(" Screen %d handle: %d\n", i, (int) screens[i]);
183 main(int argc, char *argv[])
186 +#ifdef EGL_MESA_screen_surface
188 EGLSurface pbuffer, screen_surf;
189 EGLConfig configs[10];
190 @@ -115,6 +117,7 @@ main(int argc, char *argv[])
192 EGLScreenMESA screen;
196 EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
198 @@ -132,6 +135,7 @@ main(int argc, char *argv[])
202 +#ifdef EGL_MESA_screen_surface
203 eglGetConfigs(d, configs, 10, &numConfigs);
204 printf("Got %d EGL configs:\n", numConfigs);
205 for (i = 0; i < numConfigs; i++) {
206 @@ -211,6 +215,7 @@ main(int argc, char *argv[])
207 eglDestroySurface(d, pbuffer);
208 eglDestroyContext(d, ctx);
214 diff --git a/src/egl/opengl/demo3.c b/src/egl/opengl/demo3.c
215 index f84ca23..31b5d8b 100644
216 --- a/src/egl/opengl/demo3.c
217 +++ b/src/egl/opengl/demo3.c
218 @@ -46,7 +46,7 @@ GLubyte OpenGL_bits[] = {
219 0x3e, 0x00, 0x00, 0xf8, 0x0c, 0x00,
223 +#ifdef EGL_MESA_screen_surface
224 static void Init(void)
227 @@ -551,11 +551,13 @@ write_ppm(const char *filename, const GLubyte *buffer, int width, int height)
234 main(int argc, char *argv[])
237 +#ifdef EGL_MESA_screen_surface
239 EGLSurface screen_surf;
240 EGLConfig configs[10];
241 @@ -566,6 +568,7 @@ main(int argc, char *argv[])
242 const GLubyte *bitmap;
243 EGLint screenAttribs[32];
247 EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
249 @@ -583,6 +586,7 @@ main(int argc, char *argv[])
253 +#ifdef EGL_MESA_screen_surface
254 eglGetConfigs(d, configs, 10, &numConfigs);
255 eglGetScreensMESA(d, &screen, 1, &count);
256 eglGetModesMESA(d, screen, &mode, 1, &count);
257 @@ -642,6 +646,7 @@ main(int argc, char *argv[])
258 eglDestroySurface(d, screen_surf);
259 eglDestroyContext(d, ctx);