xref: /openbmc/qemu/include/ui/egl-helpers.h (revision 13b5ae94)
1 #ifndef EGL_HELPERS_H
2 #define EGL_HELPERS_H
3 
4 #include <epoxy/gl.h>
5 #include <epoxy/egl.h>
6 #ifdef CONFIG_GBM
7 #include <gbm.h>
8 #endif
9 #include "ui/console.h"
10 #include "ui/shader.h"
11 
12 extern EGLDisplay *qemu_egl_display;
13 extern EGLConfig qemu_egl_config;
14 extern DisplayGLMode qemu_egl_mode;
15 extern bool qemu_egl_angle_d3d;
16 
17 typedef struct egl_fb {
18     int width;
19     int height;
20     GLuint texture;
21     GLuint framebuffer;
22     bool delete_texture;
23     QemuDmaBuf *dmabuf;
24 } egl_fb;
25 
26 #define EGL_FB_INIT { 0, }
27 
28 void egl_fb_destroy(egl_fb *fb);
29 void egl_fb_setup_default(egl_fb *fb, int width, int height);
30 void egl_fb_setup_for_tex(egl_fb *fb, int width, int height,
31                           GLuint texture, bool delete);
32 void egl_fb_setup_new_tex(egl_fb *fb, int width, int height);
33 void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip);
34 void egl_fb_read(DisplaySurface *dst, egl_fb *src);
35 void egl_fb_read_rect(DisplaySurface *dst, egl_fb *src, int x, int y, int w, int h);
36 
37 void egl_texture_blit(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip);
38 void egl_texture_blend(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip,
39                        int x, int y, double scale_x, double scale_y);
40 
41 extern EGLContext qemu_egl_rn_ctx;
42 
43 #ifdef CONFIG_GBM
44 
45 extern int qemu_egl_rn_fd;
46 extern struct gbm_device *qemu_egl_rn_gbm_dev;
47 
48 int egl_rendernode_init(const char *rendernode, DisplayGLMode mode);
49 int egl_get_fd_for_texture(uint32_t tex_id, EGLint *stride, EGLint *fourcc,
50                            EGLuint64KHR *modifier);
51 
52 void egl_dmabuf_import_texture(QemuDmaBuf *dmabuf);
53 void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf);
54 void egl_dmabuf_create_sync(QemuDmaBuf *dmabuf);
55 void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf);
56 
57 #endif
58 
59 EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win);
60 
61 #if defined(CONFIG_X11) || defined(CONFIG_GBM)
62 
63 int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy, DisplayGLMode mode);
64 int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode);
65 
66 #endif
67 
68 #ifdef WIN32
69 int qemu_egl_init_dpy_win32(EGLNativeDisplayType dpy, DisplayGLMode mode);
70 #endif
71 
72 EGLContext qemu_egl_init_ctx(void);
73 bool qemu_egl_has_dmabuf(void);
74 
75 bool egl_init(const char *rendernode, DisplayGLMode mode, Error **errp);
76 
77 const char *qemu_egl_get_error_string(void);
78 
79 #endif /* EGL_HELPERS_H */
80