Angband.oook.cz
Angband.oook.cz
AboutDownloadVariantsLadderForumCompetitionSpoilersComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Vanilla

Reply
 
Thread Tools Display Modes
Old June 15, 2012, 17:28   #1
PowerWyrm
Knight
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 753
PowerWyrm is on a distinguished road
[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!
PowerWyrm is offline   Reply With Quote
Old June 19, 2012, 16:47   #2
PowerWyrm
Knight
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 753
PowerWyrm is on a distinguished road
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);
			}
		}
	}
With this code, the minimap displays itself in 60ms instead of 500ms when using David Gervais tiles. And redrawing the screen with David Gervais tiles when playing in fullscreen mode takes 500ms instead of 4 seconds. And this also fixed the problem with unmapped tiles not refreshed properly...
__________________
PWMAngband variant maintainer - check http://www.mangband.org/forum/viewforum.php?f=9 to learn more about this new variant!
PowerWyrm is offline   Reply With Quote
Old June 19, 2012, 16:48   #3
fizzix
Prophet
 
Join Date: Aug 2009
Location: Madison, Wisconsin, US
Posts: 2,630
fizzix is on a distinguished road
I'll try out this patch, and let you know what I find out.
fizzix is offline   Reply With Quote
Old June 20, 2012, 09:32   #4
PowerWyrm
Knight
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 753
PowerWyrm is on a distinguished road
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!
PowerWyrm is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Display glitch with GCU client? PowerWyrm Development 13 October 15, 2012 21:58
A little bugfix for Windows users not using Win client... PowerWyrm Development 0 May 25, 2012 16:33
Chengband Win32 interface slow under Win7 Therem Harth Variants 8 May 19, 2012 19:55
[3.4-dev] Minor bugs with Win client PowerWyrm Development 0 April 18, 2012 14:17
[3.3.x] SDL client: unable to perform some commands PowerWyrm Vanilla 2 November 1, 2011 16:58


All times are GMT +1. The time now is 16:47.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.