Bye-bye old clipping codesvn update Some cleanup to follow.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14760 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adi Oanca 2005-11-07 19:01:12 +00:00
parent 64c51217b2
commit 2c8cfe2dfc
10 changed files with 58 additions and 1274 deletions

File diff suppressed because it is too large Load Diff

View File

@ -103,25 +103,6 @@ class Layer {
inline uint32 Flags() const inline uint32 Flags() const
{ return fFlags; } { 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, void Redraw(const BRegion& reg,
Layer* startFrom = NULL); Layer* startFrom = NULL);
@ -240,11 +221,7 @@ class Layer {
void CopyBits(BRect& src, BRect& dst, void CopyBits(BRect& src, BRect& dst,
int32 xOffset, int32 yOffset); 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& VisibleRegion() const { return fVisible2; }
inline const BRegion& FullVisible() const { return fFullVisible2; } inline const BRegion& FullVisible() const { return fFullVisible2; }
@ -294,8 +271,6 @@ class Layer {
void rezize_layer_redraw_more(BRegion &reg, float dx, float dy); void rezize_layer_redraw_more(BRegion &reg, float dx, float dy);
void resize_layer_full_update_on_resize(BRegion &reg, float dx, float dy); void resize_layer_full_update_on_resize(BRegion &reg, float dx, float dy);
#endif
private:
void do_CopyBits(BRect& src, BRect& dst, void do_CopyBits(BRect& src, BRect& dst,
int32 xOffset, int32 yOffset); int32 xOffset, int32 yOffset);
@ -303,18 +278,6 @@ class Layer {
friend class RootLayer; friend class RootLayer;
friend class WinBorder; friend class WinBorder;
friend class ServerWindow; 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; BRect fFrame;
// TODO: should be removed or reused in a similar fashion // TODO: should be removed or reused in a similar fashion
@ -332,18 +295,12 @@ class Layer {
mutable Layer* fCurrent; mutable Layer* fCurrent;
#ifndef NEW_CLIPPING
BRegion fVisible;
BRegion fFullVisible;
BRegion fFull;
int8 fFrameAction;
#else
private: private:
BRegion fVisible2; BRegion fVisible2;
BRegion fFullVisible2; BRegion fFullVisible2;
BRegion fDirtyForRebuild; BRegion fDirtyForRebuild;
protected: protected:
#endif
BRegion* fClipReg; BRegion* fClipReg;
ServerWindow* fServerWin; ServerWindow* fServerWin;

View File

@ -32,10 +32,6 @@ OffscreenWinBorder::OffscreenWinBorder(ServerBitmap* bitmap,
fDriver->SetHWInterface(fHWInterface); fDriver->SetHWInterface(fHWInterface);
fDriver->Initialize(); fDriver->Initialize();
fDriver->Update(); fDriver->Update();
#ifndef NEW_CLIPPING
fFull.Set(fFrame);
#endif
} }
// destructor // destructor
@ -73,11 +69,5 @@ void
OffscreenWinBorder::SetTopLayer(Layer* layer) OffscreenWinBorder::SetTopLayer(Layer* layer)
{ {
WinBorder::SetTopLayer(layer); WinBorder::SetTopLayer(layer);
#ifndef NEW_CLIPPING
fTopLayer->fFull.Set(fFrame.OffsetToCopy(0.0, 0.0));
fTopLayer->fHidden = false;
fTopLayer->fVisible = fTopLayer->fFull;
#endif
} }

View File

@ -5,7 +5,7 @@
* Authors: * Authors:
* Gabe Yoder <gyoder@stny.rr.com> * Gabe Yoder <gyoder@stny.rr.com>
* DarkWyrm <bpmagic@columbus.rr.com> * DarkWyrm <bpmagic@columbus.rr.com>
* Adrian Oanca <adioanca@cotty.iren.ro> * Adrian Oanca <adioanca@gmail.com>
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
* Axel Dörfler, axeld@pinc-software.de * Axel Dörfler, axeld@pinc-software.de
*/ */
@ -197,10 +197,7 @@ RootLayer::WorkingThread(void *data)
// first make sure we are actualy visible // first make sure we are actualy visible
oneRootLayer->Lock(); oneRootLayer->Lock();
#ifndef NEW_CLIPPING
oneRootLayer->RebuildFullRegion();
oneRootLayer->GoInvalidate(oneRootLayer, oneRootLayer->Bounds());
#else
// RootLayer starts with valid visible regions // RootLayer starts with valid visible regions
oneRootLayer->fFullVisible2.Set(oneRootLayer->Bounds()); oneRootLayer->fFullVisible2.Set(oneRootLayer->Bounds());
oneRootLayer->fVisible2.Set(oneRootLayer->Bounds()); oneRootLayer->fVisible2.Set(oneRootLayer->Bounds());
@ -210,7 +207,7 @@ RootLayer::WorkingThread(void *data)
oneRootLayer->TriggerRebuild(); oneRootLayer->TriggerRebuild();
oneRootLayer->TriggerRedraw(); oneRootLayer->TriggerRedraw();
#endif
oneRootLayer->Unlock(); oneRootLayer->Unlock();
STRACE(("info: RootLayer(%s)::WorkingThread listening on port %ld.\n", oneRootLayer->Name(), oneRootLayer->fListenPort)); 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; redraw = true;
} }
if (redraw) { if (redraw) {
#ifndef NEW_CLIPPING
fRedrawReg.Include(&dirtyRegion);
#else
MarkForRedraw(dirtyRegion); MarkForRedraw(dirtyRegion);
#endif
} }
} }
@ -836,11 +829,8 @@ RootLayer::RevealNewWMState(Workspace::State &oldWMState)
if (!stillPresent) { if (!stillPresent) {
MarkForRebuild(layer->FullVisible()); MarkForRebuild(layer->FullVisible());
MarkForRedraw(layer->FullVisible()); MarkForRedraw(layer->FullVisible());
#ifndef NEW_CLIPPING
empty_visible_regions(layer);
#else
layer->clear_visible_regions(); layer->clear_visible_regions();
#endif
} }
else { else {
oldStrippedList.AddItem(layer); oldStrippedList.AddItem(layer);
@ -899,20 +889,12 @@ GetDrawingEngine()->ConstrainClippingRegion(NULL);
// redraw of focus change is automaticaly done // redraw of focus change is automaticaly done
redraw = false; redraw = false;
// trigger region rebuilding and redraw // trigger region rebuilding and redraw
#ifndef NEW_CLIPPING
GoInvalidate(this, fFull);
#else
TriggerRebuild(); TriggerRebuild();
TriggerRedraw(); TriggerRedraw();
#endif
} }
else if (redraw) { else if (redraw) {
#ifndef NEW_CLIPPING
GoInvalidate(this, dirtyRegion);
#else
MarkForRedraw(dirtyRegion); MarkForRedraw(dirtyRegion);
TriggerRedraw(); TriggerRedraw();
#endif
} }
} }
@ -1221,12 +1203,10 @@ RootLayer::KeyboardEventHandler(BMessage *msg)
SetActiveWorkspace(scancode - 2); SetActiveWorkspace(scancode - 2);
#ifdef APPSERVER_ROOTLAYER_SHOW_WORKSPACE_NUMBER #ifdef APPSERVER_ROOTLAYER_SHOW_WORKSPACE_NUMBER
// to draw the current Workspace index on screen. // to draw the current Workspace index on screen.
#ifndef NEW_CLIPPING BRegion reg(VisibleRegion());
BRegion reg(fVisible);
fDriver->ConstrainClippingRegion(&reg); fDriver->ConstrainClippingRegion(&reg);
Draw(reg.Frame()); Draw(reg.Frame());
fDriver->ConstrainClippingRegion(NULL); fDriver->ConstrainClippingRegion(NULL);
#endif
#endif #endif
break; 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 void
RootLayer::Draw(const BRect &r) RootLayer::Draw(const BRect &r)
{ {

View File

@ -1,31 +1,17 @@
//------------------------------------------------------------------------------ /*
// Copyright (c) 2001-2005, Haiku, Inc. * Copyright 2001-2005, Haiku, Inc.
// * Distributed under the terms of the MIT License.
// Permission is hereby granted, free of charge, to any person obtaining a *
// copy of this software and associated documentation files (the "Software"), * Authors:
// to deal in the Software without restriction, including without limitation * Gabe Yoder <gyoder@stny.rr.com>
// the rights to use, copy, modify, merge, publish, distribute, sublicense, * DarkWyrm <bpmagic@columbus.rr.com>
// and/or sell copies of the Software, and to permit persons to whom the * Adrian Oanca <adioanca@gmail.com>
// Software is furnished to do so, subject to the following conditions: * Stephan Aßmus <superstippi@gmx.de>
// * Axel Dörfler, axeld@pinc-software.de
// The above copyright notice and this permission notice shall be included in */
// all copies or substantial portions of the Software.
// /** Class used for the top layer of each workspace's Layer tree */
// 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 <gyoder@stny.rr.com>
// DarkWyrm <bpmagic@columbus.rr.com>
// Stephan Aßmus <superstippi@gmx.de>
// Description: Class used for the top layer of each workspace's Layer tree
//
//------------------------------------------------------------------------------
#ifndef _ROOTLAYER_H_ #ifndef _ROOTLAYER_H_
#define _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); void change_winBorder_feel(WinBorder *winBorder, int32 newFeel);
#ifndef NEW_CLIPPING
void empty_visible_regions(Layer *layer);
#endif
// Input related methods // Input related methods
void MouseEventHandler(BMessage *msg); void MouseEventHandler(BMessage *msg);
void KeyboardEventHandler(BMessage *msg); void KeyboardEventHandler(BMessage *msg);

View File

@ -4,7 +4,7 @@
* *
* Authors: * Authors:
* DarkWyrm <bpmagic@columbus.rr.com> * DarkWyrm <bpmagic@columbus.rr.com>
* Adrian Oanca <adioanca@cotty.iren.ro> * Adrian Oanca <adioanca@gmail.com>
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
* Stefano Ceccherini (burton666@libero.it) * Stefano Ceccherini (burton666@libero.it)
* Axel Dörfler, axeld@pinc-software.de * 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. // NOTE: no need to check for a lock. This is a private method.
layer->CurrentState()->ReadFromLink(link); 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 // TODO: rework the clipping stuff to remove RootLayer dependency and then
// remove this hack: // remove this hack:
if (fWinBorder->IsOffscreenWindow()) { if (fWinBorder->IsOffscreenWindow()) {
#ifndef NEW_CLIPPING
newLayer->fVisible.Set(newLayer->fFrame);
#else
newLayer->fVisible2.Set(newLayer->fFrame); newLayer->fVisible2.Set(newLayer->fFrame);
#endif
} }
if (_parent) { if (_parent) {
@ -555,32 +551,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<float>(&dh); link.Read<float>(&dh);
link.Read<float>(&dv); link.Read<float>(&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); fCurrentLayer->ScrollBy(dh, dv);
#endif
break; break;
} }
@ -647,11 +618,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
if (parent != NULL) if (parent != NULL)
parent->AddChild(newLayer, this); parent->AddChild(newLayer, this);
if (myRootLayer && !newLayer->IsHidden() && parent) if (myRootLayer && !newLayer->IsHidden() && parent) {
#ifndef NEW_CLIPPING
myRootLayer->GoInvalidate(newLayer, newLayer->fFull);
#else
{
BRegion invalidRegion; BRegion invalidRegion;
newLayer->GetWantedRegion(invalidRegion); newLayer->GetWantedRegion(invalidRegion);
parent->MarkForRebuild(invalidRegion); parent->MarkForRebuild(invalidRegion);
@ -660,9 +627,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
myRootLayer->MarkForRedraw(newLayer->VisibleRegion()); myRootLayer->MarkForRedraw(newLayer->VisibleRegion());
myRootLayer->TriggerRedraw(); myRootLayer->TriggerRedraw();
} }
// myRootLayer->GoInvalidate(newLayer, invalidRegion);
} }
#endif
break; break;
} }
case AS_LAYER_DELETE: case AS_LAYER_DELETE:
@ -678,17 +643,10 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
// BRegion *invalidRegion = NULL; // BRegion *invalidRegion = NULL;
if (!fCurrentLayer->IsHidden() && parent && myRootLayer) { if (!fCurrentLayer->IsHidden() && parent && myRootLayer) {
#ifndef NEW_CLIPPING
if (fCurrentLayer->fFullVisible.CountRects() > 0)
invalidRegion = new BRegion(fCurrentLayer->fFullVisible);
#else
if (fCurrentLayer->FullVisible().Frame().IsValid()) { if (fCurrentLayer->FullVisible().Frame().IsValid()) {
parent->MarkForRebuild(fCurrentLayer->FullVisible()); parent->MarkForRebuild(fCurrentLayer->FullVisible());
myRootLayer->MarkForRedraw(fCurrentLayer->FullVisible()); myRootLayer->MarkForRedraw(fCurrentLayer->FullVisible());
// invalidRegion = new BRegion(fCurrentLayer->FullVisible());
} }
#endif
} }
// here we remove current layer from list. // here we remove current layer from list.
@ -716,23 +674,15 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
case AS_LAYER_SET_STATE: case AS_LAYER_SET_STATE:
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_STATE: Layer name: %s\n", fTitle, fCurrentLayer->Name())); DTRACE(("ServerWindow %s: Message AS_LAYER_SET_STATE: Layer name: %s\n", fTitle, fCurrentLayer->Name()));
// SetLayerState(fCurrentLayer);
SetLayerState(fCurrentLayer, link); SetLayerState(fCurrentLayer, link);
// TODO: should this be moved into SetLayerState? // TODO: should this be moved into SetLayerState?
// If it _always_ needs to be done afterwards, then yes! // If it _always_ needs to be done afterwards, then yes!
#ifndef NEW_CLIPPING
fCurrentLayer->RebuildFullRegion();
#endif
break; break;
} }
case AS_LAYER_SET_FONT_STATE: case AS_LAYER_SET_FONT_STATE:
{ {
DTRACE(("ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: Layer name: %s\n", fTitle, fCurrentLayer->Name())); DTRACE(("ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: Layer name: %s\n", fTitle, fCurrentLayer->Name()));
// SetLayerFontState(fCurrentLayer);
SetLayerFontState(fCurrentLayer, link); SetLayerFontState(fCurrentLayer, link);
#ifndef NEW_CLIPPING
fCurrentLayer->RebuildFullRegion();
#endif
break; break;
} }
case AS_LAYER_GET_STATE: 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())); DTRACE(("ServerWindow %s: Message AS_LAYER_PUSH_STATE: Layer: %s\n", Title(), fCurrentLayer->Name()));
fCurrentLayer->PushState(); fCurrentLayer->PushState();
#ifndef NEW_CLIPPING
fCurrentLayer->RebuildFullRegion();
#endif
break; break;
} }
case AS_LAYER_POP_STATE: 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())); DTRACE(("ServerWindow %s: Message AS_LAYER_POP_STATE: Layer: %s\n", Title(), fCurrentLayer->Name()));
fCurrentLayer->PopState(); fCurrentLayer->PopState();
#ifndef NEW_CLIPPING
fCurrentLayer->RebuildFullRegion();
#endif
break; break;
} }
case AS_LAYER_SET_SCALE: case AS_LAYER_SET_SCALE:
@ -993,18 +939,10 @@ if (myRootLayer)
myRootLayer->Lock(); myRootLayer->Lock();
fCurrentLayer->SetViewColor(RGBColor(c)); fCurrentLayer->SetViewColor(RGBColor(c));
#ifndef NEW_CLIPPING
if (myRootLayer)
myRootLayer->GoRedraw(fCurrentLayer, fCurrentLayer->fVisible);
#else
if (myRootLayer) { if (myRootLayer) {
myRootLayer->MarkForRedraw(fCurrentLayer->VisibleRegion()); myRootLayer->MarkForRedraw(fCurrentLayer->VisibleRegion());
myRootLayer->TriggerRedraw(); myRootLayer->TriggerRedraw();
} }
// if (myRootLayer)
// myRootLayer->GoRedraw(fCurrentLayer, fCurrentLayer->VisibleRegion());
#endif
if (myRootLayer) if (myRootLayer)
myRootLayer->Unlock(); myRootLayer->Unlock();
break; break;
@ -1117,14 +1055,7 @@ if (myRootLayer)
fCurrentLayer->CurrentState()->SetClippingRegion(region); fCurrentLayer->CurrentState()->SetClippingRegion(region);
#ifndef NEW_CLIPPING if (myRootLayer && !(fCurrentLayer->IsHidden()) && !fWinBorder->InUpdate()) {
fCurrentLayer->RebuildFullRegion();
#endif
if (myRootLayer && !(fCurrentLayer->IsHidden()) && !fWinBorder->InUpdate())
#ifndef NEW_CLIPPING
myRootLayer->GoInvalidate(fCurrentLayer, fCurrentLayer->fFull);
#else
{
BRegion invalidRegion; BRegion invalidRegion;
fCurrentLayer->GetWantedRegion(invalidRegion); fCurrentLayer->GetWantedRegion(invalidRegion);
@ -1134,10 +1065,7 @@ if (myRootLayer)
fCurrentLayer->fParent->TriggerRebuild(); fCurrentLayer->fParent->TriggerRebuild();
myRootLayer->MarkForRedraw(invalidRegion); myRootLayer->MarkForRedraw(invalidRegion);
myRootLayer->TriggerRedraw(); myRootLayer->TriggerRedraw();
// myRootLayer->GoInvalidate(fCurrentLayer, invalidRegion);
} }
#endif
break; break;
} }
@ -1153,21 +1081,13 @@ if (myRootLayer)
fLink.Flush(); fLink.Flush();
} else { } else {
// TODO: Watch out for the coordinate system in AS_LAYER_GET_CLIP_REGION // 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(); int32 rectCount = fCurrentLayer->fVisible2.CountRects();
#endif
fLink.StartMessage(SERVER_TRUE); fLink.StartMessage(SERVER_TRUE);
fLink.Attach<int32>(rectCount); fLink.Attach<int32>(rectCount);
for (int32 i = 0; i < rectCount; i++) for (int32 i = 0; i < rectCount; i++)
#ifndef NEW_CLIPPING
fLink.Attach<BRect>(fCurrentLayer->ConvertFromTop(fCurrentLayer->fVisible.RectAt(i)));
#else
fLink.Attach<BRect>(fCurrentLayer->ConvertFromTop(fCurrentLayer->fVisible2.RectAt(i))); fLink.Attach<BRect>(fCurrentLayer->ConvertFromTop(fCurrentLayer->fVisible2.RectAt(i)));
#endif
fLink.Flush(); fLink.Flush();
} }
@ -1194,20 +1114,9 @@ if (myRootLayer)
// restored too. "AS_LAYER_SET_CLIP_REGION" is irritating, as I think it should be // 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. // "AS_LAYER_CONSTRAIN_CLIP_REGION", since it means to "add" to the current clipping, not "set" it.
// fCurrentLayer->CurrentState()->SetClippingRegion(region); // fCurrentLayer->CurrentState()->SetClippingRegion(region);
#ifndef NEW_CLIPPING
// TODO: set the clipping // TODO: rebuild clipping and redraw
// fCurrentLayer->fVisible.IntersectWith(&region);
#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
*/
break; break;
} }
case AS_LAYER_INVAL_RECT: case AS_LAYER_INVAL_RECT:
@ -1223,12 +1132,9 @@ if (myRootLayer)
BRect converted(fCurrentLayer->ConvertToTop(invalRect.LeftTop()), BRect converted(fCurrentLayer->ConvertToTop(invalRect.LeftTop()),
fCurrentLayer->ConvertToTop(invalRect.RightBottom())); fCurrentLayer->ConvertToTop(invalRect.RightBottom()));
BRegion invalidRegion(converted); BRegion invalidRegion(converted);
#ifdef NEW_CLIPPING invalidRegion.IntersectWith(&fCurrentLayer->VisibleRegion());
invalidRegion.IntersectWith(&fCurrentLayer->fVisible2);
#endif
myRootLayer->MarkForRedraw(invalidRegion); myRootLayer->MarkForRedraw(invalidRegion);
myRootLayer->TriggerRedraw(); myRootLayer->TriggerRedraw();
// myRootLayer->GoRedraw(fWinBorder, invalidRegion);
} }
break; break;
} }
@ -1717,11 +1623,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
// NOTE: fCurrentLayer and fCurrentLayer->fLayerData cannot be NULL, // NOTE: fCurrentLayer and fCurrentLayer->fLayerData cannot be NULL,
// _DispatchGraphicsMessage() is called from _DispatchMessage() which // _DispatchGraphicsMessage() is called from _DispatchMessage() which
// checks both these conditions // checks both these conditions
#ifndef NEW_CLIPPING BRegion rreg(fCurrentLayer->VisibleRegion());
BRegion rreg(fCurrentLayer->fVisible);
#else
BRegion rreg(fCurrentLayer->fVisible2);
#endif
if (fWinBorder->InUpdate()) if (fWinBorder->InUpdate())
rreg.IntersectWith(&fWinBorder->RegionToBeUpdated()); rreg.IntersectWith(&fWinBorder->RegionToBeUpdated());
@ -2159,72 +2061,6 @@ ServerWindow::_MessageLooper()
// does not return // 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(&copyRegion);
// 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(&copyRegion, 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 status_t
ServerWindow::SendMessageToClient(const BMessage* msg, int32 target, bool usePreferred) const ServerWindow::SendMessageToClient(const BMessage* msg, int32 target, bool usePreferred) const
{ {

View File

@ -4,7 +4,7 @@
* *
* Authors: * Authors:
* DarkWyrm <bpmagic@columbus.rr.com> * DarkWyrm <bpmagic@columbus.rr.com>
* Adrian Oanca <adioanca@cotty.iren.ro> * Adrian Oanca <adioanca@gmail.com>
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
* Stefano Ceccherini (burton666@libero.it) * Stefano Ceccherini (burton666@libero.it)
* Axel Dörfler, axeld@pinc-software.de * Axel Dörfler, axeld@pinc-software.de

View File

@ -3,7 +3,7 @@
* Distributed under the terms of the MIT license. * Distributed under the terms of the MIT license.
* *
* Author: DarkWyrm <bpmagic@columbus.rr.com> * Author: DarkWyrm <bpmagic@columbus.rr.com>
* Adi Oanca <adioanca@cotty.iren.ro> * Adi Oanca <adioanca@gmail.com>
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
*/ */
@ -74,6 +74,9 @@ WinBorder::WinBorder(const BRect &frame,
fCumulativeRegion(), fCumulativeRegion(),
fInUpdateRegion(), fInUpdateRegion(),
fDecRegion(),
fRebuildDecRegion(true),
fMouseButtons(0), fMouseButtons(0),
fLastMousePosition(-1.0, -1.0), fLastMousePosition(-1.0, -1.0),
@ -105,9 +108,7 @@ WinBorder::WinBorder(const BRect &frame,
fServerWin = window; fServerWin = window;
fAdFlags = fAdFlags | B_LAYER_CHILDREN_DEPENDANT; fAdFlags = fAdFlags | B_LAYER_CHILDREN_DEPENDANT;
fFlags = B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE; fFlags = B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE;
#ifdef NEW_CLIPPING
fRebuildDecRegion = true;
#endif
QuietlySetFeel(feel); QuietlySetFeel(feel);
if (fFeel != B_NO_BORDER_WINDOW_LOOK) { 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(("WinBorder %p, %s:\n", this, Name()));
STRACE(("\tFrame: (%.1f, %.1f, %.1f, %.1f)\n", fFrame.left, fFrame.top, STRACE(("\tFrame: (%.1f, %.1f, %.1f, %.1f)\n", fFrame.left, fFrame.top,
fFrame.right, fFrame.bottom)); fFrame.right, fFrame.bottom));
@ -179,58 +176,7 @@ WinBorder::Draw(const BRect &r)
void void
WinBorder::MoveBy(float x, float y) 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); Layer::MoveBy(x, y);
#endif
} }
@ -241,20 +187,6 @@ WinBorder::ResizeBy(float x, float y)
if (!_ResizeBy(x, y)) if (!_ResizeBy(x, y))
return; 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) if (x == 0.0 && y == 0.0)
return false; 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); Layer::ResizeBy(x, y);
#endif
return true; return true;
} }
@ -312,9 +228,10 @@ WinBorder::SetName(const char* name)
// rebuild the clipping for the title area // rebuild the clipping for the title area
// and redraw it. // and redraw it.
// TODO: Adi, please have a look at this,
// it doesn't work yet.
if (fDecorator) { if (fDecorator) {
// TODO: Make sure this works!!
// before the change // before the change
BRegion invalid(fDecorator->GetTabRect()); BRegion invalid(fDecorator->GetTabRect());
@ -323,12 +240,8 @@ WinBorder::SetName(const char* name)
// after the change // after the change
invalid.Include(fDecorator->GetTabRect()); invalid.Include(fDecorator->GetTabRect());
#ifndef NEW_CLIPPING GetRootLayer()->MarkForRedraw(invalid);
RebuildFullRegion(); GetRootLayer()->TriggerRedraw();
fRootLayer->GoRedraw(this, invalid);
#else
// TODO: ...
#endif
} }
} }
@ -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 //! Sets the minimum and maximum sizes of the window
void void
WinBorder::SetSizeLimits(float minWidth, float maxWidth, WinBorder::SetSizeLimits(float minWidth, float maxWidth,
@ -792,24 +688,12 @@ WinBorder::_ActionFor(const BMessage *msg) const
msg->FindInt32("buttons", &buttons); msg->FindInt32("buttons", &buttons);
msg->FindInt32("modifiers", &modifiers); 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) if (fDecorator)
return fDecorator->Clicked(where, buttons, modifiers); return fDecorator->Clicked(where, buttons, modifiers);
else else
return DEC_NONE; return DEC_NONE;
} }
#ifdef NEW_CLIPPING
void WinBorder::MovedByHook(float dx, float dy) void WinBorder::MovedByHook(float dx, float dy)
{ {
STRACE(("WinBorder(%s)::MovedByHook(%.1f, %.1f) fDecorator: %p\n", Name(), x, y, fDecorator)); STRACE(("WinBorder(%s)::MovedByHook(%.1f, %.1f) fDecorator: %p\n", Name(), x, y, fDecorator));
@ -905,13 +789,10 @@ if (cnt != 1)
BMessage msg; BMessage msg;
msg.what = _UPDATE_; msg.what = _UPDATE_;
#ifndef NEW_CLIPPING
msg.AddRect("_rect", ConvertFromTop(fInUpdateRegion.Frame()));
#else
BRect rect(fInUpdateRegion.Frame()); BRect rect(fInUpdateRegion.Frame());
ConvertFromScreen2(&rect); ConvertFromScreen2(&rect);
msg.AddRect("_rect", rect ); msg.AddRect("_rect", rect );
#endif
msg.AddRect("debug_rect", fInUpdateRegion.Frame()); msg.AddRect("debug_rect", fInUpdateRegion.Frame());
if (Window()->SendMessageToClient(&msg) == B_OK) { if (Window()->SendMessageToClient(&msg) == B_OK) {
@ -924,7 +805,6 @@ if (cnt != 1)
} }
} }
} }
#endif
// SetTopLayer // SetTopLayer
void void

