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>
This commit is contained in:
Akihiko Odaki
2026-03-03 22:08:56 +09:00
committed by Marc-André Lureau
parent 633c529416
commit cc47123440
5 changed files with 18 additions and 21 deletions

View File

@@ -423,8 +423,8 @@ bool console_gl_check_format(DisplayChangeListener *dcl,
void surface_gl_create_texture(QemuGLShader *gls,
DisplaySurface *surface);
bool surface_gl_create_texture_from_fd(DisplaySurface *surface,
int fd, GLuint *texture,
GLuint *mem_obj);
int fd, uint32_t *texture,
uint32_t *mem_obj);
void surface_gl_update_texture(QemuGLShader *gls,
DisplaySurface *surface,
int x, int y, int w, int h);

View File

@@ -1,8 +1,6 @@
#ifndef QEMU_SHADER_H
#define QEMU_SHADER_H
#include <epoxy/gl.h>
typedef struct QemuGLShader QemuGLShader;
void qemu_gl_run_texture_blit(QemuGLShader *gls, bool flip);

View File

@@ -8,7 +8,6 @@
#include "ui/qemu-pixman.h"
#ifdef CONFIG_OPENGL
# include <epoxy/gl.h>
# include "ui/shader.h"
#endif
@@ -19,9 +18,7 @@ typedef struct DisplaySurface {
pixman_image_t *image;
uint8_t flags;
#ifdef CONFIG_OPENGL
GLenum glformat;
GLenum gltype;
GLuint texture;
uint32_t texture;
#endif
qemu_pixman_shareable share_handle;
uint32_t share_handle_offset;

View File

@@ -25,6 +25,7 @@
* THE SOFTWARE.
*/
#include "qemu/osdep.h"
#include <epoxy/gl.h>
#include "qemu/error-report.h"
#include "ui/console.h"
#include "ui/shader.h"
@@ -66,6 +67,9 @@ bool console_gl_check_format(DisplayChangeListener *dcl,
void surface_gl_create_texture(QemuGLShader *gls,
DisplaySurface *surface)
{
GLenum glformat;
GLenum gltype;
assert(gls);
assert(QEMU_IS_ALIGNED(surface_stride(surface), surface_bytes_per_pixel(surface)));
@@ -73,7 +77,7 @@ void surface_gl_create_texture(QemuGLShader *gls,
return;
}
assert(map_format(surface_format(surface), &surface->glformat, &surface->gltype));
assert(map_format(surface_format(surface), &glformat, &gltype));
glGenTextures(1, &surface->texture);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, surface->texture);
@@ -81,16 +85,12 @@ void surface_gl_create_texture(QemuGLShader *gls,
surface_stride(surface) / surface_bytes_per_pixel(surface));
if (epoxy_is_desktop_gl()) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
surface_width(surface),
surface_height(surface),
0, surface->glformat, surface->gltype,
surface_data(surface));
surface_width(surface), surface_height(surface), 0,
glformat, gltype, surface_data(surface));
} else {
glTexImage2D(GL_TEXTURE_2D, 0, surface->glformat,
surface_width(surface),
surface_height(surface),
0, surface->glformat, surface->gltype,
surface_data(surface));
glTexImage2D(GL_TEXTURE_2D, 0, glformat,
surface_width(surface), surface_height(surface), 0,
glformat, gltype, surface_data(surface));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ONE);
}
@@ -150,17 +150,18 @@ void surface_gl_update_texture(QemuGLShader *gls,
int x, int y, int w, int h)
{
uint8_t *data = (void *)surface_data(surface);
GLenum glformat;
GLenum gltype;
assert(gls);
assert(map_format(surface_format(surface), &glformat, &gltype));
if (surface->texture) {
glBindTexture(GL_TEXTURE_2D, surface->texture);
glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT,
surface_stride(surface)
/ surface_bytes_per_pixel(surface));
glTexSubImage2D(GL_TEXTURE_2D, 0,
x, y, w, h,
surface->glformat, surface->gltype,
glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, glformat, gltype,
data + surface_stride(surface) * y
+ surface_bytes_per_pixel(surface) * x);
}

View File

@@ -25,6 +25,7 @@
* THE SOFTWARE.
*/
#include "qemu/osdep.h"
#include <epoxy/gl.h>
#include "ui/shader.h"
#include "ui/shader/texture-blit-vert.h"