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