17ced9e9fSGerd Hoffmann #ifndef EGL_HELPERS_H 27ced9e9fSGerd Hoffmann #define EGL_HELPERS_H 37ced9e9fSGerd Hoffmann 47ced9e9fSGerd Hoffmann #include <epoxy/gl.h> 57ced9e9fSGerd Hoffmann #include <epoxy/egl.h> 6bc6a3565SAkihiko Odaki #ifdef CONFIG_GBM 71e316598SGerd Hoffmann #include <gbm.h> 8bc6a3565SAkihiko Odaki #endif 9ec150c7eSMarkus Armbruster #include "ui/console.h" 10ec150c7eSMarkus Armbruster #include "ui/shader.h" 117ced9e9fSGerd Hoffmann 127ced9e9fSGerd Hoffmann extern EGLDisplay *qemu_egl_display; 137ced9e9fSGerd Hoffmann extern EGLConfig qemu_egl_config; 1454d208ffSGerd Hoffmann extern DisplayGLMode qemu_egl_mode; 15*06c63a34SMarc-André Lureau extern bool qemu_egl_angle_d3d; 167ced9e9fSGerd Hoffmann 176fafc260SGerd Hoffmann typedef struct egl_fb { 186fafc260SGerd Hoffmann int width; 196fafc260SGerd Hoffmann int height; 206fafc260SGerd Hoffmann GLuint texture; 216fafc260SGerd Hoffmann GLuint framebuffer; 226fafc260SGerd Hoffmann bool delete_texture; 2365b847d2SVivek Kasireddy QemuDmaBuf *dmabuf; 246fafc260SGerd Hoffmann } egl_fb; 256fafc260SGerd Hoffmann 268bb6af67SMarc-André Lureau #define EGL_FB_INIT { 0, } 278bb6af67SMarc-André Lureau 286fafc260SGerd Hoffmann void egl_fb_destroy(egl_fb *fb); 296fafc260SGerd Hoffmann void egl_fb_setup_default(egl_fb *fb, int width, int height); 3074083f9cSGerd Hoffmann void egl_fb_setup_for_tex(egl_fb *fb, int width, int height, 3174083f9cSGerd Hoffmann GLuint texture, bool delete); 3274083f9cSGerd Hoffmann void egl_fb_setup_new_tex(egl_fb *fb, int width, int height); 336fafc260SGerd Hoffmann void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip); 34d2329237SGerd Hoffmann void egl_fb_read(DisplaySurface *dst, egl_fb *src); 35da9eb580SMarc-André Lureau void egl_fb_read_rect(DisplaySurface *dst, egl_fb *src, int x, int y, int w, int h); 366fafc260SGerd Hoffmann 370eb50c27SGerd Hoffmann void egl_texture_blit(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip); 380eb50c27SGerd Hoffmann void egl_texture_blend(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip, 39051a0cdeSChen Zhang int x, int y, double scale_x, double scale_y); 400eb50c27SGerd Hoffmann 4139324b49SMarc-André Lureau extern EGLContext qemu_egl_rn_ctx; 4239324b49SMarc-André Lureau 43bc6a3565SAkihiko Odaki #ifdef CONFIG_GBM 441e316598SGerd Hoffmann 451e316598SGerd Hoffmann extern int qemu_egl_rn_fd; 461e316598SGerd Hoffmann extern struct gbm_device *qemu_egl_rn_gbm_dev; 471e316598SGerd Hoffmann 4854d208ffSGerd Hoffmann int egl_rendernode_init(const char *rendernode, DisplayGLMode mode); 495fc1fb62SGerd Hoffmann int egl_get_fd_for_texture(uint32_t tex_id, EGLint *stride, EGLint *fourcc, 505fc1fb62SGerd Hoffmann EGLuint64KHR *modifier); 511e316598SGerd Hoffmann 5286c0522cSGerd Hoffmann void egl_dmabuf_import_texture(QemuDmaBuf *dmabuf); 5386c0522cSGerd Hoffmann void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf); 54121abaf3SVivek Kasireddy void egl_dmabuf_create_sync(QemuDmaBuf *dmabuf); 55121abaf3SVivek Kasireddy void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf); 5686c0522cSGerd Hoffmann 571e316598SGerd Hoffmann #endif 581e316598SGerd Hoffmann 59fbd57c75SAlexander Kanavin EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win); 607ced9e9fSGerd Hoffmann 61bc6a3565SAkihiko Odaki #if defined(CONFIG_X11) || defined(CONFIG_GBM) 62bc6a3565SAkihiko Odaki 6354d208ffSGerd Hoffmann int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy, DisplayGLMode mode); 6454d208ffSGerd Hoffmann int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode); 65bc6a3565SAkihiko Odaki 66bc6a3565SAkihiko Odaki #endif 67bc6a3565SAkihiko Odaki 6839324b49SMarc-André Lureau #ifdef WIN32 6939324b49SMarc-André Lureau int qemu_egl_init_dpy_win32(EGLNativeDisplayType dpy, DisplayGLMode mode); 7039324b49SMarc-André Lureau #endif 7139324b49SMarc-André Lureau 727ced9e9fSGerd Hoffmann EGLContext qemu_egl_init_ctx(void); 730df5c72bSMarc-André Lureau bool qemu_egl_has_dmabuf(void); 747ced9e9fSGerd Hoffmann 750e1be59eSMarc-André Lureau bool egl_init(const char *rendernode, DisplayGLMode mode, Error **errp); 760e1be59eSMarc-André Lureau 77044ca4bfSMarc-André Lureau const char *qemu_egl_get_error_string(void); 78044ca4bfSMarc-André Lureau 797ced9e9fSGerd Hoffmann #endif /* EGL_HELPERS_H */ 80