Added Stroke/FillRegion to DisplayDriver for convenience

Fixes to redraw code - buggy, but less so. :)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3719 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2003-06-28 20:07:36 +00:00
parent de662b01c8
commit a7699ce227
4 changed files with 71 additions and 21 deletions
+40
View File
@@ -204,6 +204,26 @@ void DisplayDriver::FillRect(BRect r, LayerData *d, int8 *pat)
{
}
/*!
\brief Convenience function for server use
\param r BRegion to be filled
\param d Data structure containing any other data necessary for the call. Always non-NULL.
\param pat 8-byte array containing the pattern to use. Always non-NULL.
*/
void DisplayDriver::FillRegion(BRegion *r, LayerData *d, int8 *pat)
{
if(!r || !d || !pat)
return;
_locker->Lock();
for(int32 i=0; i<r->CountRects();i++)
FillRect(r->RectAt(i),d,pat);
_locker->Unlock();
}
/*!
\brief Called for all BView::FillRoundRect calls
\param r The rectangle itself
@@ -419,6 +439,26 @@ void DisplayDriver::StrokeRect(BRect r, LayerData *d, int8 *pat)
{
}
/*!
\brief Convenience function for server use
\param r BRegion to be stroked
\param d Data structure containing any other data necessary for the call. Always non-NULL.
\param pat 8-byte array containing the pattern to use. Always non-NULL.
*/
void DisplayDriver::StrokeRegion(BRegion *r, LayerData *d, int8 *pat)
{
if(!r || !d || !pat)
return;
_locker->Lock();
for(int32 i=0; i<r->CountRects();i++)
StrokeRect(r->RectAt(i),d,pat);
_locker->Unlock();
}
/*!
\brief Called for all BView::StrokeRoundRect calls
\param r The rect itself
+3
View File
@@ -36,6 +36,7 @@
#include <Rect.h>
#include <Locker.h>
#include "RGBColor.h"
#include <Region.h>
class ServerCursor;
class ServerBitmap;
@@ -106,6 +107,7 @@ public:
virtual void FillEllipse(BRect r, LayerData *d, int8 *pat);
virtual void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat);
virtual void FillRect(BRect r, LayerData *d, int8 *pat);
virtual void FillRegion(BRegion *r, LayerData *d, int8 *pat);
virtual void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat);
// virtual void FillShape(SShape *sh, LayerData *d, int8 *pat);
virtual void FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat);
@@ -124,6 +126,7 @@ public:
virtual void StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat);
virtual void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true);
virtual void StrokeRect(BRect r, LayerData *d, int8 *pat);
virtual void StrokeRegion(BRegion *r, LayerData *d, int8 *pat);
virtual void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat);
// virtual void StrokeShape(SShape *sh, LayerData *d, int8 *pat);
virtual void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat);
+28 -16
View File
@@ -36,6 +36,12 @@
#include "RectUtils.h"
//#define DEBUG_LAYER
#define DEBUG_REGIONS
#ifdef DEBUG_REGIONS
#include "Desktop.h"
#include "DisplayDriver.h"
#endif
//! TokenHandler object used to provide IDs for all Layers and, thus, BViews
TokenHandler view_token_handler;
@@ -685,12 +691,20 @@ printf("Layer: %s: Move By (%.1f,%.1f)\n",_name->String(),x,y);
if(_parent)
{
if(_parent->_invalid==NULL)
_parent->_invalid=new BRegion(oldframe);
else
_parent->_invalid->Include(oldframe);
}
BRegion *i=new BRegion(oldframe);
if(TestRectIntersection(oldframe,_frame))
i->Exclude(_frame);
if(_parent->_invalid==NULL)
_parent->_invalid=i;
else
{
_parent->_invalid->Include(i);
delete i;
}
_parent->_is_dirty=true;
}
_is_dirty=true;
// for(Layer *lay=_topchild; lay!=NULL; lay=lay->_lowersibling)
// lay->MoveBy(x,y);
// Invalidate(Frame());
@@ -752,18 +766,16 @@ printf("Layer: %s: Rebuild Regions (%s)\n",_name->String(),include_children?"inc
{
if(childlay->_visible && childlay->_hidecount==0)
{
// reg is what is _visible in the layer's _parent's coordinate system
// reg=new BRegion(ConvertToParent(_visible));
// reg2 is the layer's _visible region in the sibling's coordinate system
// reg2=new BRegion(childlay->ConvertFromParent(reg));
// delete reg;
// lowersiblings occupy screen space _above_ a layer, so the layer itself
// must remove from its _visible region
// _visible->Exclude(reg2);
// delete reg2;
reg=new BRegion(ConvertToParent(_visible));
#ifdef DEBUG_REGIONS
printf("old visible:");_visible->PrintToStream();
#endif
reg=new BRegion(childlay->ConvertToParent(childlay->_visible));
_visible->Exclude(reg);
#ifdef DEBUG_REGIONS
printf("child visible:");childlay->_visible->PrintToStream();
printf("converted child visible:");reg->PrintToStream();
printf("new visible:");_visible->PrintToStream();
#endif
delete reg;
}
}
-5
View File
@@ -296,11 +296,6 @@ printf("ClickMove: Drag\n");
_win->Unlock();
lock_layers();
// _parent->Invalidate(oldmoveframe);
// MoveBy(dx,dy);
// _decorator->MoveBy(BPoint(dx, dy));
// _parent->RequestDraw();
// _decorator->Draw();
BRegion *reg=_decorator->GetFootprint();
_driver->CopyRegion(reg,_win->_frame.LeftTop());