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