- simplified a little the update code/process.
- moved part of the update code from Layer to WinBorder. Fits better there. - renamed a couple members. - some cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13273 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
b62270533e
commit
e603410b82
@ -1316,47 +1316,126 @@ Layer::PrintTree()
|
||||
printf("\t%s\t%s\n", lay->Name(), lay->IsHidden()? "Hidden": "NOT hidden");
|
||||
}
|
||||
|
||||
// UpdateStart
|
||||
// RequestDraw
|
||||
void
|
||||
Layer::UpdateStart()
|
||||
Layer::RequestDraw(const BRegion ®, Layer *startFrom)
|
||||
{
|
||||
// During updates we only want to draw what's in the update region
|
||||
if (fClassID == AS_WINBORDER_CLASS) {
|
||||
// NOTE: don't worry, RooLayer is locked here.
|
||||
WinBorder *wb = (WinBorder*)this;
|
||||
|
||||
wb->fInUpdate = true;
|
||||
wb->fRequestSent = false;
|
||||
wb->yUpdateReg = wb->fUpdateReg;
|
||||
wb->fUpdateReg.MakeEmpty();
|
||||
wb->cnt--;
|
||||
if (wb->cnt != 0)
|
||||
CRITICAL("Layer::UpdateStart(): wb->cnt != 0 -> Not Allowed!");
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateEnd
|
||||
void
|
||||
Layer::UpdateEnd()
|
||||
{
|
||||
// The usual case. Drawing is permitted in the whole visible area.
|
||||
if (fClassID == AS_WINBORDER_CLASS) {
|
||||
WinBorder *wb = (WinBorder*)this;
|
||||
|
||||
wb->yUpdateReg.MakeEmpty();
|
||||
|
||||
wb->fInUpdate = false;
|
||||
|
||||
if (wb->zUpdateReg.CountRects() > 0) {
|
||||
BRegion reg(wb->zUpdateReg);
|
||||
wb->RequestDraw(reg, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
STRACE(("Layer(%s)::RequestDraw()\n", Name()));
|
||||
|
||||
// do not redraw any child until you must
|
||||
int redraw = false;
|
||||
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->fCumulativeRegion.MakeEmpty();
|
||||
fOwner->fRequestSent = true;
|
||||
SendUpdateMsg(fOwner->fInUpdateRegion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 = BottomChild(); lay != NULL; lay = UpperSibling()) {
|
||||
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.
|
||||
BRegion updateReg(fFullVisible2);
|
||||
|
||||
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->fCumulativeRegion.MakeEmpty();
|
||||
fOwner->fRequestSent = true;
|
||||
printf("Send\n");
|
||||
SendUpdateMsg(fOwner->fInUpdateRegion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fVisible2.CountRects() > 0) {
|
||||
BRegion updateReg(fVisible2);
|
||||
updateReg.IntersectWith(®);
|
||||
|
||||
if (updateReg.CountRects() > 0) {
|
||||
fDriver->ConstrainClippingRegion(&updateReg);
|
||||
Draw(updateReg.Frame());
|
||||
fDriver->ConstrainClippingRegion(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
for (Layer *lay = BottomChild(); lay != NULL; lay = UpperSibling()) {
|
||||
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->fFullVisible2);
|
||||
common.IntersectWith(®);
|
||||
|
||||
if (common.CountRects() > 0)
|
||||
lay->RequestDraw(reg, NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NEW_CLIPPING
|
||||
|
||||
// move_layer
|
||||
void
|
||||
@ -1364,9 +1443,9 @@ Layer::move_layer(float x, float y)
|
||||
{
|
||||
/* if (fClassID == AS_WINBORDER_CLASS) {
|
||||
WinBorder *wb = (WinBorder*)this;
|
||||
wb->zUpdateReg.OffsetBy(x, y);
|
||||
wb->yUpdateReg.OffsetBy(x, y);
|
||||
wb->fUpdateReg.OffsetBy(x, y);
|
||||
wb->fCumulativeRegion.OffsetBy(x, y);
|
||||
wb->fInUpdateRegion.OffsetBy(x, y);
|
||||
wb->fSavedForUpdateRegion.OffsetBy(x, y);
|
||||
}*/
|
||||
|
||||
fFrameAction = B_LAYER_ACTION_MOVE;
|
||||
@ -1473,119 +1552,6 @@ Layer::Invalidate(const BRegion& region)
|
||||
|
||||
#endif // 5 methods
|
||||
|
||||
// RequestDraw
|
||||
void
|
||||
Layer::RequestDraw(const BRegion ®, Layer *startFrom)
|
||||
{
|
||||
STRACE(("Layer(%s)::RequestDraw()\n", Name()));
|
||||
//printf("Layer(%s)::RequestDraw()\n", Name());
|
||||
//if (fClassID == AS_ROOTLAYER_CLASS)
|
||||
// debugger("z");
|
||||
// do not redraw any child until you must
|
||||
int redraw = false;
|
||||
if (!startFrom)
|
||||
redraw = true;
|
||||
|
||||
if (HasClient() && IsTopLayer()) {
|
||||
// calculate the minimum region/rectangle to be updated with
|
||||
// a single message to the client.
|
||||
#ifndef NEW_CLIPPING
|
||||
BRegion updateReg(fFullVisible);
|
||||
#else
|
||||
BRegion updateReg(fFullVisible2);
|
||||
#endif
|
||||
|
||||
if (fFlags & B_FULL_UPDATE_ON_RESIZE
|
||||
#ifndef NEW_CLIPPING
|
||||
&& fFrameAction == B_LAYER_ACTION_RESIZE
|
||||
#endif
|
||||
)
|
||||
{
|
||||
// do nothing
|
||||
} else {
|
||||
updateReg.IntersectWith(®);
|
||||
}
|
||||
if (updateReg.CountRects() > 0) {
|
||||
fOwner->zUpdateReg.Include(&updateReg);
|
||||
if (!fOwner->fInUpdate && !fOwner->fRequestSent) {
|
||||
fOwner->fUpdateReg = fOwner->zUpdateReg;
|
||||
fOwner->cnt++;
|
||||
if (fOwner->cnt != 1)
|
||||
CRITICAL("Layer::RequestDraw(): fOwner->cnt != 1 -> Not Allowed!");
|
||||
fOwner->zUpdateReg.MakeEmpty();
|
||||
SendUpdateMsg(fOwner->fUpdateReg);
|
||||
fOwner->fRequestSent = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NEW_CLIPPING
|
||||
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 = BottomChild(); lay != NULL; lay = UpperSibling()) {
|
||||
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 (fVisible2.CountRects() > 0) {
|
||||
BRegion updateReg(fVisible2);
|
||||
// calculate the update region
|
||||
if (fFlags & B_FULL_UPDATE_ON_RESIZE
|
||||
// TODO: must be replaced!
|
||||
// && 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 = BottomChild(); lay != NULL; lay = UpperSibling()) {
|
||||
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->fFullVisible2);
|
||||
common.IntersectWith(®);
|
||||
|
||||
if (common.CountRects() > 0)
|
||||
lay->RequestDraw(reg, NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns the layer's ServerWindow
|
||||
|
@ -189,9 +189,6 @@ class Layer {
|
||||
bool IsTopLayer() const
|
||||
{ return fIsTopLayer; }
|
||||
|
||||
void UpdateStart();
|
||||
void UpdateEnd();
|
||||
|
||||
BRegion* ClippingRegion() const
|
||||
{ return fClipReg; }
|
||||
|
||||
|
@ -288,6 +288,7 @@ RootLayer::WorkingThread(void *data)
|
||||
}
|
||||
case AS_ROOTLAYER_DO_INVALIDATE:
|
||||
{
|
||||
//printf("Adi: new message\n");
|
||||
BRegion invalidRegion;
|
||||
Layer *layer = NULL;
|
||||
messageQueue.Read<Layer*>(&layer);
|
||||
@ -399,7 +400,6 @@ RootLayer::GoInvalidate(const Layer *layer, const BRegion ®ion)
|
||||
{
|
||||
BPrivate::PortLink msg(fListenPort, -1);
|
||||
msg.StartMessage(AS_ROOTLAYER_DO_INVALIDATE);
|
||||
//debugger("y");
|
||||
msg.Attach<const Layer*>(layer);
|
||||
msg.AttachRegion(region);
|
||||
msg.Flush();
|
||||
|
@ -1461,8 +1461,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
(fCurrentLayer->fVisible)
|
||||
#endif
|
||||
;
|
||||
if (fWinBorder->fInUpdate)
|
||||
rreg.IntersectWith(&fWinBorder->yUpdateReg);
|
||||
if (fWinBorder->InUpdate())
|
||||
rreg.IntersectWith(&fWinBorder->RegionToBeUpdated());
|
||||
|
||||
gDesktop->GetDisplayDriver()->ConstrainClippingRegion(&rreg);
|
||||
// rgb_color rrr = fCurrentLayer->fLayerData->viewcolor.GetColor32();
|
||||
|
@ -69,9 +69,8 @@ WinBorder::WinBorder(const BRect &r,
|
||||
fDecorator(NULL),
|
||||
fTopLayer(NULL),
|
||||
|
||||
zUpdateReg(),
|
||||
yUpdateReg(),
|
||||
fUpdateReg(),
|
||||
fCumulativeRegion(),
|
||||
fInUpdateRegion(),
|
||||
|
||||
fMouseButtons(0),
|
||||
fKeyModifiers(0),
|
||||
@ -182,9 +181,8 @@ y = (float)int32(y);
|
||||
|
||||
// NOTE: I moved this here from Layer::move_layer()
|
||||
// Should this have any bad consequences I'm not aware of?
|
||||
zUpdateReg.OffsetBy(x, y);
|
||||
yUpdateReg.OffsetBy(x, y);
|
||||
fUpdateReg.OffsetBy(x, y);
|
||||
fCumulativeRegion.OffsetBy(x, y);
|
||||
fInUpdateRegion.OffsetBy(x, y);
|
||||
|
||||
if (IsHidden()) {
|
||||
// TODO: This is a work around for a design issue:
|
||||
@ -280,6 +278,35 @@ y = (float)int32(y);
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateStart
|
||||
void
|
||||
WinBorder::UpdateStart()
|
||||
{
|
||||
// During updates we only want to draw what's in the update region
|
||||
fInUpdate = true;
|
||||
fRequestSent = false;
|
||||
|
||||
cnt--;
|
||||
if (cnt != 0)
|
||||
CRITICAL("Layer::UpdateStart(): wb->cnt != 0 -> Not Allowed!");
|
||||
}
|
||||
|
||||
// UpdateEnd
|
||||
void
|
||||
WinBorder::UpdateEnd()
|
||||
{
|
||||
// The usual case. Drawing is permitted in the whole visible area.
|
||||
|
||||
fInUpdate = false;
|
||||
|
||||
fInUpdateRegion.MakeEmpty();
|
||||
|
||||
if (fCumulativeRegion.CountRects() > 0) {
|
||||
BRegion reg(fCumulativeRegion);
|
||||
RequestDraw(reg, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NEW_CLIPPING
|
||||
|
||||
//! Rebuilds the WinBorder's "fully-visible" region based on info from the decorator
|
||||
|
@ -66,6 +66,14 @@ class WinBorder : public Layer {
|
||||
#ifndef NEW_CLIPPING
|
||||
virtual void RebuildFullRegion();
|
||||
#endif
|
||||
|
||||
void UpdateStart();
|
||||
void UpdateEnd();
|
||||
inline bool InUpdate() const
|
||||
{ return fInUpdate; }
|
||||
inline const BRegion& RegionToBeUpdated() const
|
||||
{ return fInUpdateRegion; }
|
||||
|
||||
void SetSizeLimits(float minWidth,
|
||||
float maxWidth,
|
||||
float minHeight,
|
||||
@ -132,9 +140,8 @@ class WinBorder : public Layer {
|
||||
Decorator* fDecorator;
|
||||
Layer* fTopLayer;
|
||||
|
||||
BRegion zUpdateReg;
|
||||
BRegion yUpdateReg;
|
||||
BRegion fUpdateReg;
|
||||
BRegion fCumulativeRegion;
|
||||
BRegion fInUpdateRegion;
|
||||
|
||||
int32 fMouseButtons;
|
||||
int32 fKeyModifiers;
|
||||
|
Loading…
x
Reference in New Issue
Block a user