X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/40a890760544ad228412e64a7dd91ac3135653d9..87df17a11b0017d31c09f767bd921abb27193bee:/src/msw/dc.cpp diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 2a79ff7f85..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,16 @@ 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; - HRGN hrgn = ::CreateRectRgn(XLOG2DEV(cx), YLOG2DEV(cy), - XLOG2DEV(cx + cw), YLOG2DEV(cy + ch)); + // 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")); @@ -781,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 @@ -1471,7 +1483,7 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, return FALSE; } - bool success; + bool success = FALSE; if (useMask) { @@ -1480,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