Use mac_max_scaling_factor() in create_scaled_bitmap()

This commit is contained in:
Vojtech Kral 2019-05-17 19:12:52 +02:00
parent 5161dc43d6
commit b234a1b7a7
2 changed files with 16 additions and 3 deletions

View file

@ -1,6 +1,7 @@
#include "wxExtensions.hpp"
#include <stdexcept>
#include <cmath>
#include "libslic3r/Utils.hpp"
#include "libslic3r/Model.hpp"
@ -19,6 +20,7 @@
#include "libslic3r/GCode/PreviewData.hpp"
#include "I18N.hpp"
#include "GUI_Utils.hpp"
#include "../Utils/MacDarkMode.hpp"
using Slic3r::GUI::from_u8;
@ -389,7 +391,15 @@ wxBitmap create_scaled_bitmap(wxWindow *win, const std::string& bmp_name_in,
static Slic3r::GUI::BitmapCache cache;
#ifdef __APPLE__
const float scale_factor = win != nullptr ? win->GetContentScaleFactor() : 1.0f;
// Note: win->GetContentScaleFactor() is not used anymore here because it tends to
// return bogus results quite often (such as 1.0 on Retina or even 0.0).
// We're using the max scaling factor across all screens because it's very likely to be good enough.
static float max_scaling_factor = NAN;
if (std::isnan(max_scaling_factor)) {
max_scaling_factor = Slic3r::GUI::mac_max_scaling_factor();
}
const float scale_factor = win != nullptr ? max_scaling_factor : 1.0f;
#else
(void)(win);
const float scale_factor = 1.0f;