diff --git a/src/servers/app/Layer.cpp b/src/servers/app/Layer.cpp index 8a0665c820..89f5989736 100644 --- a/src/servers/app/Layer.cpp +++ b/src/servers/app/Layer.cpp @@ -1248,8 +1248,8 @@ Layer::PruneTree(void) void Layer::PrintToStream() { - printf("\n----------- Layer %s -----------\n", Name()); - printf("\t Parent: %s\n", fParent ? fParent->Name() : ""); + printf("\n *** Layer %s:\n", Name()); + printf("\t Parent: %s", fParent ? fParent->Name() : ""); printf("\t us: %s\t ls: %s\n", fUpperSibling ? fUpperSibling->Name() : "", @@ -1259,11 +1259,12 @@ Layer::PrintToStream() fTopChild ? fTopChild->Name() : "", fBottomChild ? fBottomChild->Name() : ""); - printf("Frame: (%f, %f, %f, %f)", fFrame.left, fFrame.top, fFrame.right, fFrame.bottom); + printf("Frame: (%f, %f, %f, %f)\n", fFrame.left, fFrame.top, fFrame.right, fFrame.bottom); + printf("LocalOrigin: (%f, %f)\n", BoundsOrigin().x, BoundsOrigin().y); printf("Token: %ld\n", fViewToken); - printf("Hidden - direct: %s\n", fHidden?"true":"false"); + printf("Hidden - direct: %s ", fHidden?"true":"false"); printf("Hidden - indirect: %s\n", IsHidden()?"true":"false"); - printf("ResizingMode: %lx\n", fResizeMode); + printf("ResizingMode: %lx ", fResizeMode); printf("Flags: %lx\n", fFlags); if (fLayerData) @@ -1401,7 +1402,6 @@ if (fOwner->cnt != 1) CRITICAL("Layer::RequestDraw(): fOwner->cnt != 1 -> Not Allowed!"); fOwner->fCumulativeRegion.MakeEmpty(); fOwner->fRequestSent = true; -printf("Send\n"); SendUpdateMsg(fOwner->fInUpdateRegion); } } @@ -1574,8 +1574,14 @@ Layer::SendUpdateMsg(BRegion& reg) { BMessage msg; msg.what = _UPDATE_; - msg.AddRect("_rect", ConvertFromTop(reg.Frame()) ); - msg.AddRect("debug_rect", reg.Frame() ); +#ifndef NEW_CLIPPING + msg.AddRect("_rect", ConvertFromTop(reg.Frame())); +#else + BRect rect(reg.Frame()); + ConvertFromScreen2(&rect); + msg.AddRect("_rect", rect ); +#endif + msg.AddRect("debug_rect", reg.Frame()); // msg.AddInt32("_token",fViewToken); fOwner->Window()->SendMessageToClient(&msg); @@ -1629,6 +1635,94 @@ Layer::SetOverlayBitmap(const ServerBitmap* bitmap) } #ifdef NEW_CLIPPING + +//! converts a point from local to parent's coordinate system +void +Layer::ConvertToParent2(BPoint* pt) const +{ + if (fParent) { + BPoint origin = BoundsOrigin(); + pt->x -= origin.x; + pt->y -= origin.y; + pt->x += fFrame.left; + pt->y += fFrame.top; + } +} + +//! converts a rect from local to parent's coordinate system +void +Layer::ConvertToParent2(BRect* rect) const +{ + if (fParent) { + BPoint origin = BoundsOrigin(); + rect->OffsetBy(-origin.x, -origin.y); + rect->OffsetBy(fFrame.left, fFrame.top); + } +} + +//! converts a region from local to parent's coordinate system +void +Layer::ConvertToParent2(BRegion* reg) const +{ + if (fParent) { + BPoint origin = BoundsOrigin(); + reg->OffsetBy(-origin.x, -origin.y); + reg->OffsetBy(fFrame.left, fFrame.top); + } +} + +//! converts a point from parent's to local coordinate system +void +Layer::ConvertFromParent2(BPoint* pt) const +{ + if (fParent) { + BPoint origin = BoundsOrigin(); + pt->x += origin.x; + pt->y += origin.y; + pt->x -= fFrame.left; + pt->y -= fFrame.top; + } +} + +//! converts a rect from parent's to local coordinate system +void +Layer::ConvertFromParent2(BRect* rect) const +{ + if (fParent) { + BPoint origin = BoundsOrigin(); + rect->OffsetBy(origin.x, origin.y); + rect->OffsetBy(-fFrame.left, -fFrame.top); + } +} + +//! converts a region from parent's to local coordinate system +void +Layer::ConvertFromParent2(BRegion* reg) const +{ + if (fParent) { + BPoint origin = BoundsOrigin(); + reg->OffsetBy(origin.x, origin.y); + reg->OffsetBy(-fFrame.left, -fFrame.top); + } +} + +//! converts a point from local to screen coordinate system +void +Layer::ConvertToScreen2(BPoint* pt) const +{ + if (GetRootLayer()) + if (fParent) { + BPoint origin = BoundsOrigin(); + pt->x -= origin.x; + pt->y -= origin.y; + pt->x += fFrame.left; + pt->y += fFrame.top; + + fParent->ConvertToScreen2(pt); + } +} + +//! converts a rect from local to screen coordinate system void Layer::ConvertToScreen2(BRect* rect) const { @@ -1642,6 +1736,7 @@ Layer::ConvertToScreen2(BRect* rect) const } } +//! converts a region from local to screen coordinate system void Layer::ConvertToScreen2(BRegion* reg) const { @@ -1655,6 +1750,51 @@ Layer::ConvertToScreen2(BRegion* reg) const } } +//! converts a point from screen to local coordinate system +void +Layer::ConvertFromScreen2(BPoint* pt) const +{ + if (GetRootLayer()) + if (fParent) { + BPoint origin = BoundsOrigin(); + pt->x += origin.x; + pt->y += origin.y; + pt->x -= fFrame.left; + pt->y -= fFrame.top; + + fParent->ConvertToScreen2(pt); + } +} + +//! converts a rect from screen to local coordinate system +void +Layer::ConvertFromScreen2(BRect* rect) const +{ + if (GetRootLayer()) + if (fParent) { + BPoint origin = BoundsOrigin(); + rect->OffsetBy(origin.x, origin.y); + rect->OffsetBy(-fFrame.left, -fFrame.top); + + fParent->ConvertFromScreen2(rect); + } +} + +//! converts a region from screen to local coordinate system +void +Layer::ConvertFromScreen2(BRegion* reg) const +{ + if (GetRootLayer()) + if (fParent) { + BPoint origin = BoundsOrigin(); + reg->OffsetBy(origin.x, origin.y); + reg->OffsetBy(-fFrame.left, -fFrame.top); + + fParent->ConvertFromScreen2(reg); + } +} + + void Layer::do_Hide() { @@ -1995,31 +2135,31 @@ Layer::do_ScrollBy(float dx, float dy) if (dx != 0.0f || dy != 0.0f) ScrolledByHook(dx, dy); } + void Layer::get_user_regions(BRegion ®) { // 1) set to frame in screen coords - BRect screenFrame(Bounds()); + BRect screenFrame(Bounds()); ConvertToScreen2(&screenFrame); reg.Set(screenFrame); // 2) intersect with screen region - BRegion screenReg(GetRootLayer()->Bounds()); + BRegion screenReg(GetRootLayer()->Bounds()); reg.IntersectWith(&screenReg); -// TODO: you MUST at some point uncomment this block! -/* + // 3) impose user constrained regions - LayerData *stackData = fLayerData; - while (stackData) - { - // transform in screen coords - BRegion screenReg(stackData->ClippingRegion()); - ConvertToScreen2(&screenReg); - reg.IntersectWith(&screenReg); - stackData = stackData->prevState; + LayerData *stackData = fLayerData; + while (stackData) { + if (stackData->ClippingRegion()) { + // transform in screen coords + BRegion screenReg(*stackData->ClippingRegion()); + ConvertToScreen2(&screenReg); + reg.IntersectWith(&screenReg); + } + stackData = stackData->prevState; } -*/ } void diff --git a/src/servers/app/Layer.h b/src/servers/app/Layer.h index 6a757572d8..d51c9193dc 100644 --- a/src/servers/app/Layer.h +++ b/src/servers/app/Layer.h @@ -214,8 +214,19 @@ class Layer { virtual void ResizedByHook(float dx, float dy, bool automatic) { } virtual void ScrolledByHook(float dx, float dy) { } + void ConvertToParent2(BPoint* pt) const; + void ConvertToParent2(BRect* rect) const; + void ConvertToParent2(BRegion* reg) const; + void ConvertFromParent2(BPoint* pt) const; + void ConvertFromParent2(BRect* rect) const; + void ConvertFromParent2(BRegion* reg) const; + + void ConvertToScreen2(BPoint* pt) const; void ConvertToScreen2(BRect* rect) const; void ConvertToScreen2(BRegion* reg) const; + void ConvertFromScreen2(BPoint* pt) const; + void ConvertFromScreen2(BRect* rect) const; + void ConvertFromScreen2(BRegion* reg) const; bool IsVisuallyHidden() const; private: void do_Hide(); diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index f29236f446..155ea8ae48 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -894,7 +894,6 @@ myRootLayer->Unlock(); // TODO: you are not allowed to use Layer regions here!!! // If there is no other way, then first lock RootLayer object first. - // TODO: Watch out for the coordinate system in AS_LAYER_CLIP_TO_PICTURE int32 pictureToken; BPoint where; bool inverse = false; @@ -914,13 +913,13 @@ myRootLayer->Unlock(); // I think PictureToRegion would fit better into the Layer class (?) if (PictureToRegion(picture, region, inverse, where) < B_OK) break; - + fCurrentLayer->fLayerData->SetClippingRegion(region); #ifndef NEW_CLIPPING fCurrentLayer->RebuildFullRegion(); #endif - if (!(fCurrentLayer->IsHidden())) + if (!(fCurrentLayer->IsHidden()) && !fWinBorder->InUpdate()) #ifndef NEW_CLIPPING myRootLayer->GoInvalidate(fCurrentLayer, fCurrentLayer->fFull); #else @@ -949,9 +948,6 @@ myRootLayer->Unlock(); int32 noOfRects; ld = fCurrentLayer->fLayerData; -#ifndef NEW_CLIPPING - reg = fCurrentLayer->ConvertFromParent(&(fCurrentLayer->fVisible)); -#endif if (ld->ClippingRegion()) reg.IntersectWith(ld->ClippingRegion()); @@ -963,7 +959,7 @@ myRootLayer->Unlock(); if (ld->ClippingRegion()) reg.IntersectWith(ld->ClippingRegion()); } - + noOfRects = reg.CountRects(); fLink.StartMessage(SERVER_TRUE); fLink.Attach(noOfRects); @@ -992,11 +988,10 @@ myRootLayer->Unlock(); #ifndef NEW_CLIPPING fCurrentLayer->RebuildFullRegion(); -#endif - if (!(fCurrentLayer->IsHidden())) -#ifndef NEW_CLIPPING + if (!(fCurrentLayer->IsHidden()) && !fWinBorder->InUpdate()) myRootLayer->GoInvalidate(fCurrentLayer, fCurrentLayer->fFull); #else + if (!(fCurrentLayer->IsHidden()) && !fWinBorder->InUpdate()) myRootLayer->GoInvalidate(fCurrentLayer, fCurrentLayer->Frame()); #endif @@ -1456,11 +1451,12 @@ void ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) { fWinBorder->GetRootLayer()->Lock(); - BRegion rreg #ifndef NEW_CLIPPING - (fCurrentLayer->fVisible) + BRegion rreg(fCurrentLayer->fVisible); +#else + BRegion rreg(fCurrentLayer->fVisible2); #endif - ; + if (fWinBorder->InUpdate()) rreg.IntersectWith(&fWinBorder->RegionToBeUpdated());