Fix drawing on wxDC when using right-to-left layout in wxMSW.
Avoid integer overflow when setting wxDC scale. This affected (i.e. broke) drawing in RTL but probably not only that. Closes #16254. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77020 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1959,6 +1959,16 @@ void wxMSWDCImpl::RealizeScaleAndOrigin()
|
|||||||
ApplyEffectiveScale(m_scaleX, m_signX, &devExtX, &logExtX);
|
ApplyEffectiveScale(m_scaleX, m_signX, &devExtX, &logExtX);
|
||||||
ApplyEffectiveScale(m_scaleY, m_signY, &devExtY, &logExtY);
|
ApplyEffectiveScale(m_scaleY, m_signY, &devExtY, &logExtY);
|
||||||
|
|
||||||
|
// In GDI anisotropic mode only devExt/logExt ratio is important
|
||||||
|
// so we can reduce the fractions to avoid large numbers
|
||||||
|
// which could cause arithmetic overflows inside Win API.
|
||||||
|
unsigned int gcd = wxGCD(abs(devExtX), abs(logExtX));
|
||||||
|
devExtX /= gcd;
|
||||||
|
logExtX /= gcd;
|
||||||
|
gcd = wxGCD(abs(devExtY), abs(logExtY));
|
||||||
|
devExtY /= gcd;
|
||||||
|
logExtY /= gcd;
|
||||||
|
|
||||||
::SetViewportExtEx(GetHdc(), devExtX, devExtY, NULL);
|
::SetViewportExtEx(GetHdc(), devExtX, devExtY, NULL);
|
||||||
::SetWindowExtEx(GetHdc(), logExtX, logExtY, NULL);
|
::SetWindowExtEx(GetHdc(), logExtX, logExtY, NULL);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user