|
|
#1 |
|
Swordsman
Join Date: Apr 2008
Posts: 450
![]() |
[3.4RC - Win32 client] Minimap with tiles
Displaying the minimap is very slow when there are a lot of tiles to display (large window/small tiles). This only happens when using the Win32 client -- it's instantaneous when using the SDL client under Windows. This is probably because the SDL surface is created with each window, when the Win DC is recreated each time a tile is displayed...
__________________
PWMAngband variant maintainer - check http://www.mangband.org/forum/viewforum.php?f=9 to learn more about this new variant! |
|
|
|
|
|
#2 |
|
Swordsman
Join Date: Apr 2008
Posts: 450
![]() |
I just discovered that the code in Term_pict_win() could be massively optimized by doing the following:
Code:
/* Draw attr/char pairs */
for (i = n-1; i >= 0; i--, x2 -= w2) {
byte a = ap[i];
wchar_t c = cp[i];
/* Extract picture */
int row = (a & 0x7F);
int col = (c & 0x7F);
/* Location of bitmap cell */
x1 = col * w1;
y1 = row * h1;
if (hdcMask) {
/* Default background to darkness */
x3 = y3 = 0;
/* Use the terrain picture only if mapped */
if (tap[i] & 0x80) {
x3 = (tcp[i] & 0x7F) * w1;
y3 = (tap[i] & 0x7F) * h1;
}
/* Perfect size */
if ((w1 == tw2) && (h1 == th2)) {
/* Copy the terrain picture from the bitmap to the window */
if (x3 || y3) BitBlt(hdc, x2, y2, tw2, th2, hdcSrc, x3, y3, SRCCOPY);
/* Only draw if terrain and overlay are different */
if ((x1 != x3) || (y1 != y3)) {
/* Mask out the tile */
if (x3 || y3) BitBlt(hdc, x2, y2, tw2, th2, hdcMask, x1, y1, SRCAND);
/* Draw the tile */
if (x3 || y3) BitBlt(hdc, x2, y2, tw2, th2, hdcSrc, x1, y1, SRCPAINT);
else BitBlt(hdc, x2, y2, tw2, th2, hdcSrc, x1, y1, SRCCOPY);
}
/* Need to stretch */
} else {
/* Set the correct mode for stretching the tiles */
SetStretchBltMode(hdc, COLORONCOLOR);
/* Copy the terrain picture from the bitmap to the window */
if (x3 || y3) StretchBlt(hdc, x2, y2, tw2, th2, hdcSrc, x3, y3, w1, h1, SRCCOPY);
/* Only draw if terrain and overlay are different */
if ((x1 != x3) || (y1 != y3)) {
/* Mask out the tile */
if (x3 || y3) StretchBlt(hdc, x2, y2, tw2, th2, hdcMask, x1, y1, w1, h1, SRCAND);
/* Draw the tile */
if (x3 || y3) StretchBlt(hdc, x2, y2, tw2, th2, hdcSrc, x1, y1, w1, h1, SRCPAINT);
else StretchBlt(hdc, x2, y2, tw2, th2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
}
}
} else {
/* Perfect size */
if ((w1 == tw2) && (h1 == th2)) {
/* Copy the picture from the bitmap to the window */
BitBlt(hdc, x2, y2, tw2, th2, hdcSrc, x1, y1, SRCCOPY);
/* Need to stretch */
} else {
/* Set the correct mode for stretching the tiles */
SetStretchBltMode(hdc, COLORONCOLOR);
/* Copy the picture from the bitmap to the window */
StretchBlt(hdc, x2, y2, tw2, th2, hdcSrc, x1, y1, w1, h1, SRCCOPY);
}
}
}
__________________
PWMAngband variant maintainer - check http://www.mangband.org/forum/viewforum.php?f=9 to learn more about this new variant! |
|
|
|
|
|
#3 |
|
Veteran
Join Date: Aug 2009
Location: Madison, Wisconsin, US
Posts: 2,294
![]() |
I'll try out this patch, and let you know what I find out.
|
|
|
|
|
|
#4 |
|
Swordsman
Join Date: Apr 2008
Posts: 450
![]() |
In fact, the slowdown is caused by calling Term_putch() to display the minimap tiles. Term_putch() queues a tile with transparency = 0, which is inefficient in the case of the Win32 client, since the original code first blits the terrain tile, then ANDs the overlay mask and finally ORs the overlay tile. In this case, the costly StretchBlt() function is called three times to do 0 AND something...
Using Term_queue_char(tile, tile) in display_map() instead of the previous code should also do the trick.
__________________
PWMAngband variant maintainer - check http://www.mangband.org/forum/viewforum.php?f=9 to learn more about this new variant! |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Display glitch with GCU client? | PowerWyrm | Development | 13 | October 15, 2012 20:58 |
| A little bugfix for Windows users not using Win client... | PowerWyrm | Development | 0 | May 25, 2012 15:33 |
| Chengband Win32 interface slow under Win7 | Therem Harth | Variants | 8 | May 19, 2012 18:55 |
| [3.4-dev] Minor bugs with Win client | PowerWyrm | Development | 0 | April 18, 2012 13:17 |
| [3.3.x] SDL client: unable to perform some commands | PowerWyrm | Vanilla | 2 | November 1, 2011 15:58 |