xref: /openbmc/qemu/include/ui/egl-helpers.h (revision 6a0acfff)
1 #ifndef EGL_HELPERS_H
2 #define EGL_HELPERS_H
3 
4 #include <epoxy/gl.h>
5 #include <epoxy/egl.h>
6 #include <gbm.h>
7 #include "ui/console.h"
8 #include "ui/shader.h"
9 
10 extern EGLDisplay *qemu_egl_display;
11 extern EGLConfig qemu_egl_config;
12 extern DisplayGLMode qemu_egl_mode;
13 
14 typedef struct egl_fb {
15     int width;
16     int height;
17     GLuint texture;
18     GLuint framebuffer;
19     bool delete_texture;
20 } egl_fb;
21 
22 void egl_fb_destroy(egl_fb *fb);
23 void egl_fb_setup_default(egl_fb *fb, int width, int height);
24 void egl_fb_setup_for_tex(egl_fb *fb, int width, int height,
25                           GLuint texture, bool delete);
26 void egl_fb_setup_new_tex(egl_fb *fb, int width, int height);
27 void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip);
28 void egl_fb_read(void *dst, egl_fb *src);
29 
30 void egl_texture_blit(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip);
31 void egl_texture_blend(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip,
32                        int x, int y, double scale_x, double scale_y);
33 
34 #ifdef CONFIG_OPENGL_DMABUF
35 
36 extern int qemu_egl_rn_fd;
37 extern struct gbm_device *qemu_egl_rn_gbm_dev;
38 extern EGLContext qemu_egl_rn_ctx;
39 
40 int egl_rendernode_init(const char *rendernode, DisplayGLMode mode);
41 int egl_get_fd_for_texture(uint32_t tex_id, EGLint *stride, EGLint *fourcc,
42                            EGLuint64KHR *modifier);
43 
44 void egl_dmabuf_import_texture(QemuDmaBuf *dmabuf);
45 void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf);
46 
47 #endif
48 
49 EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win);
50 
51 int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy, DisplayGLMode mode);
52 int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode);
53 EGLContext qemu_egl_init_ctx(void);
54 
55 #endif /* EGL_HELPERS_H */
56