Got scrolling to work properly

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12722 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adi Oanca 2005-05-18 20:47:13 +00:00
parent ba2286a9a9
commit fd5fe00cb1
4 changed files with 27 additions and 14 deletions

View File

@ -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 &reg)
// 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);

View File

@ -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)
{

View File

@ -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;