[KMS/DRM] Refactor KMSDR_CreateSurface to group all non-Vulkan stuff in a block.

This commit is contained in:
Manuel Alfayate Corchete 2021-01-12 00:22:58 +01:00
parent 87eb734c4e
commit 8442754912

View File

@ -1008,24 +1008,33 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
int ret = 0;
drmModeModeInfo *mode;
if ( !(dispdata->gbm_init) && !is_vulkan && !vulkan_mode ) {
/* Allocate window internal data */
windata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData));
if (!windata) {
ret = SDL_OutOfMemory();
goto cleanup;
}
/* If this is not a Vulkan Window, then this is a GL window, so at the
end of this function, we must have marked the window as being OPENGL
and we must have loaded the GL library: both things are needed so the
GL_CreateRenderer() and GL_LoadFunctions() calls in SDL_CreateWindow()
succeed without having to re-create the window.
We must load the EGL library too, which can't be loaded until the GBM
device has been created, because SDL_EGL_Library() function uses it. */
/* Setup driver data for this window */
windata->viddata = viddata;
window->driverdata = windata;
if (!is_vulkan && !vulkan_mode) { /* NON-Vulkan block. */
if (!(dispdata->gbm_init)) {
/* In order for the GL_CreateRenderer() and GL_LoadFunctions() calls
in SDL_CreateWindow succeed (no doing so causes a windo re-creation),
At the end of this block, we must have:
-Marked the window as being OPENGL
-Loaded the GL library (which can't be loaded until the GBM
device has been created) because SDL_EGL_Library() function uses it.
*/
/* Maybe you didn't ask for an OPENGL window, but that's what you will get.
See previous comment on why. */
window->flags |= SDL_WINDOW_OPENGL;
/* Don't force fullscreen on all windows: it confuses programs that try
to set a window fullscreen after creating it as non-fullscreen (sm64ex) */
// window->flags |= SDL_WINDOW_FULLSCREEN;
/* Reopen FD, create gbm dev, setup display plane, etc,.
but only when we come here for the first time,
and only if it's not a VK window. */
@ -1060,26 +1069,17 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
KMSDRM_InitCursor();
}
/* Allocate window internal data */
windata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData));
if (!windata) {
ret = SDL_OutOfMemory();
goto cleanup;
}
/**********************************************************************/
/* We simply IGNORE if it's a fullscreen window, window->flags don't */
/* reflect it: if it's fullscreen, KMSDRM_SetWindwoFullscreen() which */
/* will be called by SDL later, and we can manage it there. */
/**********************************************************************/
/* Setup driver data for this window */
windata->viddata = viddata;
window->driverdata = windata;
/* We simply IGNORE if it's a fullscreen window, window->flags desn't reflect it.
If it's fullscreen, we will manage that in KMSDRM_SetWindwoFullscreen(),
which will be called by SDL later, if necessary. */
/* Try to find a matching video mode for the window, fallback to the
original mode if not available, and configure the mode we chose
into the CRTC. */
mode = KMSDRM_GetConnectorMode(dispdata->connector, window->w, window->h );
if (!is_vulkan && !vulkan_mode) {
/* Try to find a matching video mode for the window, with fallback to the
original mode if not available, and configure that mode into the CRTC. */
if (mode) {
windata->surface_w = window->w;
windata->surface_h = window->h;
@ -1104,7 +1104,7 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
so SDL pre-scales to that size for us. */
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED,
windata->surface_w, windata->surface_h);
}
} /* NON-Vulkan block ends. */
/* Add window to the internal list of tracked windows. Note, while it may
seem odd to support multiple fullscreen windows, some apps create an