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 #include <SDL_syswm.h> 9 #ifdef CONFIG_SDL_IMAGE 10 # include <SDL_image.h> 11 #endif 12 13 #include "ui/kbd-state.h" 14 #ifdef CONFIG_OPENGL 15 # include "ui/egl-helpers.h" 16 #endif 17 18 struct sdl2_console { 19 DisplayGLCtx dgc; 20 DisplayChangeListener dcl; 21 DisplaySurface *surface; 22 DisplayOptions *opts; 23 SDL_Texture *texture; 24 SDL_Window *real_window; 25 SDL_Renderer *real_renderer; 26 int idx; 27 int last_vm_running; /* per console for caption reasons */ 28 int x, y, w, h; 29 int hidden; 30 int opengl; 31 int updates; 32 int idle_counter; 33 int ignore_hotkeys; 34 SDL_GLContext winctx; 35 QKbdState *kbd; 36 #ifdef CONFIG_OPENGL 37 QemuGLShader *gls; 38 egl_fb guest_fb; 39 egl_fb win_fb; 40 bool y0_top; 41 bool scanout_mode; 42 #endif 43 }; 44 45 void sdl2_window_create(struct sdl2_console *scon); 46 void sdl2_window_destroy(struct sdl2_console *scon); 47 void sdl2_window_resize(struct sdl2_console *scon); 48 void sdl2_poll_events(struct sdl2_console *scon); 49 50 void sdl2_process_key(struct sdl2_console *scon, 51 SDL_KeyboardEvent *ev); 52 53 void sdl2_2d_update(DisplayChangeListener *dcl, 54 int x, int y, int w, int h); 55 void sdl2_2d_switch(DisplayChangeListener *dcl, 56 DisplaySurface *new_surface); 57 void sdl2_2d_refresh(DisplayChangeListener *dcl); 58 void sdl2_2d_redraw(struct sdl2_console *scon); 59 bool sdl2_2d_check_format(DisplayChangeListener *dcl, 60 pixman_format_code_t format); 61 62 void sdl2_gl_update(DisplayChangeListener *dcl, 63 int x, int y, int w, int h); 64 void sdl2_gl_switch(DisplayChangeListener *dcl, 65 DisplaySurface *new_surface); 66 void sdl2_gl_refresh(DisplayChangeListener *dcl); 67 void sdl2_gl_redraw(struct sdl2_console *scon); 68 69 QEMUGLContext sdl2_gl_create_context(DisplayGLCtx *dgc, 70 QEMUGLParams *params); 71 void sdl2_gl_destroy_context(DisplayGLCtx *dgc, QEMUGLContext ctx); 72 int sdl2_gl_make_context_current(DisplayGLCtx *dgc, 73 QEMUGLContext ctx); 74 75 void sdl2_gl_scanout_disable(DisplayChangeListener *dcl); 76 void sdl2_gl_scanout_texture(DisplayChangeListener *dcl, 77 uint32_t backing_id, 78 bool backing_y_0_top, 79 uint32_t backing_width, 80 uint32_t backing_height, 81 uint32_t x, uint32_t y, 82 uint32_t w, uint32_t h); 83 void sdl2_gl_scanout_flush(DisplayChangeListener *dcl, 84 uint32_t x, uint32_t y, uint32_t w, uint32_t h); 85 86 #endif /* SDL2_H */ 87