simplified polygon and bezier drawing methods, made them more efficient
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17311 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -494,11 +494,11 @@ void
|
|||||||
DrawingEngine::DrawBezier(BPoint *pts, const DrawState *d, bool filled)
|
DrawingEngine::DrawBezier(BPoint *pts, const DrawState *d, bool filled)
|
||||||
{
|
{
|
||||||
if (Lock()) {
|
if (Lock()) {
|
||||||
|
// TODO: figure out bounds and hide cursor depending on that
|
||||||
fGraphicsCard->HideSoftwareCursor();
|
fGraphicsCard->HideSoftwareCursor();
|
||||||
|
|
||||||
fPainter->SetDrawState(d);
|
fPainter->SetDrawState(d);
|
||||||
BRect touched = filled ? fPainter->FillBezier(pts)
|
BRect touched = fPainter->DrawBezier(pts, filled);
|
||||||
: fPainter->StrokeBezier(pts);
|
|
||||||
|
|
||||||
fGraphicsCard->Invalidate(touched);
|
fGraphicsCard->Invalidate(touched);
|
||||||
fGraphicsCard->ShowSoftwareCursor();
|
fGraphicsCard->ShowSoftwareCursor();
|
||||||
@@ -555,10 +555,7 @@ DrawingEngine::DrawPolygon(BPoint* ptlist, int32 numpts,
|
|||||||
fGraphicsCard->HideSoftwareCursor(bounds);
|
fGraphicsCard->HideSoftwareCursor(bounds);
|
||||||
|
|
||||||
fPainter->SetDrawState(d);
|
fPainter->SetDrawState(d);
|
||||||
if (filled)
|
fPainter->DrawPolygon(ptlist, numpts, filled, closed);
|
||||||
fPainter->FillPolygon(ptlist, numpts);
|
|
||||||
else
|
|
||||||
fPainter->StrokePolygon(ptlist, numpts, closed);
|
|
||||||
|
|
||||||
fGraphicsCard->Invalidate(bounds);
|
fGraphicsCard->Invalidate(bounds);
|
||||||
fGraphicsCard->ShowSoftwareCursor();
|
fGraphicsCard->ShowSoftwareCursor();
|
||||||
@@ -589,14 +586,7 @@ DrawingEngine::StrokeRect(BRect r, const RGBColor &color)
|
|||||||
|
|
||||||
fPainter->StrokeRect(r, color.GetColor32());
|
fPainter->StrokeRect(r, color.GetColor32());
|
||||||
|
|
||||||
fGraphicsCard->Invalidate(fPainter->ClipRect(BRect(r.left, r.top,
|
fGraphicsCard->Invalidate(clipped);
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -432,76 +432,63 @@ Painter::FillTriangle(BPoint pt1, BPoint pt2, BPoint pt3) const
|
|||||||
return _DrawTriangle(pt1, pt2, pt3, true);
|
return _DrawTriangle(pt1, pt2, pt3, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// StrokePolygon
|
// DrawPolygon
|
||||||
BRect
|
BRect
|
||||||
Painter::StrokePolygon(const BPoint* ptArray, int32 numPts,
|
Painter::DrawPolygon(BPoint* p, int32 numPts,
|
||||||
bool closed) const
|
bool filled, bool closed) const
|
||||||
{
|
{
|
||||||
return _DrawPolygon(ptArray, numPts, closed, false);
|
CHECK_CLIPPING
|
||||||
|
|
||||||
|
if (numPts > 0) {
|
||||||
|
|
||||||
|
agg::path_storage path;
|
||||||
|
_Transform(p);
|
||||||
|
path.move_to(p->x, p->y);
|
||||||
|
|
||||||
|
for (int32 i = 1; i < numPts; i++) {
|
||||||
|
p++;
|
||||||
|
_Transform(p);
|
||||||
|
path.line_to(p->x, p->y);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (closed)
|
||||||
|
path.close_polygon();
|
||||||
|
|
||||||
|
if (filled)
|
||||||
|
return _FillPath(path);
|
||||||
|
else
|
||||||
|
return _StrokePath(path);
|
||||||
|
}
|
||||||
|
return BRect(0.0, 0.0, -1.0, -1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FillPolygon
|
// DrawBezier
|
||||||
BRect
|
BRect
|
||||||
Painter::FillPolygon(const BPoint* ptArray, int32 numPts,
|
Painter::DrawBezier(BPoint* p, bool filled) const
|
||||||
bool closed) const
|
|
||||||
{
|
|
||||||
return _DrawPolygon(ptArray, numPts, closed, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// StrokeBezier
|
|
||||||
BRect
|
|
||||||
Painter::StrokeBezier(const BPoint* controlPoints) const
|
|
||||||
{
|
{
|
||||||
CHECK_CLIPPING
|
CHECK_CLIPPING
|
||||||
|
|
||||||
agg::path_storage curve;
|
agg::path_storage curve;
|
||||||
|
|
||||||
BPoint p1(controlPoints[0]);
|
_Transform(&(p[0]));
|
||||||
BPoint p2(controlPoints[1]);
|
_Transform(&(p[1]));
|
||||||
BPoint p3(controlPoints[2]);
|
_Transform(&(p[2]));
|
||||||
BPoint p4(controlPoints[3]);
|
_Transform(&(p[3]));
|
||||||
_Transform(&p1);
|
|
||||||
_Transform(&p2);
|
|
||||||
_Transform(&p3);
|
|
||||||
_Transform(&p4);
|
|
||||||
|
|
||||||
curve.move_to(p1.x, p1.y);
|
curve.move_to(p[0].x, p[0].y);
|
||||||
curve.curve4(p2.x, p2.y,
|
curve.curve4(p[1].x, p[1].y,
|
||||||
p3.x, p3.y,
|
p[2].x, p[2].y,
|
||||||
p4.x, p4.y);
|
p[3].x, p[3].y);
|
||||||
|
|
||||||
|
|
||||||
agg::conv_curve<agg::path_storage> path(curve);
|
agg::conv_curve<agg::path_storage> path(curve);
|
||||||
|
|
||||||
return _StrokePath(path);
|
if (filled) {
|
||||||
}
|
curve.close_polygon();
|
||||||
|
return _FillPath(path);
|
||||||
// FillBezier
|
} else {
|
||||||
BRect
|
return _StrokePath(path);
|
||||||
Painter::FillBezier(const BPoint* controlPoints) const
|
}
|
||||||
{
|
|
||||||
CHECK_CLIPPING
|
|
||||||
|
|
||||||
agg::path_storage curve;
|
|
||||||
|
|
||||||
BPoint p1(controlPoints[0]);
|
|
||||||
BPoint p2(controlPoints[1]);
|
|
||||||
BPoint p3(controlPoints[2]);
|
|
||||||
BPoint p4(controlPoints[3]);
|
|
||||||
_Transform(&p1);
|
|
||||||
_Transform(&p2);
|
|
||||||
_Transform(&p3);
|
|
||||||
_Transform(&p4);
|
|
||||||
|
|
||||||
curve.move_to(p1.x, p1.y);
|
|
||||||
curve.curve4(p2.x, p2.y,
|
|
||||||
p3.x, p3.y,
|
|
||||||
p4.x, p4.y);
|
|
||||||
curve.close_polygon();
|
|
||||||
|
|
||||||
agg::conv_curve<agg::path_storage> path(curve);
|
|
||||||
|
|
||||||
return _FillPath(path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this comes from Shape.cpp
|
// this comes from Shape.cpp
|
||||||
@@ -1256,36 +1243,6 @@ Painter::_DrawEllipse(BPoint center, float xRadius, float yRadius,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// _DrawPolygon
|
|
||||||
inline BRect
|
|
||||||
Painter::_DrawPolygon(const BPoint* ptArray, int32 numPts,
|
|
||||||
bool closed, bool fill) const
|
|
||||||
{
|
|
||||||
CHECK_CLIPPING
|
|
||||||
|
|
||||||
if (numPts > 0) {
|
|
||||||
|
|
||||||
agg::path_storage path;
|
|
||||||
BPoint point = _Transform(*ptArray);
|
|
||||||
path.move_to(point.x, point.y);
|
|
||||||
|
|
||||||
for (int32 i = 1; i < numPts; i++) {
|
|
||||||
ptArray++;
|
|
||||||
point = _Transform(*ptArray);
|
|
||||||
path.line_to(point.x, point.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (closed)
|
|
||||||
path.close_polygon();
|
|
||||||
|
|
||||||
if (fill)
|
|
||||||
return _FillPath(path);
|
|
||||||
else
|
|
||||||
return _StrokePath(path);
|
|
||||||
}
|
|
||||||
return BRect(0.0, 0.0, -1.0, -1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy_bitmap_row_cmap8_copy
|
// copy_bitmap_row_cmap8_copy
|
||||||
static inline void
|
static inline void
|
||||||
copy_bitmap_row_cmap8_copy(uint8* dst, const uint8* src, int32 numPixels,
|
copy_bitmap_row_cmap8_copy(uint8* dst, const uint8* src, int32 numPixels,
|
||||||
|
|||||||
@@ -105,18 +105,14 @@ class Painter {
|
|||||||
BPoint pt3) const;
|
BPoint pt3) const;
|
||||||
|
|
||||||
// polygons
|
// polygons
|
||||||
BRect StrokePolygon( const BPoint* ptArray,
|
BRect DrawPolygon( BPoint* ptArray,
|
||||||
int32 numPts,
|
int32 numPts,
|
||||||
bool closed = true) const;
|
bool filled,
|
||||||
|
bool closed) const;
|
||||||
BRect FillPolygon( const BPoint* ptArray,
|
|
||||||
int32 numPts,
|
|
||||||
bool closed = true) const;
|
|
||||||
|
|
||||||
// bezier curves
|
// bezier curves
|
||||||
BRect StrokeBezier( const BPoint* controlPoints) const;
|
BRect DrawBezier( BPoint* controlPoints,
|
||||||
|
bool filled) const;
|
||||||
BRect FillBezier( const BPoint* controlPoints) const;
|
|
||||||
|
|
||||||
// shapes
|
// shapes
|
||||||
BRect DrawShape( const int32& opCount,
|
BRect DrawShape( const int32& opCount,
|
||||||
@@ -225,10 +221,6 @@ class Painter {
|
|||||||
float xRadius,
|
float xRadius,
|
||||||
float yRadius,
|
float yRadius,
|
||||||
bool fill) const;
|
bool fill) const;
|
||||||
BRect _DrawPolygon( const BPoint* ptArray,
|
|
||||||
int32 numPts,
|
|
||||||
bool closed,
|
|
||||||
bool fill) const;
|
|
||||||
|
|
||||||
void _DrawBitmap( const agg::rendering_buffer& srcBuffer,
|
void _DrawBitmap( const agg::rendering_buffer& srcBuffer,
|
||||||
color_space format,
|
color_space format,
|
||||||
|
|||||||
Reference in New Issue
Block a user