View File

@ -3,7 +3,7 @@
* Distributed under the terms of the MIT license. * Distributed under the terms of the MIT license.
* *
* Author: DarkWyrm <bpmagic@columbus.rr.com> * Author: DarkWyrm <bpmagic@columbus.rr.com>
* Adi Oanca <adioanca@cotty.iren.ro> * Adi Oanca <adioanca@gmail.com>
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
*/ */
#ifndef _WINBORDER_H_ #ifndef _WINBORDER_H_
@ -58,11 +58,8 @@ class WinBorder : public Layer {
virtual bool IsOffscreenWindow() const virtual bool IsOffscreenWindow() const
{ return false; } { return false; }
#ifndef NEW_CLIPPING
virtual void RebuildFullRegion();
#else
virtual void GetWantedRegion(BRegion &reg); virtual void GetWantedRegion(BRegion &reg);
#endif
void UpdateStart(); void UpdateStart();
void UpdateEnd(); void UpdateEnd();
inline bool InUpdate() const inline bool InUpdate() const
@ -122,27 +119,19 @@ class WinBorder : public Layer {
SubWindowList fSubWindowList; SubWindowList fSubWindowList;
#ifdef NEW_CLIPPING
public:
virtual void MovedByHook(float dx, float dy); virtual void MovedByHook(float dx, float dy);
virtual void ResizedByHook(float dx, float dy, bool automatic); virtual void ResizedByHook(float dx, float dy, bool automatic);
void RequestClientRedraw(const BRegion &invalid); void RequestClientRedraw(const BRegion &invalid);
private:
void set_decorator_region(BRect frame);
virtual void _ReserveRegions(BRegion &reg);
BRegion fDecRegion;
bool fRebuildDecRegion;
#endif
public:
virtual void SetTopLayer(Layer* layer); virtual void SetTopLayer(Layer* layer);
inline Layer* TopLayer() const inline Layer* TopLayer() const
{ return fTopLayer; } { return fTopLayer; }
private:
void set_decorator_region(BRect frame);
virtual void _ReserveRegions(BRegion &reg);
protected: protected:
friend class Layer; friend class Layer;
friend class RootLayer; friend class RootLayer;
@ -156,6 +145,9 @@ class WinBorder : public Layer {
BRegion fCumulativeRegion; BRegion fCumulativeRegion;
BRegion fInUpdateRegion; BRegion fInUpdateRegion;
BRegion fDecRegion;
bool fRebuildDecRegion;
int32 fMouseButtons; int32 fMouseButtons;
BPoint fLastMousePosition; BPoint fLastMousePosition;
BPoint fResizingClickOffset; BPoint fResizingClickOffset;

View File

@ -163,11 +163,8 @@ WorkspacesLayer::_DrawWorkspace(int32 index)
// draw windows // draw windows
#ifndef NEW_CLIPPING
BRegion backgroundRegion = fVisible;
#else
BRegion backgroundRegion = VisibleRegion(); BRegion backgroundRegion = VisibleRegion();
#endif
// ToDo: would be nice to get the real update region here // ToDo: would be nice to get the real update region here
if (workspace != NULL) { if (workspace != NULL) {
@ -195,12 +192,8 @@ WorkspacesLayer::_DrawWorkspace(int32 index)
fDriver->FillRect(rect, color); fDriver->FillRect(rect, color);
// TODO: ConstrainClippingRegion() should accept a const parameter !! // TODO: ConstrainClippingRegion() should accept a const parameter !!
#ifndef NEW_CLIPPING
fDriver->ConstrainClippingRegion(&fVisible);
#else
BRegion cRegion(VisibleRegion()); BRegion cRegion(VisibleRegion());
fDriver->ConstrainClippingRegion(&cRegion); fDriver->ConstrainClippingRegion(&cRegion);
#endif
} }