Fix setting wxGCDC clipping region with device coordinates (wxOSX)

Currently region given in device coordinates is decomposed into the stripes which are next transformed to the logical coordinates required by underlying wxGraphicsContext::Clip() function. Some of these stripes given in device coordinates can have 1-pixel height what after transformation to logical coordinates can give zero-height stripes (after rounding). This can lead to the situation that in the region transformed to logical coordinates some stripes can disappear and final transformed region shape is different from the source shape (it has gaps).
To fix this issue device coordinates of the region are not manually transformed to the logical coordinates but instead wxGraphicsContext's is temporarily set to the state where its logical coordinates are equivalent to device coordinates and thus clipping region can be applied directly.
Solution for wxMSW, wxGTK is implemented in ea8cb7a24a.

Closes #17609.
This commit is contained in:
Artur Wieczorek
2017-07-02 14:43:50 +02:00
parent a9fcfe1085
commit c55bbdf700
2 changed files with 1 additions and 17 deletions

View File

@@ -342,22 +342,6 @@ void wxGCDCImpl::DoSetDeviceClippingRegion( const wxRegion &region )
// region is in device coordinates
wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoSetDeviceClippingRegion - invalid DC") );
#ifdef __WXOSX__
// This is a legacy implementation without
// full conversion from device to logical coordinates
// (only offset of the origin is taken into account,
// but e.g. scale is not).
// Solution with full conversion doesn't seem to work under WXOSX.
// TODO: Check wxMacCoreGraphics::Clip() and GetClipBox()
// and switch to the code used by other renderers (below).
wxRegion logRegion(region);
logRegion.Offset(DeviceToLogicalX(0), DeviceToLogicalY(0));
m_graphicContext->Clip(logRegion);
wxRect newRegion = logRegion.GetBox();
wxDCImpl::DoSetClippingRegion(newRegion.GetLeft(), newRegion.GetTop(),
newRegion.GetWidth(), newRegion.GetHeight());
#else
// Because graphics context works with logical coordinates
// and clipping region is given in device coordinates
// we need temporarily reset graphics context's coordinate system
@@ -378,7 +362,6 @@ void wxGCDCImpl::DoSetDeviceClippingRegion( const wxRegion &region )
m_clipping = true;
UpdateClipBox();
#endif // __WXOSX__ / !__WXOSX__
}
void wxGCDCImpl::DestroyClippingRegion()