From a2bc7be9eda8764b5abaf364eb465574fa041ee3 Mon Sep 17 00:00:00 2001 From: Adi Oanca Date: Thu, 31 Mar 2005 16:48:51 +0000 Subject: [PATCH] This fixes up the last known remaining issues with the update code. It works perfectly now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12197 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/Layer.cpp | 91 +++++++++++++++++--------------- src/servers/app/ServerWindow.cpp | 9 ++-- 2 files changed, 53 insertions(+), 47 deletions(-) diff --git a/src/servers/app/Layer.cpp b/src/servers/app/Layer.cpp index df6d3261cb..30ce12901c 100644 --- a/src/servers/app/Layer.cpp +++ b/src/servers/app/Layer.cpp @@ -535,42 +535,40 @@ void Layer::RequestDraw(const BRegion ®, Layer *startFrom) if (!startFrom) redraw = true; + if (HasClient() && IsTopLayer()) + { + // calculate the minimum region/rectangle to be updated with + // a single message to the client. + fUpdateReg = fFullVisible; + if (fFlags & B_FULL_UPDATE_ON_RESIZE + && fFrameAction == B_LAYER_ACTION_RESIZE) + { + // do nothing + } + else + { + fUpdateReg.IntersectWith(®); + } + if (fUpdateReg.CountRects() > 0) + { + if (!fOwner->fInUpdate) + { + fOwner->prevInvalid = fUpdateReg; + SendUpdateMsg(); + } + else + { + fOwner->zUpdateReg.Include(&fUpdateReg); + } + } + } + if (fVisible.CountRects() > 0) { // client side drawing. Send only one UPDATE message! if (HasClient()) { - if (IsTopLayer()) - { - // calculate the minimum region/rectangle to be updated with - // a single message to the client. - fUpdateReg = fFullVisible; - if (fFlags & B_FULL_UPDATE_ON_RESIZE - && fFrameAction == B_LAYER_ACTION_RESIZE) - { - // do nothing - } - else - { - fUpdateReg.IntersectWith(®); - } - - if (fUpdateReg.CountRects() > 0) - { - if (!fOwner->fInUpdate) - { - fOwner->prevInvalid = fUpdateReg; - SendUpdateMsg(); - } - else - fOwner->zUpdateReg.Include(&fUpdateReg); - } - - // we're not that different than other. We too have an - // update region to which our drawing is restrincted. - } - - // calculate the update region, then... + // calculate the update region fUpdateReg = fVisible; if (fFlags & B_FULL_UPDATE_ON_RESIZE && fFrameAction == B_LAYER_ACTION_RESIZE) @@ -586,9 +584,11 @@ void Layer::RequestDraw(const BRegion ®, Layer *startFrom) { // clear background with viewColor. fDriver->ConstrainClippingRegion(&fUpdateReg); +// RGBColor c(rand()%255,rand()%255,rand()%255); +// fDriver->FillRect(fUpdateReg.Frame(), c); fDriver->FillRect(fUpdateReg.Frame(), fLayerData->viewcolor); fDriver->ConstrainClippingRegion(NULL); - SendUpdateMsg(); + fUpdateReg.MakeEmpty(); } } else @@ -681,9 +681,9 @@ void Layer::UpdateEnd() wb->zUpdateReg.Exclude(&wb->prevInvalid); if (wb->zUpdateReg.CountRects() > 0) { - wb->prevInvalid = wb->zUpdateReg; - fUpdateReg = wb->zUpdateReg; - SendUpdateMsg(); + BRegion reg(wb->zUpdateReg); + wb->RequestDraw(reg, NULL); + wb->zUpdateReg.MakeEmpty(); } else wb->prevInvalid.MakeEmpty(); @@ -1154,6 +1154,11 @@ void Layer::move_layer(float x, float y) BPoint pt(x,y); BRect rect(fFull.Frame().OffsetByCopy(pt)); + if (fClassID == AS_WINBORDER_CLASS) + { + WinBorder *wb = (WinBorder*)this; + wb->prevInvalid.OffsetBy(x, y); + } fParent->StartRebuildRegions(BRegion(rect), this, B_LAYER_MOVE, pt); fDriver->CopyRegionList(&fRootLayer->fCopyRegList, @@ -1477,16 +1482,14 @@ void Layer::SendViewMovedMsg() //! Sends an _UPDATE_ message to the client BWindow void Layer::SendUpdateMsg() { - if( fServerWin ) - { - BMessage msg; - msg.what = _UPDATE_; - msg.AddRect("_rect", ConvertFromTop(fUpdateReg.Frame()) ); - msg.AddRect("debug_rect", fUpdateReg.Frame() ); - msg.AddInt32("_token",fViewToken); + BMessage msg; + msg.what = _UPDATE_; + msg.AddRect("_rect", ConvertFromTop(fUpdateReg.Frame()) ); + msg.AddRect("debug_rect", fUpdateReg.Frame() ); + msg.AddInt32("_token",fViewToken); - fServerWin->SendMessageToClient( &msg ); - } + fOwner->Window()->SendMessageToClient(&msg); + //fServerWin->SendMessageToClient( &msg ); } Layer *Layer::VirtualTopChild() const diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 4b60457d2a..3e13e81f27 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -1409,7 +1409,7 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link) { DTRACE(("ServerWindowo %s: AS_BEGIN_UPDATE\n",fTitle.String())); fWinBorder->GetRootLayer()->Lock(); - cl->UpdateStart(); + fWinBorder->UpdateStart(); fWinBorder->GetRootLayer()->Unlock(); break; } @@ -1417,7 +1417,7 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link) { DTRACE(("ServerWindowo %s: AS_END_UPDATE\n",fTitle.String())); fWinBorder->GetRootLayer()->Lock(); - cl->UpdateEnd(); + fWinBorder->UpdateEnd(); fWinBorder->GetRootLayer()->Unlock(); break; } @@ -1651,9 +1651,12 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link) { fWinBorder->GetRootLayer()->Lock(); BRegion rreg(cl->fVisible); - rreg.Include(&fWinBorder->yUpdateReg); + rreg.IntersectWith(&fWinBorder->yUpdateReg); desktop->GetDisplayDriver()->ConstrainClippingRegion(&rreg); +// rgb_color rrr = cl->fLayerData->viewcolor.GetColor32(); +// RGBColor c(rand()%255,rand()%255,rand()%255); +// desktop->GetDisplayDriver()->FillRect(BRect(0,0,639,479), c); switch (code) {