mirror of https://github.com/encounter/SDL.git
[KMS/DRM] Replace indent tabs with spaces, as intended.
This commit is contained in:
parent
59cd46c24a
commit
6ee53258cd
|
@ -93,8 +93,8 @@ KMSDRM_DestroyCursorBO (_THIS, SDL_VideoDisplay *display)
|
|||
|
||||
/* Destroy the curso GBM BO. */
|
||||
if (dispdata->cursor_bo) {
|
||||
KMSDRM_gbm_bo_destroy(dispdata->cursor_bo);
|
||||
dispdata->cursor_bo = NULL;
|
||||
KMSDRM_gbm_bo_destroy(dispdata->cursor_bo);
|
||||
dispdata->cursor_bo = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,33 +109,33 @@ KMSDRM_CreateCursorBO (SDL_VideoDisplay *display) {
|
|||
SDL_DisplayData *dispdata = (SDL_DisplayData *) display->driverdata;
|
||||
|
||||
if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev,
|
||||
GBM_FORMAT_ARGB8888,
|
||||
GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE))
|
||||
GBM_FORMAT_ARGB8888,
|
||||
GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE))
|
||||
{
|
||||
SDL_SetError("Unsupported pixel format for cursor");
|
||||
SDL_SetError("Unsupported pixel format for cursor");
|
||||
return;
|
||||
}
|
||||
|
||||
if (KMSDRM_drmGetCap(viddata->drm_fd,
|
||||
DRM_CAP_CURSOR_WIDTH, &dispdata->cursor_w) ||
|
||||
KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_HEIGHT,
|
||||
&dispdata->cursor_h))
|
||||
DRM_CAP_CURSOR_WIDTH, &dispdata->cursor_w) ||
|
||||
KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_HEIGHT,
|
||||
&dispdata->cursor_h))
|
||||
{
|
||||
SDL_SetError("Could not get the recommended GBM cursor size");
|
||||
SDL_SetError("Could not get the recommended GBM cursor size");
|
||||
return;
|
||||
}
|
||||
|
||||
if (dispdata->cursor_w == 0 || dispdata->cursor_h == 0) {
|
||||
SDL_SetError("Could not get an usable GBM cursor size");
|
||||
SDL_SetError("Could not get an usable GBM cursor size");
|
||||
return;
|
||||
}
|
||||
|
||||
dispdata->cursor_bo = KMSDRM_gbm_bo_create(viddata->gbm_dev,
|
||||
dispdata->cursor_w, dispdata->cursor_h,
|
||||
GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE | GBM_BO_USE_LINEAR);
|
||||
dispdata->cursor_w, dispdata->cursor_h,
|
||||
GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE | GBM_BO_USE_LINEAR);
|
||||
|
||||
if (!dispdata->cursor_bo) {
|
||||
SDL_SetError("Could not create GBM cursor BO");
|
||||
SDL_SetError("Could not create GBM cursor BO");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -150,10 +150,10 @@ KMSDRM_RemoveCursorFromBO(SDL_VideoDisplay *display)
|
|||
SDL_VideoData *viddata = ((SDL_VideoData *)video_device->driverdata);
|
||||
|
||||
ret = KMSDRM_drmModeSetCursor(viddata->drm_fd,
|
||||
dispdata->crtc->crtc_id, 0, 0, 0);
|
||||
dispdata->crtc->crtc_id, 0, 0, 0);
|
||||
|
||||
if (ret) {
|
||||
ret = SDL_SetError("Could not hide current cursor with drmModeSetCursor().");
|
||||
ret = SDL_SetError("Could not hide current cursor with drmModeSetCursor().");
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -327,15 +327,15 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
|||
|
||||
cleanup:
|
||||
if (ret == NULL) {
|
||||
if (curdata) {
|
||||
if (curdata->buffer) {
|
||||
SDL_free(curdata->buffer);
|
||||
}
|
||||
SDL_free(curdata);
|
||||
}
|
||||
if (cursor) {
|
||||
SDL_free(cursor);
|
||||
}
|
||||
if (curdata) {
|
||||
if (curdata->buffer) {
|
||||
SDL_free(curdata->buffer);
|
||||
}
|
||||
SDL_free(curdata);
|
||||
}
|
||||
if (cursor) {
|
||||
SDL_free(cursor);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -381,37 +381,37 @@ KMSDRM_ShowCursor(SDL_Cursor * cursor)
|
|||
|
||||
if (!window || !cursor) {
|
||||
|
||||
/* If no window is focused by mouse or cursor is NULL,
|
||||
since we have no window (no mouse->focus) and hence
|
||||
we have no display, we simply hide mouse on all displays.
|
||||
This happens on video quit, where we get here after
|
||||
the mouse focus has been unset, yet SDL wants to
|
||||
restore the system default cursor (makes no sense here). */
|
||||
/* If no window is focused by mouse or cursor is NULL,
|
||||
since we have no window (no mouse->focus) and hence
|
||||
we have no display, we simply hide mouse on all displays.
|
||||
This happens on video quit, where we get here after
|
||||
the mouse focus has been unset, yet SDL wants to
|
||||
restore the system default cursor (makes no sense here). */
|
||||
|
||||
num_displays = SDL_GetNumVideoDisplays();
|
||||
num_displays = SDL_GetNumVideoDisplays();
|
||||
|
||||
/* Iterate on the displays hidding the cursor. */
|
||||
for (i = 0; i < num_displays; i++) {
|
||||
for (i = 0; i < num_displays; i++) {
|
||||
display = SDL_GetDisplay(i);
|
||||
ret = KMSDRM_RemoveCursorFromBO(display);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
display = SDL_GetDisplayForWindow(window);
|
||||
display = SDL_GetDisplayForWindow(window);
|
||||
|
||||
if (display) {
|
||||
if (display) {
|
||||
|
||||
if (cursor) {
|
||||
/* Dump the cursor to the display DRM cursor BO so it becomes visible
|
||||
on that display. */
|
||||
if (cursor) {
|
||||
/* Dump the cursor to the display DRM cursor BO so it becomes visible
|
||||
on that display. */
|
||||
ret = KMSDRM_DumpCursorToBO(display, cursor);
|
||||
|
||||
} else {
|
||||
/* Hide the cursor on that display. */
|
||||
} else {
|
||||
/* Hide the cursor on that display. */
|
||||
ret = KMSDRM_RemoveCursorFromBO(display);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -441,21 +441,22 @@ KMSDRM_WarpMouseGlobal(int x, int y)
|
|||
|
||||
/* And now update the cursor graphic position on screen. */
|
||||
if (dispdata->cursor_bo) {
|
||||
int drm_fd;
|
||||
int drm_fd;
|
||||
int ret = 0;
|
||||
|
||||
drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(dispdata->cursor_bo));
|
||||
ret = KMSDRM_drmModeMoveCursor(drm_fd, dispdata->crtc->crtc_id, x, y);
|
||||
drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(dispdata->cursor_bo));
|
||||
ret = KMSDRM_drmModeMoveCursor(drm_fd, dispdata->crtc->crtc_id, x, y);
|
||||
|
||||
if (ret) {
|
||||
SDL_SetError("drmModeMoveCursor() failed.");
|
||||
}
|
||||
if (ret) {
|
||||
SDL_SetError("drmModeMoveCursor() failed.");
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
|
||||
} else {
|
||||
return SDL_SetError("Cursor not initialized properly.");
|
||||
}
|
||||
|
||||
} else {
|
||||
return SDL_SetError("No mouse or current cursor.");
|
||||
}
|
||||
|
|
|
@ -173,12 +173,12 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) {
|
|||
}
|
||||
|
||||
ret = KMSDRM_drmModePageFlip(viddata->drm_fd, dispdata->crtc->crtc_id,
|
||||
fb_info->fb_id, flip_flags, &windata->waiting_for_flip);
|
||||
fb_info->fb_id, flip_flags, &windata->waiting_for_flip);
|
||||
|
||||
if (ret == 0) {
|
||||
windata->waiting_for_flip = SDL_TRUE;
|
||||
windata->waiting_for_flip = SDL_TRUE;
|
||||
} else {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not queue pageflip: %d", ret);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not queue pageflip: %d", ret);
|
||||
}
|
||||
|
||||
/* Wait immediately for vsync (as if we only had two buffers).
|
||||
|
@ -191,10 +191,10 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) {
|
|||
Run your SDL2 program with "SDL_KMSDRM_DOUBLE_BUFFER=1 <program_name>"
|
||||
to enable this. */
|
||||
if (windata->double_buffer) {
|
||||
if (!KMSDRM_WaitPageflip(_this, windata)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Immediate wait for previous pageflip failed");
|
||||
return 0;
|
||||
}
|
||||
if (!KMSDRM_WaitPageflip(_this, windata)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Immediate wait for previous pageflip failed");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -85,11 +85,11 @@ SDL_KMSDRM_SYM(void,drmModeFreeObjectProperties,(drmModeObjectPropertiesPtr ptr)
|
|||
SDL_KMSDRM_SYM(void,drmModeFreePlane,(drmModePlanePtr ptr))
|
||||
SDL_KMSDRM_SYM(void,drmModeFreePlaneResources,(drmModePlaneResPtr ptr))
|
||||
SDL_KMSDRM_SYM(int,drmModeSetPlane,(int fd, uint32_t plane_id, uint32_t crtc_id,
|
||||
uint32_t fb_id, uint32_t flags,
|
||||
int32_t crtc_x, int32_t crtc_y,
|
||||
uint32_t crtc_w, uint32_t crtc_h,
|
||||
uint32_t src_x, uint32_t src_y,
|
||||
uint32_t src_w, uint32_t src_h))
|
||||
uint32_t fb_id, uint32_t flags,
|
||||
int32_t crtc_x, int32_t crtc_y,
|
||||
uint32_t crtc_w, uint32_t crtc_h,
|
||||
uint32_t src_x, uint32_t src_y,
|
||||
uint32_t src_w, uint32_t src_h))
|
||||
/* Planes stuff ends. */
|
||||
|
||||
SDL_KMSDRM_MODULE(GBM)
|
||||
|
|
|
@ -471,17 +471,17 @@ void KMSDRM_DeinitDisplays (_THIS) {
|
|||
/* Get the driverdata for this display */
|
||||
dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(i);
|
||||
|
||||
/* Free connector */
|
||||
if (dispdata && dispdata->connector) {
|
||||
KMSDRM_drmModeFreeConnector(dispdata->connector);
|
||||
dispdata->connector = NULL;
|
||||
}
|
||||
/* Free connector */
|
||||
if (dispdata && dispdata->connector) {
|
||||
KMSDRM_drmModeFreeConnector(dispdata->connector);
|
||||
dispdata->connector = NULL;
|
||||
}
|
||||
|
||||
/* Free CRTC */
|
||||
if (dispdata && dispdata->crtc) {
|
||||
KMSDRM_drmModeFreeCrtc(dispdata->crtc);
|
||||
dispdata->crtc = NULL;
|
||||
}
|
||||
/* Free CRTC */
|
||||
if (dispdata && dispdata->crtc) {
|
||||
KMSDRM_drmModeFreeCrtc(dispdata->crtc);
|
||||
dispdata->crtc = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1025,9 +1025,9 @@ KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
|||
for (i = 0; i < viddata->num_windows; i++) {
|
||||
SDL_Window *window = viddata->windows[i];
|
||||
|
||||
if (KMSDRM_CreateSurfaces(_this, window)) {
|
||||
return -1;
|
||||
}
|
||||
if (KMSDRM_CreateSurfaces(_this, window)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Tell app about the window resize */
|
||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, mode->w, mode->h);
|
||||
|
@ -1132,42 +1132,42 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
|
|||
|
||||
if (!is_vulkan && !vulkan_mode) { /* NON-Vulkan block. */
|
||||
|
||||
if (!(dispdata->gbm_init)) {
|
||||
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.
|
||||
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;
|
||||
/* 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;
|
||||
|
||||
/* 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. */
|
||||
if ((ret = KMSDRM_GBMInit(_this, dispdata))) {
|
||||
goto cleanup;
|
||||
}
|
||||
/* 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. */
|
||||
if ((ret = KMSDRM_GBMInit(_this, dispdata))) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Manually load the GL library. KMSDRM_EGL_LoadLibrary() has already
|
||||
been called by SDL_CreateWindow() but we don't do anything there,
|
||||
precisely to be able to load it here.
|
||||
If we let SDL_CreateWindow() load the lib, it will be loaded
|
||||
before we call KMSDRM_GBMInit(), causing GLES programs to fail. */
|
||||
if (!_this->egl_data) {
|
||||
egl_display = (NativeDisplayType)((SDL_VideoData *)_this->driverdata)->gbm_dev;
|
||||
if (SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA)) {
|
||||
goto cleanup;
|
||||
}
|
||||
/* Manually load the GL library. KMSDRM_EGL_LoadLibrary() has already
|
||||
been called by SDL_CreateWindow() but we don't do anything there,
|
||||
precisely to be able to load it here.
|
||||
If we let SDL_CreateWindow() load the lib, it will be loaded
|
||||
before we call KMSDRM_GBMInit(), causing GLES programs to fail. */
|
||||
if (!_this->egl_data) {
|
||||
egl_display = (NativeDisplayType)((SDL_VideoData *)_this->driverdata)->gbm_dev;
|
||||
if (SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA)) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (SDL_GL_LoadLibrary(NULL) < 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
if (SDL_GL_LoadLibrary(NULL) < 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create the cursor BO for the display of this window,
|
||||
now that we know this is not a VK window. */
|
||||
|
@ -1175,15 +1175,15 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
|
|||
|
||||
/* Create and set the default cursor now that we know
|
||||
this is not a VK window. */
|
||||
KMSDRM_InitMouse(_this, display);
|
||||
KMSDRM_InitMouse(_this, display);
|
||||
|
||||
/* When we destroy a window, we remove the cursor buffer from
|
||||
/* When we destroy a window, we remove the cursor buffer from
|
||||
the cursor plane and destroy the cursor GBM BO, but SDL expects
|
||||
that we keep showing the visible cursors bewteen window
|
||||
destruction/creation cycles. So we must manually re-show the
|
||||
visible cursors, if necessary, when we create a window. */
|
||||
KMSDRM_InitCursor();
|
||||
}
|
||||
KMSDRM_InitCursor();
|
||||
}
|
||||
|
||||
/* The FULLSCREEN flags are cut out from window->flags at this point,
|
||||
so we can't know if a window is fullscreen or not, hence all windows
|
||||
|
@ -1205,7 +1205,7 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
|
|||
}
|
||||
|
||||
/* Take note to do the modesettng on the CRTC in SwapWindow. */
|
||||
dispdata->modeset_pending = SDL_TRUE;
|
||||
dispdata->modeset_pending = SDL_TRUE;
|
||||
|
||||
/* Create the window surfaces with the size we have just chosen.
|
||||
Needs the window diverdata in place. */
|
||||
|
@ -1286,24 +1286,24 @@ KMSDRM_ReconfigureWindow( _THIS, SDL_Window * window) {
|
|||
refresh_rate = (uint32_t)window->fullscreen_mode.refresh_rate;
|
||||
}
|
||||
|
||||
/* Try to find a valid video mode matching the size of the window. */
|
||||
mode = KMSDRM_GetClosestDisplayMode(display,
|
||||
/* Try to find a valid video mode matching the size of the window. */
|
||||
mode = KMSDRM_GetClosestDisplayMode(display,
|
||||
window->windowed.w, window->windowed.h, refresh_rate );
|
||||
|
||||
if (mode) {
|
||||
/* If matching mode found, recreate the GBM surface with the size
|
||||
of that mode and configure it on the CRTC. */
|
||||
windata->surface_w = mode->hdisplay;
|
||||
windata->surface_h = mode->vdisplay;
|
||||
dispdata->mode = *mode;
|
||||
} else {
|
||||
/* If not matching mode found, recreate the GBM surfaces with the
|
||||
size of the mode that was originally configured on the CRTC,
|
||||
and setup that mode on the CRTC. */
|
||||
windata->surface_w = dispdata->original_mode.hdisplay;
|
||||
windata->surface_h = dispdata->original_mode.vdisplay;
|
||||
dispdata->mode = dispdata->original_mode;
|
||||
}
|
||||
if (mode) {
|
||||
/* If matching mode found, recreate the GBM surface with the size
|
||||
of that mode and configure it on the CRTC. */
|
||||
windata->surface_w = mode->hdisplay;
|
||||
windata->surface_h = mode->vdisplay;
|
||||
dispdata->mode = *mode;
|
||||
} else {
|
||||
/* If not matching mode found, recreate the GBM surfaces with the
|
||||
size of the mode that was originally configured on the CRTC,
|
||||
and setup that mode on the CRTC. */
|
||||
windata->surface_w = dispdata->original_mode.hdisplay;
|
||||
windata->surface_h = dispdata->original_mode.vdisplay;
|
||||
dispdata->mode = dispdata->original_mode;
|
||||
}
|
||||
|
||||
/* Tell app about the size we have determined for the window,
|
||||
so SDL pre-scales to that size for us. */
|
||||
|
|
|
@ -361,22 +361,22 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS,
|
|||
new_mode_parameters.visibleRegion.width = window->w;
|
||||
new_mode_parameters.visibleRegion.height = window->h;
|
||||
new_mode_parameters.refreshRate = 60000; /* Always use 60Hz for now. */
|
||||
display_mode_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR;
|
||||
display_mode_create_info.parameters = new_mode_parameters;
|
||||
result = vkCreateDisplayModeKHR(gpu,
|
||||
displays_props[display_index].display,
|
||||
&display_mode_create_info,
|
||||
NULL, display_mode);
|
||||
if (result != VK_SUCCESS) {
|
||||
SDL_SetError("Vulkan couldn't find a predefined mode for that window size and couldn't create a suitable mode.");
|
||||
goto clean;
|
||||
}
|
||||
display_mode_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR;
|
||||
display_mode_create_info.parameters = new_mode_parameters;
|
||||
result = vkCreateDisplayModeKHR(gpu,
|
||||
displays_props[display_index].display,
|
||||
&display_mode_create_info,
|
||||
NULL, display_mode);
|
||||
if (result != VK_SUCCESS) {
|
||||
SDL_SetError("Vulkan couldn't find a predefined mode for that window size and couldn't create a suitable mode.");
|
||||
goto clean;
|
||||
}
|
||||
}
|
||||
|
||||
/* Just in case we get here without a display_mode. */
|
||||
if (!display_mode) {
|
||||
SDL_SetError("Vulkan couldn't get a display mode.");
|
||||
goto clean;
|
||||
SDL_SetError("Vulkan couldn't get a display mode.");
|
||||
goto clean;
|
||||
}
|
||||
|
||||
/********************************************/
|
||||
|
|
Loading…
Reference in New Issue