Fixing QHD

This commit is contained in:
Mirek Fidler 2026-04-06 11:34:28 +02:00
parent 69e851e87a
commit b7f62fd938
3 changed files with 12 additions and 17 deletions

View file

@ -112,8 +112,9 @@ inline Upp::Rect MakeRect(const CGRect& r, int dpi) {
}
inline CGRect CGRectDPI(const Upp::Rect& r) {
double sc = GetDPIUnScaleRatio();
if(Upp::IsUHDMode())
return CGRectMake(0.5 * r.left, 0.5 * r.top, 0.5 * r.GetWidth(), 0.5 * r.GetHeight());
return CGRectMake(sc * r.left, sc * r.top, sc * r.GetWidth(), sc * r.GetHeight());
else
return CGRectMake(r.left, r.top, r.GetWidth(), r.GetHeight());
}

View file

@ -278,15 +278,17 @@ enum {
};
void SetDPIScale(int scale);
int GetDPIScale();
double GetDPIScaleRatio();
void SyncDPIScale();
inline int DPI(int a) { extern int DPIScaleGlobal_; return (DPIScaleGlobal_ * a) >> 1; }
inline double DPI(double a) { extern double DPIScaleGlobalF_; return DPIScaleGlobalF_ * a; }
inline int GetDPIScale() { extern int DPIScaleGlobal_; return DPIScaleGlobal_; }
inline double GetDPIScaleRatio() { extern double DPIScaleGlobalF_; return DPIScaleGlobalF_; }
inline double GetDPIUnScaleRatio() { extern double IDPIScaleGlobalF_; return IDPIScaleGlobalF_; }
inline Size DPI(int cx, int cy) { return Size(DPI(cx), DPI(cy)); }
inline Size DPI(Size sz) { return DPI(sz.cx, sz.cy); }
inline int DPI(int a) { return (GetDPIScale() * a) >> 1; }
inline double DPI(double a) { return GetDPIScaleRatio() * a; }
inline Size DPI(int cx, int cy) { return Size(DPI(cx), DPI(cy)); }
inline Size DPI(Size sz) { return DPI(sz.cx, sz.cy); }
int ImlFlagsToDPIScale(int imlflags);
int DPIScaleToImlFlags(int dpiscale);

View file

@ -160,22 +160,14 @@ Image Downscale6x(const Image& src)
int DPIScaleGlobal_;
double DPIScaleGlobalF_;
double IDPIScaleGlobalF_;
void SetDPIScale(int scale)
{
Iml::ResetAll();
DPIScaleGlobal_ = scale;
DPIScaleGlobalF_ = 0.5 * scale;
}
int GetDPIScale()
{
return DPIScaleGlobal_;
}
double GetDPIScaleRatio()
{
return DPIScaleGlobalF_;
IDPIScaleGlobalF_ = 1 / DPIScaleGlobalF_;
}
void SyncDPIScale()