Nothing special. Just some cleanup to the update code. There is still a problem with layers not being properly updated sometimes when you move windows arround. The same problem occurs a lot more often when resizing windows. I'm traking it... :-)
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12259 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+42
-69
@@ -103,7 +103,6 @@ Layer::Layer(BRect frame, const char *name, int32 token, uint32 resize,
|
|||||||
fHidden = false;
|
fHidden = false;
|
||||||
fEventMask = 0UL;
|
fEventMask = 0UL;
|
||||||
fEventOptions = 0UL;
|
fEventOptions = 0UL;
|
||||||
fInUpdate = false;
|
|
||||||
fIsTopLayer = false;
|
fIsTopLayer = false;
|
||||||
fLevel = -100;
|
fLevel = -100;
|
||||||
|
|
||||||
@@ -539,7 +538,7 @@ void Layer::RequestDraw(const BRegion ®, Layer *startFrom)
|
|||||||
{
|
{
|
||||||
// calculate the minimum region/rectangle to be updated with
|
// calculate the minimum region/rectangle to be updated with
|
||||||
// a single message to the client.
|
// a single message to the client.
|
||||||
fUpdateReg = fFullVisible;
|
BRegion updateReg(fFullVisible);
|
||||||
if (fFlags & B_FULL_UPDATE_ON_RESIZE
|
if (fFlags & B_FULL_UPDATE_ON_RESIZE
|
||||||
&& fFrameAction == B_LAYER_ACTION_RESIZE)
|
&& fFrameAction == B_LAYER_ACTION_RESIZE)
|
||||||
{
|
{
|
||||||
@@ -547,29 +546,28 @@ void Layer::RequestDraw(const BRegion ®, Layer *startFrom)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fUpdateReg.IntersectWith(®);
|
updateReg.IntersectWith(®);
|
||||||
}
|
}
|
||||||
if (fUpdateReg.CountRects() > 0)
|
if (updateReg.CountRects() > 0)
|
||||||
{
|
{
|
||||||
|
fOwner->zUpdateReg.Include(&updateReg);
|
||||||
if (!fOwner->fInUpdate)
|
if (!fOwner->fInUpdate)
|
||||||
{
|
{
|
||||||
fOwner->prevInvalid = fUpdateReg;
|
// TODO: WHAT if 2 or more update requests are sent before we start to processing the first one.
|
||||||
SendUpdateMsg();
|
fOwner->fUpdateReg = fOwner->zUpdateReg;
|
||||||
}
|
//fOwner->cnt++;
|
||||||
else
|
//if (fOwner->cnt != 1)
|
||||||
{
|
// debugger("Adi: Not Allowed!");
|
||||||
fOwner->zUpdateReg.Include(&fUpdateReg);
|
fOwner->zUpdateReg.MakeEmpty();
|
||||||
|
SendUpdateMsg(fOwner->fUpdateReg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fVisible.CountRects() > 0)
|
if (fVisible.CountRects() > 0)
|
||||||
{
|
{
|
||||||
// client side drawing. Send only one UPDATE message!
|
BRegion updateReg(fVisible);
|
||||||
if (HasClient())
|
|
||||||
{
|
|
||||||
// calculate the update region
|
// calculate the update region
|
||||||
fUpdateReg = fVisible;
|
|
||||||
if (fFlags & B_FULL_UPDATE_ON_RESIZE
|
if (fFlags & B_FULL_UPDATE_ON_RESIZE
|
||||||
&& fFrameAction == B_LAYER_ACTION_RESIZE)
|
&& fFrameAction == B_LAYER_ACTION_RESIZE)
|
||||||
{
|
{
|
||||||
@@ -577,48 +575,14 @@ void Layer::RequestDraw(const BRegion ®, Layer *startFrom)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fUpdateReg.IntersectWith(®);
|
updateReg.IntersectWith(®);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fUpdateReg.CountRects() > 0)
|
if (updateReg.CountRects() > 0)
|
||||||
{
|
{
|
||||||
// clear background with viewColor.
|
fDriver->ConstrainClippingRegion(&updateReg);
|
||||||
fDriver->ConstrainClippingRegion(&fUpdateReg);
|
Draw(updateReg.Frame());
|
||||||
// RGBColor c(rand()%255,rand()%255,rand()%255);
|
|
||||||
// fDriver->FillRect(fUpdateReg.Frame(), c);
|
|
||||||
fDriver->FillRect(fUpdateReg.Frame(), fLayerData->viewcolor);
|
|
||||||
fDriver->ConstrainClippingRegion(NULL);
|
fDriver->ConstrainClippingRegion(NULL);
|
||||||
fUpdateReg.MakeEmpty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// server drawings are immediate.
|
|
||||||
// No IPC is needed so this is done in place.
|
|
||||||
if (fClassID == AS_WINBORDER_CLASS)
|
|
||||||
{
|
|
||||||
WinBorder *wb = (WinBorder*)this;
|
|
||||||
wb->zUpdateReg.Include(®);
|
|
||||||
}
|
|
||||||
|
|
||||||
fUpdateReg = fVisible;
|
|
||||||
if (fFlags & B_FULL_UPDATE_ON_RESIZE
|
|
||||||
&& fFrameAction == B_LAYER_ACTION_RESIZE)
|
|
||||||
{
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fUpdateReg.IntersectWith(®);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fUpdateReg.CountRects() > 0)
|
|
||||||
{
|
|
||||||
fDriver->ConstrainClippingRegion(&fUpdateReg);
|
|
||||||
Draw(fUpdateReg.Frame());
|
|
||||||
fDriver->ConstrainClippingRegion(NULL);
|
|
||||||
fUpdateReg.MakeEmpty();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -646,7 +610,7 @@ void Layer::Draw(const BRect &r)
|
|||||||
// TODO/NOTE: this should be an empty method! the next lines are for testing only
|
// TODO/NOTE: this should be an empty method! the next lines are for testing only
|
||||||
|
|
||||||
#ifdef DEBUG_LAYER
|
#ifdef DEBUG_LAYER
|
||||||
printf("Layer::Draw: ");
|
printf("Layer(%s)::Draw: ", GetName());
|
||||||
r.PrintToStream();
|
r.PrintToStream();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -660,36 +624,38 @@ void Layer::Draw(const BRect &r)
|
|||||||
void Layer::UpdateStart()
|
void Layer::UpdateStart()
|
||||||
{
|
{
|
||||||
// During updates we only want to draw what's in the update region
|
// During updates we only want to draw what's in the update region
|
||||||
fInUpdate = true;
|
|
||||||
if (fClassID == AS_WINBORDER_CLASS)
|
if (fClassID == AS_WINBORDER_CLASS)
|
||||||
{
|
{
|
||||||
// NOTE: don't worry, RooLayer is locked here.
|
// NOTE: don't worry, RooLayer is locked here.
|
||||||
WinBorder *wb = (WinBorder*)this;
|
WinBorder *wb = (WinBorder*)this;
|
||||||
wb->yUpdateReg = wb->prevInvalid;
|
|
||||||
|
wb->fInUpdate = true;
|
||||||
|
// TODO: wb->fUpdateReg seems to be invalid from time to time. Fix that! [See TODO in RequestDraw]
|
||||||
|
wb->yUpdateReg = wb->fUpdateReg;
|
||||||
|
wb->fUpdateReg.MakeEmpty();
|
||||||
|
//wb->cnt--;
|
||||||
|
//if (wb->cnt != 0)
|
||||||
|
// debugger("Adi2: Not Allowed!");
|
||||||
}
|
}
|
||||||
fClipReg = &fUpdateReg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layer::UpdateEnd()
|
void Layer::UpdateEnd()
|
||||||
{
|
{
|
||||||
// The usual case. Drawing is permitted in the whole visible area.
|
// The usual case. Drawing is permitted in the whole visible area.
|
||||||
fUpdateReg.MakeEmpty();
|
|
||||||
if (fClassID == AS_WINBORDER_CLASS)
|
if (fClassID == AS_WINBORDER_CLASS)
|
||||||
{
|
{
|
||||||
WinBorder *wb = (WinBorder*)this;
|
WinBorder *wb = (WinBorder*)this;
|
||||||
|
|
||||||
wb->yUpdateReg.MakeEmpty();
|
wb->yUpdateReg.MakeEmpty();
|
||||||
wb->zUpdateReg.Exclude(&wb->prevInvalid);
|
|
||||||
|
wb->fInUpdate = false;
|
||||||
|
|
||||||
if (wb->zUpdateReg.CountRects() > 0)
|
if (wb->zUpdateReg.CountRects() > 0)
|
||||||
{
|
{
|
||||||
BRegion reg(wb->zUpdateReg);
|
BRegion reg(wb->zUpdateReg);
|
||||||
wb->RequestDraw(reg, NULL);
|
wb->RequestDraw(reg, NULL);
|
||||||
wb->zUpdateReg.MakeEmpty();
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
wb->prevInvalid.MakeEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fInUpdate = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -1157,7 +1123,9 @@ void Layer::move_layer(float x, float y)
|
|||||||
if (fClassID == AS_WINBORDER_CLASS)
|
if (fClassID == AS_WINBORDER_CLASS)
|
||||||
{
|
{
|
||||||
WinBorder *wb = (WinBorder*)this;
|
WinBorder *wb = (WinBorder*)this;
|
||||||
wb->prevInvalid.OffsetBy(x, y);
|
wb->zUpdateReg.OffsetBy(x, y);
|
||||||
|
wb->yUpdateReg.OffsetBy(x, y);
|
||||||
|
wb->fUpdateReg.OffsetBy(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
fParent->StartRebuildRegions(BRegion(rect), this, B_LAYER_MOVE, pt);
|
fParent->StartRebuildRegions(BRegion(rect), this, B_LAYER_MOVE, pt);
|
||||||
@@ -1369,6 +1337,12 @@ BRegion Layer::ConvertToParent(BRegion *reg)
|
|||||||
return newreg;
|
return newreg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Converts the passed rectangle from parent coordinates
|
||||||
|
BPoint Layer::ConvertFromParent(BPoint pt)
|
||||||
|
{
|
||||||
|
return (pt - fFrame.LeftTop());
|
||||||
|
}
|
||||||
|
|
||||||
//! Converts the passed rectangle from parent coordinates
|
//! Converts the passed rectangle from parent coordinates
|
||||||
BRect Layer::ConvertFromParent(BRect rect)
|
BRect Layer::ConvertFromParent(BRect rect)
|
||||||
{
|
{
|
||||||
@@ -1480,16 +1454,15 @@ void Layer::SendViewMovedMsg()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Sends an _UPDATE_ message to the client BWindow
|
//! Sends an _UPDATE_ message to the client BWindow
|
||||||
void Layer::SendUpdateMsg()
|
void Layer::SendUpdateMsg(BRegion ®)
|
||||||
{
|
{
|
||||||
BMessage msg;
|
BMessage msg;
|
||||||
msg.what = _UPDATE_;
|
msg.what = _UPDATE_;
|
||||||
msg.AddRect("_rect", ConvertFromTop(fUpdateReg.Frame()) );
|
msg.AddRect("_rect", ConvertFromTop(reg.Frame()) );
|
||||||
msg.AddRect("debug_rect", fUpdateReg.Frame() );
|
msg.AddRect("debug_rect", reg.Frame() );
|
||||||
msg.AddInt32("_token",fViewToken);
|
// msg.AddInt32("_token",fViewToken);
|
||||||
|
|
||||||
fOwner->Window()->SendMessageToClient(&msg);
|
fOwner->Window()->SendMessageToClient(&msg);
|
||||||
//fServerWin->SendMessageToClient( &msg );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Layer *Layer::VirtualTopChild() const
|
Layer *Layer::VirtualTopChild() const
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ public:
|
|||||||
|
|
||||||
BRect ConvertToParent(BRect rect);
|
BRect ConvertToParent(BRect rect);
|
||||||
BRegion ConvertToParent(BRegion *reg);
|
BRegion ConvertToParent(BRegion *reg);
|
||||||
|
BPoint ConvertFromParent(BPoint pt);
|
||||||
BRect ConvertFromParent(BRect rect);
|
BRect ConvertFromParent(BRect rect);
|
||||||
BRegion ConvertFromParent(BRegion *reg);
|
BRegion ConvertFromParent(BRegion *reg);
|
||||||
|
|
||||||
@@ -147,7 +148,6 @@ public:
|
|||||||
|
|
||||||
void UpdateStart();
|
void UpdateStart();
|
||||||
void UpdateEnd();
|
void UpdateEnd();
|
||||||
bool InUpdate() const { return fInUpdate; }
|
|
||||||
BRegion* ClippingRegion() const { return fClipReg; }
|
BRegion* ClippingRegion() const { return fClipReg; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -177,7 +177,6 @@ protected:
|
|||||||
BRegion fVisible;
|
BRegion fVisible;
|
||||||
BRegion fFullVisible;
|
BRegion fFullVisible;
|
||||||
BRegion fFull;
|
BRegion fFull;
|
||||||
BRegion fUpdateReg;
|
|
||||||
BRegion *fClipReg;
|
BRegion *fClipReg;
|
||||||
|
|
||||||
BRegion *clipToPicture;
|
BRegion *clipToPicture;
|
||||||
@@ -192,7 +191,6 @@ protected:
|
|||||||
uint32 fEventMask;
|
uint32 fEventMask;
|
||||||
uint32 fEventOptions;
|
uint32 fEventOptions;
|
||||||
bool fHidden;
|
bool fHidden;
|
||||||
bool fInUpdate;
|
|
||||||
bool fIsTopLayer;
|
bool fIsTopLayer;
|
||||||
uint16 fAdFlags;
|
uint16 fAdFlags;
|
||||||
int8 fClassID;
|
int8 fClassID;
|
||||||
@@ -208,7 +206,7 @@ private:
|
|||||||
void RequestDraw(const BRegion ®, Layer *startFrom);
|
void RequestDraw(const BRegion ®, Layer *startFrom);
|
||||||
ServerWindow *SearchForServerWindow(void);
|
ServerWindow *SearchForServerWindow(void);
|
||||||
|
|
||||||
void Layer::SendUpdateMsg();
|
void SendUpdateMsg(BRegion ®);
|
||||||
void SendViewMovedMsg(void);
|
void SendViewMovedMsg(void);
|
||||||
void SendViewResizedMsg(void);
|
void SendViewResizedMsg(void);
|
||||||
|
|
||||||
|
|||||||
@@ -925,10 +925,17 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
|
|||||||
case AS_LAYER_GET_COORD:
|
case AS_LAYER_GET_COORD:
|
||||||
{
|
{
|
||||||
STRACE(("ServerWindow %s: Message AS_LAYER_GET_COORD: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
STRACE(("ServerWindow %s: Message AS_LAYER_GET_COORD: Layer: %s\n",fTitle.String(), cl->fName->String()));
|
||||||
|
printf("Adi: %s\n", cl->GetName());
|
||||||
|
cl->fFrame.PrintToStream();
|
||||||
|
cl->fBoundsLeftTop.PrintToStream();
|
||||||
fMsgSender->StartMessage(SERVER_TRUE);
|
fMsgSender->StartMessage(SERVER_TRUE);
|
||||||
fMsgSender->Attach<float>(cl->fFrame.left);
|
BPoint pt(cl->ConvertFromParent(cl->fFrame.LeftTop()));
|
||||||
fMsgSender->Attach<float>(cl->fFrame.top);
|
fMsgSender->Attach<float>(pt.x);
|
||||||
|
fMsgSender->Attach<float>(pt.y);
|
||||||
|
// fMsgSender->Attach<float>(cl->fFrame.left);
|
||||||
|
// fMsgSender->Attach<float>(cl->fFrame.top);
|
||||||
fMsgSender->Attach<BRect>(cl->fFrame.OffsetToCopy(cl->fBoundsLeftTop));
|
fMsgSender->Attach<BRect>(cl->fFrame.OffsetToCopy(cl->fBoundsLeftTop));
|
||||||
|
// fMsgSender->Attach<BRect>(cl->ConvertFromTop(cl->fFrame.OffsetToCopy(cl->fBoundsLeftTop)));
|
||||||
fMsgSender->Flush();
|
fMsgSender->Flush();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -1437,6 +1444,7 @@ void ServerWindow::DispatchMessage(int32 code, LinkMsgReader &link)
|
|||||||
{
|
{
|
||||||
STRACE(("ServerWindow %s: Message AS_SHOW_WINDOW\n",fTitle.String()));
|
STRACE(("ServerWindow %s: Message AS_SHOW_WINDOW\n",fTitle.String()));
|
||||||
Show();
|
Show();
|
||||||
|
printf("Adi: %s shown\n", fTitle.String());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AS_HIDE_WINDOW:
|
case AS_HIDE_WINDOW:
|
||||||
@@ -1651,13 +1659,18 @@ void ServerWindow::DispatchGraphicsMessage(int32 code, LinkMsgReader &link)
|
|||||||
{
|
{
|
||||||
fWinBorder->GetRootLayer()->Lock();
|
fWinBorder->GetRootLayer()->Lock();
|
||||||
BRegion rreg(cl->fVisible);
|
BRegion rreg(cl->fVisible);
|
||||||
|
if (fWinBorder->fInUpdate)
|
||||||
rreg.IntersectWith(&fWinBorder->yUpdateReg);
|
rreg.IntersectWith(&fWinBorder->yUpdateReg);
|
||||||
|
//if (!fWinBorder->yUpdateReg.Frame().IsValid() && fWinBorder->fInUpdate)
|
||||||
|
//{
|
||||||
|
// printf("ADi: FRAME INVALID!!!!\n");
|
||||||
|
// fWinBorder->yUpdateReg.PrintToStream();
|
||||||
|
//}
|
||||||
desktop->GetDisplayDriver()->ConstrainClippingRegion(&rreg);
|
desktop->GetDisplayDriver()->ConstrainClippingRegion(&rreg);
|
||||||
// rgb_color rrr = cl->fLayerData->viewcolor.GetColor32();
|
// rgb_color rrr = cl->fLayerData->viewcolor.GetColor32();
|
||||||
// RGBColor c(rand()%255,rand()%255,rand()%255);
|
// RGBColor c(rand()%255,rand()%255,rand()%255);
|
||||||
// desktop->GetDisplayDriver()->FillRect(BRect(0,0,639,479), c);
|
// desktop->GetDisplayDriver()->FillRect(BRect(0,0,639,479), c);
|
||||||
|
// snooze(500000);
|
||||||
switch (code)
|
switch (code)
|
||||||
{
|
{
|
||||||
case AS_LAYER_SET_HIGH_COLOR:
|
case AS_LAYER_SET_HIGH_COLOR:
|
||||||
|
|||||||
@@ -83,9 +83,10 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i
|
|||||||
{
|
{
|
||||||
// unlike BViews, windows start off as hidden
|
// unlike BViews, windows start off as hidden
|
||||||
fHidden = true;
|
fHidden = true;
|
||||||
|
fInUpdate = false;
|
||||||
fServerWin = win;
|
fServerWin = win;
|
||||||
fClassID = AS_WINBORDER_CLASS;
|
fClassID = AS_WINBORDER_CLASS;
|
||||||
|
cnt = 0;
|
||||||
fMouseButtons = 0;
|
fMouseButtons = 0;
|
||||||
fKeyModifiers = 0;
|
fKeyModifiers = 0;
|
||||||
fDecorator = NULL;
|
fDecorator = NULL;
|
||||||
@@ -311,7 +312,7 @@ void WinBorder::Draw(const BRect &r)
|
|||||||
fDecorator->SetFocus(true);
|
fDecorator->SetFocus(true);
|
||||||
else
|
else
|
||||||
fDecorator->SetFocus(false);
|
fDecorator->SetFocus(false);
|
||||||
fDecorator->Draw(fUpdateReg.Frame());
|
fDecorator->Draw(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ protected:
|
|||||||
|
|
||||||
BRegion zUpdateReg;
|
BRegion zUpdateReg;
|
||||||
BRegion yUpdateReg;
|
BRegion yUpdateReg;
|
||||||
BRegion prevInvalid;
|
BRegion fUpdateReg;
|
||||||
|
|
||||||
int32 fMouseButtons;
|
int32 fMouseButtons;
|
||||||
int32 fKeyModifiers;
|
int32 fKeyModifiers;
|
||||||
@@ -124,6 +124,8 @@ protected:
|
|||||||
bool fIsMinimizing;
|
bool fIsMinimizing;
|
||||||
bool fIsZooming;
|
bool fIsZooming;
|
||||||
|
|
||||||
|
bool fInUpdate;
|
||||||
|
int cnt;
|
||||||
float fMinWidth, fMaxWidth;
|
float fMinWidth, fMaxWidth;
|
||||||
float fMinHeight, fMaxHeight;
|
float fMinHeight, fMaxHeight;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user