Removed SDL_GetDisplayDPI()

This function wasn't consistently correct across platforms and devices.

If you want the UI scale factor, you can use display_scale in the structure returned by SDL_GetDesktopDisplayMode(). If you need an approximate DPI, you can multiply this value times 160 on iPhone and Android, and 96 on other platforms.
This commit is contained in:
Sam Lantinga 2023-02-08 15:07:13 -08:00
parent b7c6fec10a
commit 824b9b0a58
28 changed files with 32 additions and 542 deletions

View file

@ -1187,8 +1187,6 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
if (state->verbose & VERBOSE_MODES) {
SDL_DisplayID *displays;
SDL_Rect bounds, usablebounds;
float hdpi = 0;
float vdpi = 0;
const SDL_DisplayMode **modes;
const SDL_DisplayMode *mode;
int bpp;
@ -1209,11 +1207,8 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
SDL_zero(usablebounds);
SDL_GetDisplayUsableBounds(displayID, &usablebounds);
SDL_GetDisplayPhysicalDPI(displayID, NULL, &hdpi, &vdpi);
SDL_Log("Bounds: %dx%d at %d,%d\n", bounds.w, bounds.h, bounds.x, bounds.y);
SDL_Log("Usable bounds: %dx%d at %d,%d\n", usablebounds.w, usablebounds.h, usablebounds.x, usablebounds.y);
SDL_Log("DPI: %gx%g\n", hdpi, vdpi);
mode = SDL_GetDesktopDisplayMode(displayID);
SDL_GetMasksForPixelFormatEnum(mode->format, &bpp, &Rmask, &Gmask,
@ -2301,7 +2296,6 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl
float fx, fy;
SDL_Rect rect;
const SDL_DisplayMode *mode;
float ddpi, hdpi, vdpi;
float scaleX, scaleY;
Uint32 flags;
SDL_DisplayID windowDisplayID = SDL_GetDisplayForWindow(window);
@ -2437,13 +2431,6 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl
textY += lineHeight;
}
if (0 == SDL_GetDisplayPhysicalDPI(windowDisplayID, &ddpi, &hdpi, &vdpi)) {
(void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayPhysicalDPI: ddpi: %g, hdpi: %g, vdpi: %g",
ddpi, hdpi, vdpi);
SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight;
}
(void)SDL_snprintf(text, sizeof text, "SDL_GetDisplayOrientation: ");
SDLTest_PrintDisplayOrientation(text, sizeof text, SDL_GetDisplayOrientation(windowDisplayID));
SDLTest_DrawString(renderer, 0.0f, textY, text);