Consistently set m_enableOffset for wxMacCoreGraphicsContext

Previously it was set to true if content scale factor was less or equal
to 1 in some places or if it was strictly less than 2 in some others.

Fix this by adding a new helper SetEnableOffsetFromScaleFactor()
function and using it everywhere to consistently only enable offset for
non-high DPI displays in all cases.
This commit is contained in:
Vadim Zeitlin
2018-11-10 23:29:54 +01:00
parent 5b891e9ffc
commit c252ececda

View File

@@ -1315,6 +1315,12 @@ public:
~wxMacCoreGraphicsContext();
// Enable offset on non-high DPI displays, i.e. those with scale factor <= 1.
void SetEnableOffsetFromScaleFactor(double factor)
{
m_enableOffset = factor <= 1.0;
}
void Init();
virtual void StartPage( wxDouble width, wxDouble height ) wxOVERRIDE;
@@ -1533,7 +1539,7 @@ wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxGraphicsRenderer* renderer
{
Init();
m_enableOffset = window->GetContentScaleFactor() <= 1;
SetEnableOffsetFromScaleFactor(window->GetContentScaleFactor());
wxSize sz = window->GetSize();
m_width = sz.x;
m_height = sz.y;
@@ -2715,7 +2721,7 @@ wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxWindowDC&
CGContextRef cgctx = (CGContextRef)(win->MacGetCGContextRef());
wxMacCoreGraphicsContext *context =
new wxMacCoreGraphicsContext( this, cgctx, sz.x, sz.y, win );
context->EnableOffset(dc.GetContentScaleFactor() < 2);
context->SetEnableOffsetFromScaleFactor(dc.GetContentScaleFactor());
return context;
}
@@ -2730,7 +2736,7 @@ wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateContext( const wxMemoryDC&
mem_impl->GetSize( &w, &h );
wxMacCoreGraphicsContext* context = new wxMacCoreGraphicsContext( this,
(CGContextRef)(mem_impl->GetGraphicsContext()->GetNativeContext()), (wxDouble) w, (wxDouble) h );
context->EnableOffset(dc.GetContentScaleFactor() < 2);
context->SetEnableOffsetFromScaleFactor(dc.GetContentScaleFactor());
return context;
}
#endif