X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8bf30fe9b0b40d1a6f54608588121212c2c4e037..87df17a11b0017d31c09f767bd921abb27193bee:/src/msw/dc.cpp diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 86e1a772cf..faa71428b5 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -40,6 +40,7 @@ #include "wx/icon.h" #endif +#include "wx/settings.h" #include "wx/dcprint.h" #include @@ -275,12 +276,29 @@ void wxDC::SelectOldObjects(WXHDC dc) m_clipY2 = (wxCoord) YDEV2LOG(rect.bottom); \ } -void wxDC::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch) +void wxDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h) { m_clipping = TRUE; - IntersectClipRect(GetHdc(), XLOG2DEV(cx), YLOG2DEV(cy), - XLOG2DEV(cx + cw), YLOG2DEV(cy + ch)); - DO_SET_CLIPPING_BOX() + + // the region coords are always the device ones, so do the translation + // manually + HRGN hrgn = ::CreateRectRgn(LogicalToDeviceX(x), + LogicalToDeviceY(y), + LogicalToDeviceX(x + w), + LogicalToDeviceY(y + h)); + if ( !hrgn ) + { + wxLogLastError(_T("CreateRectRgn")); + } + else + { + if ( ::SelectClipRgn(GetHdc(), hrgn) == ERROR ) + { + wxLogLastError(_T("SelectClipRgn")); + } + + DO_SET_CLIPPING_BOX() + } } void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region) @@ -768,16 +786,23 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask if ( useMask ) { #ifdef __WIN32__ - HDC hdcMem = ::CreateCompatibleDC(GetHdc()); - ::SelectObject(hdcMem, GetHbitmapOf(bmp)); - // use MaskBlt() with ROP which doesn't do anything to dst in the mask // points - bool ok = ::MaskBlt(GetHdc(), x, y, width, height, + // On some systems, MaskBlt succeeds yet is much much slower + // than the wxWindows fall-back implementation. So we need + // to be able to switch this on and off at runtime. + bool ok = FALSE; + if (wxSystemSettings::GetOptionInt(wxT("no-maskblt")) == 0) + { + HDC hdcMem = ::CreateCompatibleDC(GetHdc()); + ::SelectObject(hdcMem, GetHbitmapOf(bmp)); + + ok = ::MaskBlt(GetHdc(), x, y, width, height, hdcMem, 0, 0, hbmpMask, 0, 0, MAKEROP4(SRCCOPY, DSTCOPY)) != 0; - ::DeleteDC(hdcMem); + ::DeleteDC(hdcMem); + } if ( !ok ) #endif // Win32 @@ -1171,7 +1196,7 @@ void wxDC::SetRop(WXHDC dc) SetROP2(GetHdc(), rop); } -bool wxDC::StartDoc(const wxString& message) +bool wxDC::StartDoc(const wxString& WXUNUSED(message)) { // We might be previewing, so return TRUE to let it continue. return TRUE; @@ -1458,7 +1483,7 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, return FALSE; } - bool success; + bool success = FALSE; if (useMask) { @@ -1467,10 +1492,17 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, // transparent, so use "DSTCOPY" ROP for the mask points (the usual // meaning of fg and bg is inverted which corresponds to wxWin notion // of the mask which is also contrary to the Windows one) - success = ::MaskBlt(GetHdc(), xdest, ydest, width, height, + + // On some systems, MaskBlt succeeds yet is much much slower + // than the wxWindows fall-back implementation. So we need + // to be able to switch this on and off at runtime. + if (wxSystemSettings::GetOptionInt(wxT("no-maskblt")) == 0) + { + success = ::MaskBlt(GetHdc(), xdest, ydest, width, height, GetHdcOf(*source), xsrc, ysrc, (HBITMAP)mask->GetMaskBitmap(), xsrc, ysrc, MAKEROP4(dwRop, DSTCOPY)) != 0; + } if ( !success ) #endif // Win32