From de83bbe34f8900083b3a9ab4024ac9eef65eae8d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 26 Apr 2011 22:57:08 +0000 Subject: [PATCH] No changes, just simplify the mask checks in wxImage::Paste(). Replace the test of the form "(!a && b) || (a && b)" with a simple test for "b" and then also replace the test for "b || (c && !b)" with just "b || c". The end result is much easier to read and understand. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67614 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/image.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/common/image.cpp b/src/common/image.cpp index 4e4860d9c2..de87a34257 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -1428,12 +1428,15 @@ void wxImage::Paste( const wxImage &image, int x, int y ) if (width < 1) return; if (height < 1) return; - if ((!HasMask() && !image.HasMask()) || - (HasMask() && !image.HasMask()) || - ((HasMask() && image.HasMask() && + // If we can, copy the data using memcpy() as this is the fastest way. But + // for this the image being pasted must have "compatible" mask with this + // one meaning that either it must not have one at all or it must use the + // same masked colour. + if ( !image.HasMask() || + ((HasMask() && (GetMaskRed()==image.GetMaskRed()) && (GetMaskGreen()==image.GetMaskGreen()) && - (GetMaskBlue()==image.GetMaskBlue())))) + (GetMaskBlue()==image.GetMaskBlue()))) ) { const unsigned char* source_data = image.GetData() + 3*(xx + yy*image.GetWidth()); int source_step = image.GetWidth()*3; -- 2.45.2