From 32f53b5151e34e732ad61b4a0dcd423a7cc2d00f Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Thu, 29 Dec 2011 16:28:58 +0000 Subject: [PATCH] - performance fix for the new status LED code: only call the gui specific code to update the status text if there is really a change - changed the counter resolution to 5 (auto-off still happens after 0.5 seconds) - the element value -1 is only used to reset the LEDs, so we have to ignore the status flags --- bochs/gui/gui.cc | 4 +++- bochs/gui/gui.h | 1 + bochs/gui/rfb.cc | 12 ++++++++---- bochs/gui/sdl.cc | 12 ++++++++---- bochs/gui/win32.cc | 12 ++++++++---- bochs/gui/wx.cc | 32 +++++++++++++------------------- bochs/gui/x.cc | 12 ++++++++---- 7 files changed, 49 insertions(+), 36 deletions(-) diff --git a/bochs/gui/gui.cc b/bochs/gui/gui.cc index a9350047b..c5da6c873 100644 --- a/bochs/gui/gui.cc +++ b/bochs/gui/gui.cc @@ -249,7 +249,7 @@ void bx_gui_c::init(int argc, char **argv, unsigned tilewidth, unsigned tileheig // register timer for status bar LEDs if (BX_GUI_THIS led_timer_index == BX_NULL_TIMER_HANDLE) { BX_GUI_THIS led_timer_index = - DEV_register_timer(this, led_timer_handler, 50000, 1, 1, "status bar LEDs"); + DEV_register_timer(this, led_timer_handler, 100000, 1, 1, "status bar LEDs"); } } @@ -759,6 +759,8 @@ int bx_gui_c::register_statusitem(const char *text, bx_bool auto_off) statusitem[statusitem_count].text[7] = 0; statusitem[statusitem_count].auto_off = auto_off; statusitem[statusitem_count].counter = 0; + statusitem[statusitem_count].active = 0; + statusitem[statusitem_count].mode = 0; return statusitem_count++; } else { return -1; diff --git a/bochs/gui/gui.h b/bochs/gui/gui.h index 9bdf802f4..a252f71c4 100644 --- a/bochs/gui/gui.h +++ b/bochs/gui/gui.h @@ -197,6 +197,7 @@ protected: int led_timer_index; struct { char text[8]; + bx_bool active; bx_bool mode; // read/write bx_bool auto_off; Bit8u counter; diff --git a/bochs/gui/rfb.cc b/bochs/gui/rfb.cc index 8fab30224..cf302e076 100644 --- a/bochs/gui/rfb.cc +++ b/bochs/gui/rfb.cc @@ -335,13 +335,17 @@ void bx_rfb_gui_c::statusbar_setitem(int element, bx_bool active, bx_bool w) { if (element < 0) { for (unsigned i = 0; i < statusitem_count; i++) { - rfbSetStatusText(i+1, statusitem[i].text, active, w); + rfbSetStatusText(i+1, statusitem[i].text, 0, 0); } } else if ((unsigned)element < statusitem_count) { - rfbSetStatusText(element+1, statusitem[element].text, active, w); - statusitem[element].mode = w; + if ((active != statusitem[element].active) || + (w != statusitem[element].mode)) { + rfbSetStatusText(element+1, statusitem[element].text, active, w); + statusitem[element].active = active; + statusitem[element].mode = w; + } if (active && statusitem[element].auto_off) { - statusitem[element].counter = 10; + statusitem[element].counter = 5; } } } diff --git a/bochs/gui/sdl.cc b/bochs/gui/sdl.cc index 5a1cda830..549d21548 100644 --- a/bochs/gui/sdl.cc +++ b/bochs/gui/sdl.cc @@ -431,13 +431,17 @@ void bx_sdl_gui_c::statusbar_setitem(int element, bx_bool active, bx_bool w) { if (element < 0) { for (unsigned i = 0; i < statusitem_count; i++) { - sdl_set_status_text(i+1, statusitem[i].text, active, w); + sdl_set_status_text(i+1, statusitem[i].text, 0, 0); } } else if ((unsigned)element < statusitem_count) { - sdl_set_status_text(element+1, statusitem[element].text, active, w); - statusitem[element].mode = w; + if ((active != statusitem[element].active) || + (w != statusitem[element].mode)) { + sdl_set_status_text(element+1, statusitem[element].text, active, w); + statusitem[element].active = active; + statusitem[element].mode = w; + } if (active && statusitem[element].auto_off) { - statusitem[element].counter = 10; + statusitem[element].counter = 5; } } } diff --git a/bochs/gui/win32.cc b/bochs/gui/win32.cc index 05fffc9fc..7ae6d4034 100644 --- a/bochs/gui/win32.cc +++ b/bochs/gui/win32.cc @@ -961,13 +961,17 @@ void bx_win32_gui_c::statusbar_setitem(int element, bx_bool active, bx_bool w) { if (element < 0) { for (int i = 0; i < (int)statusitem_count; i++) { - SetStatusText(i+BX_SB_TEXT_ELEMENTS, statusitem[i].text, active, w); + SetStatusText(i+BX_SB_TEXT_ELEMENTS, statusitem[i].text, 0, 0); } } else if (element < (int)statusitem_count) { - SetStatusText(element+BX_SB_TEXT_ELEMENTS, statusitem[element].text, active, w); - statusitem[element].mode = w; + if ((active != statusitem[element].active) || + (w != statusitem[element].mode)) { + SetStatusText(element+BX_SB_TEXT_ELEMENTS, statusitem[element].text, active, w); + statusitem[element].active = active; + statusitem[element].mode = w; + } if (active && statusitem[element].auto_off) { - statusitem[element].counter = 10; + statusitem[element].counter = 5; } } } diff --git a/bochs/gui/wx.cc b/bochs/gui/wx.cc index f0b9975c3..ca9ccd743 100644 --- a/bochs/gui/wx.cc +++ b/bochs/gui/wx.cc @@ -1083,34 +1083,28 @@ void bx_wx_gui_c::statusbar_setitem(int element, bx_bool active, bx_bool w) wxMutexGuiEnter(); if (element < 0) { for (unsigned i = 0; i < statusitem_count; i++) { - if (active) { -#if defined(__WXMSW__) - status_text[0] = 9; - strcpy(status_text+1, statusitem[i].text); - theFrame->SetStatusText(status_text, i+1); -#else - theFrame->SetStatusText(wxString(statusitem[i].text, wxConvUTF8), i+1); -#endif - } else { - theFrame->SetStatusText(wxT(""), i+1); - } + theFrame->SetStatusText(wxT(""), i+1); } } else if ((unsigned)element < statusitem_count) { - if (active) { + if ((active != statusitem[element].active) || + (w != statusitem[element].mode)) { + if (active) { #if defined(__WXMSW__) status_text[0] = 9; strcpy(status_text+1, statusitem[element].text); theFrame->SetStatusText(status_text, element+1); #else - theFrame->SetStatusText(wxString(statusitem[element].text, wxConvUTF8), - element+1); + theFrame->SetStatusText(wxString(statusitem[element].text, wxConvUTF8), + element+1); #endif - statusitem[element].mode = w; - if (active && statusitem[element].auto_off) { - statusitem[element].counter = 10; + } else { + theFrame->SetStatusText(wxT(""), element+1); } - } else { - theFrame->SetStatusText(wxT(""), element+1); + statusitem[element].active = active; + statusitem[element].mode = w; + } + if (active && statusitem[element].auto_off) { + statusitem[element].counter = 5; } } wxMutexGuiLeave(); diff --git a/bochs/gui/x.cc b/bochs/gui/x.cc index d884c42de..8d69fba14 100644 --- a/bochs/gui/x.cc +++ b/bochs/gui/x.cc @@ -712,13 +712,17 @@ void bx_x_gui_c::statusbar_setitem(int element, bx_bool active, bx_bool w) { if (element < 0) { for (unsigned i = 0; i < statusitem_count; i++) { - set_status_text(i+1, statusitem[i].text, active, w); + set_status_text(i+1, statusitem[i].text, 0, 0); } } else if ((unsigned)element < statusitem_count) { - set_status_text(element+1, statusitem[element].text, active, w); - statusitem[element].mode = w; + if ((active != statusitem[element].active) || + (w != statusitem[element].mode)) { + set_status_text(element+1, statusitem[element].text, active, w); + statusitem[element].active = active; + statusitem[element].mode = w; + } if (active && statusitem[element].auto_off) { - statusitem[element].counter = 10; + statusitem[element].counter = 5; } } }