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