| 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 | int x; |
| 21 | int y; |
| 22 | GLuint texture; |
| 23 | GLuint framebuffer; |
| 24 | bool delete_texture; |
| 25 | QemuDmaBuf *dmabuf; |
| 26 | } egl_fb; |
| 27 | |
| 28 | #define EGL_FB_INIT { 0, } |
| 29 | |
| 30 | void egl_fb_destroy(egl_fb *fb); |
| 31 | void egl_fb_setup_default(egl_fb *fb, int width, int height, int x, int y); |
| 32 | void egl_fb_setup_for_tex(egl_fb *fb, int width, int height, |
| 33 | GLuint texture, bool delete); |
| 34 | void egl_fb_setup_new_tex(egl_fb *fb, int width, int height); |
| 35 | void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip); |
| 36 | void egl_fb_read(DisplaySurface *dst, egl_fb *src); |
| 37 | void egl_fb_read_rect(DisplaySurface *dst, egl_fb *src, int x, int y, int w, int h); |
| 38 | |
| 39 | void egl_texture_blit(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip); |
| 40 | void egl_texture_blend(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip, |
| 41 | int x, int y, double scale_x, double scale_y); |
| 42 | |
| 43 | extern EGLContext qemu_egl_rn_ctx; |
| 44 | |
| 45 | #ifdef CONFIG_GBM |
| 46 | |
| 47 | extern int qemu_egl_rn_fd; |
| 48 | extern struct gbm_device *qemu_egl_rn_gbm_dev; |
| 49 | |
| 50 | int egl_rendernode_init(const char *rendernode, DisplayGLMode mode); |
| 51 | bool egl_dmabuf_export_texture(uint32_t tex_id, int *fd, EGLint *offset, |
| 52 | EGLint *stride, EGLint *fourcc, int *num_planes, |
| 53 | EGLuint64KHR *modifier); |
| 54 | |
| 55 | void egl_dmabuf_import_texture(QemuDmaBuf *dmabuf); |
| 56 | void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf); |
| 57 | void egl_dmabuf_create_sync(QemuDmaBuf *dmabuf); |
| 58 | void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf); |
| 59 | |
| 60 | #endif |
| 61 | |
| 62 | EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win); |
| 63 | |
| 64 | #if defined(CONFIG_X11) || defined(CONFIG_GBM) || defined(WIN32) |
| 65 | EGLDisplay qemu_egl_get_display(EGLNativeDisplayType native, |
| 66 | EGLenum platform); |
| 67 | #endif |
| 68 | |
| 69 | #if defined(CONFIG_X11) || defined(CONFIG_GBM) |
| 70 | |
| 71 | int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy, DisplayGLMode mode); |
| 72 | int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode); |
| 73 | |
| 74 | #endif |
| 75 | |
| 76 | #ifdef WIN32 |
| 77 | int qemu_egl_init_dpy_win32(EGLNativeDisplayType dpy, DisplayGLMode mode); |
| 78 | #endif |
| 79 | |
| 80 | EGLContext qemu_egl_init_ctx(void); |
| 81 | bool qemu_egl_has_dmabuf(void); |
| 82 | |
| 83 | bool egl_init(const char *rendernode, DisplayGLMode mode, Error **errp); |
| 84 | void egl_cleanup(void); |
| 85 | |
| 86 | const char *qemu_egl_get_error_string(void); |
| 87 | |
| 88 | #endif /* EGL_HELPERS_H */ |