diff --git a/src/servers/app/Layer.cpp b/src/servers/app/Layer.cpp index 3036d70e9d..8a0665c820 100644 --- a/src/servers/app/Layer.cpp +++ b/src/servers/app/Layer.cpp @@ -1316,47 +1316,126 @@ Layer::PrintTree() printf("\t%s\t%s\n", lay->Name(), lay->IsHidden()? "Hidden": "NOT hidden"); } -// UpdateStart +// RequestDraw void -Layer::UpdateStart() +Layer::RequestDraw(const BRegion ®, Layer *startFrom) { - // During updates we only want to draw what's in the update region - if (fClassID == AS_WINBORDER_CLASS) { - // NOTE: don't worry, RooLayer is locked here. - WinBorder *wb = (WinBorder*)this; - - wb->fInUpdate = true; - wb->fRequestSent = false; - wb->yUpdateReg = wb->fUpdateReg; - wb->fUpdateReg.MakeEmpty(); -wb->cnt--; -if (wb->cnt != 0) - CRITICAL("Layer::UpdateStart(): wb->cnt != 0 -> Not Allowed!"); - } -} - -// UpdateEnd -void -Layer::UpdateEnd() -{ - // The usual case. Drawing is permitted in the whole visible area. - if (fClassID == AS_WINBORDER_CLASS) { - WinBorder *wb = (WinBorder*)this; - - wb->yUpdateReg.MakeEmpty(); - - wb->fInUpdate = false; - - if (wb->zUpdateReg.CountRects() > 0) { - BRegion reg(wb->zUpdateReg); - wb->RequestDraw(reg, NULL); - } - } -} + STRACE(("Layer(%s)::RequestDraw()\n", Name())); + // do not redraw any child until you must + int redraw = false; + if (!startFrom) + redraw = true; #ifndef NEW_CLIPPING + if (HasClient() && IsTopLayer()) { + // calculate the minimum region/rectangle to be updated with + // a single message to the client. + BRegion updateReg(fFullVisible); + if (fFlags & B_FULL_UPDATE_ON_RESIZE + && fFrameAction == B_LAYER_ACTION_RESIZE) + { + // do nothing + } else { + updateReg.IntersectWith(®); + } + if (updateReg.CountRects() > 0) { + fOwner->fCumulativeRegion.Include(&updateReg); + if (!fOwner->InUpdate() && !fOwner->fRequestSent) { + fOwner->fInUpdateRegion = fOwner->fCumulativeRegion; +fOwner->cnt++; +if (fOwner->cnt != 1) + CRITICAL("Layer::RequestDraw(): fOwner->cnt != 1 -> Not Allowed!"); + fOwner->fCumulativeRegion.MakeEmpty(); + fOwner->fRequestSent = true; + SendUpdateMsg(fOwner->fInUpdateRegion); + } + } + } + + if (fVisible.CountRects() > 0) { + BRegion updateReg(fVisible); + // calculate the update region + if (fFlags & B_FULL_UPDATE_ON_RESIZE && fFrameAction == B_LAYER_ACTION_RESIZE) { + // do nothing + } else { + updateReg.IntersectWith(®); + } + + if (updateReg.CountRects() > 0) { + fDriver->ConstrainClippingRegion(&updateReg); + Draw(updateReg.Frame()); + fDriver->ConstrainClippingRegion(NULL); + } + } + + for (Layer *lay = BottomChild(); lay != NULL; lay = UpperSibling()) { + if (lay == startFrom) + redraw = true; + + if (redraw && !(lay->IsHidden())) { + // no need to go deeper if not even the FullVisible region intersects + // Update one. + BRegion common(lay->fFullVisible); + common.IntersectWith(®); + + if (common.CountRects() > 0) + lay->RequestDraw(reg, NULL); + } + } +#else + if (HasClient() && IsTopLayer()) { + // calculate the minimum region/rectangle to be updated with + // a single message to the client. + BRegion updateReg(fFullVisible2); + + updateReg.IntersectWith(®); + + if (updateReg.CountRects() > 0) { + fOwner->fCumulativeRegion.Include(&updateReg); + if (!fOwner->InUpdate() && !fOwner->fRequestSent) { + fOwner->fInUpdateRegion = fOwner->fCumulativeRegion; +fOwner->cnt++; +if (fOwner->cnt != 1) + CRITICAL("Layer::RequestDraw(): fOwner->cnt != 1 -> Not Allowed!"); + fOwner->fCumulativeRegion.MakeEmpty(); + fOwner->fRequestSent = true; +printf("Send\n"); + SendUpdateMsg(fOwner->fInUpdateRegion); + } + } + } + + if (fVisible2.CountRects() > 0) { + BRegion updateReg(fVisible2); + updateReg.IntersectWith(®); + + if (updateReg.CountRects() > 0) { + fDriver->ConstrainClippingRegion(&updateReg); + Draw(updateReg.Frame()); + fDriver->ConstrainClippingRegion(NULL); + } + } + + for (Layer *lay = BottomChild(); lay != NULL; lay = UpperSibling()) { + if (lay == startFrom) + redraw = true; + + if (redraw && !(lay->IsHidden())) { + // no need to go deeper if not even the FullVisible region intersects + // Update one. + BRegion common(lay->fFullVisible2); + common.IntersectWith(®); + + if (common.CountRects() > 0) + lay->RequestDraw(reg, NULL); + } + } +#endif +} + +#ifndef NEW_CLIPPING // move_layer void @@ -1364,9 +1443,9 @@ Layer::move_layer(float x, float y) { /* if (fClassID == AS_WINBORDER_CLASS) { WinBorder *wb = (WinBorder*)this; - wb->zUpdateReg.OffsetBy(x, y); - wb->yUpdateReg.OffsetBy(x, y); - wb->fUpdateReg.OffsetBy(x, y); + wb->fCumulativeRegion.OffsetBy(x, y); + wb->fInUpdateRegion.OffsetBy(x, y); + wb->fSavedForUpdateRegion.OffsetBy(x, y); }*/ fFrameAction = B_LAYER_ACTION_MOVE; @@ -1473,119 +1552,6 @@ Layer::Invalidate(const BRegion& region) #endif // 5 methods -// RequestDraw -void -Layer::RequestDraw(const BRegion ®, Layer *startFrom) -{ - STRACE(("Layer(%s)::RequestDraw()\n", Name())); -//printf("Layer(%s)::RequestDraw()\n", Name()); -//if (fClassID == AS_ROOTLAYER_CLASS) -// debugger("z"); - // do not redraw any child until you must - int redraw = false; - if (!startFrom) - redraw = true; - - if (HasClient() && IsTopLayer()) { - // calculate the minimum region/rectangle to be updated with - // a single message to the client. -#ifndef NEW_CLIPPING - BRegion updateReg(fFullVisible); -#else - BRegion updateReg(fFullVisible2); -#endif - - if (fFlags & B_FULL_UPDATE_ON_RESIZE -#ifndef NEW_CLIPPING - && fFrameAction == B_LAYER_ACTION_RESIZE -#endif - ) - { - // do nothing - } else { - updateReg.IntersectWith(®); - } - if (updateReg.CountRects() > 0) { - fOwner->zUpdateReg.Include(&updateReg); - if (!fOwner->fInUpdate && !fOwner->fRequestSent) { - fOwner->fUpdateReg = fOwner->zUpdateReg; -fOwner->cnt++; -if (fOwner->cnt != 1) - CRITICAL("Layer::RequestDraw(): fOwner->cnt != 1 -> Not Allowed!"); - fOwner->zUpdateReg.MakeEmpty(); - SendUpdateMsg(fOwner->fUpdateReg); - fOwner->fRequestSent = true; - } - } - } - -#ifndef NEW_CLIPPING - if (fVisible.CountRects() > 0) { - BRegion updateReg(fVisible); - // calculate the update region - if (fFlags & B_FULL_UPDATE_ON_RESIZE && fFrameAction == B_LAYER_ACTION_RESIZE) { - // do nothing - } else { - updateReg.IntersectWith(®); - } - - if (updateReg.CountRects() > 0) { - fDriver->ConstrainClippingRegion(&updateReg); - Draw(updateReg.Frame()); - fDriver->ConstrainClippingRegion(NULL); - } - } - - for (Layer *lay = BottomChild(); lay != NULL; lay = UpperSibling()) { - if (lay == startFrom) - redraw = true; - - if (redraw && !(lay->IsHidden())) { - // no need to go deeper if not even the FullVisible region intersects - // Update one. - BRegion common(lay->fFullVisible); - common.IntersectWith(®); - - if (common.CountRects() > 0) - lay->RequestDraw(reg, NULL); - } - } -#else - if (fVisible2.CountRects() > 0) { - BRegion updateReg(fVisible2); - // calculate the update region - if (fFlags & B_FULL_UPDATE_ON_RESIZE -// TODO: must be replaced! -// && fFrameAction == B_LAYER_ACTION_RESIZE - ) { - // do nothing - } else { - updateReg.IntersectWith(®); - } - - if (updateReg.CountRects() > 0) { - fDriver->ConstrainClippingRegion(&updateReg); - Draw(updateReg.Frame()); - fDriver->ConstrainClippingRegion(NULL); - } - } - - for (Layer *lay = BottomChild(); lay != NULL; lay = UpperSibling()) { - if (lay == startFrom) - redraw = true; - - if (redraw && !(lay->IsHidden())) { - // no need to go deeper if not even the FullVisible region intersects - // Update one. - BRegion common(lay->fFullVisible2); - common.IntersectWith(®); - - if (common.CountRects() > 0) - lay->RequestDraw(reg, NULL); - } - } -#endif -} /*! \brief Returns the layer's ServerWindow diff --git a/src/servers/app/Layer.h b/src/servers/app/Layer.h index 6eafcb9b44..6a757572d8 100644 --- a/src/servers/app/Layer.h +++ b/src/servers/app/Layer.h @@ -189,9 +189,6 @@ class Layer { bool IsTopLayer() const { return fIsTopLayer; } - void UpdateStart(); - void UpdateEnd(); - BRegion* ClippingRegion() const { return fClipReg; } diff --git a/src/servers/app/RootLayer.cpp b/src/servers/app/RootLayer.cpp index ba2d7dfd24..aaf9368805 100644 --- a/src/servers/app/RootLayer.cpp +++ b/src/servers/app/RootLayer.cpp @@ -288,6 +288,7 @@ RootLayer::WorkingThread(void *data) } case AS_ROOTLAYER_DO_INVALIDATE: { +//printf("Adi: new message\n"); BRegion invalidRegion; Layer *layer = NULL; messageQueue.Read(&layer); @@ -399,7 +400,6 @@ RootLayer::GoInvalidate(const Layer *layer, const BRegion ®ion) { BPrivate::PortLink msg(fListenPort, -1); msg.StartMessage(AS_ROOTLAYER_DO_INVALIDATE); -//debugger("y"); msg.Attach(layer); msg.AttachRegion(region); msg.Flush(); diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index e35015cfcd..f29236f446 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -1461,8 +1461,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) (fCurrentLayer->fVisible) #endif ; - if (fWinBorder->fInUpdate) - rreg.IntersectWith(&fWinBorder->yUpdateReg); + if (fWinBorder->InUpdate()) + rreg.IntersectWith(&fWinBorder->RegionToBeUpdated()); gDesktop->GetDisplayDriver()->ConstrainClippingRegion(&rreg); // rgb_color rrr = fCurrentLayer->fLayerData->viewcolor.GetColor32(); diff --git a/src/servers/app/WinBorder.cpp b/src/servers/app/WinBorder.cpp index 791905a968..90b3bfc0e0 100644 --- a/src/servers/app/WinBorder.cpp +++ b/src/servers/app/WinBorder.cpp @@ -69,9 +69,8 @@ WinBorder::WinBorder(const BRect &r, fDecorator(NULL), fTopLayer(NULL), - zUpdateReg(), - yUpdateReg(), - fUpdateReg(), + fCumulativeRegion(), + fInUpdateRegion(), fMouseButtons(0), fKeyModifiers(0), @@ -182,9 +181,8 @@ y = (float)int32(y); // NOTE: I moved this here from Layer::move_layer() // Should this have any bad consequences I'm not aware of? -zUpdateReg.OffsetBy(x, y); -yUpdateReg.OffsetBy(x, y); -fUpdateReg.OffsetBy(x, y); +fCumulativeRegion.OffsetBy(x, y); +fInUpdateRegion.OffsetBy(x, y); if (IsHidden()) { // TODO: This is a work around for a design issue: @@ -280,6 +278,35 @@ y = (float)int32(y); } } +// UpdateStart +void +WinBorder::UpdateStart() +{ + // During updates we only want to draw what's in the update region + fInUpdate = true; + fRequestSent = false; + +cnt--; +if (cnt != 0) + CRITICAL("Layer::UpdateStart(): wb->cnt != 0 -> Not Allowed!"); +} + +// UpdateEnd +void +WinBorder::UpdateEnd() +{ + // The usual case. Drawing is permitted in the whole visible area. + + fInUpdate = false; + + fInUpdateRegion.MakeEmpty(); + + if (fCumulativeRegion.CountRects() > 0) { + BRegion reg(fCumulativeRegion); + RequestDraw(reg, NULL); + } +} + #ifndef NEW_CLIPPING //! Rebuilds the WinBorder's "fully-visible" region based on info from the decorator diff --git a/src/servers/app/WinBorder.h b/src/servers/app/WinBorder.h index 9f6102970d..d3b7e0d27c 100644 --- a/src/servers/app/WinBorder.h +++ b/src/servers/app/WinBorder.h @@ -66,6 +66,14 @@ class WinBorder : public Layer { #ifndef NEW_CLIPPING virtual void RebuildFullRegion(); #endif + + void UpdateStart(); + void UpdateEnd(); + inline bool InUpdate() const + { return fInUpdate; } + inline const BRegion& RegionToBeUpdated() const + { return fInUpdateRegion; } + void SetSizeLimits(float minWidth, float maxWidth, float minHeight, @@ -132,9 +140,8 @@ class WinBorder : public Layer { Decorator* fDecorator; Layer* fTopLayer; - BRegion zUpdateReg; - BRegion yUpdateReg; - BRegion fUpdateReg; + BRegion fCumulativeRegion; + BRegion fInUpdateRegion; int32 fMouseButtons; int32 fKeyModifiers;