Fixed creating wxPrinterDC from wxGraphicsContext with Cairo renderer (GTK).
When wxGraphicsContext is created from wxPrinterDC then also logical scaling factor applied to the source wxPrinterDC has to be explicitly applied to the Cairo context. All inherited transformation settings should be used only internally by wxGraphicsContext object and shouldn't be exposed through e.g. GetTransform() function and hence they are stored separately (in a dedicated variable) and "subtracted" from actual transformation settings for reporting purposes. Closes #17496.
This commit is contained in:
@@ -1759,35 +1759,17 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxPrinterDC&
|
|||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
const wxDCImpl *impl = dc.GetImpl();
|
const wxDCImpl *impl = dc.GetImpl();
|
||||||
cairo_t* cr = static_cast<cairo_t*>(impl->GetCairoContext());
|
cairo_t* cr = static_cast<cairo_t*>(impl->GetCairoContext());
|
||||||
if (cr)
|
Init(cr ? cairo_reference(cr) : NULL);
|
||||||
Init(cairo_reference(cr));
|
|
||||||
else
|
|
||||||
m_context = NULL;
|
|
||||||
|
|
||||||
wxSize sz = dc.GetSize();
|
wxSize sz = dc.GetSize();
|
||||||
m_width = sz.x;
|
m_width = sz.x;
|
||||||
m_height = sz.y;
|
m_height = sz.y;
|
||||||
|
|
||||||
wxPoint org = dc.GetDeviceOrigin();
|
// Store transformation settings of the underlying source context.
|
||||||
cairo_translate( m_context, org.x, org.y );
|
if ( m_context )
|
||||||
|
cairo_get_matrix(m_context, &m_internalTransform);
|
||||||
double sx,sy;
|
// Transfer transformation settings from source DC to Cairo context.
|
||||||
dc.GetUserScale( &sx, &sy );
|
ApplyTransformFromDC(dc);
|
||||||
|
|
||||||
// TODO: Determine if these fixes are needed on other platforms too.
|
|
||||||
// On MSW, without this the printer context will not respect wxDC SetMapMode calls.
|
|
||||||
// For example, using dc.SetMapMode(wxMM_POINTS) can let us share printer and screen
|
|
||||||
// drawing code
|
|
||||||
#ifdef __WXMSW__
|
|
||||||
double lsx,lsy;
|
|
||||||
dc.GetLogicalScale( &lsx, &lsy );
|
|
||||||
sx *= lsx;
|
|
||||||
sy *= lsy;
|
|
||||||
#endif
|
|
||||||
cairo_scale( m_context, sx, sy );
|
|
||||||
|
|
||||||
org = dc.GetLogicalOrigin();
|
|
||||||
cairo_translate( m_context, -org.x, -org.y );
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user