From d04e25699323d91c859988918284b0324a2297c4 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 15 Nov 2015 00:37:22 +0100 Subject: [PATCH] Optimize drawing of small bitmaps with alpha in wxMSW Don't erase alpha channel of the entire destination image after drawing on it using AlphaBlend(), we only need to do it for the area corresponding to the bitmap drawn on it. This speeds things up when drawing small bitmaps with alpha on a big bitmap without alpha selected into wxMemoryDC which is a common case. See #16766. --- src/msw/dc.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 78f0fbb3f4..4ebdcc8140 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -2624,11 +2624,12 @@ static bool AlphaBlt(wxMSWDCImpl* dcDst, if ( data ) { wxAlphaPixelData::Iterator p(data); - for ( int old_y = 0; old_y < data.GetHeight(); old_y++ ) + p.Offset(data, x, y); + for ( int yDst = 0; yDst < dstHeight; yDst++ ) { wxAlphaPixelData::Iterator rowStart = p; - for ( int old_x = 0; old_x < data.GetWidth(); old_x++ ) + for ( int xDst = 0; xDst < dstWidth; xDst++ ) { // We choose to use wxALPHA_TRANSPARENT instead // of perhaps more logical wxALPHA_OPAQUE here