From 214ed206975ce746ee0811bc4ee197a988399e86 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 2 Jul 2017 13:46:18 +0200 Subject: [PATCH] Fix wxGCDC::Clear (wxOSX) If underlying graphics context is rotated then drawing a rectangle with origin at (0,0) doesn't cover all the drawing area. To draw over entire area we need to get extents of the actual clipping region (with applied all transformations) and use it as coordinates of the drawn rectangle. Solution for wxMSW and wxGTK was implemented in 12eaa61212eaa61930. See #17636. --- src/common/dcgraph.cpp | 24 ++---------------------- src/osx/carbon/graphics.cpp | 2 -- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index 4504ab270d..167b4d6fb8 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -1257,40 +1257,20 @@ void wxGCDCImpl::Clear(void) m_graphicContext->SetPen( p ); wxCompositionMode formerMode = m_graphicContext->GetCompositionMode(); m_graphicContext->SetCompositionMode(wxCOMPOSITION_SOURCE); - #ifdef __WXOSX__ - // This is a legacy implementation which doesn't take advantage - // of clipping region bounds retrieved by wxMacCoreGraphicsContext::GetClipBox - // because this function is not yet verified. - // Note: Legacy implmentation might not work work properly - // if graphics context is rotated - // TODO: Do the tests of wxMacCoreGraphicsContext::GetClipBox - // and switch to the implmenentation used by other renderers (code below). - // - // maximum positive coordinate Cairo can handle is 2^23 - 1 - // Use a value slightly less than this to be sure we avoid the limit - DoDrawRectangle( - DeviceToLogicalX(0), DeviceToLogicalY(0), - DeviceToLogicalXRel(0x800000 - 64), DeviceToLogicalYRel(0x800000 - 64)); - #else + double x, y, w, h; m_graphicContext->GetClipBox(&x, &y, &w, &h); m_graphicContext->DrawRectangle(x, y, w, h); - #endif // __WXOSX__ / !__WXOSX__ + m_graphicContext->SetCompositionMode(formerMode); m_graphicContext->SetPen( m_pen ); m_graphicContext->SetBrush( m_brush ); } else { -#ifdef __WXOSX__ - // same comment as above applies - m_graphicContext->ClearRectangle(DeviceToLogicalX(0), DeviceToLogicalY(0), - DeviceToLogicalXRel(0x8000 - 64), DeviceToLogicalYRel(0x8000 - 64)); -#else double x, y, w, h; m_graphicContext->GetClipBox(&x, &y, &w, &h); m_graphicContext->ClearRectangle(x, y, w, h); -#endif } } diff --git a/src/osx/carbon/graphics.cpp b/src/osx/carbon/graphics.cpp index 7f71a30ea0..a69f1370ac 100644 --- a/src/osx/carbon/graphics.cpp +++ b/src/osx/carbon/graphics.cpp @@ -1906,8 +1906,6 @@ void wxMacCoreGraphicsContext::ResetClip() void wxMacCoreGraphicsContext::GetClipBox(wxDouble* x, wxDouble* y, wxDouble* w, wxDouble* h) { - // This function is not yet tested. - // TODO: Do the tests. CGRect r; if ( m_cgContext )