renamed DisplayDriverPainter to DrawingEngine, removed tons of duplicated code, and - guess what - found some bugs while doing so... but nothing critical. This patch removes the former DisplayDriver API from libappserver.so, which I think breaks Decorator plug-ins for now

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14707 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2005-11-04 18:22:22 +00:00
parent c5eb28a359
commit e7869c4c74
6 changed files with 291 additions and 481 deletions

View File

@ -41,177 +41,158 @@ public:
DrawingEngine(HWInterface* interface = NULL);
virtual ~DrawingEngine();
// when implementing, be sure to call the inherited version
virtual status_t Initialize();
virtual void Shutdown();
// when implementing, be sure to call the inherited version
status_t Initialize();
void Shutdown();
virtual void Update();
// locking
bool Lock();
void Unlock();
virtual void SetHWInterface(HWInterface* interface);
bool WriteLock();
void WriteUnlock();
// clipping for all drawing functions, passing a NULL region
// will remove any clipping (drawing allowed everywhere)
virtual void ConstrainClippingRegion(BRegion* region);
// for "changing" hardware
void Update();
// drawing functions
virtual void CopyRegion( /*const*/ BRegion* region,
void SetHWInterface(HWInterface* interface);
// for screen shots
bool DumpToFile( const char *path);
ServerBitmap* DumpToBitmap();
// clipping for all drawing functions, passing a NULL region
// will remove any clipping (drawing allowed everywhere)
void ConstrainClippingRegion(BRegion* region);
// drawing functions
void CopyRegion( /*const*/ BRegion* region,
int32 xOffset,
int32 yOffset);
virtual void CopyRegionList( BList* list,
void CopyRegionList( BList* list,
BList* pList,
int32 rCount,
BRegion* clipReg);
virtual void InvertRect( BRect r);
void InvertRect( BRect r);
virtual void DrawBitmap( ServerBitmap *bitmap,
void DrawBitmap( ServerBitmap *bitmap,
const BRect &source,
const BRect &dest,
const DrawState *d);
// drawing primitives
virtual void FillArc( BRect r,
void DrawArc( BRect r,
const float &angle,
const float &span,
const DrawState *d);
const DrawState *d,
bool filled);
virtual void FillBezier( BPoint *pts,
const DrawState *d);
void DrawBezier( BPoint *pts,
const DrawState *d,
bool filled);
virtual void FillEllipse( BRect r,
const DrawState *d);
void DrawEllipse( BRect r,
const DrawState *d,
bool filled);
virtual void FillPolygon( BPoint *ptlist,
int32 numpts,
BRect bounds,
const DrawState *d);
virtual void FillRect( BRect r,
const RGBColor &color);
virtual void FillRect( BRect r,
const DrawState *d);
virtual void FillRegion( BRegion &r,
const DrawState *d);
virtual void FillRoundRect( BRect r,
const float &xrad,
const float &yrad,
const DrawState *d);
virtual void FillShape( const BRect &bounds,
const int32 &opcount,
const int32 *oplist,
const int32 &ptcount,
const BPoint *ptlist,
const DrawState *d);
virtual void FillTriangle( BPoint *pts,
BRect bounds,
const DrawState *d);
virtual void StrokeArc( BRect r,
const float &angle,
const float &span,
const DrawState *d);
virtual void StrokeBezier( BPoint *pts,
const DrawState *d);
virtual void StrokeEllipse( BRect r,
const DrawState *d);
// this version used by Decorator
virtual void StrokeLine( const BPoint &start,
const BPoint &end,
const RGBColor &color);
virtual void StrokeLine( const BPoint &start,
const BPoint &end,
DrawState *d);
virtual void StrokeLineArray(const int32 &numlines,
const LineArrayData *data,
const DrawState *d);
// this version used by Decorator
virtual void StrokePoint( const BPoint &pt,
const RGBColor &color);
virtual void StrokePoint( const BPoint &pt,
DrawState *d);
virtual void StrokePolygon( BPoint *ptlist,
void DrawPolygon( BPoint *ptlist,
int32 numpts,
BRect bounds,
const DrawState *d,
bool is_closed=true);
bool filled,
bool closed);
// this version used by Decorator
virtual void StrokeRect( BRect r,
// this version used by Decorator
void StrokeRect( BRect r,
const RGBColor &color);
virtual void StrokeRect( BRect r,
void FillRect( BRect r,
const RGBColor &color);
void StrokeRect( BRect r,
const DrawState *d);
virtual void StrokeRegion( BRegion &r,
void FillRect( BRect r,
const DrawState *d);
virtual void StrokeRoundRect(BRect r,
// for debugging purposes?
void StrokeRegion( BRegion &r,
const DrawState *d);
void FillRegion( BRegion &r,
const DrawState *d);
void DrawRoundRect( BRect r,
const float &xrad,
const float &yrad,
const DrawState *d);
const DrawState *d,
bool filled);
virtual void StrokeShape( const BRect &bounds,
void DrawShape( const BRect &bounds,
const int32 &opcount,
const int32 *oplist,
const int32 &ptcount,
const BPoint *ptlist,
const DrawState *d);
const DrawState *d,
bool filled);
virtual void StrokeTriangle( BPoint *pts,
void DrawTriangle( BPoint *pts,
const BRect &bounds,
const DrawState *d,
bool filled);
// this version used by Decorator
void StrokeLine( const BPoint &start,
const BPoint &end,
const RGBColor &color);
void StrokeLine( const BPoint &start,
const BPoint &end,
DrawState *d);
void StrokeLineArray(const int32 &numlines,
const LineArrayData *data,
const DrawState *d);
// Font-related calls
// this version used by Decorator
void StrokePoint( const BPoint &pt,
const RGBColor &color);
void StrokePoint( const BPoint &pt,
DrawState *d);
// -------- text related calls
// DrawState is NOT const because this call updates the pen position in the passed DrawState
virtual void DrawString( const char* string,
// DrawState is NOT const because this call updates the pen position in the passed DrawState
void DrawString( const char* string,
int32 length,
const BPoint& pt,
DrawState* d,
escapement_delta* delta = NULL);
/* virtual void DrawString( const char *string,
/* void DrawString( const char *string,
const int32 &length,
const BPoint &pt,
const RGBColor &color,
escapement_delta *delta=NULL);*/
virtual float StringWidth( const char* string,
float StringWidth( const char* string,
int32 length,
const DrawState* d,
escapement_delta* delta = NULL);
virtual float StringWidth( const char* string,
float StringWidth( const char* string,
int32 length,
const ServerFont& font,
escapement_delta* delta = NULL);
virtual float StringHeight( const char* string,
float StringHeight( const char* string,
int32 length,
const DrawState* d);
virtual bool Lock();
virtual void Unlock();
bool WriteLock();
void WriteUnlock();
virtual bool DumpToFile( const char *path);
virtual ServerBitmap* DumpToBitmap();
private:
BRect _CopyRect( BRect r,
int32 xOffset,

View File

@ -27,7 +27,6 @@ SharedLibrary libappserver.so :
ColorSet.cpp
CursorData.cpp
CursorSet.cpp
Decorator.cpp
DrawState.cpp
FontFamily.cpp
IPoint.cpp
@ -49,6 +48,7 @@ SharedLibrary libappserver.so :
Server app_server :
# Misc. Sources
Decorator.cpp
DebugInfoManager.cpp
SubWindowList.cpp
PicturePlayer.cpp

View File

@ -174,49 +174,36 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, DrawState *d)
break;
}
case B_PIC_STROKE_ROUND_RECT:
{
BRect rect = GetRect();
BPoint radii = GetCoord();
fdriver->StrokeRoundRect(rect,radii.x,radii.y,&fldata);
break;
}
case B_PIC_FILL_ROUND_RECT:
{
BRect rect = GetRect();
BPoint radii = GetCoord();
fdriver->FillRoundRect(rect,radii.x,radii.y,&fldata);
fdriver->DrawRoundRect(rect, radii.x, radii.y,
&fldata, op == B_PIC_FILL_ROUND_RECT);
break;
}
case B_PIC_STROKE_BEZIER:
{
BPoint control[4];
GetData(control, sizeof(control));
fdriver->StrokeBezier(control,&fldata);
break;
}
case B_PIC_FILL_BEZIER:
{
BPoint control[4];
GetData(control, sizeof(control));
fdriver->FillBezier(control,&fldata);
fdriver->DrawBezier(control, &fldata,
op == B_PIC_FILL_BEZIER);
break;
}
case B_PIC_STROKE_POLYGON:
{
int32 numPoints = GetInt32();
BPoint *points = new BPoint[numPoints];
GetData(points, numPoints * sizeof(BPoint));
bool isClosed = GetBool();
fdriver->StrokePolygon(points,numPoints,CalculatePolygonBounds(points,numPoints),&fldata,isClosed);
delete points;
break;
}
case B_PIC_FILL_POLYGON:
{
int32 numPoints = GetInt32();
BPoint *points = new BPoint[numPoints];
GetData(points, numPoints * sizeof(BPoint));
fdriver->FillPolygon(points,numPoints,CalculatePolygonBounds(points,numPoints),&fldata);
bool closed = true;
if (op == B_PIC_STROKE_POLYGON)
closed = GetBool();
fdriver->DrawPolygon(points, numPoints,
CalculatePolygonBounds(points, numPoints),
&fldata, op == B_PIC_FILL_POLYGON,
closed);
delete points;
break;
}
@ -271,41 +258,28 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, DrawState *d)
break;
}
case B_PIC_STROKE_ARC:
{
BPoint center = GetCoord();
BPoint radii = GetCoord();
float startTheta = GetFloat();
float arcTheta = GetFloat();
fdriver->StrokeArc(BRect(center.x-radii.x,center.y-radii.y,center.x+radii.x,
center.y+radii.y),startTheta, arcTheta, &fldata);
break;
}
case B_PIC_FILL_ARC:
{
BPoint center = GetCoord();
BPoint radii = GetCoord();
float startTheta = GetFloat();
float arcTheta = GetFloat();
fdriver->FillArc(BRect(center.x-radii.x,center.y-radii.y,center.x+radii.x,
center.y+radii.y),startTheta, arcTheta, &fldata);
fdriver->DrawArc(BRect(center.x - radii.x,
center.y - radii.y,
center.x + radii.x,
center.y+radii.y),
startTheta, arcTheta, &fldata,
op == B_PIC_FILL_ARC);
break;
}
case B_PIC_STROKE_ELLIPSE:
{
BRect rect = GetRect();
BPoint center;
BPoint radii((rect.Width() + 1) / 2.0f, (rect.Height() + 1) / 2.0f);
center = rect.LeftTop() + radii;
fdriver->StrokeEllipse(rect,&fldata);
break;
}
case B_PIC_FILL_ELLIPSE:
{
BRect rect = GetRect();
BPoint center;
BPoint radii((rect.Width() + 1) / 2.0f, (rect.Height() + 1) / 2.0f);
center = rect.LeftTop() + radii;
fdriver->FillEllipse(rect,&fldata);
fdriver->DrawEllipse(rect, &fldata, op == B_PIC_FILL_ELLIPSE);
break;
}
case B_PIC_ENTER_STATE_CHANGE:

View File

@ -1824,10 +1824,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<float>(&angle);
link.Read<float>(&span);
if (code == AS_STROKE_ARC)
driver->StrokeArc(fCurrentLayer->ConvertToTop(r),angle,span, fCurrentLayer->CurrentState());
else
driver->FillArc(fCurrentLayer->ConvertToTop(r),angle,span, fCurrentLayer->CurrentState());
driver->DrawArc(fCurrentLayer->ConvertToTop(r), angle, span,
fCurrentLayer->CurrentState(), code == AS_FILL_ARC);
break;
}
@ -1842,10 +1840,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
pts[i] = fCurrentLayer->ConvertToTop(pts[i]);
}
if (code == AS_STROKE_BEZIER)
driver->StrokeBezier(pts, fCurrentLayer->CurrentState());
else
driver->FillBezier(pts, fCurrentLayer->CurrentState());
driver->DrawBezier(pts, fCurrentLayer->CurrentState(), code == AS_FILL_BEZIER);
break;
}
@ -1857,10 +1852,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
BRect rect;
link.Read<BRect>(&rect);
if (code == AS_STROKE_ELLIPSE)
driver->StrokeEllipse(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->CurrentState());
else
driver->FillEllipse(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->CurrentState());
driver->DrawEllipse(fCurrentLayer->ConvertToTop(rect),
fCurrentLayer->CurrentState(), code == AS_FILL_ELLIPSE);
break;
}
@ -1875,10 +1868,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<float>(&xrad);
link.Read<float>(&yrad);
if (code == AS_STROKE_ROUNDRECT)
driver->StrokeRoundRect(fCurrentLayer->ConvertToTop(rect),xrad,yrad, fCurrentLayer->CurrentState());
else
driver->FillRoundRect(fCurrentLayer->ConvertToTop(rect),xrad,yrad, fCurrentLayer->CurrentState());
driver->DrawRoundRect(fCurrentLayer->ConvertToTop(rect), xrad, yrad,
fCurrentLayer->CurrentState(), code == AS_FILL_ROUNDRECT);
break;
}
@ -1897,10 +1888,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<BRect>(&rect);
if (code == AS_STROKE_TRIANGLE)
driver->StrokeTriangle(pts, fCurrentLayer->ConvertToTop(rect), fCurrentLayer->CurrentState());
else
driver->FillTriangle(pts, fCurrentLayer->ConvertToTop(rect), fCurrentLayer->CurrentState());
driver->DrawTriangle(pts, fCurrentLayer->ConvertToTop(rect),
fCurrentLayer->CurrentState(), code == AS_FILL_TRIANGLE);
break;
}
@ -1910,7 +1899,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
DTRACE(("ServerWindow %s: Message AS_STROKE/FILL_POLYGON\n", Title()));
BRect polyframe;
bool isclosed;
bool isclosed = true;
int32 pointcount;
BPoint *pointlist;
@ -1926,10 +1915,9 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
for (int32 i = 0; i < pointcount; i++)
pointlist[i] = fCurrentLayer->ConvertToTop(pointlist[i]);
if (code == AS_STROKE_POLYGON)
driver->StrokePolygon(pointlist, pointcount, polyframe, fCurrentLayer->CurrentState(), isclosed);
else
driver->FillPolygon(pointlist, pointcount, polyframe, fCurrentLayer->CurrentState());
driver->DrawPolygon(pointlist, pointcount, polyframe,
fCurrentLayer->CurrentState(), code == AS_FILL_POLYGON,
isclosed);
delete [] pointlist;
break;
@ -1956,10 +1944,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
for (int32 i = 0; i < ptcount; i++)
ptlist[i] = fCurrentLayer->ConvertToTop(ptlist[i]);
if (code == AS_STROKE_SHAPE)
driver->StrokeShape(shaperect, opcount, oplist, ptcount, ptlist, fCurrentLayer->CurrentState());
else
driver->FillShape(shaperect, opcount, oplist, ptcount, ptlist, fCurrentLayer->CurrentState());
driver->DrawShape(shaperect, opcount, oplist, ptcount, ptlist,
fCurrentLayer->CurrentState(), code == AS_FILL_SHAPE);
delete[] oplist;
delete[] ptlist;

View File

@ -259,7 +259,7 @@ is_above(const BRect& a, const BRect& b)
// CopyRegion
void
DrawingEngine::CopyRegion(/*const*/ BRegion* region,
int32 xOffset, int32 yOffset)
int32 xOffset, int32 yOffset)
{
// NOTE: Write locking because we might use HW acceleration.
// This needs to be investigated, I'm doing this because of
@ -389,7 +389,7 @@ DrawingEngine::CopyRegion(/*const*/ BRegion* region,
// make much sense to me.
void
DrawingEngine::CopyRegionList(BList* list, BList* pList,
int32 rCount, BRegion* clipReg)
int32 rCount, BRegion* clipReg)
{
// NOTE: Write locking because we might use HW acceleration.
// This needs to be investigated, I'm doing this because of
@ -440,8 +440,8 @@ DrawingEngine::InvertRect(BRect r)
// DrawBitmap
void
DrawingEngine::DrawBitmap(ServerBitmap *bitmap,
const BRect &source, const BRect &dest,
const DrawState *d)
const BRect &source, const BRect &dest,
const DrawState *d)
{
if (Lock()) {
BRect clipped = fPainter->ClipRect(dest);
@ -459,25 +459,32 @@ DrawingEngine::DrawBitmap(ServerBitmap *bitmap,
}
}
// FillArc
// DrawArc
void
DrawingEngine::FillArc(BRect r, const float &angle,
const float &span, const DrawState *d)
DrawingEngine::DrawArc(BRect r, const float &angle,
const float &span, const DrawState *d,
bool filled)
{
if (Lock()) {
make_rect_valid(r);
BRect clipped = fPainter->ClipRect(r);
BRect clipped(r);
if (!filled)
extend_by_stroke_width(clipped, d);
clipped = fPainter->ClipRect(r);
if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawState(d);
float xRadius = r.Width() / 2.0;
float yRadius = r.Width() / 2.0;
float yRadius = r.Height() / 2.0;
BPoint center(r.left + xRadius,
r.top + yRadius);
fPainter->FillArc(center, xRadius, yRadius, angle, span);
if (filled)
fPainter->FillArc(center, xRadius, yRadius, angle, span);
else
fPainter->StrokeArc(center, xRadius, yRadius, angle, span);
fGraphicsCard->Invalidate(clipped);
fGraphicsCard->ShowSoftwareCursor();
@ -487,16 +494,16 @@ DrawingEngine::FillArc(BRect r, const float &angle,
}
}
// FillBezier
// DrawBezier
void
DrawingEngine::FillBezier(BPoint *pts, const DrawState *d)
DrawingEngine::DrawBezier(BPoint *pts, const DrawState *d, bool filled)
{
if (Lock()) {
fGraphicsCard->HideSoftwareCursor();
fPainter->SetDrawState(d);
BRect touched = fPainter->FillBezier(pts);
BRect touched = filled ? fPainter->FillBezier(pts)
: fPainter->StrokeBezier(pts);
fGraphicsCard->Invalidate(touched);
fGraphicsCard->ShowSoftwareCursor();
@ -505,24 +512,30 @@ DrawingEngine::FillBezier(BPoint *pts, const DrawState *d)
}
}
// FillEllipse
// DrawEllipse
void
DrawingEngine::FillEllipse(BRect r, const DrawState *d)
DrawingEngine::DrawEllipse(BRect r, const DrawState *d, bool filled)
{
if (Lock()) {
make_rect_valid(r);
BRect clipped = fPainter->ClipRect(r);
BRect clipped = r;
if (!filled)
extend_by_stroke_width(clipped, d);
clipped = fPainter->ClipRect(clipped);
if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped);
fGraphicsCard->HideSoftwareCursor(r);
fPainter->SetDrawState(d);
float xRadius = r.Width() / 2.0;
float yRadius = r.Height() / 2.0;
BPoint center(r.left + xRadius,
r.top + yRadius);
fPainter->FillEllipse(center, xRadius, yRadius);
if (filled)
fPainter->FillEllipse(center, xRadius, yRadius);
else
fPainter->StrokeEllipse(center, xRadius, yRadius);
fGraphicsCard->Invalidate(clipped);
fGraphicsCard->ShowSoftwareCursor();
@ -532,21 +545,57 @@ DrawingEngine::FillEllipse(BRect r, const DrawState *d)
}
}
// FillPolygon
// DrawPolygon
void
DrawingEngine::FillPolygon(BPoint *ptlist, int32 numpts,
BRect bounds, const DrawState *d)
DrawingEngine::DrawPolygon(BPoint* ptlist, int32 numpts,
BRect bounds, const DrawState* d,
bool filled, bool closed)
{
if (Lock()) {
make_rect_valid(bounds);
BRect clipped = fPainter->ClipRect(bounds);
if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawState(d);
fPainter->FillPolygon(ptlist, numpts);
if (!filled)
extend_by_stroke_width(bounds, d);
bounds = fPainter->ClipRect(bounds);
if (bounds.IsValid()) {
fGraphicsCard->HideSoftwareCursor(bounds);
fGraphicsCard->Invalidate(clipped);
fPainter->SetDrawState(d);
if (filled)
fPainter->FillPolygon(ptlist, numpts);
else
fPainter->StrokePolygon(ptlist, numpts, closed);
fGraphicsCard->Invalidate(bounds);
fGraphicsCard->ShowSoftwareCursor();
}
Unlock();
}
}
// StrokeRect
//
// this function is used to draw a one pixel wide rect
void
DrawingEngine::StrokeRect(BRect r, const RGBColor &color)
{
if (Lock()) {
make_rect_valid(r);
BRect clipped = fPainter->ClipRect(r);
if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->StrokeRect(r, color.GetColor32());
fGraphicsCard->Invalidate(fPainter->ClipRect(BRect(r.left, r.top,
r.right, r.top)));
fGraphicsCard->Invalidate(fPainter->ClipRect(BRect(r.left, r.top + 1,
r.left, r.bottom - 1)));
fGraphicsCard->Invalidate(fPainter->ClipRect(BRect(r.right, r.top + 1,
r.right, r.bottom - 1)));
fGraphicsCard->Invalidate(fPainter->ClipRect(BRect(r.left, r.bottom,
r.right, r.bottom)));
fGraphicsCard->ShowSoftwareCursor();
}
@ -585,6 +634,31 @@ DrawingEngine::FillRect(BRect r, const RGBColor& color)
}
}
// StrokeRect
void
DrawingEngine::StrokeRect(BRect r, const DrawState *d)
{
if (Lock()) {
// support invalid rects
make_rect_valid(r);
BRect clipped(r);
extend_by_stroke_width(clipped, d);
clipped = fPainter->ClipRect(clipped);
if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawState(d);
fPainter->StrokeRect(r);
fGraphicsCard->Invalidate(clipped);
fGraphicsCard->ShowSoftwareCursor();
}
Unlock();
}
}
// FillRect
void
DrawingEngine::FillRect(BRect r, const DrawState *d)
@ -631,6 +705,34 @@ DrawingEngine::FillRect(BRect r, const DrawState *d)
}
}
// StrokeRegion
void
DrawingEngine::StrokeRegion(BRegion& r, const DrawState *d)
{
if (Lock()) {
BRect clipped(r.Frame());
extend_by_stroke_width(clipped, d);
clipped = fPainter->ClipRect(clipped);
if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawState(d);
BRect touched = fPainter->StrokeRect(r.RectAt(0));
int32 count = r.CountRects();
for (int32 i = 1; i < count; i++) {
touched = touched | fPainter->StrokeRect(r.RectAt(i));
}
fGraphicsCard->Invalidate(touched);
fGraphicsCard->ShowSoftwareCursor();
}
Unlock();
}
}
// FillRegion
void
DrawingEngine::FillRegion(BRegion& r, const DrawState *d)
@ -678,21 +780,24 @@ DrawingEngine::FillRegion(BRegion& r, const DrawState *d)
}
}
// FillRoundRect
// DrawRoundRect
void
DrawingEngine::FillRoundRect(BRect r,
const float &xrad, const float &yrad,
const DrawState *d)
DrawingEngine::DrawRoundRect(BRect r, const float &xrad,
const float &yrad, const DrawState *d,
bool filled)
{
if (Lock()) {
// NOTE: the stroke does not extend past "r" in R5,
// though I consider this unexpected behaviour.
make_rect_valid(r);
BRect clipped = fPainter->ClipRect(r);
if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawState(d);
BRect touched = fPainter->FillRoundRect(r, xrad, yrad);
BRect touched = filled ? fPainter->FillRoundRect(r, xrad, yrad)
: fPainter->StrokeRoundRect(r, xrad, yrad);
fGraphicsCard->Invalidate(touched);
fGraphicsCard->ShowSoftwareCursor();
}
@ -701,107 +806,39 @@ DrawingEngine::FillRoundRect(BRect r,
}
}
// FillShape
// DrawShape
void
DrawingEngine::FillShape(const BRect &bounds,
const int32 &opcount, const int32 *oplist,
const int32 &ptcount, const BPoint *ptlist,
const DrawState *d)
DrawingEngine::DrawShape(const BRect &bounds, const int32 &opcount,
const int32 *oplist, const int32 &ptcount,
const BPoint *ptlist, const DrawState *d,
bool filled)
{
if (Lock()) {
printf("DrawingEngine::FillShape() - what is this stuff that gets passed here?\n");
printf("DrawingEngine::DrawShape() - what is this stuff that gets passed here?\n");
Unlock();
}
}
// FillTriangle
// DrawTriangle
void
DrawingEngine::FillTriangle(BPoint *pts, BRect bounds,
const DrawState *d)
DrawingEngine::DrawTriangle(BPoint* pts, const BRect& bounds,
const DrawState* d, bool filled)
{
if (Lock()) {
bounds = fPainter->ClipRect(bounds);
if (bounds.IsValid()) {
fGraphicsCard->HideSoftwareCursor(bounds);
fPainter->SetDrawState(d);
fPainter->FillTriangle(pts[0], pts[1], pts[2]);
fGraphicsCard->Invalidate(bounds);
fGraphicsCard->ShowSoftwareCursor();
}
Unlock();
}
}
// StrokeArc
void
DrawingEngine::StrokeArc(BRect r, const float &angle,
const float &span, const DrawState *d)
{
if (Lock()) {
make_rect_valid(r);
BRect clipped = fPainter->ClipRect(r);
if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(r);
fPainter->SetDrawState(d);
float xRadius = r.Width() / 2.0;
float yRadius = r.Width() / 2.0;
BPoint center(r.left + xRadius,
r.top + yRadius);
fPainter->StrokeArc(center, xRadius, yRadius, angle, span);
fGraphicsCard->Invalidate(clipped);
fGraphicsCard->ShowSoftwareCursor();
}
Unlock();
}
}
// StrokeBezier
void
DrawingEngine::StrokeBezier(BPoint *pts, const DrawState *d)
{
if (Lock()) {
fGraphicsCard->HideSoftwareCursor();
fPainter->SetDrawState(d);
BRect touched = fPainter->StrokeBezier(pts);
fGraphicsCard->Invalidate(touched);
fGraphicsCard->ShowSoftwareCursor();
Unlock();
}
}
// StrokeEllipse
void
DrawingEngine::StrokeEllipse(BRect r, const DrawState *d)
{
if (Lock()) {
make_rect_valid(r);
BRect clipped = r;
extend_by_stroke_width(clipped, d);
BRect clipped(bounds);
if (!filled)
extend_by_stroke_width(clipped, d);
clipped = fPainter->ClipRect(clipped);
if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(r);
fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawState(d);
float xRadius = r.Width() / 2.0;
float yRadius = r.Height() / 2.0;
BPoint center(r.left + xRadius,
r.top + yRadius);
fPainter->StrokeEllipse(center, xRadius, yRadius);
if (filled)
fPainter->FillTriangle(pts[0], pts[1], pts[2]);
else
fPainter->StrokeTriangle(pts[0], pts[1], pts[2]);
fGraphicsCard->Invalidate(clipped);
fGraphicsCard->ShowSoftwareCursor();
@ -862,8 +899,8 @@ DrawingEngine::StrokeLine(const BPoint &start, const BPoint &end, DrawState* con
// StrokeLineArray
void
DrawingEngine::StrokeLineArray(const int32 &numlines,
const LineArrayData *linedata,
const DrawState *d)
const LineArrayData *linedata,
const DrawState *d)
{
if(!d || !linedata || numlines <= 0)
return;
@ -925,172 +962,6 @@ DrawingEngine::StrokePoint(const BPoint& pt, DrawState *context)
StrokeLine(pt, pt, context);
}
// StrokePolygon
void
DrawingEngine::StrokePolygon(BPoint* ptlist, int32 numpts,
BRect bounds, const DrawState* d,
bool closed)
{
if (Lock()) {
extend_by_stroke_width(bounds, d);
bounds = fPainter->ClipRect(bounds);
if (bounds.IsValid()) {
fGraphicsCard->HideSoftwareCursor(bounds);
fPainter->SetDrawState(d);
fPainter->StrokePolygon(ptlist, numpts, closed);
fGraphicsCard->Invalidate(bounds);
fGraphicsCard->ShowSoftwareCursor();
}
Unlock();
}
}
// StrokeRect
//
// this function is used to draw a one pixel wide rect
void
DrawingEngine::StrokeRect(BRect r, const RGBColor &color)
{
if (Lock()) {
make_rect_valid(r);
BRect clipped = fPainter->ClipRect(r);
if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->StrokeRect(r, color.GetColor32());
fGraphicsCard->Invalidate(fPainter->ClipRect(BRect(r.left, r.top,
r.right, r.top)));
fGraphicsCard->Invalidate(fPainter->ClipRect(BRect(r.left, r.top + 1,
r.left, r.bottom - 1)));
fGraphicsCard->Invalidate(fPainter->ClipRect(BRect(r.right, r.top + 1,
r.right, r.bottom - 1)));
fGraphicsCard->Invalidate(fPainter->ClipRect(BRect(r.left, r.bottom,
r.right, r.bottom)));
fGraphicsCard->ShowSoftwareCursor();
}
Unlock();
}
}
// StrokeRect
void
DrawingEngine::StrokeRect(BRect r, const DrawState *d)
{
if (Lock()) {
// support invalid rects
make_rect_valid(r);
BRect clipped(r);
extend_by_stroke_width(clipped, d);
clipped = fPainter->ClipRect(clipped);
if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawState(d);
fPainter->StrokeRect(r);
fGraphicsCard->Invalidate(clipped);
fGraphicsCard->ShowSoftwareCursor();
}
Unlock();
}
}
// StrokeRegion
void
DrawingEngine::StrokeRegion(BRegion& r, const DrawState *d)
{
if (Lock()) {
BRect clipped(r.Frame());
extend_by_stroke_width(clipped, d);
clipped = fPainter->ClipRect(clipped);
if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawState(d);
BRect touched = fPainter->StrokeRect(r.RectAt(0));
int32 count = r.CountRects();
for (int32 i = 1; i < count; i++) {
touched = touched | fPainter->StrokeRect(r.RectAt(i));
}
fGraphicsCard->Invalidate(touched);
fGraphicsCard->ShowSoftwareCursor();
}
Unlock();
}
}
// StrokeRoundRect
void
DrawingEngine::StrokeRoundRect(BRect r, const float &xrad,
const float &yrad, const DrawState *d)
{
if (Lock()) {
// NOTE: the stroke does not extend past "r" in R5,
// though I consider this unexpected behaviour.
make_rect_valid(r);
BRect clipped = fPainter->ClipRect(r);
if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawState(d);
BRect touched = fPainter->StrokeRoundRect(r, xrad, yrad);
fGraphicsCard->Invalidate(touched);
fGraphicsCard->ShowSoftwareCursor();
}
Unlock();
}
}
// StrokeShape
void
DrawingEngine::StrokeShape(const BRect &bounds, const int32 &opcount,
const int32 *oplist, const int32 &ptcount,
const BPoint *ptlist, const DrawState *d)
{
if (Lock()) {
printf("DrawingEngine::StrokeShape() - what is this stuff that gets passed here?\n");
Unlock();
}
}
// StrokeTriangle
void
DrawingEngine::StrokeTriangle(BPoint *pts, const BRect &bounds,
const DrawState *d)
{
if (Lock()) {
BRect clipped(bounds);
extend_by_stroke_width(clipped, d);
clipped = fPainter->ClipRect(clipped);
if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawState(d);
fPainter->StrokeTriangle(pts[0], pts[1], pts[2]);
fGraphicsCard->Invalidate(clipped);
fGraphicsCard->ShowSoftwareCursor();
}
Unlock();
}
}
/*
// DrawString
void
@ -1107,8 +978,8 @@ DrawingEngine::DrawString(const char *string, const int32 &length,
// DrawString
void
DrawingEngine::DrawString(const char* string, int32 length,
const BPoint& pt, DrawState* d,
escapement_delta* delta)
const BPoint& pt, DrawState* d,
escapement_delta* delta)
{
// TODO: use delta
if (Lock()) {
@ -1141,8 +1012,7 @@ DrawingEngine::DrawString(const char* string, int32 length,
// StringWidth
float
DrawingEngine::StringWidth(const char* string, int32 length,
const DrawState* d,
escapement_delta* delta)
const DrawState* d, escapement_delta* delta)
{
// TODO: use delta
float width = 0.0;
@ -1158,8 +1028,7 @@ DrawingEngine::StringWidth(const char* string, int32 length,
// StringWidth
float
DrawingEngine::StringWidth(const char* string, int32 length,
const ServerFont& font,
escapement_delta* delta)
const ServerFont& font, escapement_delta* delta)
{
// TODO: use delta
FontLocker locker(&font);
@ -1171,7 +1040,7 @@ DrawingEngine::StringWidth(const char* string, int32 length,
// StringHeight
float
DrawingEngine::StringHeight(const char *string, int32 length,
const DrawState *d)
const DrawState *d)
{
float height = 0.0;
if (Lock()) {

View File

@ -56,7 +56,6 @@ SharedLibrary libhaikuappserver.so :
ColorSet.cpp
CursorData.cpp
CursorSet.cpp
Decorator.cpp
DesktopSettings.cpp
DrawState.cpp
FontFamily.cpp
@ -82,6 +81,7 @@ AddResources haiku_app_server : app_server.rdef ;
Server haiku_app_server :
# Misc. Sources
Decorator.cpp
DebugInfoManager.cpp
SubWindowList.cpp
#PicturePlayer.cpp