Potential fix for hardware-rendering high-dpi issues on Mac.

This commit is contained in:
Tommy 2022-05-19 15:51:00 +12:00 committed by Pentarctagon
parent a693aa1233
commit b8144449c6

View File

@ -195,11 +195,11 @@ void CVideo::update_framebuffer()
return;
}
// Find max valid pixel scale at current window size.
point wsize(window->get_size());
// Find max valid pixel scale at current output size.
point osize(window->get_output_size());
int max_scale = std::min(
wsize.x / preferences::min_window_width,
wsize.y / preferences::min_window_height);
osize.x / preferences::min_window_width,
osize.y / preferences::min_window_height);
max_scale = std::min(max_scale, preferences::max_pixel_scale);
// Determine best pixel scale according to preference and window size
@ -207,13 +207,13 @@ void CVideo::update_framebuffer()
if (preferences::auto_pixel_scale()) {
// Try to match the default size (1280x720) but do not reduce below
int def_scale = std::min(
wsize.x / preferences::def_window_width,
wsize.y / preferences::def_window_height);
osize.x / preferences::def_window_width,
osize.y / preferences::def_window_height);
scale = std::min(max_scale, def_scale);
// Otherwise reduce to keep below the max window size (1920x1080).
int min_scale = std::min(
wsize.x / (preferences::max_window_width+1) + 1,
wsize.y / (preferences::max_window_height+1) + 1);
osize.x / (preferences::max_window_width+1) + 1,
osize.y / (preferences::max_window_height+1) + 1);
scale = std::max(scale, min_scale);
} else {
scale = std::min(max_scale, preferences::pixel_scale());
@ -221,8 +221,8 @@ void CVideo::update_framebuffer()
// Update logical size if it doesn't match the current resolution and scale.
point lsize(window->get_logical_size());
point osize(window->get_output_size());
if (lsize.x != wsize.x / scale || lsize.y != wsize.y / scale) {
point wsize(window->get_size());
if (lsize.x != osize.x / scale || lsize.y != osize.y / scale) {
if (!preferences::auto_pixel_scale() && scale < preferences::pixel_scale()) {
LOG_DP << "reducing pixel scale from desired "
<< preferences::pixel_scale() << " to maximum allowable "
@ -244,8 +244,8 @@ void CVideo::update_framebuffer()
// Update the drawing surface if required.
if (!drawingSurface
|| drawingSurface->w != wsize.x / scale
|| drawingSurface->h != wsize.y / scale)
|| drawingSurface->w != lsize.x
|| drawingSurface->h != lsize.y)
{
uint32_t format = window->pixel_format();
int bpp = SDL_BITSPERPIXEL(format);
@ -257,8 +257,8 @@ void CVideo::update_framebuffer()
// Note: "surface" destructor automatically frees the old surface
drawingSurface = SDL_CreateRGBSurfaceWithFormat(
0,
wsize.x / scale,
wsize.y / scale,
lsize.x,
lsize.y,
bpp,
format
);