From fd5fe00cb138b59ab2d91b5432148401ebeadd8c Mon Sep 17 00:00:00 2001 From: Adi Oanca Date: Wed, 18 May 2005 20:47:13 +0000 Subject: [PATCH] Got scrolling to work properly git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12722 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../servers/app/newClipping/Clipping.proj | Bin 12050 -> 12050 bytes src/tests/servers/app/newClipping/Layer.cpp | 14 ++++------ src/tests/servers/app/newClipping/MyView.cpp | 26 ++++++++++++++---- src/tests/servers/app/newClipping/MyView.h | 1 + 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/tests/servers/app/newClipping/Clipping.proj b/src/tests/servers/app/newClipping/Clipping.proj index 26380e77bcc4b475d969c831850ce11534b89d04..3abf387499fe35daa8072a7bab4fe97c6cb0714e 100644 GIT binary patch delta 141 zcmbOfHz{tz0XCL`^U@8I7w|f6W@W#xqAT;)C7>v6pEd&+{E(OVdpVc4fkjc~@189( z4K26D!EBIZhl0#zK^+lB<{lZN$r`#dL<1mt7??nG0}wm)n05hW)F%JdEfQnf1`-AW NBxy5#u=Gm3OaKttC941c delta 141 zcmbOfHz{tz0X7zn`7#ZY7w|f6W@W#xqAT&&C7>v6pEd&+{E(OUdpVc4fkjc`uSv9W zL(6S(FdHPgQZvMWdZ=ti6-{| 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;