Rename clippReg to clipReg

Implement drawing and clipping for display driver - drawing and clipping should work including pensizes.  Drawmodes, line caps, and line joins aren't supported yet.  Some implementations will need to be revamped.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7622 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
shadow303 2004-05-20 01:31:28 +00:00
parent 225784b713
commit 43404a847e
11 changed files with 1562 additions and 365 deletions

View File

@ -758,7 +758,7 @@ void BitmapDriver::FillPatternRect(const BRect &rect, const DrawData *d)
{ {
} }
void BitmapDriver::StrokeSolidLine(const BPoint &start, const BPoint &end, const RGBColor &color) void BitmapDriver::StrokeSolidLine(int32 x1, int32 y1, int32 x2, int32 y2, const RGBColor &color)
{ {
} }

View File

@ -83,7 +83,7 @@ protected:
virtual void Blit(const BRect &src, const BRect &dest, const DrawData *d); virtual void Blit(const BRect &src, const BRect &dest, const DrawData *d);
virtual void FillSolidRect(const BRect &rect, const RGBColor &color); virtual void FillSolidRect(const BRect &rect, const RGBColor &color);
virtual void FillPatternRect(const BRect &rect, const DrawData *d); virtual void FillPatternRect(const BRect &rect, const DrawData *d);
virtual void StrokeSolidLine(const BPoint &start, const BPoint &end, const RGBColor &color); virtual void StrokeSolidLine(int32 x1, int32 y1, int32 x2, int32 y2, const RGBColor &color);
virtual void StrokePatternLine(int32 x1, int32 y1, int32 x2, int32 y2, const DrawData *d); virtual void StrokePatternLine(int32 x1, int32 y1, int32 x2, int32 y2, const DrawData *d);
virtual void StrokeSolidRect(const BRect &rect, const RGBColor &color); virtual void StrokeSolidRect(const BRect &rect, const RGBColor &color);
virtual void CopyBitmap(ServerBitmap *bitmap, const BRect &source, const BRect &dest, const DrawData *d); virtual void CopyBitmap(ServerBitmap *bitmap, const BRect &source, const BRect &dest, const DrawData *d);

View File

@ -475,14 +475,14 @@ void DirectDriver::StrokeSolidRect(const BRect &rect, const RGBColor &color)
Unlock(); Unlock();
} }
void DirectDriver::StrokeSolidLine(const BPoint &start, const BPoint &end,const RGBColor &color) void DirectDriver::StrokeSolidLine(int32 x1, int32 y1, int32 x2, int32 y2, const RGBColor &color)
{ {
Lock(); Lock();
framebuffer->Lock(); framebuffer->Lock();
drawview->SetHighColor(color.GetColor32()); drawview->SetHighColor(color.GetColor32());
drawview->StrokeLine(start,end); drawview->StrokeLine(BPoint(x1,y1),BPoint(x2,y2));
drawview->Sync(); drawview->Sync();
screenwin->rectpipe.PutRect(BRect(start,end)); screenwin->rectpipe.PutRect(BRect(x1,y1,x2,y2));
framebuffer->Unlock(); framebuffer->Unlock();
Unlock(); Unlock();
} }

View File

@ -148,7 +148,7 @@ protected:
virtual void FillSolidRect(const BRect &rect, const RGBColor &color); virtual void FillSolidRect(const BRect &rect, const RGBColor &color);
virtual void FillPatternRect(const BRect &rect, const DrawData *d); virtual void FillPatternRect(const BRect &rect, const DrawData *d);
virtual void StrokeSolidRect(const BRect &rect, const RGBColor &color); virtual void StrokeSolidRect(const BRect &rect, const RGBColor &color);
virtual void StrokeSolidLine(const BPoint &start, const BPoint &end,const RGBColor &color); virtual void StrokeSolidLine(int32 x1, int32 y1, int32 x2, int32 y2, const RGBColor &color);
virtual void StrokePatternLine(int32 x1, int32 y1, int32 x2, int32 y2, const DrawData *d); virtual void StrokePatternLine(int32 x1, int32 y1, int32 x2, int32 y2, const DrawData *d);
virtual void CopyBitmap(ServerBitmap *bitmap, const BRect &source, virtual void CopyBitmap(ServerBitmap *bitmap, const BRect &source,
const BRect &dest, const DrawData *d); const BRect &dest, const DrawData *d);

