From 66eeb096649763d5af7aee0c661bf82ef730c15a Mon Sep 17 00:00:00 2001 From: Frederic Delhoume Date: Wed, 16 Aug 2023 15:24:34 +0200 Subject: [PATCH] v2.7.0 major performance enhancement for very large number of tiles --- src/makefile | 4 ++-- src/resources/vliv.rc | 4 ++-- src/vliv.c | 13 +++++++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/makefile b/src/makefile index 5538b6c..8e5b0a3 100644 --- a/src/makefile +++ b/src/makefile @@ -7,8 +7,8 @@ LD = link DEBUG=/Ox -VERSION=2.6 -VERSIONSHORT=260 +VERSION=2.7 +VERSIONSHORT=270 CFLAGS = /nologo /W3 $(DEBUG) /D_CRT_SECURE_NO_DEPRECATE /DWIN32 /DWINDOWS /I. LDFLAGS = $(LDDEBUG) /SUBSYSTEM:WINDOWS /nodefaultlib:libc /VERSION:$(VERSION) /LARGEADDRESSAWARE diff --git a/src/resources/vliv.rc b/src/resources/vliv.rc index b5a3697..78238f5 100644 --- a/src/resources/vliv.rc +++ b/src/resources/vliv.rc @@ -21,8 +21,8 @@ STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP FONT 8, "MS Shell Dlg" BEGIN DEFPUSHBUTTON "OK",IDOK,68,75,50,14 - CTEXT "Vliv 2.6.0",IDC_VERSION,6,14,180,8 - CTEXT "(c) 2003-2022, Frederic Delhoume",4,6,45,180,8 + CTEXT "Vliv 2.7.0",IDC_VERSION,6,14,180,8 + CTEXT "(c) 2003-2023, Frederic Delhoume",4,6,45,180,8 CTEXT "https://github.com/delhoume/vliv",IDC_HYPERLINK,6,58,180,8 END diff --git a/src/vliv.c b/src/vliv.c index cd362ff..b5064ab 100644 --- a/src/vliv.c +++ b/src/vliv.c @@ -928,13 +928,14 @@ LRESULT CALLBACK VlivWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) unsigned int x, y; int startx, starty; unsigned int miny, maxy; + unsigned int minx, maxx; unsigned int currenty; si.fMask = SIF_ALL; hDC = BeginPaint(hwnd, &ps); GetClientRect(hwnd, &rect); if (image.handler == 0) { - FillRect(hDC, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); + FillRect(hDC, &rect, (HBRUSH)GetStockObject(GRAY_BRUSH)); EndPaint(hwnd, &ps); return 0; } @@ -954,12 +955,18 @@ LRESULT CALLBACK VlivWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (image.theight != 0) { miny = invalidrect.top / image.theight; maxy = invalidrect.bottom / image.theight + 1; + minx = invalidrect.left / image.twidth; + maxx = invalidrect.right / image.twidth + 1; } else { miny = invalidrect.top; maxy = image.numtilesy; + minx = invalidrect.left; + maxx = image.numtilesx; } if (maxy >= image.numtilesy) maxy = image.numtilesy; + if (maxx >= image.numtilesx) + maxx = image.numtilesx; // image is fully visible, but size not multiple of tiles if ((invalidrect.left == 0) && (invalidrect.right > (int)image.width)) @@ -974,7 +981,8 @@ LRESULT CALLBACK VlivWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) unsigned int currentx = 0; currenty = y * image.theight; CreateRow(y); - for (x = 0; x < image.numtilesx; ++x) { + // for (x = 0; x < image.numtilesx; ++x) { + for (x = minx; x < maxx; ++x) { RECT tilerect; RECT inter; currentx = x * image.twidth; @@ -1094,6 +1102,7 @@ LRESULT CALLBACK VlivWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ImageList_Destroy(imagelist); ImageList_Destroy(imagelistd); ImageList_Destroy(imagelisth); + joyReleaseCapture(JOYSTICKID1); return 0; case WM_ERASEBKGND: return 0;