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
This commit is contained in:
Stephan Aßmus
2008-06-19 13:07:44 +00:00
parent 2ccfe98f46
commit eaa6da1ef7
3 changed files with 12 additions and 3 deletions
+1 -1
View File
@@ -332,6 +332,7 @@ private:
char* fTitle; char* fTitle;
int32 _unused0; int32 _unused0;
bool fInTransaction; bool fInTransaction;
bool fUpdateRequested;
bool fActive; bool fActive;
short fShowLevel; short fShowLevel;
uint32 fFlags; uint32 fFlags;
@@ -344,7 +345,6 @@ private:
BButton* fDefaultButton; BButton* fDefaultButton;
BList fShortcuts; BList fShortcuts;
int32 fTopViewToken; int32 fTopViewToken;
bool _unused2;
bool _unused3; bool _unused3;
bool fIsFilePanel; bool fIsFilePanel;
bool _unused4; bool _unused4;
+7
View File
@@ -3371,7 +3371,11 @@ BView::Invalidate(BRect invalRect)
fOwner->fLink->StartMessage(AS_VIEW_INVALIDATE_RECT); fOwner->fLink->StartMessage(AS_VIEW_INVALIDATE_RECT);
fOwner->fLink->Attach<BRect>(invalRect); fOwner->fLink->Attach<BRect>(invalRect);
if (!fOwner->fUpdateRequested) {
fOwner->fLink->Flush(); fOwner->fLink->Flush();
fOwner->fUpdateRequested = true;
}
} }
@@ -3386,7 +3390,10 @@ BView::Invalidate(const BRegion* region)
fOwner->fLink->StartMessage(AS_VIEW_INVALIDATE_REGION); fOwner->fLink->StartMessage(AS_VIEW_INVALIDATE_REGION);
fOwner->fLink->AttachRegion(*region); fOwner->fLink->AttachRegion(*region);
if (!fOwner->fUpdateRequested) {
fOwner->fLink->Flush(); fOwner->fLink->Flush();
fOwner->fUpdateRequested = true;
}
} }
+2
View File
@@ -1245,6 +1245,7 @@ FrameMoved(origin);
fLink->StartMessage(AS_END_UPDATE); fLink->StartMessage(AS_END_UPDATE);
fLink->Flush(); fLink->Flush();
fInTransaction = false; fInTransaction = false;
fUpdateRequested = false;
//printf("BWindow(%s) - UPDATE took %lld usecs\n", Title(), system_time() - now); //printf("BWindow(%s) - UPDATE took %lld usecs\n", Title(), system_time() - now);
break; break;
@@ -2460,6 +2461,7 @@ BWindow::_InitData(BRect frame, const char* title, window_look look,
fFlags = flags | B_ASYNCHRONOUS_CONTROLS; fFlags = flags | B_ASYNCHRONOUS_CONTROLS;
fInTransaction = false; fInTransaction = false;
fUpdateRequested = false;
fActive = false; fActive = false;
fShowLevel = 0; fShowLevel = 0;