X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8a438f46b50a70cff345870e1324226dc7809f0a..3d7a1b394baa3255d084c877b5caae4b29720a12:/src/mac/carbon/dcclient.cpp diff --git a/src/mac/carbon/dcclient.cpp b/src/mac/carbon/dcclient.cpp index 7023f8cc9f..27164c2c9e 100644 --- a/src/mac/carbon/dcclient.cpp +++ b/src/mac/carbon/dcclient.cpp @@ -112,6 +112,9 @@ static wxBrush MacGetBackgroundBrush( wxWindow* window ) wxWindowDC::wxWindowDC() { m_window = NULL ; +#if wxMAC_USE_CORE_GRAPHICS + m_release = false; +#endif } wxWindowDC::wxWindowDC(wxWindow *window) @@ -142,8 +145,6 @@ wxWindowDC::wxWindowDC(wxWindow *window) SetGraphicsContext( wxGraphicsContext::CreateFromNative( cg ) ); } - m_graphicContext->SetPen( m_pen ) ; - m_graphicContext->SetBrush( m_brush ) ; SetClippingRegion( 0 , 0 , m_width , m_height ) ; #else int x , y ; @@ -165,11 +166,12 @@ wxWindowDC::wxWindowDC(wxWindow *window) wxWindowDC::~wxWindowDC() { #if wxMAC_USE_CORE_GRAPHICS - if ( m_release && m_graphicContext ) + if ( m_release ) { + // this must not necessarily be the current context, we must restore the state of the + // cg we started with above (before the CGContextTranslateCTM call) CGContextRef cg = (CGContextRef) m_window->MacGetCGContextRef(); CGContextRestoreGState(cg); - //CGContextRef cg = (CGContextRef) m_graphicContext->GetNativeContext() ; } #endif } @@ -189,6 +191,11 @@ void wxWindowDC::DoGetSize( int* width, int* height ) const wxBitmap wxWindowDC::DoGetAsBitmap(const wxRect *subrect) const { + // wxScreenDC is derived from wxWindowDC, so a screen dc will + // call this method when a Blit is performed with it as a source. + if (!m_window) + return wxNullBitmap; + ControlRef handle = (ControlRef) m_window->GetHandle(); if ( !handle ) return wxNullBitmap;