From eaa6da1ef750d815d4318870eb24ccabc326c4c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Thu, 19 Jun 2008 13:07:44 +0000 Subject: [PATCH] Use a flag in BWindow to store whether an update to a view (Invalidate()) has been requested. The first call to a BView::Invalidate() will flush the link so that app_server is notified as soon as possible. It makes no sense for further calls to Invalidate() to flush also, since Flush() is not cheap. This trick makes Invalidate() about 3.2 times faster, making it a cheaper operation. I could not see any negative effects, I tested with apps that invalidate multiple different parts inside a window in reaction to something. Thanks go to Ingo who had the idea. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26020 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/interface/Window.h | 2 +- src/kits/interface/View.cpp | 11 +++++++++-- src/kits/interface/Window.cpp | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/headers/os/interface/Window.h b/headers/os/interface/Window.h index 0c02587188..57462e5274 100644 --- a/headers/os/interface/Window.h +++ b/headers/os/interface/Window.h @@ -332,6 +332,7 @@ private: char* fTitle; int32 _unused0; bool fInTransaction; + bool fUpdateRequested; bool fActive; short fShowLevel; uint32 fFlags; @@ -344,7 +345,6 @@ private: BButton* fDefaultButton; BList fShortcuts; int32 fTopViewToken; - bool _unused2; bool _unused3; bool fIsFilePanel; bool _unused4; diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index 1d5561b3a4..a92c466885 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -3371,7 +3371,11 @@ BView::Invalidate(BRect invalRect) fOwner->fLink->StartMessage(AS_VIEW_INVALIDATE_RECT); fOwner->fLink->Attach(invalRect); - fOwner->fLink->Flush(); + + if (!fOwner->fUpdateRequested) { + fOwner->fLink->Flush(); + fOwner->fUpdateRequested = true; + } } @@ -3386,7 +3390,10 @@ BView::Invalidate(const BRegion* region) fOwner->fLink->StartMessage(AS_VIEW_INVALIDATE_REGION); fOwner->fLink->AttachRegion(*region); - fOwner->fLink->Flush(); + if (!fOwner->fUpdateRequested) { + fOwner->fLink->Flush(); + fOwner->fUpdateRequested = true; + } } diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index ecac335c21..bc335308d3 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -1245,6 +1245,7 @@ FrameMoved(origin); fLink->StartMessage(AS_END_UPDATE); fLink->Flush(); fInTransaction = false; + fUpdateRequested = false; //printf("BWindow(%s) - UPDATE took %lld usecs\n", Title(), system_time() - now); break; @@ -2460,6 +2461,7 @@ BWindow::_InitData(BRect frame, const char* title, window_look look, fFlags = flags | B_ASYNCHRONOUS_CONTROLS; fInTransaction = false; + fUpdateRequested = false; fActive = false; fShowLevel = 0;