| 1 | #ifndef SDL2_H |
| 2 | #define SDL2_H |
| 3 | |
| 4 | /* Avoid compiler warning because macro is redefined in SDL_syswm.h. */ |
| 5 | #undef WIN32_LEAN_AND_MEAN |
| 6 | |
| 7 | #include <SDL.h> |
| 8 | |
| 9 | /* with Alpine / muslc SDL headers pull in directfb headers |
| 10 | * which in turn trigger warning about redundant decls for |
| 11 | * direct_waitqueue_deinit. |
| 12 | */ |
| 13 | #pragma GCC diagnostic push |
| 14 | #pragma GCC diagnostic ignored "-Wredundant-decls" |
| 15 | |
| 16 | #include <SDL_syswm.h> |
| 17 | |
| 18 | #pragma GCC diagnostic pop |
| 19 | |
| 20 | #ifdef CONFIG_SDL_IMAGE |
| 21 | # include <SDL_image.h> |
| 22 | #endif |
| 23 | |
| 24 | #include "ui/kbd-state.h" |
| 25 | #ifdef CONFIG_OPENGL |
| 26 | # include "ui/egl-helpers.h" |
| 27 | #endif |
| 28 | |
| 29 | struct sdl2_console { |
| 30 | DisplayGLCtx dgc; |
| 31 | DisplayChangeListener dcl; |
| 32 | DisplaySurface *surface; |
| 33 | DisplayOptions *opts; |
| 34 | SDL_Texture *texture; |
| 35 | SDL_Window *real_window; |
| 36 | SDL_Renderer *real_renderer; |
| 37 | int idx; |
| 38 | int last_vm_running; /* per console for caption reasons */ |
| 39 | int x, y, w, h; |
| 40 | int hidden; |
| 41 | int opengl; |
| 42 | int updates; |
| 43 | int idle_counter; |
| 44 | int ignore_hotkeys; |
| 45 | bool gui_keysym; |
| 46 | SDL_GLContext winctx; |
| 47 | QKbdState *kbd; |
| 48 | bool has_dmabuf; |
| 49 | #ifdef CONFIG_OPENGL |
| 50 | QemuGLShader *gls; |
| 51 | egl_fb guest_fb; |
| 52 | egl_fb win_fb; |
| 53 | bool y0_top; |
| 54 | bool scanout_mode; |
| 55 | #endif |
| 56 | }; |
| 57 | |
| 58 | void sdl2_window_create(struct sdl2_console *scon); |
| 59 | void sdl2_window_destroy(struct sdl2_console *scon); |
| 60 | void sdl2_window_resize(struct sdl2_console *scon); |
| 61 | void sdl2_poll_events(struct sdl2_console *scon); |
| 62 | |
| 63 | void sdl2_process_key(struct sdl2_console *scon, |
| 64 | SDL_KeyboardEvent *ev); |
| 65 | void sdl2_release_modifiers(struct sdl2_console *scon); |
| 66 | |
| 67 | void sdl2_2d_update(DisplayChangeListener *dcl, |
| 68 | int x, int y, int w, int h); |
| 69 | void sdl2_2d_switch(DisplayChangeListener *dcl, |
| 70 | DisplaySurface *new_surface); |
| 71 | void sdl2_2d_refresh(DisplayChangeListener *dcl); |
| 72 | void sdl2_2d_redraw(struct sdl2_console *scon); |
| 73 | bool sdl2_2d_check_format(DisplayChangeListener *dcl, |
| 74 | pixman_format_code_t format); |
| 75 | |
| 76 | void sdl2_gl_update(DisplayChangeListener *dcl, |
| 77 | int x, int y, int w, int h); |
| 78 | void sdl2_gl_switch(DisplayChangeListener *dcl, |
| 79 | DisplaySurface *new_surface); |
| 80 | void sdl2_gl_refresh(DisplayChangeListener *dcl); |
| 81 | void sdl2_gl_redraw(struct sdl2_console *scon); |
| 82 | |
| 83 | QEMUGLContext sdl2_gl_create_context(DisplayGLCtx *dgc, |
| 84 | QEMUGLParams *params); |
| 85 | void sdl2_gl_destroy_context(DisplayGLCtx *dgc, QEMUGLContext ctx); |
| 86 | int sdl2_gl_make_context_current(DisplayGLCtx *dgc, |
| 87 | QEMUGLContext ctx); |
| 88 | |
| 89 | void sdl2_gl_scanout_disable(DisplayChangeListener *dcl); |
| 90 | void sdl2_gl_scanout_texture(DisplayChangeListener *dcl, |
| 91 | uint32_t backing_id, |
| 92 | bool backing_y_0_top, |
| 93 | uint32_t backing_width, |
| 94 | uint32_t backing_height, |
| 95 | uint32_t x, uint32_t y, |
| 96 | uint32_t w, uint32_t h, |
| 97 | void *d3d_tex2d); |
| 98 | void sdl2_gl_scanout_flush(DisplayChangeListener *dcl, |
| 99 | uint32_t x, uint32_t y, uint32_t w, uint32_t h); |
| 100 | void sdl2_gl_scanout_dmabuf(DisplayChangeListener *dcl, |
| 101 | QemuDmaBuf *dmabuf); |
| 102 | void sdl2_gl_release_dmabuf(DisplayChangeListener *dcl, |
| 103 | QemuDmaBuf *dmabuf); |
| 104 | bool sdl2_gl_has_dmabuf(DisplayChangeListener *dcl); |
| 105 | void sdl2_gl_console_init(struct sdl2_console *scon); |
| 106 | |
| 107 | #endif /* SDL2_H */ |