integration of the new clipping code continues

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13277 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adi Oanca 2005-06-25 15:45:58 +00:00
parent d06e1bff11
commit e3fbc7752f
3 changed files with 181 additions and 34 deletions

View File

@ -1248,8 +1248,8 @@ Layer::PruneTree(void)
void
Layer::PrintToStream()
{
printf("\n----------- Layer %s -----------\n", Name());
printf("\t Parent: %s\n", fParent ? fParent->Name() : "<no parent>");
printf("\n *** Layer %s:\n", Name());
printf("\t Parent: %s", fParent ? fParent->Name() : "<no parent>");
printf("\t us: %s\t ls: %s\n",
fUpperSibling ? fUpperSibling->Name() : "<none>",
@ -1259,11 +1259,12 @@ Layer::PrintToStream()
fTopChild ? fTopChild->Name() : "<none>",
fBottomChild ? fBottomChild->Name() : "<none>");
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 &reg)
{
// 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

View File

@ -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();

View File

@ -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<int32>(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());