From 0231c616992c331a0bd0556ed5ce46fb09854c74 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Sun, 6 Mar 2005 13:28:40 +0000 Subject: Win32 simulator performance optimisation: Invalidate onle the part of the window that actually changed in lcd_update() and lcd_update_rect(). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6150 a1c6a512-1295-4272-9138-f99709370657 --- uisimulator/win32/lcd-win32.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'uisimulator/win32') diff --git a/uisimulator/win32/lcd-win32.c b/uisimulator/win32/lcd-win32.c index 243e83dd2e..8b01803978 100644 --- a/uisimulator/win32/lcd-win32.c +++ b/uisimulator/win32/lcd-win32.c @@ -58,6 +58,8 @@ void lcd_set_invert_display(bool invert) void lcd_update() { int x, y; + RECT r; + if (hGUIWnd == NULL) _endthread (); @@ -82,10 +84,13 @@ void lcd_update() for (y = 0; y < LCD_HEIGHT; y++) bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1); - InvalidateRect (hGUIWnd, NULL, FALSE); - - /* natural sleep :) Bagder: why is this here? */ - //Sleep (50); + /* Invalidate only the window part that actually did change */ + GetClientRect (hGUIWnd, &r); + r.left = UI_LCD_POSX * r.right / UI_WIDTH; + r.top = UI_LCD_POSY * r.bottom / UI_HEIGHT; + r.right = (UI_LCD_POSX + UI_LCD_WIDTH) * r.right / UI_WIDTH; + r.bottom = (UI_LCD_POSY + UI_LCD_HEIGHT) * r.bottom / UI_HEIGHT; + InvalidateRect (hGUIWnd, &r, FALSE); } void lcd_update_rect(int x_start, int y_start, @@ -93,6 +98,7 @@ void lcd_update_rect(int x_start, int y_start, { int x, y; int xmax, ymax; + RECT r; ymax = y_start + height; xmax = x_start + width; @@ -109,10 +115,17 @@ void lcd_update_rect(int x_start, int y_start, for (y = y_start; y < ymax; y++) bitmap[y][x] = ((lcd_framebuffer[y/8][x] >> (y & 7)) & 1); - /* Bagder: If I only knew how, I would make this call only invalidate - the actual rectangle we want updated here, this NULL thing here will - make the full rectangle updated! */ - InvalidateRect (hGUIWnd, NULL, FALSE); + /* Invalidate only the window part that actually did change */ + GetClientRect (hGUIWnd, &r); + r.left = (UI_LCD_POSX + (UI_LCD_WIDTH * x_start / LCD_WIDTH)) + * r.right / UI_WIDTH; + r.top = (UI_LCD_POSY + (UI_LCD_HEIGHT * y_start / LCD_HEIGHT)) + * r.bottom / UI_HEIGHT; + r.right = (UI_LCD_POSX + (UI_LCD_WIDTH * xmax / LCD_WIDTH)) + * r.right / UI_WIDTH; + r.bottom = (UI_LCD_POSY + (UI_LCD_HEIGHT * ymax / LCD_HEIGHT)) + * r.bottom / UI_HEIGHT; + InvalidateRect (hGUIWnd, &r, FALSE); } /* lcd_backlight() -- cgit v1.2.3