File diff suppressed because it is too large Load Diff

View File

@ -600,8 +600,8 @@ void Layer::RebuildFullRegion( ){
ld = _layerdata; ld = _layerdata;
do{ do{
// clip to user region // clip to user region
if(ld->clippReg) if(ld->clipReg)
_full.IntersectWith( ld->clippReg ); _full.IntersectWith( ld->clipReg );
} while( (ld = ld->prevState) ); } while( (ld = ld->prevState) );
// clip to user picture region // clip to user picture region

View File

@ -52,7 +52,7 @@ DrawData::DrawData(void)
if(fontserver) if(fontserver)
font=*(fontserver->GetSystemPlain()); font=*(fontserver->GetSystemPlain());
clippReg=NULL; clipReg=NULL;
edelta.space=0; edelta.space=0;
edelta.nonspace=0; edelta.nonspace=0;
@ -60,8 +60,8 @@ DrawData::DrawData(void)
DrawData::~DrawData(void) DrawData::~DrawData(void)
{ {
if (clippReg) if (clipReg)
delete clippReg; delete clipReg;
} }
DrawData::DrawData(const DrawData &data) DrawData::DrawData(const DrawData &data)
@ -90,12 +90,12 @@ DrawData &DrawData::operator=(const DrawData &from)
fontAliasing=from.fontAliasing; fontAliasing=from.fontAliasing;
font=from.font; font=from.font;
if(from.clippReg) if(from.clipReg)
{ {
if(clippReg) if(clipReg)
*clippReg=*(from.clippReg); *clipReg=*(from.clipReg);
else else
clippReg=new BRegion(*(from.clippReg)); clipReg=new BRegion(*(from.clipReg));
} }
edelta=from.edelta; edelta=from.edelta;
@ -150,12 +150,12 @@ LayerData &LayerData::operator=(const LayerData &from)
fontAliasing=from.fontAliasing; fontAliasing=from.fontAliasing;
font=from.font; font=from.font;
if(from.clippReg) if(from.clipReg)
{ {
if(clippReg) if(clipReg)
*clippReg=*(from.clippReg); *clipReg=*(from.clipReg);
else else
clippReg=new BRegion(*(from.clippReg)); clipReg=new BRegion(*(from.clipReg));
} }
edelta=from.edelta; edelta=from.edelta;
@ -182,8 +182,8 @@ void LayerData::PrintToStream() const{
printf("\t LineCap: %d\t LineJoin: %d\t MiterLimit: %f\n", (int16)lineCap, (int16)lineJoin, miterLimit); printf("\t LineCap: %d\t LineJoin: %d\t MiterLimit: %f\n", (int16)lineCap, (int16)lineJoin, miterLimit);
printf("\t AlphaSrcMode: %ld\t AlphaFncMode: %ld\n", (int32)alphaSrcMode, (int32)alphaFncMode); printf("\t AlphaSrcMode: %ld\t AlphaFncMode: %ld\n", (int32)alphaSrcMode, (int32)alphaFncMode);
printf("\t Scale: %f\n", scale); printf("\t Scale: %f\n", scale);
if (clippReg) if (clipReg)
clippReg->PrintToStream(); clipReg->PrintToStream();
printf("\t ===== Font Data =====\n"); printf("\t ===== Font Data =====\n");
printf("\t FontStyle: CURRENTLY NOT SET\n"); printf("\t FontStyle: CURRENTLY NOT SET\n");

View File

@ -595,7 +595,7 @@ void ServerWindow::SetLayerState(Layer *layer){
lowColor, lowColor,
viewColor; viewColor;
pattern patt; pattern patt;
int32 clippRegRects; int32 clipRegRects;
fSession->ReadPoint( &(layer->_layerdata->penlocation)); fSession->ReadPoint( &(layer->_layerdata->penlocation));
fSession->ReadFloat( &(layer->_layerdata->pensize)); fSession->ReadFloat( &(layer->_layerdata->pensize));
@ -612,30 +612,30 @@ void ServerWindow::SetLayerState(Layer *layer){
fSession->ReadInt8((int8*) &(layer->_layerdata->alphaFncMode)); fSession->ReadInt8((int8*) &(layer->_layerdata->alphaFncMode));
fSession->ReadFloat( &(layer->_layerdata->scale)); fSession->ReadFloat( &(layer->_layerdata->scale));
fSession->ReadBool( &(layer->_layerdata->fontAliasing)); fSession->ReadBool( &(layer->_layerdata->fontAliasing));
fSession->ReadInt32( &clippRegRects); fSession->ReadInt32( &clipRegRects);
layer->_layerdata->patt.Set(*((uint64*)&patt)); layer->_layerdata->patt.Set(*((uint64*)&patt));
layer->_layerdata->highcolor.SetColor(highColor); layer->_layerdata->highcolor.SetColor(highColor);
layer->_layerdata->lowcolor.SetColor(lowColor); layer->_layerdata->lowcolor.SetColor(lowColor);
layer->_layerdata->viewcolor.SetColor(viewColor); layer->_layerdata->viewcolor.SetColor(viewColor);
if(clippRegRects != 0){ if(clipRegRects != 0){
if(layer->_layerdata->clippReg == NULL) if(layer->_layerdata->clipReg == NULL)
layer->_layerdata->clippReg = new BRegion(); layer->_layerdata->clipReg = new BRegion();
else else
layer->_layerdata->clippReg->MakeEmpty(); layer->_layerdata->clipReg->MakeEmpty();
BRect rect; BRect rect;
for(int32 i = 0; i < clippRegRects; i++){ for(int32 i = 0; i < clipRegRects; i++){
fSession->ReadRect(&rect); fSession->ReadRect(&rect);
layer->_layerdata->clippReg->Include(rect); layer->_layerdata->clipReg->Include(rect);
} }
} }
else{ else{
if (layer->_layerdata->clippReg){ if (layer->_layerdata->clipReg){
delete layer->_layerdata->clippReg; delete layer->_layerdata->clipReg;
layer->_layerdata->clippReg = NULL; layer->_layerdata->clipReg = NULL;
} }
} }
STRACE(("DONE: ServerWindow %s: Message AS_LAYER_SET_STATE: Layer: %s\n",fTitle.String(), layer->_name->String())); STRACE(("DONE: ServerWindow %s: Message AS_LAYER_SET_STATE: Layer: %s\n",fTitle.String(), layer->_name->String()));
@ -890,13 +890,13 @@ void ServerWindow::DispatchMessage(int32 code)
fSession->WriteFloat(ld->fontAliasing); fSession->WriteFloat(ld->fontAliasing);
int32 noOfRects = 0; int32 noOfRects = 0;
if (ld->clippReg) if (ld->clipReg)
noOfRects = ld->clippReg->CountRects(); noOfRects = ld->clipReg->CountRects();
fSession->WriteInt32(noOfRects); fSession->WriteInt32(noOfRects);
for(int i = 0; i < noOfRects; i++){ for(int i = 0; i < noOfRects; i++){
fSession->WriteRect(ld->clippReg->RectAt(i)); fSession->WriteRect(ld->clipReg->RectAt(i));
} }
fSession->WriteFloat(cl->_frame.left); fSession->WriteFloat(cl->_frame.left);
@ -1331,12 +1331,12 @@ void ServerWindow::DispatchMessage(int32 code)
ld = cl->_layerdata; ld = cl->_layerdata;
reg = cl->ConvertFromParent(&(cl->_visible)); reg = cl->ConvertFromParent(&(cl->_visible));
if(ld->clippReg) if(ld->clipReg)
reg.IntersectWith(ld->clippReg); reg.IntersectWith(ld->clipReg);
while((ld = ld->prevState)) while((ld = ld->prevState))
if(ld->clippReg) if(ld->clipReg)
reg.IntersectWith(ld->clippReg); reg.IntersectWith(ld->clipReg);
noOfRects = reg.CountRects(); noOfRects = reg.CountRects();
fSession->WriteInt32(noOfRects); fSession->WriteInt32(noOfRects);
@ -1356,16 +1356,16 @@ void ServerWindow::DispatchMessage(int32 code)
int32 noOfRects; int32 noOfRects;
BRect r; BRect r;
if(cl->_layerdata->clippReg) if(cl->_layerdata->clipReg)
cl->_layerdata->clippReg->MakeEmpty(); cl->_layerdata->clipReg->MakeEmpty();
else else
cl->_layerdata->clippReg = new BRegion(); cl->_layerdata->clipReg = new BRegion();
fSession->ReadInt32(&noOfRects); fSession->ReadInt32(&noOfRects);
for(int i = 0; i < noOfRects; i++){ for(int i = 0; i < noOfRects; i++){
fSession->ReadRect(&r); fSession->ReadRect(&r);
cl->_layerdata->clippReg->Include(r); cl->_layerdata->clipReg->Include(r);
} }
cl->RebuildFullRegion(); cl->RebuildFullRegion();

View File

@ -706,7 +706,7 @@ void ViewDriver::StrokePatternLine(int32 x1, int32 y1, int32 x2, int32 y2, const
screenwin->Unlock(); screenwin->Unlock();
} }
void ViewDriver::StrokeSolidLine(const BPoint &start, const BPoint &end, const RGBColor &color) void ViewDriver::StrokeSolidLine(int32 x1, int32 y1, int32 x2, int32 y2, const RGBColor &color)
{ {
if(!is_initialized) if(!is_initialized)
return; return;
@ -714,9 +714,9 @@ void ViewDriver::StrokeSolidLine(const BPoint &start, const BPoint &end, const R
screenwin->Lock(); screenwin->Lock();
framebuffer->Lock(); framebuffer->Lock();
drawview->SetHighColor(color.GetColor32()); drawview->SetHighColor(color.GetColor32());
drawview->StrokeLine(start,end); drawview->StrokeLine(BPoint(x1,y1),BPoint(x2,y2));
drawview->Sync(); drawview->Sync();
screenwin->view->Invalidate(BRect(start,end)); screenwin->view->Invalidate(BRect(x1,y1,x2,y2));
framebuffer->Unlock(); framebuffer->Unlock();
screenwin->Unlock(); screenwin->Unlock();
} }

View File

@ -133,7 +133,7 @@ protected:
virtual void FillSolidRect(const BRect &rect, const RGBColor &color); virtual void FillSolidRect(const BRect &rect, const RGBColor &color);
virtual void FillPatternRect(const BRect &rect, const DrawData *d); virtual void FillPatternRect(const BRect &rect, const DrawData *d);
virtual void StrokeSolidRect(const BRect &rect, const RGBColor &color); virtual void StrokeSolidRect(const BRect &rect, const RGBColor &color);
virtual void StrokeSolidLine(const BPoint &start, const BPoint &end, virtual void StrokeSolidLine(int32 x1, int32 y1, int32 x2, int32 y2,
const RGBColor &color); const RGBColor &color);
virtual void SetDrawData(const DrawData *d, bool set_font_data=false); virtual void SetDrawData(const DrawData *d, bool set_font_data=false);
virtual void StrokePatternLine(int32 x1, int32 y1, int32 x2, int32 y2, virtual void StrokePatternLine(int32 x1, int32 y1, int32 x2, int32 y2,

View File

@ -140,8 +140,8 @@ void WinBorder::RebuildFullRegion(void){
ld = topLayer->_layerdata; ld = topLayer->_layerdata;
do{ do{
// clip to user region // clip to user region
if(ld->clippReg) if(ld->clipReg)
topLayerFull.IntersectWith( ld->clippReg ); topLayerFull.IntersectWith( ld->clipReg );
} while( (ld = ld->prevState) ); } while( (ld = ld->prevState) );
// clip to user picture region // clip to user picture region