From f252296386a9665dfc7c3a111b95d5870121d227 Mon Sep 17 00:00:00 2001 From: Lyve Date: Wed, 18 Mar 2020 13:47:19 +0100 Subject: [PATCH] introduce BltMemcpy which is faster than the SSSE3 version --- SSE Hand Relief Very Nice/Surface.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/SSE Hand Relief Very Nice/Surface.h b/SSE Hand Relief Very Nice/Surface.h index 710ab9b..e5234e8 100644 --- a/SSE Hand Relief Very Nice/Surface.h +++ b/SSE Hand Relief Very Nice/Surface.h @@ -560,6 +560,26 @@ class Surface } } } + void BltMemcpy(Vei2 dstPt, const RectI& srcRect, const Surface& src) + { + const Color* __restrict ptSrc = src.GetBufferConst(); + Color* __restrict ptDst = GetBuffer(); + + ptSrc += srcRect.top * src.GetWidth() + srcRect.left; + ptDst += dstPt.y * GetWidth() + dstPt.x; + + Color* ptDstEnd = ptDst + srcRect.GetHeight() * GetWidth(); + + const int rowByteSize = srcRect.GetWidth() * sizeof(Color); + + while (ptDst < ptDstEnd) + { + ::memcpy(ptDst, ptSrc, rowByteSize); + + ptDst += GetWidth(); + ptSrc += src.GetWidth(); + } + } void BltBlend( Vei2 dstPt,const RectI& srcRect,const Surface& src,unsigned char alpha ) { const unsigned int mask = 0xFF; @@ -2237,4 +2257,4 @@ class TextSurface : public Surface private: Gdiplus::Bitmap bitmap; Gdiplus::Graphics g; -}; \ No newline at end of file +};