From 6be6eb2f18d356f1105f9ef13452f175d598c053 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 16 Jan 2017 11:36:35 +0100 Subject: [PATCH] Optimized freerdp_image_fill --- libfreerdp/codec/color.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libfreerdp/codec/color.c b/libfreerdp/codec/color.c index f88282f..c7515fd 100644 --- a/libfreerdp/codec/color.c +++ b/libfreerdp/codec/color.c @@ -556,16 +556,20 @@ BOOL freerdp_image_fill(BYTE* pDstData, DWORD DstFormat, UINT32 nWidth, UINT32 nHeight, UINT32 color) { UINT32 x, y; + const UINT32 bpp = GetBytesPerPixel(DstFormat); + BYTE* pFirstDstLine = &pDstData[nYDst * nDstStep]; + BYTE* pFirstDstLineXOffset = &pFirstDstLine[nXDst * bpp]; - for (y = 0; y < nHeight; y++) + for (x = 0; x < nWidth; x++) { - BYTE* pDstLine = &pDstData[(y + nYDst) * nDstStep]; + BYTE* pDst = &pFirstDstLine[(x + nXDst) * bpp]; + WriteColor(pDst, DstFormat, color); + } - for (x = 0; x < nWidth; x++) - { - BYTE* pDst = &pDstLine[(x + nXDst) * GetBytesPerPixel(DstFormat)]; - WriteColor(pDst, DstFormat, color); - } + for (y = 1; y < nHeight; y++) + { + BYTE* pDstLine = &pDstData[(y + nYDst) * nDstStep + nXDst * bpp]; + memcpy(pDstLine, pFirstDstLineXOffset, nWidth * bpp); } return TRUE; -- 2.7.4