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
+88 -107
View File
@@ -41,177 +41,158 @@ public:
DrawingEngine(HWInterface* interface = NULL); DrawingEngine(HWInterface* interface = NULL);
virtual ~DrawingEngine(); virtual ~DrawingEngine();
// when implementing, be sure to call the inherited version // when implementing, be sure to call the inherited version
virtual status_t Initialize(); status_t Initialize();
virtual void Shutdown(); 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 // for "changing" hardware
// will remove any clipping (drawing allowed everywhere) void Update();
virtual void ConstrainClippingRegion(BRegion* region);
// drawing functions void SetHWInterface(HWInterface* interface);
virtual void CopyRegion( /*const*/ BRegion* region,
// 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 xOffset,
int32 yOffset); int32 yOffset);
virtual void CopyRegionList( BList* list, void CopyRegionList( BList* list,
BList* pList, BList* pList,
int32 rCount, int32 rCount,
BRegion* clipReg); 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 &source,
const BRect &dest, const BRect &dest,
const DrawState *d); const DrawState *d);
// drawing primitives
virtual void FillArc( BRect r, void DrawArc( BRect r,
const float &angle, const float &angle,
const float &span, const float &span,
const DrawState *d); const DrawState *d,
bool filled);
virtual void FillBezier( BPoint *pts, void DrawBezier( BPoint *pts,
const DrawState *d); const DrawState *d,
bool filled);
virtual void FillEllipse( BRect r, void DrawEllipse( BRect r,
const DrawState *d); const DrawState *d,
bool filled);
virtual void FillPolygon( BPoint *ptlist, void DrawPolygon( 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,
int32 numpts, int32 numpts,
BRect bounds, BRect bounds,
const DrawState *d, const DrawState *d,
bool is_closed=true); bool filled,
bool closed);
// this version used by Decorator // this version used by Decorator
virtual void StrokeRect( BRect r, void StrokeRect( BRect r,
const RGBColor &color); const RGBColor &color);
virtual void StrokeRect( BRect r, void FillRect( BRect r,
const RGBColor &color);
void StrokeRect( BRect r,
const DrawState *d); const DrawState *d);
virtual void StrokeRegion( BRegion &r, void FillRect( BRect r,
const DrawState *d); 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 &xrad,
const float &yrad, 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 &opcount,
const int32 *oplist, const int32 *oplist,
const int32 &ptcount, const int32 &ptcount,
const BPoint *ptlist, const BPoint *ptlist,
const DrawState *d); const DrawState *d,
bool filled);
virtual void StrokeTriangle( BPoint *pts, void DrawTriangle( BPoint *pts,
const BRect &bounds, 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); 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 // DrawState is NOT const because this call updates the pen position in the passed DrawState
virtual void DrawString( const char* string, void DrawString( const char* string,
int32 length, int32 length,
const BPoint& pt, const BPoint& pt,
DrawState* d, DrawState* d,
escapement_delta* delta = NULL); escapement_delta* delta = NULL);
/* virtual void DrawString( const char *string, /* void DrawString( const char *string,
const int32 &length, const int32 &length,
const BPoint &pt, const BPoint &pt,
const RGBColor &color, const RGBColor &color,
escapement_delta *delta=NULL);*/ escapement_delta *delta=NULL);*/
virtual float StringWidth( const char* string, float StringWidth( const char* string,
int32 length, int32 length,
const DrawState* d, const DrawState* d,
escapement_delta* delta = NULL); escapement_delta* delta = NULL);
virtual float StringWidth( const char* string, float StringWidth( const char* string,
int32 length, int32 length,
const ServerFont& font, const ServerFont& font,
escapement_delta* delta = NULL); escapement_delta* delta = NULL);
virtual float StringHeight( const char* string, float StringHeight( const char* string,
int32 length, int32 length,
const DrawState* d); const DrawState* d);
virtual bool Lock();
virtual void Unlock();
bool WriteLock();
void WriteUnlock();
virtual bool DumpToFile( const char *path);
virtual ServerBitmap* DumpToBitmap();
private: private:
BRect _CopyRect( BRect r, BRect _CopyRect( BRect r,
int32 xOffset, int32 xOffset,
+1 -1
View File
@@ -27,7 +27,6 @@ SharedLibrary libappserver.so :
ColorSet.cpp ColorSet.cpp
CursorData.cpp CursorData.cpp
CursorSet.cpp CursorSet.cpp
Decorator.cpp
DrawState.cpp DrawState.cpp
FontFamily.cpp FontFamily.cpp
IPoint.cpp IPoint.cpp
@@ -49,6 +48,7 @@ SharedLibrary libappserver.so :
Server app_server : Server app_server :
# Misc. Sources # Misc. Sources
Decorator.cpp
DebugInfoManager.cpp DebugInfoManager.cpp
SubWindowList.cpp SubWindowList.cpp
PicturePlayer.cpp PicturePlayer.cpp
+18 -44
View File
@@ -174,49 +174,36 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, DrawState *d)
break; break;
} }
case B_PIC_STROKE_ROUND_RECT: 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: case B_PIC_FILL_ROUND_RECT:
{ {
BRect rect = GetRect(); BRect rect = GetRect();
BPoint radii = GetCoord(); 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; break;
} }
case B_PIC_STROKE_BEZIER: case B_PIC_STROKE_BEZIER:
{
BPoint control[4];
GetData(control, sizeof(control));
fdriver->StrokeBezier(control,&fldata);
break;
}
case B_PIC_FILL_BEZIER: case B_PIC_FILL_BEZIER:
{ {
BPoint control[4]; BPoint control[4];
GetData(control, sizeof(control)); GetData(control, sizeof(control));
fdriver->FillBezier(control,&fldata); fdriver->DrawBezier(control, &fldata,
op == B_PIC_FILL_BEZIER);
break; break;
} }
case B_PIC_STROKE_POLYGON: 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: case B_PIC_FILL_POLYGON:
{ {
int32 numPoints = GetInt32(); int32 numPoints = GetInt32();
BPoint *points = new BPoint[numPoints]; BPoint *points = new BPoint[numPoints];
GetData(points, numPoints * sizeof(BPoint)); 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; delete points;
break; break;
} }
@@ -271,41 +258,28 @@ status_t PicturePlayer::Play(int32 tableEntries,void *userData, DrawState *d)
break; break;
} }
case B_PIC_STROKE_ARC: 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: case B_PIC_FILL_ARC:
{ {
BPoint center = GetCoord(); BPoint center = GetCoord();
BPoint radii = GetCoord(); BPoint radii = GetCoord();
float startTheta = GetFloat(); float startTheta = GetFloat();
float arcTheta = GetFloat(); float arcTheta = GetFloat();
fdriver->FillArc(BRect(center.x-radii.x,center.y-radii.y,center.x+radii.x, fdriver->DrawArc(BRect(center.x - radii.x,
center.y+radii.y),startTheta, arcTheta, &fldata); center.y - radii.y,
center.x + radii.x,
center.y+radii.y),
startTheta, arcTheta, &fldata,
op == B_PIC_FILL_ARC);
break; break;
} }
case B_PIC_STROKE_ELLIPSE: 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: case B_PIC_FILL_ELLIPSE:
{ {
BRect rect = GetRect(); BRect rect = GetRect();
BPoint center; BPoint center;
BPoint radii((rect.Width() + 1) / 2.0f, (rect.Height() + 1) / 2.0f); BPoint radii((rect.Width() + 1) / 2.0f, (rect.Height() + 1) / 2.0f);
center = rect.LeftTop() + radii; center = rect.LeftTop() + radii;
fdriver->FillEllipse(rect,&fldata); fdriver->DrawEllipse(rect, &fldata, op == B_PIC_FILL_ELLIPSE);
break; break;
} }
case B_PIC_ENTER_STATE_CHANGE: case B_PIC_ENTER_STATE_CHANGE:
+15 -29
View File
@@ -1824,10 +1824,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<float>(&angle); link.Read<float>(&angle);
link.Read<float>(&span); link.Read<float>(&span);
if (code == AS_STROKE_ARC) driver->DrawArc(fCurrentLayer->ConvertToTop(r), angle, span,
driver->StrokeArc(fCurrentLayer->ConvertToTop(r),angle,span, fCurrentLayer->CurrentState()); fCurrentLayer->CurrentState(), code == AS_FILL_ARC);
else
driver->FillArc(fCurrentLayer->ConvertToTop(r),angle,span, fCurrentLayer->CurrentState());
break; break;
} }
@@ -1842,10 +1840,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
pts[i] = fCurrentLayer->ConvertToTop(pts[i]); pts[i] = fCurrentLayer->ConvertToTop(pts[i]);
} }
if (code == AS_STROKE_BEZIER) driver->DrawBezier(pts, fCurrentLayer->CurrentState(), code == AS_FILL_BEZIER);
driver->StrokeBezier(pts, fCurrentLayer->CurrentState());
else
driver->FillBezier(pts, fCurrentLayer->CurrentState());
break; break;
} }
@@ -1857,10 +1852,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
BRect rect; BRect rect;
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
if (code == AS_STROKE_ELLIPSE) driver->DrawEllipse(fCurrentLayer->ConvertToTop(rect),
driver->StrokeEllipse(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->CurrentState()); fCurrentLayer->CurrentState(), code == AS_FILL_ELLIPSE);
else
driver->FillEllipse(fCurrentLayer->ConvertToTop(rect), fCurrentLayer->CurrentState());
break; break;
} }
@@ -1875,10 +1868,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<float>(&xrad); link.Read<float>(&xrad);
link.Read<float>(&yrad); link.Read<float>(&yrad);
if (code == AS_STROKE_ROUNDRECT) driver->DrawRoundRect(fCurrentLayer->ConvertToTop(rect), xrad, yrad,
driver->StrokeRoundRect(fCurrentLayer->ConvertToTop(rect),xrad,yrad, fCurrentLayer->CurrentState()); fCurrentLayer->CurrentState(), code == AS_FILL_ROUNDRECT);
else
driver->FillRoundRect(fCurrentLayer->ConvertToTop(rect),xrad,yrad, fCurrentLayer->CurrentState());
break; break;
} }
@@ -1897,10 +1888,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
link.Read<BRect>(&rect); link.Read<BRect>(&rect);
if (code == AS_STROKE_TRIANGLE) driver->DrawTriangle(pts, fCurrentLayer->ConvertToTop(rect),
driver->StrokeTriangle(pts, fCurrentLayer->ConvertToTop(rect), fCurrentLayer->CurrentState()); fCurrentLayer->CurrentState(), code == AS_FILL_TRIANGLE);
else
driver->FillTriangle(pts, fCurrentLayer->ConvertToTop(rect), fCurrentLayer->CurrentState());
break; break;
} }
@@ -1910,7 +1899,7 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
DTRACE(("ServerWindow %s: Message AS_STROKE/FILL_POLYGON\n", Title())); DTRACE(("ServerWindow %s: Message AS_STROKE/FILL_POLYGON\n", Title()));
BRect polyframe; BRect polyframe;
bool isclosed; bool isclosed = true;
int32 pointcount; int32 pointcount;
BPoint *pointlist; BPoint *pointlist;
@@ -1926,10 +1915,9 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
for (int32 i = 0; i < pointcount; i++) for (int32 i = 0; i < pointcount; i++)
pointlist[i] = fCurrentLayer->ConvertToTop(pointlist[i]); pointlist[i] = fCurrentLayer->ConvertToTop(pointlist[i]);
if (code == AS_STROKE_POLYGON) driver->DrawPolygon(pointlist, pointcount, polyframe,
driver->StrokePolygon(pointlist, pointcount, polyframe, fCurrentLayer->CurrentState(), isclosed); fCurrentLayer->CurrentState(), code == AS_FILL_POLYGON,
else isclosed);
driver->FillPolygon(pointlist, pointcount, polyframe, fCurrentLayer->CurrentState());
delete [] pointlist; delete [] pointlist;
break; break;
@@ -1956,10 +1944,8 @@ ServerWindow::_DispatchGraphicsMessage(int32 code, BPrivate::LinkReceiver &link)
for (int32 i = 0; i < ptcount; i++) for (int32 i = 0; i < ptcount; i++)
ptlist[i] = fCurrentLayer->ConvertToTop(ptlist[i]); ptlist[i] = fCurrentLayer->ConvertToTop(ptlist[i]);
if (code == AS_STROKE_SHAPE) driver->DrawShape(shaperect, opcount, oplist, ptcount, ptlist,
driver->StrokeShape(shaperect, opcount, oplist, ptcount, ptlist, fCurrentLayer->CurrentState()); fCurrentLayer->CurrentState(), code == AS_FILL_SHAPE);
else
driver->FillShape(shaperect, opcount, oplist, ptcount, ptlist, fCurrentLayer->CurrentState());
delete[] oplist; delete[] oplist;
delete[] ptlist; delete[] ptlist;
+168 -299
View File
@@ -259,7 +259,7 @@ is_above(const BRect& a, const BRect& b)
// CopyRegion // CopyRegion
void void
DrawingEngine::CopyRegion(/*const*/ BRegion* region, DrawingEngine::CopyRegion(/*const*/ BRegion* region,
int32 xOffset, int32 yOffset) int32 xOffset, int32 yOffset)
{ {
// NOTE: Write locking because we might use HW acceleration. // NOTE: Write locking because we might use HW acceleration.
// This needs to be investigated, I'm doing this because of // 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. // make much sense to me.
void void
DrawingEngine::CopyRegionList(BList* list, BList* pList, DrawingEngine::CopyRegionList(BList* list, BList* pList,
int32 rCount, BRegion* clipReg) int32 rCount, BRegion* clipReg)
{ {
// NOTE: Write locking because we might use HW acceleration. // NOTE: Write locking because we might use HW acceleration.
// This needs to be investigated, I'm doing this because of // This needs to be investigated, I'm doing this because of
@@ -440,8 +440,8 @@ DrawingEngine::InvertRect(BRect r)
// DrawBitmap // DrawBitmap
void void
DrawingEngine::DrawBitmap(ServerBitmap *bitmap, DrawingEngine::DrawBitmap(ServerBitmap *bitmap,
const BRect &source, const BRect &dest, const BRect &source, const BRect &dest,
const DrawState *d) const DrawState *d)
{ {
if (Lock()) { if (Lock()) {
BRect clipped = fPainter->ClipRect(dest); BRect clipped = fPainter->ClipRect(dest);
@@ -459,25 +459,32 @@ DrawingEngine::DrawBitmap(ServerBitmap *bitmap,
} }
} }
// FillArc // DrawArc
void void
DrawingEngine::FillArc(BRect r, const float &angle, DrawingEngine::DrawArc(BRect r, const float &angle,
const float &span, const DrawState *d) const float &span, const DrawState *d,
bool filled)
{ {
if (Lock()) { if (Lock()) {
make_rect_valid(r); 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()) { if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped); fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawState(d); fPainter->SetDrawState(d);
float xRadius = r.Width() / 2.0; float xRadius = r.Width() / 2.0;
float yRadius = r.Width() / 2.0; float yRadius = r.Height() / 2.0;
BPoint center(r.left + xRadius, BPoint center(r.left + xRadius,
r.top + yRadius); 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->Invalidate(clipped);
fGraphicsCard->ShowSoftwareCursor(); fGraphicsCard->ShowSoftwareCursor();
@@ -487,16 +494,16 @@ DrawingEngine::FillArc(BRect r, const float &angle,
} }
} }
// FillBezier // DrawBezier
void void
DrawingEngine::FillBezier(BPoint *pts, const DrawState *d) DrawingEngine::DrawBezier(BPoint *pts, const DrawState *d, bool filled)
{ {
if (Lock()) { if (Lock()) {
fGraphicsCard->HideSoftwareCursor(); fGraphicsCard->HideSoftwareCursor();
fPainter->SetDrawState(d); fPainter->SetDrawState(d);
BRect touched = filled ? fPainter->FillBezier(pts)
BRect touched = fPainter->FillBezier(pts); : fPainter->StrokeBezier(pts);
fGraphicsCard->Invalidate(touched); fGraphicsCard->Invalidate(touched);
fGraphicsCard->ShowSoftwareCursor(); fGraphicsCard->ShowSoftwareCursor();
@@ -505,24 +512,30 @@ DrawingEngine::FillBezier(BPoint *pts, const DrawState *d)
} }
} }
// FillEllipse // DrawEllipse
void void
DrawingEngine::FillEllipse(BRect r, const DrawState *d) DrawingEngine::DrawEllipse(BRect r, const DrawState *d, bool filled)
{ {
if (Lock()) { if (Lock()) {
make_rect_valid(r); 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()) { if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped); fGraphicsCard->HideSoftwareCursor(r);
fPainter->SetDrawState(d); fPainter->SetDrawState(d);
float xRadius = r.Width() / 2.0; float xRadius = r.Width() / 2.0;
float yRadius = r.Height() / 2.0; float yRadius = r.Height() / 2.0;
BPoint center(r.left + xRadius, BPoint center(r.left + xRadius,
r.top + yRadius); 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->Invalidate(clipped);
fGraphicsCard->ShowSoftwareCursor(); fGraphicsCard->ShowSoftwareCursor();
@@ -532,21 +545,57 @@ DrawingEngine::FillEllipse(BRect r, const DrawState *d)
} }
} }
// FillPolygon // DrawPolygon
void void
DrawingEngine::FillPolygon(BPoint *ptlist, int32 numpts, DrawingEngine::DrawPolygon(BPoint* ptlist, int32 numpts,
BRect bounds, const DrawState *d) BRect bounds, const DrawState* d,
bool filled, bool closed)
{ {
if (Lock()) { if (Lock()) {
make_rect_valid(bounds); make_rect_valid(bounds);
BRect clipped = fPainter->ClipRect(bounds); if (!filled)
if (clipped.IsValid()) { extend_by_stroke_width(bounds, d);
fGraphicsCard->HideSoftwareCursor(clipped); bounds = fPainter->ClipRect(bounds);
if (bounds.IsValid()) {
fPainter->SetDrawState(d); fGraphicsCard->HideSoftwareCursor(bounds);
fPainter->FillPolygon(ptlist, numpts);
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(); 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 // FillRect
void void
DrawingEngine::FillRect(BRect r, const DrawState *d) 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 // FillRegion
void void
DrawingEngine::FillRegion(BRegion& r, const DrawState *d) DrawingEngine::FillRegion(BRegion& r, const DrawState *d)
@@ -678,21 +780,24 @@ DrawingEngine::FillRegion(BRegion& r, const DrawState *d)
} }
} }
// FillRoundRect // DrawRoundRect
void void
DrawingEngine::FillRoundRect(BRect r, DrawingEngine::DrawRoundRect(BRect r, const float &xrad,
const float &xrad, const float &yrad, const float &yrad, const DrawState *d,
const DrawState *d) bool filled)
{ {
if (Lock()) { if (Lock()) {
// NOTE: the stroke does not extend past "r" in R5,
// though I consider this unexpected behaviour.
make_rect_valid(r); make_rect_valid(r);
BRect clipped = fPainter->ClipRect(r); BRect clipped = fPainter->ClipRect(r);
if (clipped.IsValid()) { if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(clipped); fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawState(d); 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->Invalidate(touched);
fGraphicsCard->ShowSoftwareCursor(); fGraphicsCard->ShowSoftwareCursor();
} }
@@ -701,107 +806,39 @@ DrawingEngine::FillRoundRect(BRect r,
} }
} }
// FillShape // DrawShape
void void
DrawingEngine::FillShape(const BRect &bounds, DrawingEngine::DrawShape(const BRect &bounds, const int32 &opcount,
const int32 &opcount, const int32 *oplist, const int32 *oplist, const int32 &ptcount,
const int32 &ptcount, const BPoint *ptlist, const BPoint *ptlist, const DrawState *d,
const DrawState *d) bool filled)
{ {
if (Lock()) { 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(); Unlock();
} }
} }
// FillTriangle // DrawTriangle
void void
DrawingEngine::FillTriangle(BPoint *pts, BRect bounds, DrawingEngine::DrawTriangle(BPoint* pts, const BRect& bounds,
const DrawState *d) const DrawState* d, bool filled)
{ {
if (Lock()) { if (Lock()) {
bounds = fPainter->ClipRect(bounds); BRect clipped(bounds);
if (bounds.IsValid()) { if (!filled)
fGraphicsCard->HideSoftwareCursor(bounds); extend_by_stroke_width(clipped, d);
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);
clipped = fPainter->ClipRect(clipped); clipped = fPainter->ClipRect(clipped);
if (clipped.IsValid()) { if (clipped.IsValid()) {
fGraphicsCard->HideSoftwareCursor(r); fGraphicsCard->HideSoftwareCursor(clipped);
fPainter->SetDrawState(d); fPainter->SetDrawState(d);
if (filled)
float xRadius = r.Width() / 2.0; fPainter->FillTriangle(pts[0], pts[1], pts[2]);
float yRadius = r.Height() / 2.0; else
BPoint center(r.left + xRadius, fPainter->StrokeTriangle(pts[0], pts[1], pts[2]);
r.top + yRadius);
fPainter->StrokeEllipse(center, xRadius, yRadius);
fGraphicsCard->Invalidate(clipped); fGraphicsCard->Invalidate(clipped);
fGraphicsCard->ShowSoftwareCursor(); fGraphicsCard->ShowSoftwareCursor();
@@ -862,8 +899,8 @@ DrawingEngine::StrokeLine(const BPoint &start, const BPoint &end, DrawState* con
// StrokeLineArray // StrokeLineArray
void void
DrawingEngine::StrokeLineArray(const int32 &numlines, DrawingEngine::StrokeLineArray(const int32 &numlines,
const LineArrayData *linedata, const LineArrayData *linedata,
const DrawState *d) const DrawState *d)
{ {
if(!d || !linedata || numlines <= 0) if(!d || !linedata || numlines <= 0)
return; return;
@@ -925,172 +962,6 @@ DrawingEngine::StrokePoint(const BPoint& pt, DrawState *context)
StrokeLine(pt, pt, 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 // DrawString
void void
@@ -1107,8 +978,8 @@ DrawingEngine::DrawString(const char *string, const int32 &length,
// DrawString // DrawString
void void
DrawingEngine::DrawString(const char* string, int32 length, DrawingEngine::DrawString(const char* string, int32 length,
const BPoint& pt, DrawState* d, const BPoint& pt, DrawState* d,
escapement_delta* delta) escapement_delta* delta)
{ {
// TODO: use delta // TODO: use delta
if (Lock()) { if (Lock()) {
@@ -1141,8 +1012,7 @@ DrawingEngine::DrawString(const char* string, int32 length,
// StringWidth // StringWidth
float float
DrawingEngine::StringWidth(const char* string, int32 length, DrawingEngine::StringWidth(const char* string, int32 length,
const DrawState* d, const DrawState* d, escapement_delta* delta)
escapement_delta* delta)
{ {
// TODO: use delta // TODO: use delta
float width = 0.0; float width = 0.0;
@@ -1158,8 +1028,7 @@ DrawingEngine::StringWidth(const char* string, int32 length,
// StringWidth // StringWidth
float float
DrawingEngine::StringWidth(const char* string, int32 length, DrawingEngine::StringWidth(const char* string, int32 length,
const ServerFont& font, const ServerFont& font, escapement_delta* delta)
escapement_delta* delta)
{ {
// TODO: use delta // TODO: use delta
FontLocker locker(&font); FontLocker locker(&font);
@@ -1171,7 +1040,7 @@ DrawingEngine::StringWidth(const char* string, int32 length,
// StringHeight // StringHeight
float float
DrawingEngine::StringHeight(const char *string, int32 length, DrawingEngine::StringHeight(const char *string, int32 length,
const DrawState *d) const DrawState *d)
{ {
float height = 0.0; float height = 0.0;
if (Lock()) { if (Lock()) {
+1 -1
View File
@@ -56,7 +56,6 @@ SharedLibrary libhaikuappserver.so :
ColorSet.cpp ColorSet.cpp
CursorData.cpp CursorData.cpp
CursorSet.cpp CursorSet.cpp
Decorator.cpp
DesktopSettings.cpp DesktopSettings.cpp
DrawState.cpp DrawState.cpp
FontFamily.cpp FontFamily.cpp
@@ -82,6 +81,7 @@ AddResources haiku_app_server : app_server.rdef ;
Server haiku_app_server : Server haiku_app_server :
# Misc. Sources # Misc. Sources
Decorator.cpp
DebugInfoManager.cpp DebugInfoManager.cpp
SubWindowList.cpp SubWindowList.cpp
#PicturePlayer.cpp #PicturePlayer.cpp