mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-21 16:14:12 +00:00
Potential fix for hardware-rendering high-dpi issues on Mac.
This commit is contained in:
parent
a693aa1233
commit
b8144449c6
@ -195,11 +195,11 @@ void CVideo::update_framebuffer()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find max valid pixel scale at current window size.
|
// Find max valid pixel scale at current output size.
|
||||||
point wsize(window->get_size());
|
point osize(window->get_output_size());
|
||||||
int max_scale = std::min(
|
int max_scale = std::min(
|
||||||
wsize.x / preferences::min_window_width,
|
osize.x / preferences::min_window_width,
|
||||||
wsize.y / preferences::min_window_height);
|
osize.y / preferences::min_window_height);
|
||||||
max_scale = std::min(max_scale, preferences::max_pixel_scale);
|
max_scale = std::min(max_scale, preferences::max_pixel_scale);
|
||||||
|
|
||||||
// Determine best pixel scale according to preference and window size
|
// Determine best pixel scale according to preference and window size
|
||||||
@ -207,13 +207,13 @@ void CVideo::update_framebuffer()
|
|||||||
if (preferences::auto_pixel_scale()) {
|
if (preferences::auto_pixel_scale()) {
|
||||||
// Try to match the default size (1280x720) but do not reduce below
|
// Try to match the default size (1280x720) but do not reduce below
|
||||||
int def_scale = std::min(
|
int def_scale = std::min(
|
||||||
wsize.x / preferences::def_window_width,
|
osize.x / preferences::def_window_width,
|
||||||
wsize.y / preferences::def_window_height);
|
osize.y / preferences::def_window_height);
|
||||||
scale = std::min(max_scale, def_scale);
|
scale = std::min(max_scale, def_scale);
|
||||||
// Otherwise reduce to keep below the max window size (1920x1080).
|
// Otherwise reduce to keep below the max window size (1920x1080).
|
||||||
int min_scale = std::min(
|
int min_scale = std::min(
|
||||||
wsize.x / (preferences::max_window_width+1) + 1,
|
osize.x / (preferences::max_window_width+1) + 1,
|
||||||
wsize.y / (preferences::max_window_height+1) + 1);
|
osize.y / (preferences::max_window_height+1) + 1);
|
||||||
scale = std::max(scale, min_scale);
|
scale = std::max(scale, min_scale);
|
||||||
} else {
|
} else {
|
||||||
scale = std::min(max_scale, preferences::pixel_scale());
|
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.
|
// Update logical size if it doesn't match the current resolution and scale.
|
||||||
point lsize(window->get_logical_size());
|
point lsize(window->get_logical_size());
|
||||||
point osize(window->get_output_size());
|
point wsize(window->get_size());
|
||||||
if (lsize.x != wsize.x / scale || lsize.y != wsize.y / scale) {
|
if (lsize.x != osize.x / scale || lsize.y != osize.y / scale) {
|
||||||
if (!preferences::auto_pixel_scale() && scale < preferences::pixel_scale()) {
|
if (!preferences::auto_pixel_scale() && scale < preferences::pixel_scale()) {
|
||||||
LOG_DP << "reducing pixel scale from desired "
|
LOG_DP << "reducing pixel scale from desired "
|
||||||
<< preferences::pixel_scale() << " to maximum allowable "
|
<< preferences::pixel_scale() << " to maximum allowable "
|
||||||
@ -244,8 +244,8 @@ void CVideo::update_framebuffer()
|
|||||||
|
|
||||||
// Update the drawing surface if required.
|
// Update the drawing surface if required.
|
||||||
if (!drawingSurface
|
if (!drawingSurface
|
||||||
|| drawingSurface->w != wsize.x / scale
|
|| drawingSurface->w != lsize.x
|
||||||
|| drawingSurface->h != wsize.y / scale)
|
|| drawingSurface->h != lsize.y)
|
||||||
{
|
{
|
||||||
uint32_t format = window->pixel_format();
|
uint32_t format = window->pixel_format();
|
||||||
int bpp = SDL_BITSPERPIXEL(format);
|
int bpp = SDL_BITSPERPIXEL(format);
|
||||||
@ -257,8 +257,8 @@ void CVideo::update_framebuffer()
|
|||||||
// Note: "surface" destructor automatically frees the old surface
|
// Note: "surface" destructor automatically frees the old surface
|
||||||
drawingSurface = SDL_CreateRGBSurfaceWithFormat(
|
drawingSurface = SDL_CreateRGBSurfaceWithFormat(
|
||||||
0,
|
0,
|
||||||
wsize.x / scale,
|
lsize.x,
|
||||||
wsize.y / scale,
|
lsize.y,
|
||||||
bpp,
|
bpp,
|
||||||
format
|
format
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user