(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
know how many lines we are going to draw. On certain architectures this results in a minor penalty of local function performance if only 1 line is drawn. But starting from 2 and more you'll get a net gain.
This commit is contained in:
		
							
								
								
									
										34
									
								
								texteff.c
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								texteff.c
									
									
									
									
									
								
							@@ -177,8 +177,7 @@ void TextMessageDailyLoop(void)
 | 
				
			|||||||
// Draw the textmessage-box
 | 
					// Draw the textmessage-box
 | 
				
			||||||
void DrawTextMessage(void)
 | 
					void DrawTextMessage(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int i, j;
 | 
						uint y, count;
 | 
				
			||||||
	bool has_message;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!_textmessage_dirty) return;
 | 
						if (!_textmessage_dirty) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -188,13 +187,8 @@ void DrawTextMessage(void)
 | 
				
			|||||||
	if (_iconsole_mode == ICONSOLE_FULL) return;
 | 
						if (_iconsole_mode == ICONSOLE_FULL) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Check if we have anything to draw at all */
 | 
						/* Check if we have anything to draw at all */
 | 
				
			||||||
	has_message = false;
 | 
						count = GetTextMessageCount();
 | 
				
			||||||
	for ( i = 0; i < MAX_CHAT_MESSAGES; i++) {
 | 
						if (count == 0) return;
 | 
				
			||||||
		if (_textmsg_list[i].message[0] == '\0') break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		has_message = true;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (!has_message) return;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Make a copy of the screen as it is before painting (for undraw)
 | 
						// Make a copy of the screen as it is before painting (for undraw)
 | 
				
			||||||
	memcpy_pitch(
 | 
						memcpy_pitch(
 | 
				
			||||||
@@ -202,18 +196,20 @@ void DrawTextMessage(void)
 | 
				
			|||||||
		_screen.dst_ptr + _textmsg_box.x + (_screen.height - _textmsg_box.y - _textmsg_box.height) * _screen.pitch,
 | 
							_screen.dst_ptr + _textmsg_box.x + (_screen.height - _textmsg_box.y - _textmsg_box.height) * _screen.pitch,
 | 
				
			||||||
		_textmsg_box.width, _textmsg_box.height, _screen.pitch, _textmsg_box.width);
 | 
							_textmsg_box.width, _textmsg_box.height, _screen.pitch, _textmsg_box.width);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Switch to _screen painting
 | 
						_cur_dpi = &_screen; // switch to _screen painting
 | 
				
			||||||
	_cur_dpi = &_screen;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	j = 0;
 | 
						/* Paint a half-transparent box behind the text messages */
 | 
				
			||||||
	// Paint the messages
 | 
						GfxFillRect(
 | 
				
			||||||
	for (i = MAX_CHAT_MESSAGES - 1; i >= 0; i--) {
 | 
								_textmsg_box.x,
 | 
				
			||||||
		if (_textmsg_list[i].message[0] == '\0') continue;
 | 
								_screen.height - _textmsg_box.y - count * 13 - 2,
 | 
				
			||||||
 | 
								_textmsg_box.x + _textmsg_box.width - 1,
 | 
				
			||||||
 | 
								_screen.height - _textmsg_box.y - 2,
 | 
				
			||||||
 | 
								0x322 | USE_COLORTABLE // black, but with some alpha for background
 | 
				
			||||||
 | 
							);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		j++;
 | 
						/* Paint the messages starting with the lowest at the bottom */
 | 
				
			||||||
		GfxFillRect(_textmsg_box.x, _screen.height-_textmsg_box.y-j*13-2, _textmsg_box.x+_textmsg_box.width - 1, _screen.height-_textmsg_box.y-j*13+10, /* black, but with some alpha */ 0x322 | USE_COLORTABLE);
 | 
						for (y = 13; count-- != 0; y += 13) {
 | 
				
			||||||
 | 
							DoDrawString(_textmsg_list[count].message, _textmsg_box.x + 3, _screen.height - _textmsg_box.y - y + 1, _textmsg_list[count].color);
 | 
				
			||||||
		DoDrawString(_textmsg_list[i].message, _textmsg_box.x + 3, _screen.height - _textmsg_box.y - j * 13, _textmsg_list[i].color);
 | 
					 | 
				
			||||||
 	}
 | 
					 	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Make sure the data is updated next flush
 | 
						// Make sure the data is updated next flush
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user