X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0ebd9515e5df4a756d27eea9ea9ee9ac193dd7bd..8d1517cef26509f5b2fca218145af4e4db7a4be2:/src/common/dcgraph.cpp diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index c9889d2d39..be08d5b29c 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -61,15 +61,17 @@ void wxGCDC::SetGraphicsContext( wxGraphicsContext* ctx ) { delete m_graphicContext; m_graphicContext = ctx; - m_matrixOriginal = m_graphicContext->GetTransform(); + if ( m_graphicContext ) + { + m_matrixOriginal = m_graphicContext->GetTransform(); + m_ok = true; + } } wxGCDC::wxGCDC(const wxWindowDC& dc) { Init(); - m_graphicContext = wxGraphicsContext::Create(dc); - m_matrixOriginal = m_graphicContext->GetTransform(); - m_ok = true; + SetGraphicsContext( wxGraphicsContext::Create(dc) ); if ( dc.GetFont().Ok()) m_graphicContext->SetFont( m_graphicContext->CreateFont(dc.GetFont(),dc.GetTextForeground())); if ( dc.GetPen().Ok()) @@ -291,12 +293,11 @@ void wxGCDC::ComputeScaleAndOrigin() { m_scaleX = m_logicalScaleX * m_userScaleX; m_scaleY = m_logicalScaleY * m_userScaleY; - m_deviceOriginX = /* m_deviceOriginX + */ m_logicalOriginX; - m_deviceOriginY = /* m_deviceOriginY + */ m_logicalOriginY; m_matrixCurrent = m_graphicContext->CreateMatrix(); - m_matrixCurrent.Translate( m_deviceOriginX , m_deviceOriginY ); + m_matrixCurrent.Translate( m_deviceOriginX, m_deviceOriginY ); m_matrixCurrent.Scale( m_scaleX, m_scaleY ); + m_matrixCurrent.Translate( m_logicalOriginX, m_logicalOriginY ); m_graphicContext->SetTransform( m_matrixOriginal ); m_graphicContext->ConcatTransform( m_matrixCurrent ); @@ -715,59 +716,11 @@ bool wxGCDC::DoBlit( ysrcMask = ysrc; } - wxCoord yysrc = source-> LogicalToDeviceY(ysrc); - wxCoord xxsrc = source-> LogicalToDeviceX(xsrc); - wxCoord wwsrc = source-> LogicalToDeviceXRel(width); - wxCoord hhsrc = source-> LogicalToDeviceYRel(height); - - wxBitmap blit; - wxMemoryDC* memdc = wxDynamicCast(source,wxMemoryDC); - if ( memdc ) - { - blit = memdc->GetSelectedBitmap(); - - wxASSERT_MSG( blit.Ok() , wxT("Invalid bitmap for blitting") ); - - wxCoord bmpwidth = blit.GetWidth(); - wxCoord bmpheight = blit.GetHeight(); - - if ( xxsrc != 0 || yysrc != 0 || bmpwidth != wwsrc || bmpheight != hhsrc ) - { - wwsrc = wxMin( wwsrc , bmpwidth - xxsrc ); - hhsrc = wxMin( hhsrc , bmpheight - yysrc ); - if ( wwsrc > 0 && hhsrc > 0 ) - { - if ( xxsrc >= 0 && yysrc >= 0 ) - { - wxRect subrect( xxsrc, yysrc, wwsrc , hhsrc ); - // TODO we perhaps could add a DrawSubBitmap call to dc for performance reasons - blit = blit.GetSubBitmap( subrect ); - } - else - { - // in this case we'd probably have to adjust the different coordinates, but - // we have to find out proper contract first - blit = wxNullBitmap; - } - } - else - { - blit = wxNullBitmap; - } - } - } - else - { - wxWindowDC* windc = wxDynamicCast(source,wxWindowDC); - if (windc) - { - wxBitmap bmp; - bmp = windc->GetAsBitmap(); - if (bmp.IsOk()) - blit = bmp.GetSubBitmap( wxRect(xsrc, ysrc, width, height ) ); - } - } - + wxRect subrect(source-> LogicalToDeviceX(xsrc),source-> LogicalToDeviceY(ysrc), + source-> LogicalToDeviceXRel(width),source-> LogicalToDeviceYRel(height)); + + wxBitmap blit = source->GetAsBitmap( &subrect ); + if ( blit.Ok() ) { m_graphicContext->DrawBitmap( blit, xdest , ydest , width , height );