- wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::DoBlit - invalid DC") );
- wxCHECK_MSG( source->Ok(), false, wxT("wxGCDC(cg)::DoBlit - invalid source DC") );
-
- if ( logical_func == wxNO_OP )
- return true;
-
- if (xsrcMask == -1 && ysrcMask == -1)
- {
- xsrcMask = xsrc;
- ysrcMask = ysrc;
- }
-
- wxCoord yysrc = source-> LogicalToDeviceY(ysrc);
- wxCoord xxsrc = source-> LogicalToDeviceX(xsrc);
- wxCoord wwsrc = source-> LogicalToDeviceXRel(width);
- wxCoord hhsrc = source-> LogicalToDeviceYRel(height);
-
- wxCoord yydest = LogicalToDeviceY(ydest);
- wxCoord xxdest = LogicalToDeviceX(xdest);
- wxCoord wwdest = LogicalToDeviceXRel(width);
- wxCoord hhdest = LogicalToDeviceYRel(height);
-
- wxMemoryDC* memdc = dynamic_cast<wxMemoryDC*>(source);
- if ( memdc && logical_func == wxCOPY )
- {
- wxBitmap 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;
- }
- }
-
- if ( blit.Ok() )
- {
- m_graphicContext->DrawBitmap( blit, xxdest , yydest , wwdest , hhdest );
- }
- }