ui/surface: Avoid including epoxy/gl.h in header files
include/ui/shader.h and include/ui/surface.h are included by files that do not depend on Epoxy so they shouldn't include epoxy/gl.h. Otherwise, compilations of these files can fail because the path to the directory containing epoxy/gl.h may not be passed to the compiler. Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20260303-gl-v1-3-d90f0a237a52@rsg.ci.i.u-tokyo.ac.jp>
Akihiko Odaki committed
Mar 3, 2026 at 22:08 UTC
cc471234406d6a5592d2db5fd28bca3fd3216cbb
5 files changed
+18
-21
include/ui/console.h
+2
-2
@@ -423,8 +423,8 @@ bool console_gl_check_format(DisplayChangeListener *dcl,
423
void surface_gl_create_texture(QemuGLShader *gls,
424
DisplaySurface *surface);
425
bool surface_gl_create_texture_from_fd(DisplaySurface *surface,
426
- int fd, GLuint *texture,
427
- GLuint *mem_obj);
426
+ int fd, uint32_t *texture,
427
+ uint32_t *mem_obj);
428
void surface_gl_update_texture(QemuGLShader *gls,
429
DisplaySurface *surface,
430
int x, int y, int w, int h);
include/ui/shader.h
-2
@@ -1,8 +1,6 @@
1
#ifndef QEMU_SHADER_H
2
#define QEMU_SHADER_H
3
4
-#include <epoxy/gl.h>
5
-
4
typedef struct QemuGLShader QemuGLShader;
5
6
void qemu_gl_run_texture_blit(QemuGLShader *gls, bool flip);
include/ui/surface.h
+1
-4
@@ -8,7 +8,6 @@
8
#include "ui/qemu-pixman.h"
9
10
#ifdef CONFIG_OPENGL
11
-# include <epoxy/gl.h>
11
# include "ui/shader.h"
12
#endif
13
@@ -19,9 +18,7 @@ typedef struct DisplaySurface {
18
pixman_image_t *image;
19
uint8_t flags;
20
#ifdef CONFIG_OPENGL
22
- GLenum glformat;
23
- GLenum gltype;
24
- GLuint texture;
21
+ uint32_t texture;
22
#endif
23
qemu_pixman_shareable share_handle;
24
uint32_t share_handle_offset;
ui/console-gl.c
+14
-13
@@ -25,6 +25,7 @@
25
* THE SOFTWARE.
26
*/
27
#include "qemu/osdep.h"
28
+#include <epoxy/gl.h>
29
#include "qemu/error-report.h"
30
#include "ui/console.h"
31
#include "ui/shader.h"
@@ -66,6 +67,9 @@ bool console_gl_check_format(DisplayChangeListener *dcl,
67
void surface_gl_create_texture(QemuGLShader *gls,
68
DisplaySurface *surface)
69
{
70
+ GLenum glformat;
71
+ GLenum gltype;
72
+
73
assert(gls);
74
assert(QEMU_IS_ALIGNED(surface_stride(surface), surface_bytes_per_pixel(surface)));
75
@@ -73,7 +77,7 @@ void surface_gl_create_texture(QemuGLShader *gls,
77
return;
78
}
79
76
- assert(map_format(surface_format(surface), &surface->glformat, &surface->gltype));
80
+ assert(map_format(surface_format(surface), &glformat, &gltype));
81
glGenTextures(1, &surface->texture);
82
glEnable(GL_TEXTURE_2D);
83
glBindTexture(GL_TEXTURE_2D, surface->texture);
@@ -81,16 +85,12 @@ void surface_gl_create_texture(QemuGLShader *gls,
85
surface_stride(surface) / surface_bytes_per_pixel(surface));
86
if (epoxy_is_desktop_gl()) {
87
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
84
- surface_width(surface),
85
- surface_height(surface),
86
- 0, surface->glformat, surface->gltype,
87
- surface_data(surface));
88
+ surface_width(surface), surface_height(surface), 0,
89
+ glformat, gltype, surface_data(surface));
90
} else {
89
- glTexImage2D(GL_TEXTURE_2D, 0, surface->glformat,
90
- surface_width(surface),
91
- surface_height(surface),
92
- 0, surface->glformat, surface->gltype,
93
- surface_data(surface));
91
+ glTexImage2D(GL_TEXTURE_2D, 0, glformat,
92
+ surface_width(surface), surface_height(surface), 0,
93
+ glformat, gltype, surface_data(surface));
94
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ONE);
95
}
96
@@ -150,17 +150,18 @@ void surface_gl_update_texture(QemuGLShader *gls,
150
int x, int y, int w, int h)
151
{
152
uint8_t *data = (void *)surface_data(surface);
153
+ GLenum glformat;
154
+ GLenum gltype;
155
156
assert(gls);
157
+ assert(map_format(surface_format(surface), &glformat, &gltype));
158
159
if (surface->texture) {
160
glBindTexture(GL_TEXTURE_2D, surface->texture);
161
glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,
162
surface_stride(surface)
163
/ surface_bytes_per_pixel(surface));
161
- glTexSubImage2D(GL_TEXTURE_2D, 0,
162
- x, y, w, h,
163
- surface->glformat, surface->gltype,
164
+ glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, glformat, gltype,
165
data + surface_stride(surface) * y
166
+ surface_bytes_per_pixel(surface) * x);
167
}
ui/shader.c
+1
@@ -25,6 +25,7 @@
25
* THE SOFTWARE.
26
*/
27
#include "qemu/osdep.h"
28
+#include <epoxy/gl.h>
29
#include "ui/shader.h"
30
31
#include "ui/shader/texture-blit-vert.h"