From 646998871e5214d181729afbe3d1dc8f10186966 Mon Sep 17 00:00:00 2001 From: zeromus Date: Thu, 16 Jul 2009 04:45:04 +0000 Subject: [PATCH] win32: scalers: add a slightly optimized case for non-filtered. probably doesn't add up to much --- desmume/src/windows/main.cpp | 18 ++++++++++-------- desmume/src/windows/video.h | 9 +++++++-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 66b13fd9f..83254d8ab 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -646,6 +646,8 @@ template static T convert(u16 val) template static void doRotate(void* dst) { u8* buffer = (u8*)dst; + int size = video.size(); + u16* src = video.finalBuffer(); switch(video.rotation) { case 0: @@ -654,11 +656,11 @@ template static void doRotate(void* dst) if(ddsd.lPitch == 1024) { if(video.rotation==180) - for(int i = 0, j=video.size()-1; j>=0; i++,j--) - ((T*)buffer)[i] = convert(((u16*)video.filteredbuffer)[j]); + for(int i = 0, j=size-1; j>=0; i++,j--) + ((T*)buffer)[i] = convert((src)[j]); else - for(int i = 0; i < video.size(); i++) - ((T*)buffer)[i] = convert(((u16*)video.filteredbuffer)[i]); + for(int i = 0; i < size; i++) + ((T*)buffer)[i] = convert(src[i]); } else { @@ -666,7 +668,7 @@ template static void doRotate(void* dst) for(int y = 0; y < video.height; y++) { for(int x = 0; x < video.width; x++) - ((T*)buffer)[x] = convert(((u16*)video.filteredbuffer)[video.height*video.width - (y * video.width) - x - 1]); + ((T*)buffer)[x] = convert(src[video.height*video.width - (y * video.width) - x - 1]); buffer += ddsd.lPitch; } @@ -674,7 +676,7 @@ template static void doRotate(void* dst) for(int y = 0; y < video.height; y++) { for(int x = 0; x < video.width; x++) - ((T*)buffer)[x] = convert(((u16*)video.filteredbuffer)[(y * video.width) + x]); + ((T*)buffer)[x] = convert(src[(y * video.width) + x]); buffer += ddsd.lPitch; } @@ -688,7 +690,7 @@ template static void doRotate(void* dst) for(int y = 0; y < video.width; y++) { for(int x = 0; x < video.height; x++) - ((T*)buffer)[x] = convert(((u16*)video.filteredbuffer)[(((video.height-1)-x) * video.width) + y]); + ((T*)buffer)[x] = convert(src[(((video.height-1)-x) * video.width) + y]); buffer += ddsd.lPitch; } @@ -696,7 +698,7 @@ template static void doRotate(void* dst) for(int y = 0; y < video.width; y++) { for(int x = 0; x < video.height; x++) - ((T*)buffer)[x] = convert(((u16*)video.filteredbuffer)[((x) * video.width) + (video.width-1) - y]); + ((T*)buffer)[x] = convert(src[((x) * video.width) + (video.width-1) - y]); buffer += ddsd.lPitch; } diff --git a/desmume/src/windows/video.h b/desmume/src/windows/video.h index 4f2f6e52b..04a250603 100644 --- a/desmume/src/windows/video.h +++ b/desmume/src/windows/video.h @@ -28,7 +28,6 @@ public: void reset() { width = 256; height = 384; - } void setfilter(int filter) { @@ -51,6 +50,13 @@ public: SSurface src; SSurface dst; + u16* finalBuffer() const + { + if(currentfilter == NONE) + return (u16*)GPU_screen; + else return (u16*)filteredbuffer; + } + void filter() { src.Height = 384; @@ -66,7 +72,6 @@ public: switch(currentfilter) { case NONE: - memcpy(filteredbuffer, GPU_screen, 256*192*4); break; case HQ2X: RenderHQ2X(src, dst);