12 double AspectRatio,
double RefreshRate)
13 : m_width(Resolution.width()),
14 m_height(Resolution.height()),
15 m_widthMM(PhysicalSize.width()),
16 m_heightMM(PhysicalSize.height())
23 double AspectRatio,
double RefreshRate)
129 return (
static_cast<uint64_t
>(Size.width()) << 34) |
130 (
static_cast<uint64_t
>(Size.height()) << 18) |
131 (
static_cast<uint64_t
>(Rate * 1000.0));
137 return qAbs(First - Second) < Precision;
143 double videorate =
Mode.RefreshRate();
148 if ((videorate > 24.5) && (videorate < 30.5))
155 for (
size_t i = 0; i < Modes.size(); ++i)
157 if (Modes[i].
Width() ==
Mode.Width() && Modes[i].Height() ==
Mode.Height())
159 auto rates = Modes[i].RefreshRates();
160 if (!rates.empty() && !qFuzzyCompare(videorate + 1.0, 1.0))
164 for (
double precision : { 0.001, 0.01, 0.1 })
166 for (
double rate : rates)
170 (qAbs(videorate - fmod(rate, videorate))
172 (fmod(rate,videorate) <= precision))
175 return static_cast<int>(i);
181 for (
double precision : { 0.01, 0.1, 1.0 })
183 double rounded = round(videorate);
184 for (
double rate : rates)
188 (qAbs(rounded - fmod(rate, rounded)) <= precision) ||
189 (fmod(rate,rounded) <= precision))
192 return static_cast<int>(i);
206 TargetRate = rates[rates.size() - 1];
208 else if (!rates.empty())
210 TargetRate = rates[rates.size() - 1];
212 return static_cast<int>(i);
218 static void extract_key(uint64_t key,
double& rate,
int& height,
int& width)
220 rate = (key & ((1 << 18) - 1)) / 1000.0;
221 height = (key >> 18) & ((1 << 16) - 1);
222 width = (key >> 34) & ((1 << 16) - 1);
226 int Width,
int Height,
double Rate)
234 for (
const auto & it : Map)
244 for (
const auto & it : Map)
250 if (width ==
Width && height ==
Height && qFuzzyCompare(rate + 1.0, 1.0))
254 for (
const auto & it : Map)
260 if ((width == 0 && height ==
Height &&
261 (
CompareRates(Rate, rate, 0.01) || qFuzzyCompare(rate + 1.0, 1.0))) ||
262 (width == 0 && height == 0 &&
CompareRates(Rate, rate * 2.0, 0.01)) ||
263 (width == 0 && height == 0 &&
CompareRates(Rate, rate, 0.01)))
276 rates << QString::number(rate,
'f', 2);
277 return QObject::tr(
"%1x%2@%3Hz").arg(
m_width).arg(
m_height).arg(rates.join(
", "));