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