Mir: Do not use opengl to find the valid pixel format if we dont use opengl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
diff --git a/src/video/mir/SDL_mirwindow.c b/src/video/mir/SDL_mirwindow.c
index c4e643a..2d6f4a5 100644
--- a/src/video/mir/SDL_mirwindow.c
+++ b/src/video/mir/SDL_mirwindow.c
@@ -46,6 +46,32 @@ IsSurfaceValid(MIR_Window* mir_window)
return 0;
}
+MirPixelFormat
+FindValidPixelFormat(MIR_Data* mir_data)
+{
+ unsigned int pf_size = 32;
+ unsigned int valid_formats;
+ unsigned int f;
+
+ MirPixelFormat formats[pf_size];
+ MIR_mir_connection_get_available_surface_formats(mir_data->connection, formats,
+ pf_size, &valid_formats);
+
+ for (f = 0; f < valid_formats; f++) {
+ MirPixelFormat cur_pf = formats[f];
+
+ if (cur_pf == mir_pixel_format_abgr_8888 ||
+ cur_pf == mir_pixel_format_xbgr_8888 ||
+ cur_pf == mir_pixel_format_argb_8888 ||
+ cur_pf == mir_pixel_format_xrgb_8888) {
+
+ return cur_pf;
+ }
+ }
+
+ return mir_pixel_format_invalid;
+}
+
int
MIR_CreateWindow(_THIS, SDL_Window* window)
{
@@ -72,9 +98,14 @@ MIR_CreateWindow(_THIS, SDL_Window* window)
mir_window->mir_data = mir_data;
mir_window->sdl_window = window;
- pixel_format = MIR_mir_connection_get_egl_pixel_format(mir_data->connection,
- _this->egl_data->egl_display,
- _this->egl_data->egl_config);
+ if (window->flags & SDL_WINDOW_OPENGL) {
+ pixel_format = MIR_mir_connection_get_egl_pixel_format(mir_data->connection,
+ _this->egl_data->egl_display,
+ _this->egl_data->egl_config);
+ }
+ else {
+ pixel_format = FindValidPixelFormat(mir_data);
+ }
mir_data->pixel_format = pixel_format;
if (pixel_format == mir_pixel_format_invalid) {