Fixed creating wxGraphicsContext from wxPrinterDC with Cairo (MSW).

Modification of the mapping mode of underlying DC encapsulated in wxPrinterDC (from MM_ANISOTROPIC to MM_TEXT) which is done prior to creating Cairo context affects the value of device origin which needs to be applied to the Cairo context. Due to the change of the mapping mode it has to be rescaled based on the current scaling factor value.

See #17496.
This commit is contained in:
Artur Wieczorek
2016-04-16 21:06:03 +02:00
parent fe716b3c8e
commit 9a215bb393

View File

@@ -1746,7 +1746,15 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxPrinterDC&
::SetMapMode(hdc, MM_TEXT);
m_mswSurface = cairo_win32_printing_surface_create(hdc);
Init( cairo_create(m_mswSurface) );
#endif
wxSize sz = dc.GetSize();
m_width = sz.x;
m_height = sz.y;
// Transfer transformation settings from source DC to Cairo context on our own.
// Since we switched from MM_ANISOTROPIC to MM_TEXT mapping mode
// we have to apply rescaled DC's device origin to Cairo context.
ApplyTransformFromDC(dc, Apply_scaled_dev_origin);
#endif // __WXMSW__
#ifdef __WXGTK20__
const wxDCImpl *impl = dc.GetImpl();
@@ -1755,7 +1763,7 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxPrinterDC&
Init(cairo_reference(cr));
else
m_context = NULL;
#endif
wxSize sz = dc.GetSize();
m_width = sz.x;
m_height = sz.y;
@@ -1780,6 +1788,7 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxPrinterDC&
org = dc.GetLogicalOrigin();
cairo_translate( m_context, -org.x, -org.y );
#endif
}
#endif