From 3ded9e191d7c0b7ed49e5448baed3ab9dc54106d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 29 Jan 2014 22:25:56 +0000 Subject: [PATCH] Fix handling of wxSET, wxCLEAR and wxINVERT ROPs in wxMSW. Avoid passing source HDC to MaskBlt() for these ROPs which only use the destination HDC as they produce garbage instead of just ignoring the source in if it's non-NULL. Closes #2047. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75738 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/dc.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 8bff54a175..7f12076c4e 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -2186,7 +2186,7 @@ bool wxMSWDCImpl::DoStretchBlit(wxCoord xdest, wxCoord ydest, return false; } - const HDC hdcSrc = GetHdcOf(*implSrc); + HDC hdcSrc = GetHdcOf(*implSrc); // if either the source or destination has alpha channel, we must use // AlphaBlt() as other function don't handle it correctly @@ -2243,6 +2243,16 @@ bool wxMSWDCImpl::DoStretchBlit(wxCoord xdest, wxCoord ydest, return false; } + // Most of the operations involve the source or the pattern, but a few of + // them (and only those few, no other are possible) only use destination + // HDC. For them we must not give a valid source HDC to MaskBlt() as it + // still uses it, somehow, and the result is garbage. + if ( dwRop == BLACKNESS || dwRop == WHITENESS || + dwRop == DSTINVERT || dwRop == DSTCOPY ) + { + hdcSrc = NULL; + } + bool success = false; if (useMask)