From 4a503ef5cfbd0ed740961df0df4b2c930f539981 Mon Sep 17 00:00:00 2001 From: spacy51 Date: Sat, 15 Dec 2007 13:28:09 +0000 Subject: [PATCH] remove assembler version of copyImage because it is not faster as C version declare copyImage as inline move code from display.cpp to Display.h delete display.cpp --- VBA.vcproj | 4 -- src/win32/Display.h | 44 ++++++++++++++- src/win32/display.cpp | 122 ------------------------------------------ 3 files changed, 43 insertions(+), 127 deletions(-) delete mode 100644 src/win32/display.cpp diff --git a/VBA.vcproj b/VBA.vcproj index 0024b45e..d137da97 100644 --- a/VBA.vcproj +++ b/VBA.vcproj @@ -1339,10 +1339,6 @@ RelativePath=".\src\win32\DirectSound.cpp" > - - diff --git a/src/win32/Display.h b/src/win32/Display.h index bc787915..f0b353f4 100644 --- a/src/win32/Display.h +++ b/src/win32/Display.h @@ -43,4 +43,46 @@ class IDisplay { virtual int selectFullScreenMode(GUID **) = 0; }; -void copyImage( void *source, void *destination, unsigned int width, unsigned int height, unsigned int destinationPitch, unsigned int colorDepth ); +inline void copyImage( void *source, void *destination, unsigned int width, unsigned int height, unsigned int destinationPitch, unsigned int colorDepth ) +{ + // fast, iterative C version + register unsigned int lineSize; + register unsigned char *src, *dst; + switch(colorDepth) + { + case 16: + lineSize = width<<1; + src = ((unsigned char*)source) + lineSize + 4; + dst = (unsigned char*)destination; + do { + MoveMemory( dst, src, lineSize ); + src+=lineSize; + dst+=lineSize; + src += 2; + dst += (destinationPitch - lineSize); + } while ( --height); + break; + case 32: + lineSize = width<<2; + src = ((unsigned char*)source) + lineSize + 4; + dst = (unsigned char*)destination; + do { + MoveMemory( dst, src, lineSize ); + src+=lineSize; + dst+=lineSize; + src += 4; + dst += (destinationPitch - lineSize); + } while ( --height); + break; + } + + // compact but slow C version + //unsigned int nBytesPerPixel = colorDepth>>3; + //unsigned int i, x, y, srcPitch = (width+1) * nBytesPerPixel; + //unsigned char * src = ((unsigned char*)source)+srcPitch; + //unsigned char * dst = (unsigned char*)destination; + //for (y=0;y>3; - //unsigned int i, x, y, srcPitch = (width+1) * nBytesPerPixel; - //unsigned char * src = ((unsigned char*)source)+srcPitch; - //unsigned char * dst = (unsigned char*)destination; - //for (y=0;y