[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
1 changed files with 61 additions and 61 deletions

View File

@ -1008,24 +1008,33 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
int ret = 0; int ret = 0;
drmModeModeInfo *mode; 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 /* Setup driver data for this window */
end of this function, we must have marked the window as being OPENGL windata->viddata = viddata;
and we must have loaded the GL library: both things are needed so the window->driverdata = windata;
GL_CreateRenderer() and GL_LoadFunctions() calls in SDL_CreateWindow()
succeed without having to re-create the window. if (!is_vulkan && !vulkan_mode) { /* NON-Vulkan block. */
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. */ 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. /* Maybe you didn't ask for an OPENGL window, but that's what you will get.
See previous comment on why. */ See previous comment on why. */
window->flags |= SDL_WINDOW_OPENGL; 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,. /* Reopen FD, create gbm dev, setup display plane, etc,.
but only when we come here for the first time, but only when we come here for the first time,
and only if it's not a VK window. */ and only if it's not a VK window. */
@ -1060,26 +1069,17 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
KMSDRM_InitCursor(); KMSDRM_InitCursor();
} }
/* Allocate window internal data */ /**********************************************************************/
windata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); /* We simply IGNORE if it's a fullscreen window, window->flags don't */
if (!windata) { /* reflect it: if it's fullscreen, KMSDRM_SetWindwoFullscreen() which */
ret = SDL_OutOfMemory(); /* will be called by SDL later, and we can manage it there. */
goto cleanup; /**********************************************************************/
}
/* Setup driver data for this window */ /* Try to find a matching video mode for the window, fallback to the
windata->viddata = viddata; original mode if not available, and configure the mode we chose
window->driverdata = windata; into the CRTC. */
/* 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. */
mode = KMSDRM_GetConnectorMode(dispdata->connector, window->w, window->h ); 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) { if (mode) {
windata->surface_w = window->w; windata->surface_w = window->w;
windata->surface_h = window->h; windata->surface_h = window->h;
@ -1104,7 +1104,7 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
so SDL pre-scales to that size for us. */ so SDL pre-scales to that size for us. */
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED,
windata->surface_w, windata->surface_h); windata->surface_w, windata->surface_h);
} } /* NON-Vulkan block ends. */
/* Add window to the internal list of tracked windows. Note, while it may /* Add window to the internal list of tracked windows. Note, while it may
seem odd to support multiple fullscreen windows, some apps create an seem odd to support multiple fullscreen windows, some apps create an