kmsdrm: Do NOT modify window size manually from the backend: doing so caused renderer scaling params miscalculation.
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
diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c
index 01d5a8b..59dadab 100644
--- a/src/video/kmsdrm/SDL_kmsdrmopengles.c
+++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c
@@ -143,8 +143,8 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window)
info.crtc_id = dispdata->crtc->crtc->crtc_id;
info.fb_id = fb->fb_id;
- info.src_w = window->w;
- info.src_h = window->h;
+ info.src_w = windata->src_w;
+ info.src_h = windata->src_h;
info.crtc_w = windata->output_w;
info.crtc_h = windata->output_h;
info.crtc_x = windata->output_x;
@@ -240,8 +240,8 @@ KMSDRM_GLES_SwapWindowDB(_THIS, SDL_Window * window)
info.crtc_id = dispdata->crtc->crtc->crtc_id;
info.fb_id = fb->fb_id;
- info.src_w = window->w;
- info.src_h = window->h;
+ info.src_w = windata->src_w;
+ info.src_h = windata->src_h;
info.crtc_w = windata->output_w;
info.crtc_h = windata->output_h;
info.crtc_x = windata->output_x;
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index db28080..e933095 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -652,7 +652,7 @@ KMSDRM_CreateDevice(int devindex)
device->GL_SwapWindow = KMSDRM_GLES_SwapWindowDB;
else
device->GL_SwapWindow = KMSDRM_GLES_SwapWindow;
-
+
device->GL_DeleteContext = KMSDRM_GLES_DeleteContext;
#endif
device->PumpEvents = KMSDRM_PumpEvents;
@@ -815,15 +815,26 @@ KMSDRM_CreateSurfaces(_THIS, SDL_Window * window)
{
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
SDL_WindowData *windata = (SDL_WindowData *)window->driverdata;
- Uint32 width = window->w;
- Uint32 height = window->h;
- Uint32 surface_fmt = GBM_FORMAT_ARGB8888;
- Uint32 surface_flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING;
+ 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;
+ uint32_t width, height;
+
#if SDL_VIDEO_OPENGL_EGL
EGLContext egl_context;
SDL_EGL_SetRequiredVisualId(_this, surface_fmt);
egl_context = (EGLContext)SDL_GL_GetCurrentContext();
#endif
+
+ if (window->flags & SDL_WINDOW_FULLSCREEN) {
+ width = dispdata->mode.hdisplay;
+ height = dispdata->mode.vdisplay;
+ }
+ else {
+ width = window->w;
+ height = window->h;
+ }
+
if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev, surface_fmt, surface_flags)) {
SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "GBM surface format not supported. Trying anyway.");
}
@@ -861,16 +872,17 @@ KMSDRM_ReconfigureWindow( _THIS, SDL_Window * window) {
KMSDRM_SetPendingSurfacesDestruction(_this, window);
- if (window->flags & SDL_WINDOW_FULLSCREEN ) {
- /* Windows only have one possible size in fullscreen mode. */
- window->w = dispdata->mode.hdisplay;
- window->h = dispdata->mode.vdisplay;
+ if (window->flags & SDL_WINDOW_FULLSCREEN) {
+ windata->src_w = dispdata->mode.hdisplay;
+ windata->src_h = dispdata->mode.vdisplay;
windata->output_w = dispdata->mode.hdisplay;
windata->output_h = dispdata->mode.vdisplay;
windata->output_x = 0;
} else {
/* Get output (CRTC) size and position, for AR correction. */
ratio = (float)window->w / (float)window->h;
+ windata->src_w = window->w;
+ windata->src_h = window->h;
windata->output_w = dispdata->mode.vdisplay * ratio;
windata->output_h = dispdata->mode.vdisplay;
windata->output_x = (dispdata->mode.hdisplay - windata->output_w) / 2;
@@ -1339,15 +1351,16 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
dispdata = display->driverdata;
if (window->flags & SDL_WINDOW_FULLSCREEN) {
- /* Windows only have one possible size in fullscreen mode. */
- window->w = dispdata->mode.hdisplay;
- window->h = dispdata->mode.vdisplay;
+ windata->src_w = dispdata->mode.hdisplay;
+ windata->src_h = dispdata->mode.vdisplay;
windata->output_w = dispdata->mode.hdisplay;
windata->output_h = dispdata->mode.vdisplay;
windata->output_x = 0;
} else {
/* Get output (CRTC) size and position, for AR correction. */
ratio = (float)window->w / (float)window->h;
+ windata->src_w = window->w;
+ windata->src_h = window->h;
windata->output_w = dispdata->mode.vdisplay * ratio;
windata->output_h = dispdata->mode.vdisplay;
windata->output_x = (dispdata->mode.hdisplay - windata->output_w) / 2;
@@ -1455,6 +1468,7 @@ KMSDRM_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * displa
{
KMSDRM_ReconfigureWindow(_this, window);
}
+
void
KMSDRM_ShowWindow(_THIS, SDL_Window * window)
{
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.h b/src/video/kmsdrm/SDL_kmsdrmvideo.h
index 72acb10..fb707f2 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.h
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h
@@ -127,6 +127,8 @@ typedef struct SDL_WindowData
#endif
/* For scaling and AR correction. */
+ int32_t src_w;
+ int32_t src_h;
int32_t output_w;
int32_t output_h;
int32_t output_x;