diff --git a/src/servers/app/Layer.cpp b/src/servers/app/Layer.cpp index 145c6a6193..d97301b605 100644 --- a/src/servers/app/Layer.cpp +++ b/src/servers/app/Layer.cpp @@ -65,18 +65,10 @@ Layer::Layer(BRect frame, const char* name, int32 token, fCurrent(NULL), // all regions (fVisible, fFullVisible, fFull) start empty -#ifndef NEW_CLIPPING - fVisible(), - fFullVisible(), - fFull(), - fFrameAction(B_LAYER_ACTION_NONE), - fClipReg(&fVisible), -#else fVisible2(), fFullVisible2(), fDirtyForRebuild(), fClipReg(&fVisible2), -#endif fServerWin(NULL), fName(name), @@ -191,10 +183,6 @@ Layer::AddChild(Layer* layer, ServerWindow* serverWin) // 2.2) this Layer must know if it has a ServerWindow object attached. c->fServerWin=serverWin; - // 2.3) we are attached to the main tree so build our full region. -#ifndef NEW_CLIPPING - c->RebuildFullRegion(); -#endif // tree parsing algorithm if (c->fFirstChild) { // go deep @@ -266,10 +254,7 @@ Layer::RemoveChild(Layer *layer) layer->fPreviousSibling = NULL; layer->fNextSibling = NULL; - -#ifdef NEW_CLIPPING layer->clear_visible_regions(); -#endif // 2) Iterate over all of the removed-layer's descendants and unset the // root layer, server window, and all redraw-related regions @@ -284,14 +269,6 @@ Layer::RemoveChild(Layer *layer) c->SetRootLayer(NULL); // 2.2) this Layer must know if it has a ServerWindow object attached. c->fServerWin = NULL; - // 2.3) we were removed from the main tree so clear our full region. -#ifndef NEW_CLIPPING - c->fFull.MakeEmpty(); - // 2.4) clear fullVisible region. - c->fFullVisible.MakeEmpty(); - // 2.5) we don't have a visible region anymore. - c->fVisible.MakeEmpty(); -#endif } // tree parsing algorithm @@ -404,17 +381,6 @@ Layer::LayerAt(const BPoint &pt, bool recursive) return NULL; } -#ifndef NEW_CLIPPING - if (fVisible.Contains(pt)) - return this; - - if (fFullVisible.Contains(pt)) { - for (Layer* child = LastChild(); child; child = PreviousChild()) { - if (Layer* layer = child->LayerAt(pt)) - return layer; - } - } -#else if (fVisible2.Contains(pt)) return this; @@ -424,7 +390,7 @@ Layer::LayerAt(const BPoint &pt, bool recursive) return layer; } } -#endif + return NULL; } @@ -475,398 +441,6 @@ Layer::SetFlags(uint32 flags) fDrawState->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE); } -#ifndef NEW_CLIPPING - -//! Rebuilds the layer's "completely visible" region -void -Layer::RebuildFullRegion(void) -{ - STRACE(("Layer(%s)::RebuildFullRegion()\n", Name())); - - if (fParent) - fFull.Set(fParent->ConvertToTop(fFrame )); - else - fFull.Set(fFrame); - - // TODO: restrict to screen coordinates - - // TODO: Convert to screen coordinates - - DrawState *ld; - ld = fDrawState; - do { - // clip to user region - if (const BRegion* userClipping = ld->ClippingRegion()) - fFull.IntersectWith(userClipping); - - } while ((ld = ld->PreviousState())); -} - -// StartRebuildRegions -void -Layer::StartRebuildRegions( const BRegion& reg, Layer *target, uint32 action, BPoint& pt) -{ - STRACE(("Layer(%s)::StartRebuildRegions() START\n", Name())); - RBTRACE(("\n\nLayer(%s)::StartRebuildRegions() START\n", Name())); - if (!fParent) - fFullVisible = fFull; - - BRegion oldVisible = fVisible; - - fVisible = fFullVisible; - - // Rebuild regions for children... - for (Layer *lay = LastChild(); lay; lay = PreviousChild()) { - if (lay == target) - lay->RebuildRegions(reg, action, pt, BPoint(0.0f, 0.0f)); - else - lay->RebuildRegions(reg, B_LAYER_NONE, pt, BPoint(0.0f, 0.0f)); - } - - #ifdef DEBUG_LAYER_REBUILD - printf("\nSRR: Layer(%s) ALMOST done regions:\n", Name()); - printf("\tVisible Region:\n"); - fVisible.PrintToStream(); - printf("\tFull Visible Region:\n"); - fFullVisible.PrintToStream(); - #endif - - BRegion redrawReg(fVisible); - - // if this is the first time - if (oldVisible.CountRects() > 0) - redrawReg.Exclude(&oldVisible); - - if (redrawReg.CountRects() > 0) - fRootLayer->fRedrawReg.Include(&redrawReg); - - #ifdef DEBUG_LAYER_REBUILD - printf("\nLayer(%s)::StartRebuildRegions() DONE. Results:\n", Name()); - printf("\tRedraw Region:\n"); - fRootLayer->fRedrawReg.PrintToStream(); - printf("\tCopy Region:\n"); - for (int32 k=0; kfCopyRegList.CountItems(); k++) { - ((BRegion*)(fRootLayer->fCopyRegList.ItemAt(k)))->PrintToStream(); - ((BPoint*)(fRootLayer->fCopyList.ItemAt(k)))->PrintToStream(); - } - printf("\n"); - #endif - - STRACE(("Layer(%s)::StartRebuildRegions() END\n", Name())); - RBTRACE(("Layer(%s)::StartRebuildRegions() END\n", Name())); -} - -// RebuildRegions -void -Layer::RebuildRegions( const BRegion& reg, uint32 action, BPoint pt, BPoint ptOffset) -{ - STRACE(("Layer(%s)::RebuildRegions() START\n", Name())); - - // TODO:/NOTE: this method must be executed as quickly as possible. - - // Currently SendView[Moved/Resized]Msg() simply constructs a message and calls - // ServerWindow::SendMessageToClient(). This involves the alternative use of - // kernel and this code in the CPU, so there are a lot of context switches. - // This is NOT good at all! - - // One alternative would be the use of a BMessageQueue per ServerWindows OR only - // one for app_server which will be emptied as soon as this critical operation ended. - // Talk to DW, Gabe. - - BRegion oldRegion; - uint32 newAction = action; - BPoint newPt = pt; - BPoint newOffset = ptOffset; // used for resizing only - - BPoint dummyNewLocation; - - RRLabel1: - switch(action) { - case B_LAYER_NONE: { - RBTRACE(("1) Layer(%s): Action B_LAYER_NONE\n", Name())); - STRACE(("1) Layer(%s): Action B_LAYER_NONE\n", Name())); - oldRegion = fVisible; - break; - } - case B_LAYER_MOVE: { - RBTRACE(("1) Layer(%s): Action B_LAYER_MOVE\n", Name())); - STRACE(("1) Layer(%s): Action B_LAYER_MOVE\n", Name())); - oldRegion = fFullVisible; - fFrame.OffsetBy(pt.x, pt.y); - fFull.OffsetBy(pt.x, pt.y); - - // TODO: investigate combining frame event messages for efficiency - //SendViewMovedMsg(); - AddToViewsWithInvalidCoords(); - - newAction = B_LAYER_SIMPLE_MOVE; - break; - } - case B_LAYER_SIMPLE_MOVE: { - RBTRACE(("1) Layer(%s): Action B_LAYER_SIMPLE_MOVE\n", Name())); - STRACE(("1) Layer(%s): Action B_LAYER_SIMPLE_MOVE\n", Name())); - fFull.OffsetBy(pt.x, pt.y); - - break; - } - case B_LAYER_RESIZE: { - RBTRACE(("1) Layer(%s): Action B_LAYER_RESIZE\n", Name())); - STRACE(("1) Layer(%s): Action B_LAYER_RESIZE\n", Name())); - oldRegion = fVisible; - - fFrame.right += pt.x; - fFrame.bottom += pt.y; - RebuildFullRegion(); - - // TODO: investigate combining frame event messages for efficiency - //SendViewResizedMsg(); - AddToViewsWithInvalidCoords(); - - newAction = B_LAYER_MASK_RESIZE; - break; - } - case B_LAYER_MASK_RESIZE: { - RBTRACE(("1) Layer(%s): Action B_LAYER_MASK_RESIZE\n", Name())); - STRACE(("1) Layer(%s): Action B_LAYER_MASK_RESIZE\n", Name())); - oldRegion = fVisible; - - BPoint offset, rSize; - BPoint coords[2]; - - ResizeOthers(pt.x, pt.y, coords, NULL); - offset = coords[0]; - rSize = coords[1]; - newOffset = offset + ptOffset; - - if (!(rSize.x == 0.0f && rSize.y == 0.0f)) { - fFrame.OffsetBy(offset); - fFrame.right += rSize.x; - fFrame.bottom += rSize.y; - RebuildFullRegion(); - - // TODO: investigate combining frame event messages for efficiency - //SendViewResizedMsg(); - AddToViewsWithInvalidCoords(); - - newAction = B_LAYER_MASK_RESIZE; - newPt = rSize; - dummyNewLocation = newOffset; - } else { - if (!(offset.x == 0.0f && offset.y == 0.0f)) { - pt = newOffset; - action = B_LAYER_MOVE; - newPt = pt; - goto RRLabel1; - } else { - pt = ptOffset; - action = B_LAYER_MOVE; - newPt = pt; - goto RRLabel1; - } - } - break; - } - } - - if (!IsHidden()) { - #ifdef DEBUG_LAYER_REBUILD - printf("Layer(%s) real action START\n", Name()); - fFull.PrintToStream(); - #endif - fFullVisible.MakeEmpty(); - fVisible = fFull; - - if (fParent && fVisible.CountRects() > 0) { - // not the usual case, but support fot this is needed. - if (fParent->fAdFlags & B_LAYER_CHILDREN_DEPENDANT) { - #ifdef DEBUG_LAYER_REBUILD - printf(" B_LAYER_CHILDREN_DEPENDANT Parent\n"); - #endif - - // because we're skipping one level, we need to do out - // parent business as well. - - // our visible area is relative to our parent's parent. - if (fParent->fParent) - fVisible.IntersectWith(&(fParent->fParent->fVisible)); - - // exclude parent's visible area which could be composed by - // prior siblings' visible areas. - if (fVisible.CountRects() > 0) - fVisible.Exclude(&(fParent->fVisible)); - - // we have a final visible area. Include it to our parent's one, - // exclude from parent's parent. - if (fVisible.CountRects() > 0) { - fParent->fFullVisible.Include(&fVisible); - - if (fParent->fParent) - fParent->fParent->fVisible.Exclude(&fVisible); - } - } else { - // for 95+% of cases - - #ifdef DEBUG_LAYER_REBUILD - printf(" (!)B_LAYER_CHILDREN_DEPENDANT Parent\n"); - #endif - - // the visible area is the one common with parent's one. - fVisible.IntersectWith(&(fParent->fVisible)); - - // exclude from parent's visible area. we're the owners now. - if (fVisible.CountRects() > 0) - fParent->fVisible.Exclude(&fVisible); - } - } - fFullVisible = fVisible; - } - - // Rebuild regions for children... - for(Layer *lay = LastChild(); lay != NULL; lay = PreviousChild()) - lay->RebuildRegions(reg, newAction, newPt, newOffset); - - #ifdef DEBUG_LAYER_REBUILD - printf("\nLayer(%s) ALMOST done regions:\n", Name()); - printf("\tVisible Region:\n"); - fVisible.PrintToStream(); - printf("\tFull Visible Region:\n"); - fFullVisible.PrintToStream(); - #endif - - if(!IsHidden()) { - switch(action) { - case B_LAYER_NONE: { - RBTRACE(("2) Layer(%s): Action B_LAYER_NONE\n", Name())); - BRegion r(fVisible); - if (oldRegion.CountRects() > 0) - r.Exclude(&oldRegion); - - if(r.CountRects() > 0) - fRootLayer->fRedrawReg.Include(&r); - break; - } - case B_LAYER_MOVE: { - RBTRACE(("2) Layer(%s): Action B_LAYER_MOVE\n", Name())); - BRegion redrawReg; - BRegion *copyReg = new BRegion(); - BRegion screenReg(fRootLayer->Bounds()); - - oldRegion.OffsetBy(pt.x, pt.y); - oldRegion.IntersectWith(&fFullVisible); - - *copyReg = oldRegion; - copyReg->IntersectWith(&screenReg); - if (copyReg->CountRects() > 0 && !(pt.x == 0.0f && pt.y == 0.0f)) { - copyReg->OffsetBy(-pt.x, -pt.y); - BPoint *point = new BPoint(pt); - fRootLayer->fCopyRegList.AddItem(copyReg); - fRootLayer->fCopyList.AddItem(point); - } else { - delete copyReg; - } - - redrawReg = fFullVisible; - redrawReg.Exclude(&oldRegion); - if (redrawReg.CountRects() > 0 && !(pt.x == 0.0f && pt.y == 0.0f)) { - fRootLayer->fRedrawReg.Include(&redrawReg); - } - - break; - } - case B_LAYER_RESIZE: { - RBTRACE(("2) Layer(%s): Action B_LAYER_RESIZE\n", Name())); - BRegion redrawReg; - - redrawReg = fVisible; - redrawReg.Exclude(&oldRegion); - if(redrawReg.CountRects() > 0) - fRootLayer->fRedrawReg.Include(&redrawReg); - - break; - } - case B_LAYER_MASK_RESIZE: { - RBTRACE(("2) Layer(%s): Action B_LAYER_MASK_RESIZE\n", Name())); - BRegion redrawReg; - BRegion *copyReg = new BRegion(); - - oldRegion.OffsetBy(dummyNewLocation.x, dummyNewLocation.y); - - redrawReg = fVisible; - redrawReg.Exclude(&oldRegion); - if (redrawReg.CountRects() > 0) - fRootLayer->fRedrawReg.Include(&redrawReg); - - *copyReg = fVisible; - copyReg->IntersectWith(&oldRegion); - copyReg->OffsetBy(-dummyNewLocation.x, -dummyNewLocation.y); - if (copyReg->CountRects() > 0 - && !(dummyNewLocation.x == 0.0f && dummyNewLocation.y == 0.0f)) { - fRootLayer->fCopyRegList.AddItem(copyReg); - fRootLayer->fCopyList.AddItem(new BPoint(dummyNewLocation)); - } - - break; - } - default: - RBTRACE(("2) Layer(%s): Action default\n", Name())); - break; - } - } -/* if (IsHidden()) { - fFullVisible.MakeEmpty(); - fVisible.MakeEmpty(); - } -*/ - - STRACE(("Layer(%s)::RebuildRegions() END\n", Name())); -} - -// ResizeOthers -uint32 -Layer::ResizeOthers(float x, float y, BPoint coords[], BPoint *ptOffset) -{ - STRACE(("Layer(%s)::ResizeOthers() START\n", Name())); - uint32 rmask = fResizeMode; - - // offset - coords[0].x = 0.0f; - coords[0].y = 0.0f; - - // resize by width/height - coords[1].x = 0.0f; - coords[1].y = 0.0f; - - if ((rmask & 0x00000f00UL)>>8 == _VIEW_LEFT_ && - (rmask & 0x0000000fUL)>>0 == _VIEW_RIGHT_) { - coords[1].x = x; - } else if ((rmask & 0x00000f00UL)>>8 == _VIEW_LEFT_) { - } else if ((rmask & 0x0000000fUL)>>0 == _VIEW_RIGHT_) { - coords[0].x = x; - } else if ((rmask & 0x00000f00UL)>>8 == _VIEW_CENTER_) { - coords[0].x = x/2; - } else { - // illegal flag. Do nothing. - } - - - if ((rmask & 0x0000f000UL)>>12 == _VIEW_TOP_ && - (rmask & 0x000000f0UL)>>4 == _VIEW_BOTTOM_) { - coords[1].y = y; - } else if ((rmask & 0x0000f000UL)>>12 == _VIEW_TOP_) { - } else if ((rmask & 0x000000f0UL)>>4 == _VIEW_BOTTOM_) { - coords[0].y = y; - } else if ((rmask & 0x0000f000UL)>>12 == _VIEW_CENTER_) { - coords[0].y = y/2; - } else { - // illegal flag. Do nothing. - } - - STRACE(("Layer(%s)::ResizeOthers() END\n", Name())); - return 0UL; -} - -#endif - // Redraw void Layer::Redraw(const BRegion& reg, Layer *startFrom) @@ -897,25 +471,6 @@ Layer::Draw(const BRect &rect) fDriver->FillRect(rect, ViewColor()); } -#ifndef NEW_CLIPPING -// EmptyGlobals -void -Layer::EmptyGlobals() -{ - fRootLayer->fRedrawReg.MakeEmpty(); - - int32 count = fRootLayer->fCopyRegList.CountItems(); - for (int32 i = 0; i < count; i++) - delete (BRegion*)fRootLayer->fCopyRegList.ItemAt(i); - fRootLayer->fCopyRegList.MakeEmpty(); - - count = fRootLayer->fCopyList.CountItems(); - for (int32 i = 0; i < count; i++) - delete (BPoint*)fRootLayer->fCopyList.ItemAt(i); - fRootLayer->fCopyList.MakeEmpty(); -} -#endif - /*! \brief Shows the layer \param invalidate Invalidate the region when showing the layer. defaults to true @@ -935,14 +490,6 @@ Layer::Show(bool invalidate) SendViewCoordUpdateMsg(); -// NOTE: I added this here and it solves the invalid region problem -// for Windows that have been resized before they were shown. -Stephan -#ifndef NEW_CLIPPING -RebuildFullRegion(); - - if (invalidate) - GetRootLayer()->GoInvalidate(this, fFull); -#else if (invalidate) { // compute the region this layer wants for itself BRegion invalid; @@ -953,11 +500,8 @@ RebuildFullRegion(); fParent->TriggerRebuild(); GetRootLayer()->TriggerRedraw(); - -// GetRootLayer()->GoInvalidate(this, invalid); } } -#endif } /*! @@ -976,10 +520,6 @@ Layer::Hide(bool invalidate) } fHidden = true; -#ifndef NEW_CLIPPING - if (invalidate) - GetRootLayer()->GoInvalidate(this, fFullVisible); -#else if (invalidate && fFullVisible2.CountRects() > 0) { BRegion invalid(fFullVisible2); @@ -988,10 +528,7 @@ Layer::Hide(bool invalidate) fParent->TriggerRebuild(); GetRootLayer()->TriggerRedraw(); - -// GetRootLayer()->GoInvalidate(this, fFullVisible2); } -#endif } //! Returns true if the layer is hidden @@ -1013,6 +550,8 @@ Layer::PushState() { fDrawState = fDrawState->PushState(); fDrawState->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE); + + // TODO: rebuild clipping and redraw } @@ -1026,6 +565,8 @@ Layer::PopState() fDrawState = fDrawState->PopState(); fDrawState->SetSubPixelPrecise(fFlags & B_SUBPIXEL_PRECISE); + + // TODO: rebuild clipping and redraw } @@ -1057,11 +598,7 @@ Layer::MoveBy(float x, float y) } GetRootLayer()->Lock(); -#ifndef NEW_CLIPPING - move_layer(x, y); -#else do_MoveBy(x, y); -#endif GetRootLayer()->Unlock(); STRACE(("Layer(%s)::MoveBy() END\n", Name())); @@ -1079,11 +616,7 @@ Layer::ResizeBy(float x, float y) } GetRootLayer()->Lock(); -#ifndef NEW_CLIPPING - resize_layer(x, y); -#else do_ResizeBy(x, y); -#endif GetRootLayer()->Unlock(); STRACE(("Layer(%s)::ResizeBy() END\n", Name())); @@ -1096,11 +629,7 @@ Layer::ScrollBy(float x, float y) STRACE(("Layer(%s)::ScrollBy() START\n", Name())); GetRootLayer()->Lock(); -#ifndef NEW_CLIPPING - // nothing -#else do_ScrollBy(x, y); -#endif GetRootLayer()->Unlock(); STRACE(("Layer(%s)::ScrollBy() END\n", Name())); @@ -1226,199 +755,100 @@ Layer::Scale() const BPoint Layer::ConvertToParent(BPoint pt) { -#ifndef NEW_CLIPPING - pt -= BoundsOrigin(); - pt += fFrame.LeftTop(); - return pt; -#else ConvertToParent2(&pt); return pt; -#endif } //! Converts the passed rectangle to parent coordinates BRect Layer::ConvertToParent(BRect rect) { -#ifndef NEW_CLIPPING -// rect.OffsetBy(fFrame.LeftTop()); -// return rect; - BPoint origin = BoundsOrigin(); - rect.OffsetBy(-origin.x, -origin.y); - rect.OffsetBy(fFrame.LeftTop()); - return rect; -#else ConvertToParent2(&rect); return rect; -#endif } //! Converts the passed region to parent coordinates BRegion Layer::ConvertToParent(BRegion* reg) { -#ifndef NEW_CLIPPING - // TODO: wouldn't it be more efficient to use the copy - // constructor for BRegion and then call OffsetBy()? - BRegion newreg; - for (int32 i = 0; i < reg->CountRects(); i++) - newreg.Include(ConvertToParent(reg->RectAt(i))); - return newreg; -#else BRegion newReg(*reg); ConvertToParent2(&newReg); return newReg; -#endif } //! Converts the passed point from parent coordinates BPoint Layer::ConvertFromParent(BPoint pt) { -#ifndef NEW_CLIPPING -// return pt - fFrame.LeftTop(); - pt -= fFrame.LeftTop(); - pt += BoundsOrigin(); - return pt; -#else ConvertFromParent2(&pt); return pt; -#endif } //! Converts the passed rectangle from parent coordinates BRect Layer::ConvertFromParent(BRect rect) { -#ifndef NEW_CLIPPING -// rect.OffsetBy(-fFrame.left, -fFrame.top); -// return rect; - rect.OffsetBy(-fFrame.left, -fFrame.top); - rect.OffsetBy(BoundsOrigin()); - return rect; -#else ConvertFromParent2(&rect); return rect; -#endif } //! Converts the passed region from parent coordinates BRegion Layer::ConvertFromParent(BRegion *reg) { -#ifndef NEW_CLIPPING - BRegion newreg; - for(int32 i=0; iCountRects();i++) - newreg.Include(ConvertFromParent(reg->RectAt(i))); - return newreg; -#else BRegion newReg(*reg); ConvertFromParent2(&newReg); return newReg; -#endif } // ConvertToTop BPoint Layer::ConvertToTop(BPoint pt) { -#ifndef NEW_CLIPPING - if (fParent) { -// return (fParent->ConvertToTop(pt + fFrame.LeftTop())); - pt = ConvertToParent(pt); - return fParent->ConvertToTop(pt); - } else - return pt; -#else ConvertToScreen2(&pt); return pt; -#endif } //! Converts the passed rectangle to screen coordinates BRect Layer::ConvertToTop(BRect rect) { -#ifndef NEW_CLIPPING - if (fParent) { -// return fParent->ConvertToTop(rect.OffsetByCopy(fFrame.LeftTop())); - rect = ConvertToParent(rect); - return fParent->ConvertToTop(rect); - } else - return rect; -#else ConvertToScreen2(&rect); return rect; -#endif } //! Converts the passed region to screen coordinates BRegion Layer::ConvertToTop(BRegion *reg) { -#ifndef NEW_CLIPPING - BRegion newreg; - for (int32 i = 0; i < reg->CountRects();i++) - newreg.Include(ConvertToTop(reg->RectAt(i))); - return newreg; -#else BRegion newReg(*reg); ConvertToScreen2(&newReg); return newReg; -#endif } // ConvertFromTop BPoint Layer::ConvertFromTop(BPoint pt) { -#ifndef NEW_CLIPPING - if (fParent) { -// return fParent->ConvertFromTop(pt-fFrame.LeftTop()); - pt = ConvertFromParent(pt); - return fParent->ConvertFromTop(pt); - } else - return pt; -#else ConvertFromScreen2(&pt); return pt; -#endif } //! Converts the passed rectangle from screen coordinates BRect Layer::ConvertFromTop(BRect rect) { -#ifndef NEW_CLIPPING - if (fParent) { -// return fParent->ConvertFromTop(rect.OffsetByCopy(-fFrame.LeftTop().x, -// -fFrame.LeftTop().y)); - rect = ConvertFromParent(rect); - return fParent->ConvertFromTop(rect); - } else - return rect; -#else ConvertFromScreen2(&rect); return rect; -#endif } //! Converts the passed region from screen coordinates BRegion Layer::ConvertFromTop(BRegion *reg) { -#ifndef NEW_CLIPPING - BRegion newreg; - - for (int32 i = 0; i < reg->CountRects(); i++) - newreg.Include(ConvertFromTop(reg->RectAt(i))); - - return newreg; -#else BRegion newReg(*reg); ConvertFromScreen2(&newReg); return newReg; -#endif } //! Recursively deletes all children of the calling layer @@ -1503,9 +933,6 @@ Layer::PrintNode() printf("Bottom child: %s (%p)\n", fLastChild->Name(), fLastChild); else printf("Bottom child: NULL\n"); -#ifndef NEW_CLIPPING - printf("Visible Areas: "); fVisible.PrintToStream(); -#endif } //! Prints the tree hierarchy from the current layer down @@ -1529,69 +956,6 @@ Layer::RequestDraw(const BRegion ®, Layer *startFrom) 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->fRequestSent = true; // this is here to avoid a possible de-synchronization - if (SendUpdateMsg(fOwner->fInUpdateRegion) == B_OK) { - fOwner->fCumulativeRegion.MakeEmpty(); - } - else { - fOwner->fRequestSent = false; - fOwner->fInUpdateRegion.MakeEmpty(); - } - } - } - } - - 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 = LastChild(); lay != NULL; lay = PreviousChild()) { - 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. @@ -1643,136 +1007,8 @@ if (fOwner->cnt != 1) lay->RequestDraw(reg, NULL); } } -#endif } -#ifndef NEW_CLIPPING - -// move_layer -void -Layer::move_layer(float x, float y) -{ -/* if (fClassID == AS_WINBORDER_CLASS) { - WinBorder *wb = (WinBorder*)this; - wb->fCumulativeRegion.OffsetBy(x, y); - wb->fInUpdateRegion.OffsetBy(x, y); - wb->fSavedForUpdateRegion.OffsetBy(x, y); - }*/ - - fFrameAction = B_LAYER_ACTION_MOVE; - - BPoint pt(x, y); - BRect rect(fFull.Frame().OffsetByCopy(pt)); - -if (!fParent) { -printf("no parent in Layer::move_layer() (%s)\n", Name()); -fFrameAction = B_LAYER_ACTION_NONE; -return; -} - - fParent->StartRebuildRegions(BRegion(rect), this, B_LAYER_MOVE, pt); - - fDriver->CopyRegionList(&fRootLayer->fCopyRegList, - &fRootLayer->fCopyList, - fRootLayer->fCopyRegList.CountItems(), - &fFullVisible); - - fParent->Redraw(fRootLayer->fRedrawReg, this); - - // redraw workspaces layer - if (dynamic_cast(this) != NULL && fRootLayer->WorkspacesLayer() != NULL) { - fRootLayer->GoRedraw(fRootLayer->WorkspacesLayer(), fRootLayer->WorkspacesLayer()->fVisible); - } - - SendViewCoordUpdateMsg(); - - EmptyGlobals(); - - fFrameAction = B_LAYER_ACTION_NONE; -} - -// resize_layer -void -Layer::resize_layer(float x, float y) -{ - fFrameAction = B_LAYER_ACTION_RESIZE; - - BPoint pt(x,y); - - BRect rect(fFull.Frame()); - rect.right += x; - rect.bottom += y; - -if (!fParent) { -printf("no parent in Layer::resize_layer() (%s)\n", Name()); -fFrameAction = B_LAYER_ACTION_NONE; -return; -} - - fParent->StartRebuildRegions(BRegion(rect), this, B_LAYER_RESIZE, pt); - - fDriver->CopyRegionList(&fRootLayer->fCopyRegList, &fRootLayer->fCopyList, fRootLayer->fCopyRegList.CountItems(), &fFullVisible); - - fParent->Redraw(fRootLayer->fRedrawReg, this); - - // redraw workspaces layer - if (dynamic_cast(this) != NULL && fRootLayer->WorkspacesLayer() != NULL) { - fRootLayer->GoRedraw(fRootLayer->WorkspacesLayer(), fRootLayer->WorkspacesLayer()->fVisible); - } - - SendViewCoordUpdateMsg(); - - EmptyGlobals(); - - fFrameAction = B_LAYER_ACTION_NONE; -} - -// FullInvalidate -void -Layer::FullInvalidate(const BRect &rect) -{ - FullInvalidate(BRegion(rect)); -} - -// FullInvalidate -void -Layer::FullInvalidate(const BRegion& region) -{ - STRACE(("Layer(%s)::FullInvalidate():\n", Name())); - -#ifdef DEBUG_LAYER - region.PrintToStream(); - printf("\n"); -#endif - - BPoint pt(0,0); - StartRebuildRegions(region, NULL,/* B_LAYER_INVALIDATE, pt); */B_LAYER_NONE, pt); - - Redraw(fRootLayer->fRedrawReg); - - EmptyGlobals(); -} - -// Invalidate -void -Layer::Invalidate(const BRegion& region) -{ - STRACE(("Layer(%s)::Invalidate():\n", Name())); -#ifdef DEBUG_LAYER - region.PrintToStream(); - printf("\n"); -#endif - - fRootLayer->fRedrawReg = region; - - Redraw(fRootLayer->fRedrawReg); - - EmptyGlobals(); -} - -#endif // 5 methods - - /*! \brief Returns the layer's ServerWindow @@ -1794,13 +1030,9 @@ Layer::SendUpdateMsg(BRegion& reg) { BMessage msg; msg.what = _UPDATE_; -#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); @@ -1883,42 +1115,6 @@ Layer::do_CopyBits(BRect& src, BRect& dst, int32 xOffset, int32 yOffset) { if (!GetRootLayer()) return; -#ifndef NEW_CLIPPING - - // the region that is going to be copied - BRegion copyRegion(src); - // apply the current clipping of the layer - copyRegion.IntersectWith(&fVisible); - // don't scroll regions that are pending for - // (or already in) an update - // NOTE: this fixes the visible glitches that resulted from - // scrolling, but it brings up a new problem, which looks - // like the the client receives multiple update messages for - // the same area - // NOTE2: if you don't include both regions, it doesn't work - copyRegion.Exclude(&fOwner->CulmulatedUpdateRegion()); - copyRegion.Exclude(&fOwner->RegionToBeUpdated()); - - // offset the region to the destination - // and apply the current clipping there as well - copyRegion.OffsetBy(xOffset, yOffset); - copyRegion.IntersectWith(&fVisible); - - // the region at the destination that needs invalidation - GetRootLayer()->fRedrawReg.Set(dst); - // exclude the region drawn by the copy operation - GetRootLayer()->fRedrawReg.Exclude(©Region); - // apply the current clipping as well - GetRootLayer()->fRedrawReg.IntersectWith(&fVisible); - - // move the region back for the actual operation - copyRegion.OffsetBy(-xOffset, -yOffset); - - GetDrawingEngine()->CopyRegion(©Region, xOffset, yOffset); - - // trigger the redraw - GetRootLayer()->RequestDraw(GetRootLayer()->fRedrawReg, NULL); -#else // the region that is going to be copied BRegion copyRegion(src); // apply the current clipping of the layer @@ -1945,12 +1141,8 @@ Layer::do_CopyBits(BRect& src, BRect& dst, int32 xOffset, int32 yOffset) { // trigger the redraw GetRootLayer()->RequestDraw(GetRootLayer()->fRedrawReg, NULL); -#endif - } -#ifdef NEW_CLIPPING - void Layer::MovedByHook(float dx, float dy) { @@ -2636,5 +1828,3 @@ Layer::_AllRedraw(const BRegion &invalid) } } -#endif - diff --git a/src/servers/app/Layer.h b/src/servers/app/Layer.h index ba0b3a59ca..90c6ed0ec0 100644 --- a/src/servers/app/Layer.h +++ b/src/servers/app/Layer.h @@ -103,25 +103,6 @@ class Layer { inline uint32 Flags() const { return fFlags; } -#ifndef NEW_CLIPPING - virtual void RebuildFullRegion(); - void StartRebuildRegions(const BRegion& reg, - Layer* target, - uint32 action, - BPoint& pt); - - void RebuildRegions(const BRegion& reg, - uint32 action, - BPoint pt, - BPoint ptOffset); - - uint32 ResizeOthers(float x, float y, - BPoint coords[], - BPoint* ptOffset); - - void EmptyGlobals(); - -#endif void Redraw(const BRegion& reg, Layer* startFrom = NULL); @@ -240,11 +221,7 @@ class Layer { void CopyBits(BRect& src, BRect& dst, int32 xOffset, int32 yOffset); -#ifndef NEW_CLIPPING - inline const BRegion& VisibleRegion() const { return fVisible; } - inline const BRegion& FullVisible() const { return fFullVisible; } -#else inline const BRegion& VisibleRegion() const { return fVisible2; } inline const BRegion& FullVisible() const { return fFullVisible2; } @@ -294,8 +271,6 @@ class Layer { void rezize_layer_redraw_more(BRegion ®, float dx, float dy); void resize_layer_full_update_on_resize(BRegion ®, float dx, float dy); -#endif - private: void do_CopyBits(BRect& src, BRect& dst, int32 xOffset, int32 yOffset); @@ -303,18 +278,6 @@ class Layer { friend class RootLayer; friend class WinBorder; friend class ServerWindow; -#ifndef NEW_CLIPPING - friend class OffscreenWinBorder; -#endif - -#ifndef NEW_CLIPPING - void move_layer(float x, float y); - void resize_layer(float x, float y); - - void FullInvalidate(const BRect& rect); - void FullInvalidate(const BRegion& region); - void Invalidate(const BRegion& region); -#endif BRect fFrame; // TODO: should be removed or reused in a similar fashion @@ -332,18 +295,12 @@ class Layer { mutable Layer* fCurrent; -#ifndef NEW_CLIPPING - BRegion fVisible; - BRegion fFullVisible; - BRegion fFull; - int8 fFrameAction; -#else private: BRegion fVisible2; BRegion fFullVisible2; BRegion fDirtyForRebuild; protected: -#endif + BRegion* fClipReg; ServerWindow* fServerWin; diff --git a/src/servers/app/OffscreenWinBorder.cpp b/src/servers/app/OffscreenWinBorder.cpp index db39367c54..367470f818 100644 --- a/src/servers/app/OffscreenWinBorder.cpp +++ b/src/servers/app/OffscreenWinBorder.cpp @@ -32,10 +32,6 @@ OffscreenWinBorder::OffscreenWinBorder(ServerBitmap* bitmap, fDriver->SetHWInterface(fHWInterface); fDriver->Initialize(); fDriver->Update(); - -#ifndef NEW_CLIPPING - fFull.Set(fFrame); -#endif } // destructor @@ -73,11 +69,5 @@ void OffscreenWinBorder::SetTopLayer(Layer* layer) { WinBorder::SetTopLayer(layer); - -#ifndef NEW_CLIPPING -fTopLayer->fFull.Set(fFrame.OffsetToCopy(0.0, 0.0)); -fTopLayer->fHidden = false; -fTopLayer->fVisible = fTopLayer->fFull; -#endif } diff --git a/src/servers/app/RootLayer.cpp b/src/servers/app/RootLayer.cpp index 94bf59707d..e0f7eb1282 100644 --- a/src/servers/app/RootLayer.cpp +++ b/src/servers/app/RootLayer.cpp @@ -5,7 +5,7 @@ * Authors: * Gabe Yoder * DarkWyrm - * Adrian Oanca + * Adrian Oanca * Stephan Aßmus * Axel Dörfler, axeld@pinc-software.de */ @@ -197,10 +197,7 @@ RootLayer::WorkingThread(void *data) // first make sure we are actualy visible oneRootLayer->Lock(); -#ifndef NEW_CLIPPING - oneRootLayer->RebuildFullRegion(); - oneRootLayer->GoInvalidate(oneRootLayer, oneRootLayer->Bounds()); -#else + // RootLayer starts with valid visible regions oneRootLayer->fFullVisible2.Set(oneRootLayer->Bounds()); oneRootLayer->fVisible2.Set(oneRootLayer->Bounds()); @@ -210,7 +207,7 @@ RootLayer::WorkingThread(void *data) oneRootLayer->TriggerRebuild(); oneRootLayer->TriggerRedraw(); -#endif + oneRootLayer->Unlock(); STRACE(("info: RootLayer(%s)::WorkingThread listening on port %ld.\n", oneRootLayer->Name(), oneRootLayer->fListenPort)); @@ -798,11 +795,7 @@ RootLayer::RevealNewWMState(Workspace::State &oldWMState) redraw = true; } if (redraw) { -#ifndef NEW_CLIPPING - fRedrawReg.Include(&dirtyRegion); -#else MarkForRedraw(dirtyRegion); -#endif } } @@ -836,11 +829,8 @@ RootLayer::RevealNewWMState(Workspace::State &oldWMState) if (!stillPresent) { MarkForRebuild(layer->FullVisible()); MarkForRedraw(layer->FullVisible()); -#ifndef NEW_CLIPPING - empty_visible_regions(layer); -#else + layer->clear_visible_regions(); -#endif } else { oldStrippedList.AddItem(layer); @@ -899,20 +889,12 @@ GetDrawingEngine()->ConstrainClippingRegion(NULL); // redraw of focus change is automaticaly done redraw = false; // trigger region rebuilding and redraw -#ifndef NEW_CLIPPING - GoInvalidate(this, fFull); -#else TriggerRebuild(); TriggerRedraw(); -#endif } else if (redraw) { -#ifndef NEW_CLIPPING - GoInvalidate(this, dirtyRegion); -#else MarkForRedraw(dirtyRegion); TriggerRedraw(); -#endif } } @@ -1221,12 +1203,10 @@ RootLayer::KeyboardEventHandler(BMessage *msg) SetActiveWorkspace(scancode - 2); #ifdef APPSERVER_ROOTLAYER_SHOW_WORKSPACE_NUMBER // to draw the current Workspace index on screen. -#ifndef NEW_CLIPPING - BRegion reg(fVisible); + BRegion reg(VisibleRegion()); fDriver->ConstrainClippingRegion(®); Draw(reg.Frame()); fDriver->ConstrainClippingRegion(NULL); -#endif #endif break; } @@ -1581,23 +1561,6 @@ RootLayer::change_winBorder_feel(WinBorder *winBorder, int32 newFeel) } } -#ifndef NEW_CLIPPING -void -RootLayer::empty_visible_regions(Layer *layer) -{ -// TODO: optimize by avoiding recursion? - // NOTE: first 'layer' must be a WinBorder - layer->fFullVisible.MakeEmpty(); - layer->fVisible.MakeEmpty(); - - Layer* child = layer->LastChild(); - while (child) { - empty_visible_regions(child); - child = layer->PreviousChild(); - } -} -#endif - void RootLayer::Draw(const BRect &r) { diff --git a/src/servers/app/RootLayer.h b/src/servers/app/RootLayer.h index 0a3099ed97..96c8156584 100644 --- a/src/servers/app/RootLayer.h +++ b/src/servers/app/RootLayer.h @@ -1,31 +1,17 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2005, Haiku, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// File Name: RootLayer.h -// Author: Gabe Yoder -// DarkWyrm -// Stephan Aßmus -// Description: Class used for the top layer of each workspace's Layer tree -// -//------------------------------------------------------------------------------ +/* + * Copyright 2001-2005, Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Gabe Yoder + * DarkWyrm + * Adrian Oanca + * Stephan Aßmus + * Axel Dörfler, axeld@pinc-software.de + */ + +/** Class used for the top layer of each workspace's Layer tree */ + #ifndef _ROOTLAYER_H_ #define _ROOTLAYER_H_ @@ -160,9 +146,6 @@ friend class WinBorder; // temporarily, I need invalidate_layer() void change_winBorder_feel(WinBorder *winBorder, int32 newFeel); -#ifndef NEW_CLIPPING - void empty_visible_regions(Layer *layer); -#endif // Input related methods void MouseEventHandler(BMessage *msg); void KeyboardEventHandler(BMessage *msg); diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index beb54c8036..2fc936816b 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -4,7 +4,7 @@ * * Authors: * DarkWyrm - * Adrian Oanca + * Adrian Oanca * Stephan Aßmus * Stefano Ceccherini (burton666@libero.it) * Axel Dörfler, axeld@pinc-software.de @@ -442,7 +442,7 @@ ServerWindow::SetLayerState(Layer *layer, BPrivate::LinkReceiver &link) // NOTE: no need to check for a lock. This is a private method. layer->CurrentState()->ReadFromLink(link); - // TODO: Rebuild clipping here? + // TODO: Rebuild clipping here! } @@ -508,11 +508,7 @@ ServerWindow::CreateLayerTree(BPrivate::LinkReceiver &link, Layer **_parent) // TODO: rework the clipping stuff to remove RootLayer dependency and then // remove this hack: if (fWinBorder->IsOffscreenWindow()) { -#ifndef NEW_CLIPPING - newLayer->fVisible.Set(newLayer->fFrame); -#else newLayer->fVisible2.Set(newLayer->fFrame); -#endif } if (_parent) { @@ -555,32 +551,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) link.Read(&dh); link.Read(&dv); -#ifndef NEW_CLIPPING - // scroll visually by using the CopyBits() implementation - // this will also take care of invalidating previously invisible - // areas (areas scrolled into view) - BRect src = fCurrentLayer->Bounds(); - BRect dst = src; - // NOTE: if we scroll down, the contents are moved *up* - dst.OffsetBy(-dh, -dv); - - // TODO: Are origin and scale handled in this conversion? - src = fCurrentLayer->ConvertToTop(src); - dst = fCurrentLayer->ConvertToTop(dst); - - int32 xOffset = (int32)(dst.left - src.left); - int32 yOffset = (int32)(dst.top - src.top); - - // this little detail is where it differs from CopyBits() - // -> it will invalidate areas previously out of screen - dst = dst | src; - - fCurrentLayer->CurrentState()->OffsetOrigin(BPoint(dh, dv)); - - fCurrentLayer->CopyBits(src, dst, xOffset, yOffset); -#else fCurrentLayer->ScrollBy(dh, dv); -#endif break; } @@ -647,11 +618,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) if (parent != NULL) parent->AddChild(newLayer, this); - if (myRootLayer && !newLayer->IsHidden() && parent) -#ifndef NEW_CLIPPING - myRootLayer->GoInvalidate(newLayer, newLayer->fFull); -#else - { + if (myRootLayer && !newLayer->IsHidden() && parent) { BRegion invalidRegion; newLayer->GetWantedRegion(invalidRegion); parent->MarkForRebuild(invalidRegion); @@ -660,9 +627,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) myRootLayer->MarkForRedraw(newLayer->VisibleRegion()); myRootLayer->TriggerRedraw(); } -// myRootLayer->GoInvalidate(newLayer, invalidRegion); } -#endif break; } case AS_LAYER_DELETE: @@ -678,17 +643,10 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) // BRegion *invalidRegion = NULL; if (!fCurrentLayer->IsHidden() && parent && myRootLayer) { -#ifndef NEW_CLIPPING - if (fCurrentLayer->fFullVisible.CountRects() > 0) - invalidRegion = new BRegion(fCurrentLayer->fFullVisible); -#else if (fCurrentLayer->FullVisible().Frame().IsValid()) { parent->MarkForRebuild(fCurrentLayer->FullVisible()); myRootLayer->MarkForRedraw(fCurrentLayer->FullVisible()); - -// invalidRegion = new BRegion(fCurrentLayer->FullVisible()); } -#endif } // here we remove current layer from list. @@ -716,23 +674,15 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) case AS_LAYER_SET_STATE: { DTRACE(("ServerWindow %s: Message AS_LAYER_SET_STATE: Layer name: %s\n", fTitle, fCurrentLayer->Name())); -// SetLayerState(fCurrentLayer); SetLayerState(fCurrentLayer, link); // TODO: should this be moved into SetLayerState? // If it _always_ needs to be done afterwards, then yes! -#ifndef NEW_CLIPPING - fCurrentLayer->RebuildFullRegion(); -#endif break; } case AS_LAYER_SET_FONT_STATE: { DTRACE(("ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: Layer name: %s\n", fTitle, fCurrentLayer->Name())); -// SetLayerFontState(fCurrentLayer); SetLayerFontState(fCurrentLayer, link); -#ifndef NEW_CLIPPING - fCurrentLayer->RebuildFullRegion(); -#endif break; } case AS_LAYER_GET_STATE: @@ -912,9 +862,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) DTRACE(("ServerWindow %s: Message AS_LAYER_PUSH_STATE: Layer: %s\n", Title(), fCurrentLayer->Name())); fCurrentLayer->PushState(); -#ifndef NEW_CLIPPING - fCurrentLayer->RebuildFullRegion(); -#endif + break; } case AS_LAYER_POP_STATE: @@ -922,9 +870,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) DTRACE(("ServerWindow %s: Message AS_LAYER_POP_STATE: Layer: %s\n", Title(), fCurrentLayer->Name())); fCurrentLayer->PopState(); -#ifndef NEW_CLIPPING - fCurrentLayer->RebuildFullRegion(); -#endif + break; } case AS_LAYER_SET_SCALE: @@ -993,18 +939,10 @@ if (myRootLayer) myRootLayer->Lock(); fCurrentLayer->SetViewColor(RGBColor(c)); -#ifndef NEW_CLIPPING - if (myRootLayer) - myRootLayer->GoRedraw(fCurrentLayer, fCurrentLayer->fVisible); -#else if (myRootLayer) { myRootLayer->MarkForRedraw(fCurrentLayer->VisibleRegion()); myRootLayer->TriggerRedraw(); } - -// if (myRootLayer) -// myRootLayer->GoRedraw(fCurrentLayer, fCurrentLayer->VisibleRegion()); -#endif if (myRootLayer) myRootLayer->Unlock(); break; @@ -1117,14 +1055,7 @@ if (myRootLayer) fCurrentLayer->CurrentState()->SetClippingRegion(region); -#ifndef NEW_CLIPPING - fCurrentLayer->RebuildFullRegion(); -#endif - if (myRootLayer && !(fCurrentLayer->IsHidden()) && !fWinBorder->InUpdate()) -#ifndef NEW_CLIPPING - myRootLayer->GoInvalidate(fCurrentLayer, fCurrentLayer->fFull); -#else - { + if (myRootLayer && !(fCurrentLayer->IsHidden()) && !fWinBorder->InUpdate()) { BRegion invalidRegion; fCurrentLayer->GetWantedRegion(invalidRegion); @@ -1134,10 +1065,7 @@ if (myRootLayer) fCurrentLayer->fParent->TriggerRebuild(); myRootLayer->MarkForRedraw(invalidRegion); myRootLayer->TriggerRedraw(); - -// myRootLayer->GoInvalidate(fCurrentLayer, invalidRegion); } -#endif break; } @@ -1153,21 +1081,13 @@ if (myRootLayer) fLink.Flush(); } else { // TODO: Watch out for the coordinate system in AS_LAYER_GET_CLIP_REGION -#ifndef NEW_CLIPPING - int32 rectCount = fCurrentLayer->fVisible.CountRects(); -#else int32 rectCount = fCurrentLayer->fVisible2.CountRects(); -#endif fLink.StartMessage(SERVER_TRUE); fLink.Attach(rectCount); for (int32 i = 0; i < rectCount; i++) -#ifndef NEW_CLIPPING - fLink.Attach(fCurrentLayer->ConvertFromTop(fCurrentLayer->fVisible.RectAt(i))); -#else fLink.Attach(fCurrentLayer->ConvertFromTop(fCurrentLayer->fVisible2.RectAt(i))); -#endif fLink.Flush(); } @@ -1194,20 +1114,9 @@ if (myRootLayer) // restored too. "AS_LAYER_SET_CLIP_REGION" is irritating, as I think it should be // "AS_LAYER_CONSTRAIN_CLIP_REGION", since it means to "add" to the current clipping, not "set" it. // fCurrentLayer->CurrentState()->SetClippingRegion(region); -#ifndef NEW_CLIPPING -// TODO: set the clipping -// fCurrentLayer->fVisible.IntersectWith(®ion); -#endif -/* -#ifndef NEW_CLIPPING - fCurrentLayer->RebuildFullRegion(); - if (myRootLayer && !(fCurrentLayer->IsHidden()) && !fWinBorder->InUpdate()) - myRootLayer->GoInvalidate(fCurrentLayer, fCurrentLayer->fFull); -#else - if (myRootLayer && !(fCurrentLayer->IsHidden()) && !fWinBorder->InUpdate()) - myRootLayer->GoInvalidate(fCurrentLayer, fCurrentLayer->Frame()); -#endif -*/ + + // TODO: rebuild clipping and redraw + break; } case AS_LAYER_INVAL_RECT: @@ -1223,12 +1132,9 @@ if (myRootLayer) BRect converted(fCurrentLayer->ConvertToTop(invalRect.LeftTop()), fCurrentLayer->ConvertToTop(invalRect.RightBottom())); BRegion invalidRegion(converted); -#ifdef NEW_CLIPPING - invalidRegion.IntersectWith(&fCurrentLayer->fVisible2); -#endif + invalidRegion.IntersectWith(&fCurrentLayer->VisibleRegion()); myRootLayer->MarkForRedraw(invalidRegion); myRootLayer->TriggerRedraw(); -// myRootLayer->GoRedraw(fWinBorder, invalidRegion); } break; } @@ -1717,11 +1623,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link) // NOTE: fCurrentLayer and fCurrentLayer->fLayerData cannot be NULL, // _DispatchGraphicsMessage() is called from _DispatchMessage() which // checks both these conditions -#ifndef NEW_CLIPPING - BRegion rreg(fCurrentLayer->fVisible); -#else - BRegion rreg(fCurrentLayer->fVisible2); -#endif + BRegion rreg(fCurrentLayer->VisibleRegion()); if (fWinBorder->InUpdate()) rreg.IntersectWith(&fWinBorder->RegionToBeUpdated()); @@ -2159,72 +2061,6 @@ ServerWindow::_MessageLooper() // does not return } -/* -void -ServerWindow::_CopyBits(RootLayer* rootLayer, Layer* layer, - BRect& src, BRect& dst, - int32 xOffset, int32 yOffset) const -{ - // NOTE: The correct behaviour is this: - // * The region that is copied is the - // src rectangle, no matter if it fits - // into the dst rectangle. It is copied - // by the offset dst.LeftTop() - src.LeftTop() - // * The dst rectangle is used for invalidation: - // Any area in the dst rectangle that could - // not be copied from src (because either the - // src rectangle was not big enough, or because there - // were parts cut off by the current layer clipping), - // are triggering BView::Draw() to be called - // and for these parts only. - -#ifndef NEW_CLIPPING - - // the region that is going to be copied - BRegion copyRegion(src); - // apply the current clipping of the layer - - copyRegion.IntersectWith(&layer->fVisible); - - // offset the region to the destination - // and apply the current clipping there as well - copyRegion.OffsetBy(xOffset, yOffset); - copyRegion.IntersectWith(&layer->fVisible); - - // the region at the destination that needs invalidation - BRegion invalidRegion(dst); - // exclude the region drawn by the copy operation - invalidRegion.Exclude(©Region); - // apply the current clipping as well - invalidRegion.IntersectWith(&layer->fVisible); - - // move the region back for the actual operation - copyRegion.OffsetBy(-xOffset, -yOffset); - - layer->GetDrawingEngine()->CopyRegion(©Region, xOffset, yOffset); - - // trigger the redraw - if (rootLayer) { - // the following code solves a "concurrency" problem: - // since the scrolling might happen more often - // than redrawing, we need to keep track of the region - // pending for redraw that might fall into the area - // that is scrolled. - BRegion scrolledInvalid(fWinBorder->CulmulatedUpdateRegion()); - scrolledInvalid.IntersectWith(&layer->fVisible); - if (scrolledInvalid.Frame().IsValid()) { -//printf("the layer has pending updates that will be scrolled\n"); - scrolledInvalid.OffsetBy(xOffset, yOffset); - invalidRegion.Include(&scrolledInvalid); - } - - rootLayer->GoRedraw(fWinBorder, invalidRegion); - } - -#endif -}*/ - - status_t ServerWindow::SendMessageToClient(const BMessage* msg, int32 target, bool usePreferred) const { diff --git a/src/servers/app/ServerWindow.h b/src/servers/app/ServerWindow.h index cc6d16eb3f..244cded7ec 100644 --- a/src/servers/app/ServerWindow.h +++ b/src/servers/app/ServerWindow.h @@ -4,7 +4,7 @@ * * Authors: * DarkWyrm - * Adrian Oanca + * Adrian Oanca * Stephan Aßmus * Stefano Ceccherini (burton666@libero.it) * Axel Dörfler, axeld@pinc-software.de diff --git a/src/servers/app/WinBorder.cpp b/src/servers/app/WinBorder.cpp index 6e925f6c20..96f5dcf133 100644 --- a/src/servers/app/WinBorder.cpp +++ b/src/servers/app/WinBorder.cpp @@ -3,7 +3,7 @@ * Distributed under the terms of the MIT license. * * Author: DarkWyrm - * Adi Oanca + * Adi Oanca * Stephan Aßmus */ @@ -74,6 +74,9 @@ WinBorder::WinBorder(const BRect &frame, fCumulativeRegion(), fInUpdateRegion(), + fDecRegion(), + fRebuildDecRegion(true), + fMouseButtons(0), fLastMousePosition(-1.0, -1.0), @@ -105,9 +108,7 @@ WinBorder::WinBorder(const BRect &frame, fServerWin = window; fAdFlags = fAdFlags | B_LAYER_CHILDREN_DEPENDANT; fFlags = B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE; -#ifdef NEW_CLIPPING - fRebuildDecRegion = true; -#endif + QuietlySetFeel(feel); if (fFeel != B_NO_BORDER_WINDOW_LOOK) { @@ -136,10 +137,6 @@ WinBorder::WinBorder(const BRect &frame, } } -#ifndef NEW_CLIPPING - RebuildFullRegion(); -#endif - STRACE(("WinBorder %p, %s:\n", this, Name())); STRACE(("\tFrame: (%.1f, %.1f, %.1f, %.1f)\n", fFrame.left, fFrame.top, fFrame.right, fFrame.bottom)); @@ -179,58 +176,7 @@ WinBorder::Draw(const BRect &r) void WinBorder::MoveBy(float x, float y) { -#ifndef NEW_CLIPPING - -x = (float)int32(x); -y = (float)int32(y); - - if (x == 0.0 && y == 0.0) - return; - - STRACE(("WinBorder(%s)::MoveBy(%.1f, %.1f) fDecorator: %p\n", Name(), x, y, fDecorator)); - if (fDecorator) - fDecorator->MoveBy(x,y); - -// NOTE: I moved this here from Layer::move_layer() -// Should this have any bad consequences I'm not aware of? -fCumulativeRegion.OffsetBy(x, y); -fInUpdateRegion.OffsetBy(x, y); - - if (IsHidden()) { -// TODO: This is a work around for a design issue: -// The actual movement of a layer is done during -// the region rebuild. The mechanism is somewhat -// complicated and scheduled for refractoring... -// The problem here for hidden layers is that -// they seem *not* to be part of the layer tree. -// I don't think this is wrong as such, but of -// course the rebuilding of regions does not take -// place then. I don't understand yet the consequences -// for normal views, but this here fixes at least -// BWindows being MoveTo()ed before they are Show()n. -// In Layer::move_to, StartRebuildRegions() is called -// on fParent. But the rest of the this layers tree -// has not been added to fParent apperantly. So now -// you ask why fParent is even valid? Me too. - fFrame.OffsetBy(x, y); - fFull.OffsetBy(x, y); - fTopLayer->move_layer(x, y); - // ...and here we get really hacky... - fTopLayer->fFrame.OffsetTo(0.0, 0.0); - } else { - Layer::move_layer(x, y); - } - - if (Window()) { - // dispatch a message to the client informing about the changed size - BMessage msg(B_WINDOW_MOVED); - msg.AddPoint("where", fFrame.LeftTop()); - Window()->SendMessageToClient(&msg, B_NULL_TOKEN, false); - } - -#else Layer::MoveBy(x, y); -#endif } @@ -241,20 +187,6 @@ WinBorder::ResizeBy(float x, float y) if (!_ResizeBy(x, y)) return; - -#ifndef NEW_CLIPPING - if (Window()) { - // send a message to the client informing about the changed size - BMessage msg(B_WINDOW_RESIZED); - msg.AddInt64("when", system_time()); - - BRect frame(fTopLayer->Frame()); - msg.AddInt32("width", frame.IntegerWidth()); - msg.AddInt32("height", frame.IntegerHeight()); - - Window()->SendMessageToClient(&msg, B_NULL_TOKEN, false); - } -#endif } @@ -282,23 +214,7 @@ WinBorder::_ResizeBy(float x, float y) if (x == 0.0 && y == 0.0) return false; -#ifndef NEW_CLIPPING - if (fDecorator) - fDecorator->ResizeBy(x, y); - - if (IsHidden()) { - // TODO: See large comment in MoveBy() - fFrame.right += x; - fFrame.bottom += y; - - if (fTopLayer) - fTopLayer->resize_layer(x, y); - } else { - resize_layer(x, y); - } -#else Layer::ResizeBy(x, y); -#endif return true; } @@ -312,9 +228,10 @@ WinBorder::SetName(const char* name) // rebuild the clipping for the title area // and redraw it. - // TODO: Adi, please have a look at this, - // it doesn't work yet. if (fDecorator) { + +// TODO: Make sure this works!! + // before the change BRegion invalid(fDecorator->GetTabRect()); @@ -323,12 +240,8 @@ WinBorder::SetName(const char* name) // after the change invalid.Include(fDecorator->GetTabRect()); -#ifndef NEW_CLIPPING - RebuildFullRegion(); - fRootLayer->GoRedraw(this, invalid); -#else - // TODO: ... -#endif + GetRootLayer()->MarkForRedraw(invalid); + GetRootLayer()->TriggerRedraw(); } } @@ -361,23 +274,6 @@ WinBorder::UpdateEnd() } } -#ifndef NEW_CLIPPING - -//! Rebuilds the WinBorder's "fully-visible" region based on info from the decorator -void -WinBorder::RebuildFullRegion() -{ - STRACE(("WinBorder(%s)::RebuildFullRegion()\n", Name())); - - fFull.MakeEmpty(); - - // Winborder holds Decorator's full regions. if any... - if (fDecorator) - fDecorator->GetFootprint(&fFull); -} - -#endif - //! Sets the minimum and maximum sizes of the window void WinBorder::SetSizeLimits(float minWidth, float maxWidth, @@ -792,24 +688,12 @@ WinBorder::_ActionFor(const BMessage *msg) const msg->FindInt32("buttons", &buttons); msg->FindInt32("modifiers", &modifiers); -#ifndef NEW_INPUT_HANDING -#ifndef NEW_CLIPPING - if (fTopLayer->fFullVisible.Contains(where)) - return DEC_NONE; - else -#else - if (fTopLayer->fFullVisible2.Contains(where)) - return DEC_NONE; - else -#endif -#endif if (fDecorator) return fDecorator->Clicked(where, buttons, modifiers); else return DEC_NONE; } -#ifdef NEW_CLIPPING void WinBorder::MovedByHook(float dx, float dy) { STRACE(("WinBorder(%s)::MovedByHook(%.1f, %.1f) fDecorator: %p\n", Name(), x, y, fDecorator)); @@ -905,13 +789,10 @@ if (cnt != 1) BMessage msg; msg.what = _UPDATE_; -#ifndef NEW_CLIPPING - msg.AddRect("_rect", ConvertFromTop(fInUpdateRegion.Frame())); -#else + BRect rect(fInUpdateRegion.Frame()); ConvertFromScreen2(&rect); msg.AddRect("_rect", rect ); -#endif msg.AddRect("debug_rect", fInUpdateRegion.Frame()); if (Window()->SendMessageToClient(&msg) == B_OK) { @@ -924,7 +805,6 @@ if (cnt != 1) } } } -#endif // SetTopLayer void diff --git a/src/servers/app/WinBorder.h b/src/servers/app/WinBorder.h index 51478224d4..62c24a1123 100644 --- a/src/servers/app/WinBorder.h +++ b/src/servers/app/WinBorder.h @@ -3,7 +3,7 @@ * Distributed under the terms of the MIT license. * * Author: DarkWyrm - * Adi Oanca + * Adi Oanca * Stephan Aßmus */ #ifndef _WINBORDER_H_ @@ -58,11 +58,8 @@ class WinBorder : public Layer { virtual bool IsOffscreenWindow() const { return false; } -#ifndef NEW_CLIPPING - virtual void RebuildFullRegion(); -#else virtual void GetWantedRegion(BRegion ®); -#endif + void UpdateStart(); void UpdateEnd(); inline bool InUpdate() const @@ -122,27 +119,19 @@ class WinBorder : public Layer { SubWindowList fSubWindowList; -#ifdef NEW_CLIPPING - public: virtual void MovedByHook(float dx, float dy); virtual void ResizedByHook(float dx, float dy, bool automatic); void RequestClientRedraw(const BRegion &invalid); - private: - void set_decorator_region(BRect frame); - virtual void _ReserveRegions(BRegion ®); - - BRegion fDecRegion; - bool fRebuildDecRegion; - -#endif - - public: virtual void SetTopLayer(Layer* layer); inline Layer* TopLayer() const { return fTopLayer; } + private: + void set_decorator_region(BRect frame); + virtual void _ReserveRegions(BRegion ®); + protected: friend class Layer; friend class RootLayer; @@ -156,6 +145,9 @@ class WinBorder : public Layer { BRegion fCumulativeRegion; BRegion fInUpdateRegion; + BRegion fDecRegion; + bool fRebuildDecRegion; + int32 fMouseButtons; BPoint fLastMousePosition; BPoint fResizingClickOffset; diff --git a/src/servers/app/WorkspacesLayer.cpp b/src/servers/app/WorkspacesLayer.cpp index 24624f47d3..8b2f52157c 100644 --- a/src/servers/app/WorkspacesLayer.cpp +++ b/src/servers/app/WorkspacesLayer.cpp @@ -163,11 +163,8 @@ WorkspacesLayer::_DrawWorkspace(int32 index) // draw windows -#ifndef NEW_CLIPPING - BRegion backgroundRegion = fVisible; -#else BRegion backgroundRegion = VisibleRegion(); -#endif + // ToDo: would be nice to get the real update region here if (workspace != NULL) { @@ -195,12 +192,8 @@ WorkspacesLayer::_DrawWorkspace(int32 index) fDriver->FillRect(rect, color); // TODO: ConstrainClippingRegion() should accept a const parameter !! -#ifndef NEW_CLIPPING - fDriver->ConstrainClippingRegion(&fVisible); -#else BRegion cRegion(VisibleRegion()); fDriver->ConstrainClippingRegion(&cRegion); -#endif }