fix confusion with (Do)DrawSplines() overloads; don't allocate points on the heap unnecessarily when we can just do it on the stack

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53490 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2008-05-08 14:12:38 +00:00
parent 6bc7b9138d
commit 7210c3a12c
2 changed files with 18 additions and 31 deletions

View File

@ -469,8 +469,12 @@ public:
#if wxUSE_SPLINES
virtual void DoDrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3);
virtual void DoDrawSpline(int n, wxPoint points[]);
void DrawSpline(wxCoord x1, wxCoord y1,
wxCoord x2, wxCoord y2,
wxCoord x3, wxCoord y3);
void DrawSpline(int n, wxPoint points[]);
void DrawSpline(const wxPointList *points) { DoDrawSpline(points); }
virtual void DoDrawSpline(const wxPointList *points);
#endif
@ -1077,11 +1081,11 @@ public:
void DrawSpline(wxCoord x1, wxCoord y1,
wxCoord x2, wxCoord y2,
wxCoord x3, wxCoord y3)
{ m_pimpl->DoDrawSpline(x1,y1,x2,y2,x3,y3); }
{ m_pimpl->DrawSpline(x1,y1,x2,y2,x3,y3); }
void DrawSpline(int n, wxPoint points[])
{ m_pimpl->DoDrawSpline(n,points); }
{ m_pimpl->DrawSpline(n,points); }
void DrawSpline(const wxPointList *points)
{ m_pimpl->DoDrawSpline(points); }
{ m_pimpl->DrawSpline(points); }
#endif // wxUSE_SPLINES

View File

@ -758,38 +758,21 @@ wxDCImpl::DoDrawPolyPolygon(int n,
#if wxUSE_SPLINES
void wxDCImpl::DoDrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3)
void wxDCImpl::DrawSpline(wxCoord x1, wxCoord y1,
wxCoord x2, wxCoord y2,
wxCoord x3, wxCoord y3)
{
wxPointList point_list;
wxPoint *point1 = new wxPoint;
point1->x = x1; point1->y = y1;
point_list.Append( point1 );
wxPoint *point2 = new wxPoint;
point2->x = x2; point2->y = y2;
point_list.Append( point2 );
wxPoint *point3 = new wxPoint;
point3->x = x3; point3->y = y3;
point_list.Append( point3 );
DoDrawSpline(&point_list);
for( wxPointList::compatibility_iterator node = point_list.GetFirst(); node; node = node->GetNext() )
{
wxPoint *p = node->GetData();
delete p;
}
wxPoint points[] = { wxPoint(x1, y1), wxPoint(x2, y2), wxPoint(x3, y3) };
DrawSpline(WXSIZEOF(points), points);
}
void wxDCImpl::DoDrawSpline(int n, wxPoint points[])
void wxDCImpl::DrawSpline(int n, wxPoint points[])
{
wxPointList list;
for (int i =0; i < n; i++)
list.Append( &points[i] );
for ( int i = 0; i < n; i++ )
list.Append(&points[i]);
DoDrawSpline(&list);
DrawSpline(&list);
}
// ----------------------------------- spline code ----------------------------------------