Merge branch 'dc-cleanup'
Some cleanup in wxDC code: remove unnecessary casts, use RAII helpers instead of manual memory and other resources management. No real changes. See #22378.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#endif
|
||||
|
||||
#include "wx/display.h"
|
||||
#include "wx/scopedarray.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Local functions
|
||||
@@ -282,8 +283,7 @@ void wxGCDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y,
|
||||
m_graphicContext->DrawBitmap( bmpCopy, x, y, w, h );
|
||||
}
|
||||
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + w, y + h);
|
||||
CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
|
||||
@@ -296,8 +296,7 @@ void wxGCDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
|
||||
|
||||
m_graphicContext->DrawIcon( icon , x, y, w, h );
|
||||
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + w, y + h);
|
||||
CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
|
||||
}
|
||||
|
||||
bool wxGCDCImpl::StartDoc( const wxString& message )
|
||||
@@ -685,8 +684,7 @@ void wxGCDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
|
||||
|
||||
m_graphicContext->StrokeLine(x1,y1,x2,y2);
|
||||
|
||||
CalcBoundingBox(x1, y1);
|
||||
CalcBoundingBox(x2, y2);
|
||||
CalcBoundingBox(x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoCrossHair( wxCoord x, wxCoord y )
|
||||
@@ -703,8 +701,7 @@ void wxGCDCImpl::DoCrossHair( wxCoord x, wxCoord y )
|
||||
m_graphicContext->StrokeLine(0,y,w,y);
|
||||
m_graphicContext->StrokeLine(x,0,x,h);
|
||||
|
||||
CalcBoundingBox(0, 0);
|
||||
CalcBoundingBox(w, h);
|
||||
CalcBoundingBox(0, 0, w, h);
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawArc( wxCoord x1, wxCoord y1,
|
||||
@@ -752,10 +749,7 @@ void wxGCDCImpl::DoDrawArc( wxCoord x1, wxCoord y1,
|
||||
path.AddLineToPoint( xc, yc );
|
||||
m_graphicContext->DrawPath(path);
|
||||
|
||||
wxRect2DDouble box = path.GetBox();
|
||||
CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y));
|
||||
CalcBoundingBox(wxRound(box.m_x + box.m_width),
|
||||
wxRound(box.m_y + box.m_height));
|
||||
CalcBoundingBoxForBox(path.GetBox());
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
||||
@@ -805,9 +799,7 @@ void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
||||
box.m_x += dx;
|
||||
box.m_y += dy;
|
||||
|
||||
CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y));
|
||||
CalcBoundingBox(wxRound(box.m_x + box.m_width),
|
||||
wxRound(box.m_y + box.m_height));
|
||||
CalcBoundingBoxForBox(box);
|
||||
|
||||
m_graphicContext->PopState();
|
||||
}
|
||||
@@ -842,7 +834,7 @@ void wxGCDCImpl::DoDrawLines(int n, const wxPoint points[],
|
||||
int maxX = minX;
|
||||
int maxY = minY;
|
||||
|
||||
wxPoint2DDouble* pointsD = new wxPoint2DDouble[n];
|
||||
wxScopedArray<wxPoint2DDouble> pointsD(n);
|
||||
for( int i = 0; i < n; ++i)
|
||||
{
|
||||
wxPoint p = points[i];
|
||||
@@ -855,11 +847,10 @@ void wxGCDCImpl::DoDrawLines(int n, const wxPoint points[],
|
||||
else if (p.y > maxY) maxY = p.y;
|
||||
}
|
||||
|
||||
m_graphicContext->StrokeLines( n , pointsD);
|
||||
delete[] pointsD;
|
||||
m_graphicContext->StrokeLines( n , pointsD.get());
|
||||
|
||||
CalcBoundingBox(minX + xoffset, minY + yoffset);
|
||||
CalcBoundingBox(maxX + xoffset, maxY + yoffset);
|
||||
CalcBoundingBox(minX + xoffset, minY + yoffset,
|
||||
maxX + xoffset, maxY + yoffset);
|
||||
}
|
||||
|
||||
#if wxUSE_SPLINES
|
||||
@@ -898,10 +889,7 @@ void wxGCDCImpl::DoDrawSpline(const wxPointList *points)
|
||||
|
||||
m_graphicContext->StrokePath( path );
|
||||
|
||||
wxRect2DDouble box = path.GetBox();
|
||||
CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y));
|
||||
CalcBoundingBox(wxRound(box.m_x + box.m_width),
|
||||
wxRound(box.m_y + box.m_height));
|
||||
CalcBoundingBoxForBox(path.GetBox());
|
||||
}
|
||||
#endif // wxUSE_SPLINES
|
||||
|
||||
@@ -927,7 +915,7 @@ void wxGCDCImpl::DoDrawPolygon( int n, const wxPoint points[],
|
||||
int maxX = minX;
|
||||
int maxY = minY;
|
||||
|
||||
wxPoint2DDouble* pointsD = new wxPoint2DDouble[n+(closeIt?1:0)];
|
||||
wxScopedArray<wxPoint2DDouble> pointsD(n+(closeIt?1:0));
|
||||
for( int i = 0; i < n; ++i)
|
||||
{
|
||||
wxPoint p = points[i];
|
||||
@@ -942,11 +930,10 @@ void wxGCDCImpl::DoDrawPolygon( int n, const wxPoint points[],
|
||||
if ( closeIt )
|
||||
pointsD[n] = pointsD[0];
|
||||
|
||||
m_graphicContext->DrawLines( n+(closeIt?1:0) , pointsD, fillStyle);
|
||||
delete[] pointsD;
|
||||
m_graphicContext->DrawLines( n+(closeIt?1:0) , pointsD.get(), fillStyle);
|
||||
|
||||
CalcBoundingBox(minX + xoffset, minY + yoffset);
|
||||
CalcBoundingBox(maxX + xoffset, maxY + yoffset);
|
||||
CalcBoundingBox(minX + xoffset, minY + yoffset,
|
||||
maxX + xoffset, maxY + yoffset);
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawPolyPolygon(int n,
|
||||
@@ -977,10 +964,7 @@ void wxGCDCImpl::DoDrawPolyPolygon(int n,
|
||||
}
|
||||
m_graphicContext->DrawPath( path , fillStyle);
|
||||
|
||||
wxRect2DDouble box = path.GetBox();
|
||||
CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y));
|
||||
CalcBoundingBox(wxRound(box.m_x + box.m_width),
|
||||
wxRound(box.m_y + box.m_height));
|
||||
CalcBoundingBoxForBox(path.GetBox());
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
|
||||
@@ -994,8 +978,7 @@ void wxGCDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
|
||||
if (w == 0 || h == 0)
|
||||
return;
|
||||
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + w, y + h);
|
||||
CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
|
||||
|
||||
if (m_pen.IsOk() && m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT && m_pen.GetWidth() > 0)
|
||||
{
|
||||
@@ -1022,8 +1005,7 @@ void wxGCDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
|
||||
if (w == 0 || h == 0)
|
||||
return;
|
||||
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + w, y + h);
|
||||
CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
|
||||
|
||||
if (m_pen.IsOk() && m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT && m_pen.GetWidth() > 0)
|
||||
{
|
||||
@@ -1041,8 +1023,7 @@ void wxGCDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
|
||||
if ( !m_logicalFunctionSupported )
|
||||
return;
|
||||
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + w, y + h);
|
||||
CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
|
||||
|
||||
m_graphicContext->DrawEllipse(x,y,w,h);
|
||||
}
|
||||
@@ -1148,8 +1129,7 @@ bool wxGCDCImpl::DoStretchBlit(
|
||||
// reset composition
|
||||
m_graphicContext->SetCompositionMode(formerMode);
|
||||
|
||||
CalcBoundingBox(xdest, ydest);
|
||||
CalcBoundingBox(xdest + dstWidth, ydest + dstHeight);
|
||||
CalcBoundingBox(wxPoint(xdest, ydest), wxSize(dstWidth, dstHeight));
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -1202,14 +1182,12 @@ void wxGCDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
|
||||
// determining which of them is really topmost/leftmost/...)
|
||||
|
||||
// "upper left" and "upper right"
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
|
||||
CalcBoundingBox(x, y, x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
|
||||
|
||||
// "bottom left" and "bottom right"
|
||||
x += (wxCoord)(h*sin(rad));
|
||||
y += (wxCoord)(h*cos(rad));
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
|
||||
CalcBoundingBox(x, y, x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y)
|
||||
@@ -1245,10 +1223,7 @@ void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y)
|
||||
|
||||
m_graphicContext->SetCompositionMode(curMode);
|
||||
|
||||
wxCoord w, h;
|
||||
GetOwner()->GetTextExtent(str, &w, &h);
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + w, y + h);
|
||||
CalcBoundingBox(wxPoint(x, y), GetOwner()->GetTextExtent(str));
|
||||
}
|
||||
|
||||
bool wxGCDCImpl::CanGetTextExtent() const
|
||||
@@ -1410,8 +1385,7 @@ void wxGCDCImpl::DoGradientFillLinear(const wxRect& rect,
|
||||
m_graphicContext->SetPen(m_pen);
|
||||
m_graphicContext->SetBrush(m_brush);
|
||||
|
||||
CalcBoundingBox(rect.x, rect.y);
|
||||
CalcBoundingBox(rect.x + rect.width, rect.y + rect.height);
|
||||
CalcBoundingBox(rect);
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoGradientFillConcentric(const wxRect& rect,
|
||||
@@ -1442,8 +1416,7 @@ void wxGCDCImpl::DoGradientFillConcentric(const wxRect& rect,
|
||||
m_graphicContext->SetPen(m_pen);
|
||||
m_graphicContext->SetBrush(m_brush);
|
||||
|
||||
CalcBoundingBox(rect.x, rect.y);
|
||||
CalcBoundingBox(rect.x + rect.width, rect.y + rect.height);
|
||||
CalcBoundingBox(rect);
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawCheckMark(wxCoord x, wxCoord y,
|
||||
|
||||
Reference in New Issue
Block a user