mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-23 09:15:41 +00:00
workaround for libmali gbm_device_get_fd()
gbm_device_get_fd() in at least some libmali versions duplicates handle. Other implementations do not do duplication. To prevent handle leak save drm_fd in SDL_DisplayData.
This commit is contained in:
parent
0c7c4bfcf9
commit
66b0a6ee15
|
@ -73,6 +73,7 @@ KMSDRM_DestroyCursorBO (_THIS, SDL_VideoDisplay *display)
|
||||||
if (dispdata->cursor_bo) {
|
if (dispdata->cursor_bo) {
|
||||||
KMSDRM_gbm_bo_destroy(dispdata->cursor_bo);
|
KMSDRM_gbm_bo_destroy(dispdata->cursor_bo);
|
||||||
dispdata->cursor_bo = NULL;
|
dispdata->cursor_bo = NULL;
|
||||||
|
dispdata->cursor_bo_drm_fd = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +117,8 @@ KMSDRM_CreateCursorBO (SDL_VideoDisplay *display) {
|
||||||
SDL_SetError("Could not create GBM cursor BO");
|
SDL_SetError("Could not create GBM cursor BO");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dispdata->cursor_bo_drm_fd = viddata->drm_fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove a cursor buffer from a display's DRM cursor BO. */
|
/* Remove a cursor buffer from a display's DRM cursor BO. */
|
||||||
|
@ -384,11 +387,9 @@ KMSDRM_WarpMouseGlobal(int x, int y)
|
||||||
|
|
||||||
/* And now update the cursor graphic position on screen. */
|
/* And now update the cursor graphic position on screen. */
|
||||||
if (dispdata->cursor_bo) {
|
if (dispdata->cursor_bo) {
|
||||||
int drm_fd;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(dispdata->cursor_bo));
|
ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, x, y);
|
||||||
ret = KMSDRM_drmModeMoveCursor(drm_fd, dispdata->crtc->crtc_id, x, y);
|
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
SDL_SetError("drmModeMoveCursor() failed.");
|
SDL_SetError("drmModeMoveCursor() failed.");
|
||||||
|
@ -437,7 +438,6 @@ static void
|
||||||
KMSDRM_MoveCursor(SDL_Cursor * cursor)
|
KMSDRM_MoveCursor(SDL_Cursor * cursor)
|
||||||
{
|
{
|
||||||
SDL_Mouse *mouse = SDL_GetMouse();
|
SDL_Mouse *mouse = SDL_GetMouse();
|
||||||
int drm_fd;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/* We must NOT call SDL_SendMouseMotion() here or we will enter recursivity!
|
/* We must NOT call SDL_SendMouseMotion() here or we will enter recursivity!
|
||||||
|
@ -452,9 +452,7 @@ KMSDRM_MoveCursor(SDL_Cursor * cursor)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(dispdata->cursor_bo));
|
ret = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, mouse->x, mouse->y);
|
||||||
|
|
||||||
ret = KMSDRM_drmModeMoveCursor(drm_fd, dispdata->crtc->crtc_id, mouse->x, mouse->y);
|
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
SDL_SetError("drmModeMoveCursor() failed.");
|
SDL_SetError("drmModeMoveCursor() failed.");
|
||||||
|
|
|
@ -95,7 +95,6 @@ SDL_KMSDRM_SYM(int,drmModeSetPlane,(int fd, uint32_t plane_id, uint32_t crtc_id,
|
||||||
/* Planes stuff ends. */
|
/* Planes stuff ends. */
|
||||||
|
|
||||||
SDL_KMSDRM_MODULE(GBM)
|
SDL_KMSDRM_MODULE(GBM)
|
||||||
SDL_KMSDRM_SYM(int,gbm_device_get_fd,(struct gbm_device *gbm))
|
|
||||||
SDL_KMSDRM_SYM(int,gbm_device_is_format_supported,(struct gbm_device *gbm,
|
SDL_KMSDRM_SYM(int,gbm_device_is_format_supported,(struct gbm_device *gbm,
|
||||||
uint32_t format, uint32_t usage))
|
uint32_t format, uint32_t usage))
|
||||||
SDL_KMSDRM_SYM(void,gbm_device_destroy,(struct gbm_device *gbm))
|
SDL_KMSDRM_SYM(void,gbm_device_destroy,(struct gbm_device *gbm))
|
||||||
|
|
|
@ -555,6 +555,7 @@ KMSDRM_AddDisplay (_THIS, drmModeConnector *connector, drmModeRes *resources) {
|
||||||
/* Initialize some of the members of the new display's driverdata
|
/* Initialize some of the members of the new display's driverdata
|
||||||
to sane values. */
|
to sane values. */
|
||||||
dispdata->cursor_bo = NULL;
|
dispdata->cursor_bo = NULL;
|
||||||
|
dispdata->cursor_bo_drm_fd = -1;
|
||||||
|
|
||||||
/* Since we create and show the default cursor on KMSDRM_InitMouse(),
|
/* Since we create and show the default cursor on KMSDRM_InitMouse(),
|
||||||
and we call KMSDRM_InitMouse() when we create a window, we have to know
|
and we call KMSDRM_InitMouse() when we create a window, we have to know
|
||||||
|
|
|
@ -77,6 +77,7 @@ typedef struct SDL_DisplayData
|
||||||
where we may not have an SDL_Cursor at all (so no SDL_Cursor driverdata).
|
where we may not have an SDL_Cursor at all (so no SDL_Cursor driverdata).
|
||||||
There's only one cursor GBM BO because we only support one cursor. */
|
There's only one cursor GBM BO because we only support one cursor. */
|
||||||
struct gbm_bo *cursor_bo;
|
struct gbm_bo *cursor_bo;
|
||||||
|
int cursor_bo_drm_fd;
|
||||||
uint64_t cursor_w, cursor_h;
|
uint64_t cursor_w, cursor_h;
|
||||||
|
|
||||||
SDL_bool default_cursor_init;
|
SDL_bool default_cursor_init;
|
||||||
|
|
Loading…
Reference in a new issue