[KMS/DRM] Move surface size info to window driverdata, for coherency.
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index 781b796..f860815 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -823,7 +823,7 @@ KMSDRM_CreateSurfaces(_THIS, SDL_Window * window)
{
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
SDL_WindowData *windata = (SDL_WindowData *)window->driverdata;
- SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
+
uint32_t surface_fmt = GBM_FORMAT_ARGB8888;
uint32_t surface_flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING;
@@ -845,7 +845,7 @@ KMSDRM_CreateSurfaces(_THIS, SDL_Window * window)
}
windata->gs = KMSDRM_gbm_surface_create(viddata->gbm_dev,
- dispdata->surface_w, dispdata->surface_h, surface_fmt, surface_flags);
+ windata->surface_w, windata->surface_h, surface_fmt, surface_flags);
if (!windata->gs) {
return SDL_SetError("Could not create GBM surface");
@@ -1020,14 +1020,11 @@ KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
return SDL_SetError("Mode doesn't have an associated index");
}
- /* Take note of the new mode to be set, and leave the modeset pending. */
+ /* Take note of the new mode to be set, and leave the CRTC modeset pending
+ so it's done in SwapWindow. */
dispdata->mode = conn->modes[modedata->mode_index];
dispdata->modeset_pending = SDL_TRUE;
- /* Set the new surface size. */
- dispdata->surface_w = dispdata->mode.hdisplay;
- dispdata->surface_h = dispdata->mode.vdisplay;
-
for (i = 0; i < viddata->num_windows; i++) {
SDL_Window *window = viddata->windows[i];
@@ -1193,16 +1190,17 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
/* 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) {
- dispdata->surface_w = window->w;
- dispdata->surface_h = window->h;
+ windata->surface_w = window->w;
+ windata->surface_h = window->h;
dispdata->mode = *mode;
}
else {
- dispdata->surface_w = dispdata->original_mode.hdisplay;
- dispdata->surface_h = dispdata->original_mode.vdisplay;
+ windata->surface_w = dispdata->original_mode.hdisplay;
+ windata->surface_h = dispdata->original_mode.vdisplay;
dispdata->mode = dispdata->original_mode;
}
+ /* Take note to do the modesettng on the CRTC in SwapWindow. */
dispdata->modeset_pending = SDL_TRUE;
/* Create the window surfaces with the size we have just chosen.
@@ -1239,7 +1237,7 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
/* Tell app about the size we have determined for the window,
so SDL pre-scales to that size for us. */
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED,
- dispdata->surface_w, dispdata->surface_h);
+ windata->surface_w, windata->surface_h);
/***********************************************************/
/* Tell SDL that the mouse has entered the window using an */
@@ -1266,8 +1264,8 @@ cleanup:
/*****************************************************************************/
void
KMSDRM_ReconfigureWindow( _THIS, SDL_Window * window) {
-
SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
+ SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) ==
SDL_WINDOW_FULLSCREEN_DESKTOP)
@@ -1275,8 +1273,8 @@ KMSDRM_ReconfigureWindow( _THIS, SDL_Window * window) {
/* Update the current mode to the desktop mode,
take note of pending mode configuration to the CRTC,
and recreate the GBM surface with the same size as the size. */
- dispdata->surface_w = dispdata->original_mode.hdisplay;
- dispdata->surface_h = dispdata->original_mode.vdisplay;
+ windata->surface_w = dispdata->original_mode.hdisplay;
+ windata->surface_h = dispdata->original_mode.vdisplay;
dispdata->mode = dispdata->original_mode;
}
else
@@ -1288,16 +1286,16 @@ KMSDRM_ReconfigureWindow( _THIS, SDL_Window * window) {
if (mode) {
/* If matching mode found, recreate the GBM surface with the size
of that mode and configure it on the CRTC. */
- dispdata->surface_w = window->windowed.w;
- dispdata->surface_h = window->windowed.h;
+ windata->surface_w = window->windowed.w;
+ windata->surface_h = window->windowed.h;
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. */
- dispdata->surface_w = dispdata->original_mode.hdisplay;
- dispdata->surface_h = dispdata->original_mode.vdisplay;
+ windata->surface_w = dispdata->original_mode.hdisplay;
+ windata->surface_h = dispdata->original_mode.vdisplay;
dispdata->mode = dispdata->original_mode;
}
}
@@ -1310,7 +1308,7 @@ KMSDRM_ReconfigureWindow( _THIS, SDL_Window * window) {
/* Tell app about the size we have determined for the window,
so SDL pre-scales to that size for us. */
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED,
- dispdata->surface_w, dispdata->surface_h);
+ windata->surface_w, windata->surface_h);
}
int
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.h b/src/video/kmsdrm/SDL_kmsdrmvideo.h
index 74af9f0..d089e10 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.h
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h
@@ -78,9 +78,6 @@ typedef struct SDL_DisplayData
SDL_bool set_default_cursor_pending;
SDL_bool modeset_pending;
- uint32_t surface_w;
- uint32_t surface_h;
-
} SDL_DisplayData;
typedef struct SDL_WindowData
@@ -99,6 +96,12 @@ typedef struct SDL_WindowData
EGLSurface egl_surface;
+ /* The size we chose for the GBM surface. REMEMBER that the CRTC must always have
+ a mode with the same size configured before trying to flip to a buffer of that
+ surface or drmModePageFlip() will return -28. */
+ uint32_t surface_w;
+ uint32_t surface_h;
+
} SDL_WindowData;
typedef struct KMSDRM_FBInfo