From b7f62fd93836f045c208a4f966e6d92e6c34fd0c Mon Sep 17 00:00:00 2001 From: Mirek Fidler Date: Mon, 6 Apr 2026 11:34:28 +0200 Subject: [PATCH] Fixing QHD --- uppsrc/CtrlCore/CocoMM.h | 3 ++- uppsrc/Draw/ImageOp.h | 14 ++++++++------ uppsrc/Draw/Uhd.cpp | 12 ++---------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/uppsrc/CtrlCore/CocoMM.h b/uppsrc/CtrlCore/CocoMM.h index 900081660..6ba9eeb6c 100644 --- a/uppsrc/CtrlCore/CocoMM.h +++ b/uppsrc/CtrlCore/CocoMM.h @@ -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()); } diff --git a/uppsrc/Draw/ImageOp.h b/uppsrc/Draw/ImageOp.h index e63aba0aa..035c56105 100644 --- a/uppsrc/Draw/ImageOp.h +++ b/uppsrc/Draw/ImageOp.h @@ -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); diff --git a/uppsrc/Draw/Uhd.cpp b/uppsrc/Draw/Uhd.cpp index e0a41a212..725f2e424 100644 --- a/uppsrc/Draw/Uhd.cpp +++ b/uppsrc/Draw/Uhd.cpp @@ -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()