diff --git a/src/tests/servers/app/newClipping/Clipping.proj b/src/tests/servers/app/newClipping/Clipping.proj index 26380e77bc..3abf387499 100644 Binary files a/src/tests/servers/app/newClipping/Clipping.proj and b/src/tests/servers/app/newClipping/Clipping.proj differ diff --git a/src/tests/servers/app/newClipping/Layer.cpp b/src/tests/servers/app/newClipping/Layer.cpp index fa1c332021..772958b9a2 100644 --- a/src/tests/servers/app/newClipping/Layer.cpp +++ b/src/tests/servers/app/newClipping/Layer.cpp @@ -281,8 +281,7 @@ void Layer::MoveBy(float dx, float dy) // offset back and instruct the HW to do the actual copying. oldFullVisible.OffsetBy(-dx, -dy); -// TODO: HACK this! -// GetDisplayDriver()->CopyRegion(&oldFullVisible, dx, dy); + GetRootLayer()->CopyRegion(&oldFullVisible, dx, dy); // add redrawReg to our RootLayer's redraw region. GetRootLayer()->fRedrawReg.Include(&redrawReg); @@ -313,16 +312,14 @@ void Layer::ScrollBy(float dx, float dy) // offset old region so that we can start comparing. invalid.OffsetBy(dx, dy); - // no need to redraw common regions. redraw only what's needed. - redrawReg.Exclude(&invalid); - // compute the common region. we'll use HW acc to copy this to the new location. invalid.IntersectWith(&fFullVisible); + GetRootLayer()->CopyRegion(&invalid, -dx, -dy); - // offset back and instruct the driver to do the actual copying. + // common region goes back to its original location. then, by excluding + // it from curent fullVisible we'll obtain the region that needs to be redrawn. invalid.OffsetBy(-dx, -dy); -// TODO: HACK this! -// GetDisplayDriver()->CopyRegion(&invalid, dx, dy); + redrawReg.Exclude(&invalid); GetRootLayer()->fRedrawReg.Include(&redrawReg); GetRootLayer()->RequestRedraw(); // TODO: what if we pass (fParent, startFromTHIS, &redrawReg)? @@ -337,7 +334,6 @@ void Layer::set_user_regions(BRegion ®) // OPT: maybe we should have all these cached in a 'fFull' member // 1) set to frame in screen coords -// BRect screenFrame(fFrame); BRect screenFrame(Bounds()); ConvertToScreen2(&screenFrame); reg.Set(screenFrame); diff --git a/src/tests/servers/app/newClipping/MyView.cpp b/src/tests/servers/app/newClipping/MyView.cpp index a1a8aae05e..b15cfb6b3b 100644 --- a/src/tests/servers/app/newClipping/MyView.cpp +++ b/src/tests/servers/app/newClipping/MyView.cpp @@ -20,8 +20,8 @@ MyView::MyView(BRect frame, const char *name, uint32 resizingMode, uint32 flags) topLayer = new Layer(Bounds(), "topLayer", B_FOLLOW_ALL, col); topLayer->SetRootLayer(this); -// topLayer->RebuildVisibleRegions(BRegion(Bounds()), NULL); topLayer->rebuild_visible_regions(BRegion(Bounds()), BRegion(Bounds()), NULL); + fRedrawReg.Set(Bounds()); } MyView::~MyView() @@ -48,9 +48,20 @@ Layer* MyView::FindLayer(Layer *lay, const char *bytes) const return NULL; } +void MyView::CopyRegion(BRegion *reg, float dx, float dy) +{ +wind->Lock(); +// ConstrainClippingRegion(&r); +// CopyBits(Bounds(), Bounds().OffsetByCopy(dx, dy)); + // TODO: properly do that! + // LAME, I know! + CopyBits(reg->Frame(), reg->Frame().OffsetByCopy(dx, dy)); +// ConstrainClippingRegion(NULL); +wind->Unlock(); +} + void MyView::RequestRedraw() { - // TODO: implement wind->Lock(); Invalidate(); wind->Unlock(); @@ -58,14 +69,19 @@ void MyView::RequestRedraw() void MyView::Draw(BRect area) { + ConstrainClippingRegion(&fRedrawReg); + PushState(); DrawSubTree(topLayer); + PopState(); + ConstrainClippingRegion(NULL); + fRedrawReg.MakeEmpty(); } void MyView::DrawSubTree(Layer* lay) { -printf("======== %s =======\n", lay->Name()); - lay->Visible()->PrintToStream(); - lay->FullVisible()->PrintToStream(); +//printf("======== %s =======\n", lay->Name()); +// lay->Visible()->PrintToStream(); +// lay->FullVisible()->PrintToStream(); Layer *child = lay->VirtualBottomChild(); while(child) { diff --git a/src/tests/servers/app/newClipping/MyView.h b/src/tests/servers/app/newClipping/MyView.h index a54a610408..4a8a5e93b7 100644 --- a/src/tests/servers/app/newClipping/MyView.h +++ b/src/tests/servers/app/newClipping/MyView.h @@ -12,6 +12,7 @@ public: virtual void Draw(BRect area); + void CopyRegion(BRegion *reg, float dx, float dy); void RequestRedraw(); Layer* FindLayer(Layer *lay, const char *bytes) const;