From c7a498a163ffa2c020ddbd5ec90535ec4fa3c16b Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 10 Apr 2016 20:40:33 +0200 Subject: [PATCH] Fixed reporting transformation settings from wxGraphicsContext with Cairo renderer (GTK+ 3). When wxGraphicsContext is created from wxWindowDC or wxMemoryDC then transformation settings applied initially to the underlying source Cairo context need to be stored (in a dedicated variable) in order to have ability to determine what transformations were applied to wxGC instance since its creation. Only these explicitly applied transformations are reported by GetTransform(). Closes #17491. --- src/generic/graphicc.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/generic/graphicc.cpp b/src/generic/graphicc.cpp index 48ff657996..b02f4df8af 100644 --- a/src/generic/graphicc.cpp +++ b/src/generic/graphicc.cpp @@ -1776,15 +1776,17 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxWindowDC& #ifdef __WXGTK3__ cairo_t* cr = static_cast(dc.GetImpl()->GetCairoContext()); - if (cr) - Init(cairo_reference(cr)); + Init(cr ? cairo_reference(cr) : NULL); + // Store transformation settings of the underlying source context. + if ( m_context ) + cairo_get_matrix(m_context, &m_internalTransform); #elif defined __WXGTK20__ wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl(); Init( gdk_cairo_create( impldc->GetGDKWindow() ) ); // Transfer transformation settings from source DC to Cairo context on our own. ApplyTransformFromDC(dc); -#endif +#endif // __WXGTK3__ || __WXGTK20__ #ifdef __WXX11__ cairo_t* cr = static_cast(dc.GetImpl()->GetCairoContext()); @@ -1936,15 +1938,17 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxMemoryDC& #ifdef __WXGTK3__ cairo_t* cr = static_cast(dc.GetImpl()->GetCairoContext()); - if (cr) - Init(cairo_reference(cr)); + Init(cr ? cairo_reference(cr) : NULL); + // Store transformation settings of the underlying source context. + if ( m_context ) + cairo_get_matrix(m_context, &m_internalTransform); #elif defined __WXGTK20__ wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl(); Init( gdk_cairo_create( impldc->GetGDKWindow() ) ); // Transfer transformation settings from source DC to Cairo context on our own. ApplyTransformFromDC(dc); -#endif +#endif // __WXGTK3__ || __WXGTK20__ #ifdef __WXX11__ cairo_t* cr = static_cast(dc.GetImpl()->GetCairoContext()); @@ -2101,9 +2105,11 @@ void wxCairoContext::Init(cairo_t *context) { m_context = context; cairo_matrix_init_identity(&m_internalTransform); - - PushState(); - PushState(); + if ( m_context ) + { + PushState(); + PushState(); + } } void wxCairoContext::ApplyTransformFromDC(const wxDC& dc)