From cca16c9cb191c2b3fb88fa08949232f2fbb53eac Mon Sep 17 00:00:00 2001 From: Manuel Alfayate Corchete Date: Thu, 15 Oct 2020 17:56:19 +0200 Subject: [PATCH] kmsdrm: merge GetDisplayDPI implementation by bms20 --- src/video/kmsdrm/SDL_kmsdrmvideo.c | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index a125365ec..c73a02545 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -712,6 +712,38 @@ KMSDRM_DeleteDevice(SDL_VideoDevice * device) SDL_KMSDRM_UnloadSymbols(); } +static int +KMSDRM_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi) +{ + int w, h; + + uint32_t display_mm_width; + uint32_t display_mm_height; + + SDL_DisplayData *dispdata; + + dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0); //viddata->devindex); + + + if (!dispdata) { + return SDL_SetError("No available displays"); + } + + display_mm_width = dispdata->connector->connector->mmWidth; + display_mm_height = dispdata->connector->connector->mmHeight; + + w = dispdata->mode.hdisplay; + h = dispdata->mode.vdisplay; + + *hdpi = display_mm_width ? (((float) w) * 25.4f / display_mm_width) : 0.0f; + *vdpi = display_mm_height ? (((float) h) * 25.4f / display_mm_height) : 0.0f; + *ddpi = SDL_ComputeDiagonalDPI(w, h, ((float) display_mm_width) / 25.4f,((float) display_mm_height) / 25.4f); + + return 0; +} + + + static SDL_VideoDevice * KMSDRM_CreateDevice(int devindex) { @@ -756,6 +788,7 @@ KMSDRM_CreateDevice(int devindex) device->VideoQuit = KMSDRM_VideoQuit; device->GetDisplayModes = KMSDRM_GetDisplayModes; device->SetDisplayMode = KMSDRM_SetDisplayMode; + device->GetDisplayDPI = KMSDRM_GetDisplayDPI; device->CreateSDLWindow = KMSDRM_CreateWindow; device->CreateSDLWindowFrom = KMSDRM_CreateWindowFrom; device->SetWindowTitle = KMSDRM_SetWindowTitle;