* Renamed Layer::GetWantedRegion() to GetOnScreenRegion().

* minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14920 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-11-14 17:50:39 +00:00
parent 618c515c4c
commit 5df853ea79
6 changed files with 50 additions and 46 deletions
+36 -31
View File
@@ -482,7 +482,7 @@ Layer::Show(bool invalidate)
if (invalidate) { if (invalidate) {
// compute the region this layer wants for itself // compute the region this layer wants for itself
BRegion invalid; BRegion invalid;
GetWantedRegion(invalid); GetOnScreenRegion(invalid);
if (invalid.CountRects() > 0) { if (invalid.CountRects() > 0) {
fParent->MarkForRebuild(invalid); fParent->MarkForRebuild(invalid);
GetRootLayer()->MarkForRedraw(invalid); GetRootLayer()->MarkForRedraw(invalid);
@@ -598,7 +598,7 @@ Layer::MoveBy(float x, float y)
// we'll invalidate the old position and the new, maxmial one. // we'll invalidate the old position and the new, maxmial one.
BRegion invalid; BRegion invalid;
GetWantedRegion(invalid); GetOnScreenRegion(invalid);
invalid.Include(&fFullVisible2); invalid.Include(&fFullVisible2);
fParent->MarkForRebuild(invalid); fParent->MarkForRebuild(invalid);
@@ -673,7 +673,7 @@ Layer::ResizeBy(float x, float y)
// we'll invalidate the old area and the new, maxmial one. // we'll invalidate the old area and the new, maxmial one.
BRegion invalid; BRegion invalid;
GetWantedRegion(invalid); GetOnScreenRegion(invalid);
invalid.Include(&fFullVisible2); invalid.Include(&fFullVisible2);
fParent->MarkForRebuild(invalid); fParent->MarkForRebuild(invalid);
@@ -1173,6 +1173,7 @@ Layer::do_Hide()
} }
} }
void void
Layer::do_Show() Layer::do_Show()
{ {
@@ -1181,7 +1182,7 @@ Layer::do_Show()
if (fParent && !fParent->IsHidden() && GetRootLayer()) { if (fParent && !fParent->IsHidden() && GetRootLayer()) {
BRegion invalid; BRegion invalid;
GetWantedRegion(invalid); GetOnScreenRegion(invalid);
if (invalid.CountRects() > 0) { if (invalid.CountRects() > 0) {
fParent->MarkForRebuild(invalid); fParent->MarkForRebuild(invalid);
@@ -1193,11 +1194,12 @@ Layer::do_Show()
} }
} }
inline void
void
Layer::_ResizeLayerFrameBy(float x, float y) Layer::_ResizeLayerFrameBy(float x, float y)
{ {
uint16 rm = fResizeMode & 0x0000FFFF; uint16 rm = fResizeMode & 0x0000FFFF;
BRect newFrame = fFrame; BRect newFrame = fFrame;
if ((rm & 0x0F00U) == _VIEW_LEFT_ << 8) if ((rm & 0x0F00U) == _VIEW_LEFT_ << 8)
newFrame.left += 0.0f; newFrame.left += 0.0f;
@@ -1254,12 +1256,12 @@ Layer::_ResizeLayerFrameBy(float x, float y)
// TODO: the above code is CORRECT!!! // TODO: the above code is CORRECT!!!
// It's commented because BView::FrameResized()/Moved() be called twice a given view. FIX THIS! // It's commented because BView::FrameResized()/Moved() be called twice a given view. FIX THIS!
if (newFrame != fFrame) { if (newFrame != fFrame) {
float dx, dy; float dx, dy;
dx = newFrame.Width() - fFrame.Width(); dx = newFrame.Width() - fFrame.Width();
dy = newFrame.Height() - fFrame.Height(); dy = newFrame.Height() - fFrame.Height();
fFrame = newFrame; fFrame = newFrame;
if (dx != 0.0f || dy != 0.0f) { if (dx != 0.0f || dy != 0.0f) {
// call hook function // call hook function
@@ -1272,7 +1274,8 @@ Layer::_ResizeLayerFrameBy(float x, float y)
} }
} }
inline void
void
Layer::_RezizeLayerRedrawMore(BRegion &reg, float dx, float dy) Layer::_RezizeLayerRedrawMore(BRegion &reg, float dx, float dy)
{ {
if (dx == 0 && dy == 0) if (dx == 0 && dy == 0)
@@ -1311,19 +1314,17 @@ Layer::_RezizeLayerRedrawMore(BRegion &reg, float dx, float dy)
// above, OR this: // above, OR this:
// reg.Include(&child->fFullVisible2); // reg.Include(&child->fFullVisible2);
} } else if (((rm & 0x0F0F) == (uint16)B_FOLLOW_RIGHT && dx != 0)
else || ((rm & 0x0F0F) == (uint16)B_FOLLOW_H_CENTER && dx != 0)
if (((rm & 0x0F0F) == (uint16)B_FOLLOW_RIGHT && dx != 0) || || ((rm & 0xF0F0) == (uint16)B_FOLLOW_BOTTOM && dy != 0)
((rm & 0x0F0F) == (uint16)B_FOLLOW_H_CENTER && dx != 0) || || ((rm & 0xF0F0) == (uint16)B_FOLLOW_V_CENTER && dy != 0)) {
((rm & 0xF0F0) == (uint16)B_FOLLOW_BOTTOM && dy != 0)||
((rm & 0xF0F0) == (uint16)B_FOLLOW_V_CENTER && dy != 0))
{
reg.Include(&child->fFullVisible2); reg.Include(&child->fFullVisible2);
} }
} }
} }
inline void
void
Layer::_ResizeLayerFullUpdateOnResize(BRegion &reg, float dx, float dy) Layer::_ResizeLayerFullUpdateOnResize(BRegion &reg, float dx, float dy)
{ {
if (dx == 0 && dy == 0) if (dx == 0 && dy == 0)
@@ -1343,17 +1344,21 @@ Layer::_ResizeLayerFullUpdateOnResize(BRegion &reg, float dx, float dy)
} }
} }
/*!
\brief Returns the region of the layer that is within the screen region
*/
void void
Layer::GetWantedRegion(BRegion &reg) Layer::GetOnScreenRegion(BRegion &region)
{ {
// 1) set to frame in screen coords // 1) set to frame in screen coords
BRect screenFrame(Bounds()); BRect frame(Bounds());
ConvertToScreen(&screenFrame); ConvertToScreen(&frame);
reg.Set(screenFrame); region.Set(frame);
// 2) intersect with screen region // 2) intersect with screen region
BRegion screenReg(GetRootLayer()->Bounds()); BRegion screenRegion(GetRootLayer()->Bounds());
reg.IntersectWith(&screenReg); region.IntersectWith(&screenRegion);
/* /*
// 3) impose user constrained regions // 3) impose user constrained regions
@@ -1366,10 +1371,10 @@ Layer::GetWantedRegion(BRegion &reg)
}*/ }*/
} }
void void
Layer::_RebuildVisibleRegions( const BRegion &invalid, Layer::_RebuildVisibleRegions(const BRegion &invalid,
const BRegion &parentLocalVisible, const BRegion &parentLocalVisible, const Layer *startFrom)
const Layer *startFrom)
{ {
/* /*
// no point in continuing if this layer is hidden. // no point in continuing if this layer is hidden.
@@ -1385,7 +1390,7 @@ Layer::_RebuildVisibleRegions( const BRegion &invalid,
// intersect maximum wanted region with the invalid region // intersect maximum wanted region with the invalid region
BRegion common; BRegion common;
GetWantedRegion(common); GetOnScreenRegion(common);
common.IntersectWith(&invalid); common.IntersectWith(&invalid);
// if the resulted region is not valid, this layer is not in the catchment area // if the resulted region is not valid, this layer is not in the catchment area
@@ -1437,7 +1442,7 @@ Layer::_RebuildVisibleRegions( const BRegion &invalid,
return; return;
BRegion common; BRegion common;
GetWantedRegion(common); GetOnScreenRegion(common);
// see how much you can take // see how much you can take
common.IntersectWith(&parentLocalVisible); common.IntersectWith(&parentLocalVisible);
+1 -1
View File
@@ -203,7 +203,7 @@ class Layer {
inline const BRegion& FullVisible() const { return fFullVisible2; } inline const BRegion& FullVisible() const { return fFullVisible2; }
inline const BRegion& DrawingRegion() const { return fDrawingRegion; } inline const BRegion& DrawingRegion() const { return fDrawingRegion; }
virtual void GetWantedRegion(BRegion& reg); virtual void GetOnScreenRegion(BRegion& region);
void MarkForRebuild(const BRegion &dirty); void MarkForRebuild(const BRegion &dirty);
void TriggerRebuild(); void TriggerRebuild();
+3 -3
View File
@@ -872,7 +872,7 @@ RootLayer::RevealNewWMState(Workspace::State &oldWMState)
BRegion invalid; BRegion invalid;
// invalidate the maximum area which this layer/window can occupy. // invalidate the maximum area which this layer/window can occupy.
layer->GetWantedRegion(invalid); layer->GetOnScreenRegion(invalid);
MarkForRebuild(invalid); MarkForRebuild(invalid);
MarkForRedraw(invalid); MarkForRedraw(invalid);
@@ -893,7 +893,7 @@ RootLayer::RevealNewWMState(Workspace::State &oldWMState)
BRegion invalid; BRegion invalid;
// start by invalidating the maximum area which this layer/window can occupy. // start by invalidating the maximum area which this layer/window can occupy.
layer->GetWantedRegion(invalid); layer->GetOnScreenRegion(invalid);
// no reason to invalidate what's currently visible. // no reason to invalidate what's currently visible.
invalid.Exclude(&layer->FullVisible()); invalid.Exclude(&layer->FullVisible());
@@ -1398,7 +1398,7 @@ RootLayer::ClearNotifyLayer()
} }
} }
// LayerRemoved
void void
RootLayer::LayerRemoved(Layer* layer) RootLayer::LayerRemoved(Layer* layer)
{ {
+2 -2
View File
@@ -625,7 +625,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
if (myRootLayer && !newLayer->IsHidden() && parent) { if (myRootLayer && !newLayer->IsHidden() && parent) {
BRegion invalidRegion; BRegion invalidRegion;
newLayer->GetWantedRegion(invalidRegion); newLayer->GetOnScreenRegion(invalidRegion);
parent->MarkForRebuild(invalidRegion); parent->MarkForRebuild(invalidRegion);
parent->TriggerRebuild(); parent->TriggerRebuild();
if (newLayer->VisibleRegion().Frame().IsValid()) { if (newLayer->VisibleRegion().Frame().IsValid()) {
@@ -1058,7 +1058,7 @@ if (myRootLayer)
if (myRootLayer && !(fCurrentLayer->IsHidden()) && !fWinBorder->InUpdate()) { if (myRootLayer && !(fCurrentLayer->IsHidden()) && !fWinBorder->InUpdate()) {
BRegion invalidRegion; BRegion invalidRegion;
fCurrentLayer->GetWantedRegion(invalidRegion); fCurrentLayer->GetOnScreenRegion(invalidRegion);
// TODO: this is broken! a smaller area may be invalidated! // TODO: this is broken! a smaller area may be invalidated!
+7 -8
View File
@@ -798,20 +798,19 @@ WinBorder::_ReserveRegions(BRegion &reg)
void void
WinBorder::GetWantedRegion(BRegion &reg) WinBorder::GetOnScreenRegion(BRegion& region)
{ {
if (fRebuildDecRegion) if (fRebuildDecRegion)
set_decorator_region(Bounds()); set_decorator_region(Bounds());
BRect screenFrame(Bounds()); BRect frame(Bounds());
ConvertToScreen(&screenFrame); ConvertToScreen(&frame);
reg.Set(screenFrame); region.Set(frame);
reg.Include(&fDecRegion); region.Include(&fDecRegion);
BRegion screenReg(GetRootLayer()->Bounds()); BRegion screenRegion(GetRootLayer()->Bounds());
region.IntersectWith(&screenRegion);
reg.IntersectWith(&screenReg);
} }
+1 -1
View File
@@ -57,7 +57,7 @@ class WinBorder : public Layer {
virtual bool IsOffscreenWindow() const virtual bool IsOffscreenWindow() const
{ return false; } { return false; }
virtual void GetWantedRegion(BRegion &reg); virtual void GetOnScreenRegion(BRegion& region);
void UpdateStart(); void UpdateStart();
void UpdateEnd(); void UpdateEnd();