Skip to content

Commit

Permalink
v2.7.0
Browse files Browse the repository at this point in the history
major performance enhancement for very large number of tiles
  • Loading branch information
Frederic Delhoume committed Aug 16, 2023
1 parent 161db16 commit 66eeb09
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/resources/vliv.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 11 additions & 2 deletions src/vliv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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))
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 66eeb09

Please sign in to comment.