sdl2.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef SDL2_H
  2. #define SDL2_H
  3. /* Avoid compiler warning because macro is redefined in SDL_syswm.h. */
  4. #undef WIN32_LEAN_AND_MEAN
  5. #include <SDL.h>
  6. /* with Alpine / muslc SDL headers pull in directfb headers
  7. * which in turn trigger warning about redundant decls for
  8. * direct_waitqueue_deinit.
  9. */
  10. #pragma GCC diagnostic push
  11. #pragma GCC diagnostic ignored "-Wredundant-decls"
  12. #include <SDL_syswm.h>
  13. #pragma GCC diagnostic pop
  14. #ifdef CONFIG_SDL_IMAGE
  15. # include <SDL_image.h>
  16. #endif
  17. #include "ui/kbd-state.h"
  18. #ifdef CONFIG_OPENGL
  19. # include "ui/egl-helpers.h"
  20. #endif
  21. struct sdl2_console {
  22. DisplayGLCtx dgc;
  23. DisplayChangeListener dcl;
  24. DisplaySurface *surface;
  25. DisplayOptions *opts;
  26. SDL_Texture *texture;
  27. SDL_Window *real_window;
  28. SDL_Renderer *real_renderer;
  29. int idx;
  30. int last_vm_running; /* per console for caption reasons */
  31. int x, y, w, h;
  32. int hidden;
  33. int opengl;
  34. int updates;
  35. int idle_counter;
  36. int ignore_hotkeys;
  37. bool gui_keysym;
  38. SDL_GLContext winctx;
  39. QKbdState *kbd;
  40. #ifdef CONFIG_OPENGL
  41. QemuGLShader *gls;
  42. egl_fb guest_fb;
  43. egl_fb win_fb;
  44. bool y0_top;
  45. bool scanout_mode;
  46. #endif
  47. };
  48. void sdl2_window_create(struct sdl2_console *scon);
  49. void sdl2_window_destroy(struct sdl2_console *scon);
  50. void sdl2_window_resize(struct sdl2_console *scon);
  51. void sdl2_poll_events(struct sdl2_console *scon);
  52. void sdl2_process_key(struct sdl2_console *scon,
  53. SDL_KeyboardEvent *ev);
  54. void sdl2_release_modifiers(struct sdl2_console *scon);
  55. void sdl2_2d_update(DisplayChangeListener *dcl,
  56. int x, int y, int w, int h);
  57. void sdl2_2d_switch(DisplayChangeListener *dcl,
  58. DisplaySurface *new_surface);
  59. void sdl2_2d_refresh(DisplayChangeListener *dcl);
  60. void sdl2_2d_redraw(struct sdl2_console *scon);
  61. bool sdl2_2d_check_format(DisplayChangeListener *dcl,
  62. pixman_format_code_t format);
  63. void sdl2_gl_update(DisplayChangeListener *dcl,
  64. int x, int y, int w, int h);
  65. void sdl2_gl_switch(DisplayChangeListener *dcl,
  66. DisplaySurface *new_surface);
  67. void sdl2_gl_refresh(DisplayChangeListener *dcl);
  68. void sdl2_gl_redraw(struct sdl2_console *scon);
  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. void sdl2_gl_scanout_disable(DisplayChangeListener *dcl);
  75. void sdl2_gl_scanout_texture(DisplayChangeListener *dcl,
  76. uint32_t backing_id,
  77. DisplayGLTextureBorrower backing_borrow,
  78. uint32_t x, uint32_t y,
  79. uint32_t w, uint32_t h);
  80. void sdl2_gl_scanout_flush(DisplayChangeListener *dcl,
  81. uint32_t x, uint32_t y, uint32_t w, uint32_t h);
  82. #endif /* SDL2_H */