From 03b9be08de7ba44b2d88279b1ae09759ef8d4aa4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 29 Apr 2022 15:54:12 +0100 Subject: [PATCH 1/7] Remove useless casts to int from wxMSW wxDC::SetDeviceOrigin() The variables are already of type int (== wxCoord). No real changes. --- src/msw/dc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 33cc1cf537..a588ae82ae 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -2147,7 +2147,7 @@ void wxMSWDCImpl::SetDeviceOrigin(wxCoord x, wxCoord y) wxDCImpl::SetDeviceOrigin( x, y ); - ::SetViewportOrgEx(GetHdc(), (int)m_deviceOriginX, (int)m_deviceOriginY, NULL); + ::SetViewportOrgEx(GetHdc(), m_deviceOriginX, m_deviceOriginY, NULL); m_isClipBoxValid = false; } From 2fbb40ab61ca71fb6a1f79f0c3022a2ce0993c2f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 29 Apr 2022 16:54:45 +0100 Subject: [PATCH 2/7] Remove RealizeScaleAndOrigin() call from wxMSWDCImpl::Clear() It seems unnecessary here as this function doesn't change neither scale nor the origin, so there should be no need to realize them neither. --- src/msw/dc.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index a588ae82ae..c757728573 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -813,8 +813,6 @@ void wxMSWDCImpl::Clear() // of complex transformation (is e.g. rotated). ::InflateRect(&rect, 1, 1); ::FillRect(GetHdc(), &rect, hbr); - - RealizeScaleAndOrigin(); } bool wxMSWDCImpl::DoFloodFill(wxCoord x, From 6383bc39ff0a3283e9d74f02cba2505d7936e854 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Apr 2022 18:58:48 +0100 Subject: [PATCH 3/7] Add convenient wxDCImpl::CalcBoundingBox() overloads and use them No real changes, just make the code updating the bounding box slightly shorter by providing convenient and slightly higher-level overloads. For now these functions are only in wxDCImpl, it's not clear if we really need them in wxDC, so don't add them to the public API. --- include/wx/dc.h | 17 +++++++++++ include/wx/dcgraph.h | 9 ++++++ src/common/dcbase.cpp | 10 +++---- src/common/dcgraph.cpp | 68 +++++++++++++----------------------------- src/common/dcsvg.cpp | 15 ++++------ src/dfb/dc.cpp | 15 ++++------ src/generic/dcpsg.cpp | 41 ++++++++----------------- src/gtk/dc.cpp | 3 +- src/gtk/dcclient.cpp | 31 +++++++------------ src/gtk/print.cpp | 37 ++++++++--------------- src/gtk1/dcclient.cpp | 30 +++++++------------ src/motif/dcclient.cpp | 27 ++++++----------- src/msw/dc.cpp | 51 ++++++++++--------------------- src/x11/dcclient.cpp | 33 +++++++------------- 14 files changed, 144 insertions(+), 243 deletions(-) diff --git a/include/wx/dc.h b/include/wx/dc.h index d6c2881ef2..96c4da6647 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -353,6 +353,23 @@ public: m_maxY = y; } } + + void CalcBoundingBox(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) + { + CalcBoundingBox(x1, y1); + CalcBoundingBox(x2, y2); + } + + void CalcBoundingBox(const wxPoint& pt, const wxSize& sz) + { + CalcBoundingBox(pt.x, pt.y, pt.x + sz.x, pt.y + sz.y); + } + + void CalcBoundingBox(const wxRect& rect) + { + CalcBoundingBox(rect.GetPosition(), rect.GetSize()); + } + void ResetBoundingBox() { m_isBBoxValid = false; diff --git a/include/wx/dcgraph.h b/include/wx/dcgraph.h index a57e8168e1..35d6245bef 100644 --- a/include/wx/dcgraph.h +++ b/include/wx/dcgraph.h @@ -258,6 +258,15 @@ private: // fields, returns true if the context was valid. bool DoInitContext(wxGraphicsContext* ctx); + // Another convenient wrapper for CalcBoundingBox(). + // This is not an overload in order to avoid hiding the base class ones. + void CalcBoundingBoxForBox(const wxRect2DDouble& box) + { + CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y)); + CalcBoundingBox(wxRound(box.m_x + box.m_width), + wxRound(box.m_y + box.m_height)); + } + wxDECLARE_CLASS(wxGCDCImpl); wxDECLARE_NO_COPY_CLASS(wxGCDCImpl); }; diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp index 82be5c669d..4e656015e8 100644 --- a/src/common/dcbase.cpp +++ b/src/common/dcbase.cpp @@ -637,8 +637,7 @@ void wxDCImpl::DoDrawCheckMark(wxCoord x1, wxCoord y1, DoDrawLine(x1, y3, x3, y2); DoDrawLine(x3, y2, x2, y1); - CalcBoundingBox(x1, y1); - CalcBoundingBox(x2, y2); + CalcBoundingBox(x1, y1, x2, y2); } bool @@ -1335,8 +1334,7 @@ void wxDC::DrawLabel(const wxString& text, *rectBounding = wxRect(x, y - heightText, widthText, heightText); } - CalcBoundingBox(x0, y0); - CalcBoundingBox(x0 + width0, y0 + height); + m_pimpl->CalcBoundingBox(wxPoint(x0, y0), wxSize(width0, height)); } #if WXWIN_COMPATIBILITY_2_8 @@ -1394,8 +1392,8 @@ void wxDC::GetClippingBox(long *x, long *y, long *w, long *h) const void wxDC::DrawObject(wxDrawObject* drawobject) { drawobject->Draw(*this); - CalcBoundingBox(drawobject->MinX(),drawobject->MinY()); - CalcBoundingBox(drawobject->MaxX(),drawobject->MaxY()); + CalcBoundingBox(drawobject->MinX(),drawobject->MinY(), + drawobject->MaxX(),drawobject->MaxY()); } #endif // WXWIN_COMPATIBILITY_2_8 diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index 368ddfed83..8c77b37d19 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -277,8 +277,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 ) @@ -291,8 +290,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 +683,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 +700,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 +748,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 +798,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(); } @@ -858,8 +849,8 @@ void wxGCDCImpl::DoDrawLines(int n, const wxPoint points[], m_graphicContext->StrokeLines( n , pointsD); delete[] pointsD; - 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 @@ -945,8 +933,8 @@ void wxGCDCImpl::DoDrawPolygon( int n, const wxPoint points[], m_graphicContext->DrawLines( n+(closeIt?1:0) , pointsD, fillStyle); delete[] pointsD; - 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 +965,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 +979,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 +1006,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 +1024,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 +1130,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 +1183,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 +1224,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 +1386,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 +1417,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, diff --git a/src/common/dcsvg.cpp b/src/common/dcsvg.cpp index 6104c349d3..dc3e18e9ac 100644 --- a/src/common/dcsvg.cpp +++ b/src/common/dcsvg.cpp @@ -601,8 +601,7 @@ void wxSVGFileDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) write(s); - CalcBoundingBox(x1, y1); - CalcBoundingBox(x2, y2); + CalcBoundingBox(x1, y1, x2, y2); } void wxSVGFileDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset) @@ -832,8 +831,7 @@ void wxSVGFileDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width write(s); - CalcBoundingBox(x, y); - CalcBoundingBox(x + width, y + height); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); } void wxSVGFileDCImpl::DoDrawPolygon(int n, const wxPoint points[], @@ -916,8 +914,7 @@ void wxSVGFileDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord write(s); - CalcBoundingBox(x, y); - CalcBoundingBox(x + width, y + height); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); } void wxSVGFileDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc) @@ -1115,8 +1112,7 @@ void wxSVGFileDCImpl::DoGradientFillLinear(const wxRect& rect, write(s); - CalcBoundingBox(rect.x, rect.y); - CalcBoundingBox(rect.x + rect.width, rect.y + rect.height); + CalcBoundingBox(rect); } void wxSVGFileDCImpl::DoGradientFillConcentric(const wxRect& rect, @@ -1155,8 +1151,7 @@ void wxSVGFileDCImpl::DoGradientFillConcentric(const wxRect& rect, write(s); - CalcBoundingBox(rect.x, rect.y); - CalcBoundingBox(rect.x + rect.width, rect.y + rect.height); + CalcBoundingBox(rect); } void wxSVGFileDCImpl::DoSetDeviceClippingRegion(const wxRegion& region) diff --git a/src/dfb/dc.cpp b/src/dfb/dc.cpp index 13956da7d3..c0a1c2c0e5 100644 --- a/src/dfb/dc.cpp +++ b/src/dfb/dc.cpp @@ -134,8 +134,7 @@ void wxDFBDCImpl::Clear() m_surface->Clear(clr.Red(), clr.Green(), clr.Blue(), clr.Alpha()); wxSize size(GetSize()); - CalcBoundingBox(XDEV2LOG(0), YDEV2LOG(0)); - CalcBoundingBox(XDEV2LOG(size.x), YDEV2LOG(size.y)); + CalcBoundingBox(XDEV2LOG(0), YDEV2LOG(0), XDEV2LOG(size.x), YDEV2LOG(size.y)); } extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, @@ -203,8 +202,7 @@ void wxDFBDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) m_surface->DrawLine(xx1, yy1, xx2, yy2); - CalcBoundingBox(x1, y1); - CalcBoundingBox(x2, y2); + CalcBoundingBox(x1, y1, x2, y2); } // Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1) @@ -284,8 +282,7 @@ void wxDFBDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord h m_surface->DrawRectangle(xx, yy, ww, hh); } - CalcBoundingBox(x, y); - CalcBoundingBox(x + width, y + height); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); } void wxDFBDCImpl::DoDrawRoundedRectangle(wxCoord WXUNUSED(x), @@ -330,9 +327,8 @@ void wxDFBDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y) // update the bounding box wxCoord w, h; - CalcBoundingBox(x, y); DoGetTextExtent(text, &w, &h); - CalcBoundingBox(x + w, y + h); + CalcBoundingBox(wxPoint(x, y), wxSize(w, h)); // if background mode is solid, DrawText must paint text's background: if ( m_backgroundMode == wxBRUSHSTYLE_SOLID ) @@ -693,8 +689,7 @@ bool wxDFBDCImpl::DoBlitFromSurface(const wxIDirectFBSurfacePtr& src, return false; } - CalcBoundingBox(dstx, dsty); - CalcBoundingBox(dstx + w, dsty + h); + CalcBoundingBox(wxPoint(dstx, dsty), wxSize(w, h)); DFBRectangle srcRect = { srcx, srcy, w, h }; DFBRectangle dstRect = { XLOG2DEV(dstx), YLOG2DEV(dsty), diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index a089c8a8d1..7c12378567 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -420,8 +420,7 @@ void wxPostScriptDCImpl::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord buffer.Replace( ",", "." ); PsPrint( buffer ); - CalcBoundingBox( x1, y1 ); - CalcBoundingBox( x2, y2 ); + CalcBoundingBox( x1, y1, x2, y2 ); } void wxPostScriptDCImpl::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc) @@ -500,8 +499,7 @@ void wxPostScriptDCImpl::DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord PsPrint( "stroke\n" ); } - CalcBoundingBox( xc-i_radius, yc-i_radius ); - CalcBoundingBox( xc+i_radius, yc+i_radius ); + CalcBoundingBox( xc-i_radius, yc-i_radius, xc+i_radius, yc+i_radius ); } void wxPostScriptDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) @@ -536,8 +534,7 @@ void wxPostScriptDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord buffer.Replace( ",", "." ); PsPrint( buffer ); - CalcBoundingBox( x ,y ); - CalcBoundingBox( x+w, y+h ); + CalcBoundingBox( wxPoint(x, y), wxSize(w, h) ); } if ( m_pen.IsNonTransparent() ) @@ -553,8 +550,7 @@ void wxPostScriptDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord buffer.Replace( ",", "." ); PsPrint( buffer ); - CalcBoundingBox( x ,y ); - CalcBoundingBox( x+w, y+h ); + CalcBoundingBox( wxPoint(x, y), wxSize(w, h) ); } } @@ -787,8 +783,7 @@ void wxPostScriptDCImpl::DoDrawRectangle (wxCoord x, wxCoord y, wxCoord width, w buffer.Replace( ",", "." ); PsPrint( buffer ); - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); + CalcBoundingBox( wxPoint(x, y), wxSize(width, height) ); } if ( m_pen.IsNonTransparent() ) @@ -810,8 +805,7 @@ void wxPostScriptDCImpl::DoDrawRectangle (wxCoord x, wxCoord y, wxCoord width, w buffer.Replace( ",", "." ); PsPrint( buffer ); - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); + CalcBoundingBox( wxPoint(x, y), wxSize(width, height) ); } } @@ -860,8 +854,7 @@ void wxPostScriptDCImpl::DoDrawRoundedRectangle (wxCoord x, wxCoord y, wxCoord w buffer.Replace( ",", "." ); PsPrint( buffer ); - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); + CalcBoundingBox( wxPoint(x, y), wxSize(width, height) ); } if ( m_pen.IsNonTransparent() ) @@ -892,8 +885,7 @@ void wxPostScriptDCImpl::DoDrawRoundedRectangle (wxCoord x, wxCoord y, wxCoord w buffer.Replace( ",", "." ); PsPrint( buffer ); - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); + CalcBoundingBox( wxPoint(x, y), wxSize(width, height) ); } } @@ -917,8 +909,7 @@ void wxPostScriptDCImpl::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxC buffer.Replace( ",", "." ); PsPrint( buffer ); - CalcBoundingBox( x - width, y - height ); - CalcBoundingBox( x + width, y + height ); + CalcBoundingBox( x - width, y - height, x + width, y + height ); } if ( m_pen.IsNonTransparent() ) @@ -934,8 +925,7 @@ void wxPostScriptDCImpl::DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxC buffer.Replace( ",", "." ); PsPrint( buffer ); - CalcBoundingBox( x - width, y - height ); - CalcBoundingBox( x + width, y + height ); + CalcBoundingBox( x - width, y - height, x + width, y + height ); } } @@ -1375,10 +1365,7 @@ void wxPostScriptDCImpl::DoDrawText( const wxString& text, wxCoord x, wxCoord y DrawAnyText(textbuf, text_descent, size); - wxCoord w, h; - GetOwner()->GetMultiLineTextExtent(text, &w, &h); - CalcBoundingBox(x, y); - CalcBoundingBox(x + w , y + h); + CalcBoundingBox(wxPoint(x, y), GetOwner()->GetMultiLineTextExtent(text)); } void wxPostScriptDCImpl::DoDrawRotatedText( const wxString& text, wxCoord x, wxCoord y, double angle ) @@ -1423,13 +1410,11 @@ void wxPostScriptDCImpl::DoDrawRotatedText( const wxString& text, wxCoord x, wxC wxCoord w, h; GetOwner()->GetMultiLineTextExtent(text, &w, &h); // "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 wxPostScriptDCImpl::SetBackground (const wxBrush& brush) diff --git a/src/gtk/dc.cpp b/src/gtk/dc.cpp index 08cda73695..574497437d 100644 --- a/src/gtk/dc.cpp +++ b/src/gtk/dc.cpp @@ -103,8 +103,7 @@ void wxGTKCairoDCImpl::DoDrawText(const wxString& text, int x, int y) int w, h; DoGetTextExtent(text, &w, &h); - CalcBoundingBox(x, y); - CalcBoundingBox(x + w, y + h); + CalcBoundingBox(wxPoint(x, y), wxSize(w, h)); const bool yInverted = m_signY < 0; if (xInverted || yInverted) diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index fed357b468..b8a9869d47 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -518,8 +518,7 @@ void wxWindowDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 if (m_gdkwindow) gdk_draw_line( m_gdkwindow, m_penGC, XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2) ); - CalcBoundingBox(x1, y1); - CalcBoundingBox(x2, y2); + CalcBoundingBox(x1, y1, x2, y2); } } @@ -649,8 +648,7 @@ void wxWindowDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, } } - CalcBoundingBox (x1, y1); - CalcBoundingBox (x2, y2); + CalcBoundingBox(x1, y1, x2, y2); } void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double sa, double ea ) @@ -697,8 +695,7 @@ void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxC gdk_draw_arc( m_gdkwindow, m_penGC, FALSE, xx, yy, ww, hh, start, end ); } - CalcBoundingBox (x, y); - CalcBoundingBox (x + width, y + height); + CalcBoundingBox( wxPoint(x, y), wxSize(width, height) ); } void wxWindowDCImpl::DoDrawPoint( wxCoord x, wxCoord y ) @@ -853,8 +850,7 @@ void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoo } } - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); + CalcBoundingBox( wxPoint(x, y), wxSize(width, height) ); } void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius ) @@ -932,8 +928,7 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width } // this ignores the radius - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); + CalcBoundingBox( wxPoint(x, y), wxSize(width, height) ); } void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) @@ -975,8 +970,7 @@ void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord gdk_draw_arc( m_gdkwindow, m_penGC, false, xx, yy, ww, hh, 0, 360*64 ); } - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); + CalcBoundingBox( wxPoint(x, y), wxSize(width, height) ); } void wxWindowDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y ) @@ -1087,8 +1081,7 @@ void wxWindowDCImpl::DoDrawBitmap( const wxBitmap &bitmap, // notice that as the bitmap is not drawn upside down (or right to left) // even if the corresponding axis direction is inversed, we need to take it // into account when calculating its bounding box - CalcBoundingBox(x, y); - CalcBoundingBox(x + m_signX*w, y + m_signY*h); + CalcBoundingBox(wxPoint(x, y), wxSize(m_signX*w, m_signY*h)); // device coords int xx = LogicalToDeviceX(x); @@ -1237,8 +1230,7 @@ bool wxWindowDCImpl::DoBlit( wxCoord xdest, wxCoord ydest, return false; } - CalcBoundingBox(xdest, ydest); - CalcBoundingBox(xdest + width, ydest + height); + CalcBoundingBox(wxPoint(xdest, ydest), wxSize(width, height) ); // source device coords int src_x = source->LogicalToDeviceX(xsrc); @@ -1424,8 +1416,7 @@ void wxWindowDCImpl::DoDrawRotatedText(const wxString& text, int xLogical, int y if (wxIsNullDouble(angle)) { - CalcBoundingBox(xLogical, yLogical); - CalcBoundingBox(xLogical + w, yLogical + h); + CalcBoundingBox(wxPoint(xLogical, yLogical), wxSize(w, h)); } else { @@ -1448,8 +1439,8 @@ void wxWindowDCImpl::DoDrawRotatedText(const wxString& text, int xLogical, int y minY = (wxCoord)(dmin(dmin(0, y2), dmin(y3, y4)) - 0.5); x += minX; y += minY; - CalcBoundingBox(DeviceToLogicalX(x), DeviceToLogicalY(y)); - CalcBoundingBox(DeviceToLogicalX(x + maxX - minX), DeviceToLogicalY(y + maxY - minY)); + CalcBoundingBox(DeviceToLogicalX(x), DeviceToLogicalY(y), + DeviceToLogicalX(x + maxX - minX), DeviceToLogicalY(y + maxY - minY)); } gdk_draw_layout_with_colors(m_gdkwindow, m_textGC, x, y, m_layout, NULL, bg_col); diff --git a/src/gtk/print.cpp b/src/gtk/print.cpp index e263b23561..e4f087aabc 100644 --- a/src/gtk/print.cpp +++ b/src/gtk/print.cpp @@ -1342,8 +1342,7 @@ void wxGtkPrinterDCImpl::DoGradientFillConcentric(const wxRect& rect, const wxCo cairo_pattern_destroy(gradient); - CalcBoundingBox(xR, yR); - CalcBoundingBox(xR+w, yR+h); + CalcBoundingBox(wxPoint(xR, yR), wxSize(w, h)); } void wxGtkPrinterDCImpl::DoGradientFillLinear(const wxRect& rect, const wxColour& initialColour, const wxColour& destColour, wxDirection nDirection) @@ -1392,8 +1391,7 @@ void wxGtkPrinterDCImpl::DoGradientFillLinear(const wxRect& rect, const wxColour cairo_pattern_destroy(gradient); - CalcBoundingBox(x, y); - CalcBoundingBox(x+w, y+h); + CalcBoundingBox(wxPoint(x, y), wxSize(w, h)); } bool wxGtkPrinterDCImpl::DoGetPixel(wxCoord WXUNUSED(x1), @@ -1414,8 +1412,7 @@ void wxGtkPrinterDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord cairo_line_to ( m_cairo, XLOG2DEV(x2), YLOG2DEV(y2) ); cairo_stroke ( m_cairo ); - CalcBoundingBox( x1, y1 ); - CalcBoundingBox( x2, y2 ); + CalcBoundingBox( x1, y1, x2, y2 ); } void wxGtkPrinterDCImpl::DoCrossHair(wxCoord x, wxCoord y) @@ -1431,8 +1428,7 @@ void wxGtkPrinterDCImpl::DoCrossHair(wxCoord x, wxCoord y) cairo_line_to (m_cairo, XLOG2DEVREL(w), YLOG2DEV(y)); cairo_stroke (m_cairo); - CalcBoundingBox( 0, 0 ); - CalcBoundingBox( w, h ); + CalcBoundingBox( 0, 0, w, h ); } void wxGtkPrinterDCImpl::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc) @@ -1511,8 +1507,7 @@ void wxGtkPrinterDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord cairo_restore( m_cairo ); - CalcBoundingBox( x, y); - CalcBoundingBox( x+w, y+h ); + CalcBoundingBox(wxPoint(x, y), wxSize(w, h)); } void wxGtkPrinterDCImpl::DoDrawPoint(wxCoord x, wxCoord y) @@ -1624,8 +1619,7 @@ void wxGtkPrinterDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wx cairo_stroke(m_cairo); } - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); } void wxGtkPrinterDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) @@ -1678,8 +1672,7 @@ void wxGtkPrinterDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord wi cairo_stroke(m_cairo); } - CalcBoundingBox(x,y); - CalcBoundingBox(x+width,y+height); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); } void wxGtkPrinterDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) @@ -1707,8 +1700,7 @@ void wxGtkPrinterDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCo cairo_stroke(m_cairo); } - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); cairo_restore (m_cairo); } @@ -1742,8 +1734,7 @@ void wxGtkPrinterDCImpl::DoDrawSpline(const wxPointList *points) cairo_move_to( m_cairo, XLOG2DEV((wxCoord)x1), YLOG2DEV((wxCoord)y1) ); cairo_line_to( m_cairo, XLOG2DEV((wxCoord)x3), YLOG2DEV((wxCoord)y3) ); - CalcBoundingBox( (wxCoord)x1, (wxCoord)y1 ); - CalcBoundingBox( (wxCoord)x3, (wxCoord)y3 ); + CalcBoundingBox( (wxCoord)x1, (wxCoord)y1, (wxCoord)x3, (wxCoord)y3 ); node = node->GetNext(); while (node) @@ -1765,8 +1756,7 @@ void wxGtkPrinterDCImpl::DoDrawSpline(const wxPointList *points) XLOG2DEV((wxCoord)x2), YLOG2DEV((wxCoord)y2), XLOG2DEV((wxCoord)x3), YLOG2DEV((wxCoord)y3) ); - CalcBoundingBox( (wxCoord)x1, (wxCoord)y1 ); - CalcBoundingBox( (wxCoord)x3, (wxCoord)y3 ); + CalcBoundingBox( (wxCoord)x1, (wxCoord)y1, (wxCoord)x3, (wxCoord)y3 ); node = node->GetNext(); } @@ -1842,8 +1832,7 @@ void wxGtkPrinterDCImpl::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoor cairo_fill(m_cairo); #endif - CalcBoundingBox(0,0); - CalcBoundingBox(bw,bh); + CalcBoundingBox(0, 0, bw, bh); cairo_restore(m_cairo); } @@ -1931,9 +1920,7 @@ void wxGtkPrinterDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCo pango_layout_set_attributes(m_layout, NULL); } - // Back to device units: - CalcBoundingBox (x, y); - CalcBoundingBox (x + w, y + h); + CalcBoundingBox(wxPoint(x, y), wxSize(w, h)); } void wxGtkPrinterDCImpl::Clear() diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index 668d79e3de..c949ae93ba 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -458,8 +458,7 @@ void wxWindowDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 if (m_window) gdk_draw_line( m_window, m_penGC, XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2) ); - CalcBoundingBox(x1, y1); - CalcBoundingBox(x2, y2); + CalcBoundingBox(x1, y1, x2, y2); } } @@ -570,8 +569,7 @@ void wxWindowDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, } } - CalcBoundingBox (x1, y1); - CalcBoundingBox (x2, y2); + CalcBoundingBox(x1, y1, x2, y2); } void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double sa, double ea ) @@ -632,8 +630,7 @@ void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxC gdk_draw_arc( m_window, m_penGC, FALSE, xx, yy, ww, hh, start, end ); } - CalcBoundingBox (x, y); - CalcBoundingBox (x + width, y + height); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); } void wxWindowDCImpl::DoDrawPoint( wxCoord x, wxCoord y ) @@ -803,8 +800,7 @@ void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoo gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 ); } - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); } void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius ) @@ -926,8 +922,7 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width } // this ignores the radius - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); } void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) @@ -985,8 +980,7 @@ void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord gdk_draw_arc( m_window, m_penGC, FALSE, xx, yy, ww, hh, 0, 360*64 ); } - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); } void wxWindowDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y ) @@ -1012,8 +1006,7 @@ void wxWindowDCImpl::DoDrawBitmap( const wxBitmap &bitmap, int w = bitmap.GetWidth(); int h = bitmap.GetHeight(); - CalcBoundingBox( x, y ); - CalcBoundingBox( x + w, y + h ); + CalcBoundingBox(wxPoint(x, y), wxSize(w, h)); if (!m_window) return; @@ -1197,8 +1190,7 @@ bool wxWindowDCImpl::DoBlit( wxCoord xdest, wxCoord ydest, } } - CalcBoundingBox( xdest, ydest ); - CalcBoundingBox( xdest + width, ydest + height ); + CalcBoundingBox(wxPoint(xdest, ydest), wxSize(width, height)); // scale/translate size and position wxCoord xx = XLOG2DEV(xdest); @@ -1430,8 +1422,7 @@ void wxWindowDCImpl::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) width = wxCoord(width / m_scaleX); height = wxCoord(height / m_scaleY); - CalcBoundingBox (x + width, y + height); - CalcBoundingBox (x, y); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); } @@ -1541,8 +1532,7 @@ void wxWindowDCImpl::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord #endif // 0 // update the bounding box - CalcBoundingBox(x + minX, y + minY); - CalcBoundingBox(x + maxX, y + maxY); + CalcBoundingBox(x + minX, y + minY, x + maxX, y + maxY); } void wxWindowDCImpl::DoGetTextExtent(const wxString &string, diff --git a/src/motif/dcclient.cpp b/src/motif/dcclient.cpp index 16e026dc20..1cee3077fb 100644 --- a/src/motif/dcclient.cpp +++ b/src/motif/dcclient.cpp @@ -259,8 +259,7 @@ void wxWindowDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 XLOG2DEV_2(x1), YLOG2DEV_2(y1), XLOG2DEV_2(x2), YLOG2DEV_2(y2)); - CalcBoundingBox(x1, y1); - CalcBoundingBox(x2, y2); + CalcBoundingBox(x1, y1, x2, y2); } void wxWindowDCImpl::DoCrossHair( wxCoord x, wxCoord y ) @@ -369,8 +368,7 @@ void wxWindowDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking, xxc_2 - r, yyc_2 - r, 2 * r, 2 * r, alpha1, alpha2); } - CalcBoundingBox (x1, y1); - CalcBoundingBox (x2, y2); + CalcBoundingBox(x1, y1, x2, y2); } void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double sa, double ea ) @@ -414,8 +412,7 @@ void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxC XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking, XLOG2DEV_2 (x), YLOG2DEV_2 (y),wd,hd,start,end); } - CalcBoundingBox (x, y); - CalcBoundingBox (x + width, y + height); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); } void wxWindowDCImpl::DoDrawPoint( wxCoord x, wxCoord y ) @@ -555,8 +552,7 @@ void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoo XLOG2DEV_2 (x), YLOG2DEV_2 (y), wd, hd); } - CalcBoundingBox (x, y); - CalcBoundingBox (x + width, y + height); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); } void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius ) @@ -715,8 +711,7 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width rw_d2, rh_d2, 180 * 64, 90 * 64); } } - CalcBoundingBox (x, y); - CalcBoundingBox (x + width, y + height); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); } void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) @@ -767,8 +762,7 @@ void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord XLOG2DEVREL (width) - WX_GC_CF, YLOG2DEVREL (height) - WX_GC_CF, 0, angle); } - CalcBoundingBox (x, y); - CalcBoundingBox (x + width, y + height); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); } @@ -993,8 +987,7 @@ bool wxWindowDCImpl::DoBlit( wxCoord xdest, wxCoord ydest, } } /* Remote/local (Display*) m_display */ - CalcBoundingBox (xdest, ydest); - CalcBoundingBox (xdest + width, ydest + height); + CalcBoundingBox(wxPoint(xdest, ydest), wxSize(width, height)); SetLogicalFunction(orig); @@ -1154,8 +1147,7 @@ void wxWindowDCImpl::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) wxCoord w, h; DoGetTextExtent (text, &w, &h); - CalcBoundingBox (x + w, y + h); - CalcBoundingBox (x, y); + CalcBoundingBox(wxPoint(x, y), wxSize(w, h)); } void wxWindowDCImpl::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, @@ -1290,8 +1282,7 @@ void wxWindowDCImpl::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord oldForegroundPixel); } - CalcBoundingBox (minx, miny); - CalcBoundingBox (maxx, maxy); + CalcBoundingBox(minx, miny, maxx, maxy); } bool wxWindowDCImpl::CanGetTextExtent() const diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index c757728573..1c54f14a0e 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -911,8 +911,7 @@ void wxMSWDCImpl::DoCrossHair(wxCoord x, wxCoord y) wxDrawLine(GetHdc(), XLOG2DEV(x), YLOG2DEV(rect.top), XLOG2DEV(x), YLOG2DEV(rect.bottom)); } - CalcBoundingBox(rect.left, rect.top); - CalcBoundingBox(rect.right, rect.bottom); + CalcBoundingBox(rect.left, rect.top, rect.right, rect.bottom); } void wxMSWDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) @@ -944,8 +943,7 @@ void wxMSWDCImpl::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) wxDrawLine(GetHdc(), XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2)); } - CalcBoundingBox(x1, y1); - CalcBoundingBox(x2, y2); + CalcBoundingBox(x1, y1, x2, y2); } // Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1) @@ -997,8 +995,7 @@ void wxMSWDCImpl::DoDrawArc(wxCoord x1, wxCoord y1, Arc(GetHdc(),xxx1,yyy1,xxx2,yyy2, xx1,yy1,xx2,yy2); } - CalcBoundingBox(xc - r, yc - r); - CalcBoundingBox(xc + r, yc + r); + CalcBoundingBox(xc - r, yc - r, xc + r, yc + r); } void wxMSWDCImpl::DoDrawPoint(wxCoord x, wxCoord y) @@ -1147,8 +1144,7 @@ void wxMSWDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord h (void)Rectangle(GetHdc(), x1dev, y1dev, x2dev, y2dev); - CalcBoundingBox(x, y); - CalcBoundingBox(x2, y2); + CalcBoundingBox(x, y, x2, y2); } void wxMSWDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) @@ -1179,8 +1175,7 @@ void wxMSWDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wx (void)RoundRect(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2), YLOG2DEV(y2), (int) (2*XLOG2DEV(radius)), (int)( 2*YLOG2DEV(radius))); - CalcBoundingBox(x, y); - CalcBoundingBox(x2, y2); + CalcBoundingBox(x, y, x2, y2); } void wxMSWDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) @@ -1197,8 +1192,7 @@ void wxMSWDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord hei ::Ellipse(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2), YLOG2DEV(y2)); - CalcBoundingBox(x, y); - CalcBoundingBox(x2, y2); + CalcBoundingBox(x, y, x2, y2); } #if wxUSE_SPLINES @@ -1331,8 +1325,7 @@ void wxMSWDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,doub (void)Arc(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), XLOG2DEV(x2), YLOG2DEV(y2), rx1, ry1, rx2, ry2); - CalcBoundingBox(x, y); - CalcBoundingBox(x2, y2); + CalcBoundingBox(x, y, x2, y2); } void wxMSWDCImpl::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) @@ -1356,8 +1349,7 @@ void wxMSWDCImpl::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) ::DrawIconEx(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), GetHiconOf(icon), icon.GetWidth(), icon.GetHeight(), 0, NULL, DI_NORMAL); } - CalcBoundingBox(x, y); - CalcBoundingBox(x + icon.GetWidth(), y + icon.GetHeight()); + CalcBoundingBox(wxPoint(x, y), icon.GetSize()); } void wxMSWDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask ) @@ -1401,8 +1393,7 @@ void wxMSWDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool if ( AlphaBlt(this, x, y, width, height, 0, 0, width, height, hdcMem, curBmp) ) { - CalcBoundingBox(x, y); - CalcBoundingBox(x + bmp.GetWidth(), y + bmp.GetHeight()); + CalcBoundingBox(wxPoint(x, y), bmp.GetSize()); return; } } @@ -1510,8 +1501,7 @@ void wxMSWDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool ::DeleteDC( memdc ); } - CalcBoundingBox(x, y); - CalcBoundingBox(x + bmp.GetWidth(), y + bmp.GetHeight()); + CalcBoundingBox(wxPoint(x, y), bmp.GetSize()); } void wxMSWDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y) @@ -1536,11 +1526,7 @@ void wxMSWDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y) DrawAnyText(text, x, y); // update the bounding box - CalcBoundingBox(x, y); - - wxCoord w, h; - GetOwner()->GetTextExtent(text, &w, &h); - CalcBoundingBox(x + w, y + h); + CalcBoundingBox(wxPoint(x, y), GetOwner()->GetTextExtent(text)); } void wxMSWDCImpl::DrawAnyText(const wxString& text, wxCoord x, wxCoord y) @@ -1633,14 +1619,12 @@ void wxMSWDCImpl::DoDrawRotatedText(const wxString& text, // 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))); } // --------------------------------------------------------------------------- @@ -2306,8 +2290,7 @@ bool wxMSWDCImpl::DoStretchBlit(wxCoord xdest, wxCoord ydest, if ( AlphaBlt(this, xdest, ydest, dstWidth, dstHeight, xsrc, ysrc, srcWidth, srcHeight, hdcSrc, bmpSrc) ) { - CalcBoundingBox(xdest, ydest); - CalcBoundingBox(xdest + dstWidth, ydest + dstHeight); + CalcBoundingBox(wxPoint(xdest, ydest), wxSize(dstWidth, dstHeight)); return true; } } @@ -2595,8 +2578,7 @@ bool wxMSWDCImpl::DoStretchBlit(wxCoord xdest, wxCoord ydest, if ( success ) { - CalcBoundingBox(xdest, ydest); - CalcBoundingBox(xdest + dstWidth, ydest + dstHeight); + CalcBoundingBox(wxPoint(xdest, ydest), wxSize(dstWidth, dstHeight)); } return success; @@ -2943,8 +2925,7 @@ void wxMSWDCImpl::DoGradientFillLinear (const wxRect& rect, : GRADIENT_FILL_RECT_V ) ) { - CalcBoundingBox(rect.GetLeft(), rect.GetBottom()); - CalcBoundingBox(rect.GetRight(), rect.GetTop()); + CalcBoundingBox(rect); } else { diff --git a/src/x11/dcclient.cpp b/src/x11/dcclient.cpp index 58f3bc2e24..5464eb16db 100644 --- a/src/x11/dcclient.cpp +++ b/src/x11/dcclient.cpp @@ -411,8 +411,7 @@ void wxWindowDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 // (GC) m_penGC, XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2) ); } - CalcBoundingBox(x1, y1); - CalcBoundingBox(x2, y2); + CalcBoundingBox(x1, y1, x2, y2); } } @@ -543,8 +542,7 @@ void wxWindowDCImpl::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, } } - CalcBoundingBox (x1, y1); - CalcBoundingBox (x2, y2); + CalcBoundingBox(x1, y1, x2, y2); } void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double sa, double ea ) @@ -623,8 +621,7 @@ void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxC } } - CalcBoundingBox (x, y); - CalcBoundingBox (x + width, y + height); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); } void wxWindowDCImpl::DoDrawPoint( wxCoord x, wxCoord y ) @@ -819,8 +816,7 @@ void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoo } } - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); } void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius ) @@ -942,8 +938,7 @@ void wxWindowDCImpl::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width } // this ignores the radius - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); } void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) @@ -1019,8 +1014,7 @@ void wxWindowDCImpl::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord } } - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); } void wxWindowDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y) @@ -1046,8 +1040,7 @@ void wxWindowDCImpl::DoDrawBitmap( const wxBitmap &bitmap, int w = bitmap.GetWidth(); int h = bitmap.GetHeight(); - CalcBoundingBox( x, y ); - CalcBoundingBox( x + w, y + h ); + CalcBoundingBox(wxPoint(x, y), wxSize(w, h)); if (!m_x11window) return; @@ -1165,8 +1158,7 @@ void wxWindowDCImpl::DoDrawBitmap( const wxBitmap &bitmap, int w = bitmap.GetWidth(); int h = bitmap.GetHeight(); - CalcBoundingBox( x, y ); - CalcBoundingBox( x + w, y + h ); + CalcBoundingBox(wxPoint(x, y), wxSize(w, h)); if (!m_x11window) return; @@ -1384,8 +1376,7 @@ bool wxWindowDCImpl::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoor } } - CalcBoundingBox( xdest, ydest ); - CalcBoundingBox( xdest + width, ydest + height ); + CalcBoundingBox(wxPoint(xdest, ydest), wxSize(width, height)); // scale/translate size and position wxCoord xx = XLOG2DEV(xdest); @@ -1601,8 +1592,7 @@ void wxWindowDCImpl::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) g_object_unref( G_OBJECT( layout ) ); - CalcBoundingBox (x + width, y + height); - CalcBoundingBox (x, y); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); #else XFontStruct *xfont = (XFontStruct*) m_font.GetFontStruct( m_scaleY, m_display ); @@ -1658,8 +1648,7 @@ void wxWindowDCImpl::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) width = wxCoord(width / m_scaleX); height = wxCoord(height / m_scaleY); - CalcBoundingBox (x + width, y + height); - CalcBoundingBox (x, y); + CalcBoundingBox(wxPoint(x, y), wxSize(width, height)); #endif #endif } From 481b73d14c9107c13e33759e9406695fe8c2f80d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Apr 2022 20:49:58 +0100 Subject: [PATCH 4/7] Use wxScopedArray<> instead of manual memory management in wxDC Update similar code in all ports to use wxScopedArray for arrays of points, dashes etc in various wxDC implementations instead of using new[] and delete[] manually. No real changes, just make the code safer and shorter. --- include/wx/dcmirror.h | 10 ++++------ src/common/dcbase.cpp | 21 ++++++++------------- src/common/dcgraph.cpp | 11 +++++------ src/gtk/dcclient.cpp | 32 +++++++++++++------------------- src/gtk1/dcclient.cpp | 30 +++++++++++++----------------- src/motif/dcclient.cpp | 24 +++++++++++------------- src/msw/dc.cpp | 32 ++++++++++++++------------------ src/x11/dcclient.cpp | 23 ++++++++++------------- 8 files changed, 78 insertions(+), 105 deletions(-) diff --git a/include/wx/dcmirror.h b/include/wx/dcmirror.h index 4bbd27e777..44747c1582 100644 --- a/include/wx/dcmirror.h +++ b/include/wx/dcmirror.h @@ -13,6 +13,8 @@ #include "wx/dc.h" +#include "wx/scopedarray.h" + // ---------------------------------------------------------------------------- // wxMirrorDC allows to write the same code for horz/vertical layout // ---------------------------------------------------------------------------- @@ -224,25 +226,21 @@ protected: virtual void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset) wxOVERRIDE { - wxPoint* points_alloc = Mirror(n, points); + wxScopedArray points_alloc(Mirror(n, points)); m_dc.DoDrawLines(n, points, GetX(xoffset, yoffset), GetY(xoffset, yoffset)); - - delete[] points_alloc; } virtual void DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle = wxODDEVEN_RULE) wxOVERRIDE { - wxPoint* points_alloc = Mirror(n, points); + wxScopedArray points_alloc(Mirror(n, points)); m_dc.DoDrawPolygon(n, points, GetX(xoffset, yoffset), GetY(xoffset, yoffset), fillStyle); - - delete[] points_alloc; } virtual void DoSetDeviceClippingRegion(const wxRegion& WXUNUSED(region)) wxOVERRIDE diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp index 4e656015e8..30eb2b857b 100644 --- a/src/common/dcbase.cpp +++ b/src/common/dcbase.cpp @@ -26,6 +26,7 @@ #include "wx/dcscreen.h" #include "wx/dcprint.h" #include "wx/prntbase.h" +#include "wx/scopedarray.h" #include "wx/scopeguard.h" #include "wx/stack.h" @@ -694,7 +695,7 @@ wxDCImpl::DoStretchBlit(wxCoord xdest, wxCoord ydest, void wxDCImpl::DrawLines(const wxPointList *list, wxCoord xoffset, wxCoord yoffset) { int n = list->GetCount(); - wxPoint *points = new wxPoint[n]; + wxScopedArray points(n); int i = 0; for ( wxPointList::compatibility_iterator node = list->GetFirst(); node; node = node->GetNext(), i++ ) @@ -704,9 +705,7 @@ void wxDCImpl::DrawLines(const wxPointList *list, wxCoord xoffset, wxCoord yoffs points[i].y = point->y; } - DoDrawLines(n, points, xoffset, yoffset); - - delete [] points; + DoDrawLines(n, points.get(), xoffset, yoffset); } void wxDCImpl::DrawPolygon(const wxPointList *list, @@ -714,7 +713,7 @@ void wxDCImpl::DrawPolygon(const wxPointList *list, wxPolygonFillMode fillStyle) { int n = list->GetCount(); - wxPoint *points = new wxPoint[n]; + wxScopedArray points(n); int i = 0; for ( wxPointList::compatibility_iterator node = list->GetFirst(); node; node = node->GetNext(), i++ ) @@ -724,9 +723,7 @@ void wxDCImpl::DrawPolygon(const wxPointList *list, points[i].y = point->y; } - DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); - - delete [] points; + DoDrawPolygon(n, points.get(), xoffset, yoffset, fillStyle); } void @@ -743,14 +740,13 @@ wxDCImpl::DoDrawPolyPolygon(int n, } int i, j, lastOfs; - wxPoint* pts; for (i = j = lastOfs = 0; i < n; i++) { lastOfs = j; j += count[i]; } - pts = new wxPoint[j+n-1]; + wxScopedArray pts(j+n-1); for (i = 0; i < j; i++) pts[i] = points[i]; for (i = 2; i <= n; i++) @@ -761,15 +757,14 @@ wxDCImpl::DoDrawPolyPolygon(int n, { wxDCPenChanger setTransp(*m_owner, *wxTRANSPARENT_PEN); - DoDrawPolygon(j, pts, xoffset, yoffset, fillStyle); + DoDrawPolygon(j, pts.get(), xoffset, yoffset, fillStyle); } for (i = j = 0; i < n; i++) { - DoDrawLines(count[i], pts+j, xoffset, yoffset); + DoDrawLines(count[i], pts.get()+j, xoffset, yoffset); j += count[i]; } - delete[] pts; } #if wxUSE_SPLINES diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index 8c77b37d19..f0980a4cfc 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -25,6 +25,7 @@ #endif #include "wx/display.h" +#include "wx/scopedarray.h" //----------------------------------------------------------------------------- // Local functions @@ -833,7 +834,7 @@ void wxGCDCImpl::DoDrawLines(int n, const wxPoint points[], int maxX = minX; int maxY = minY; - wxPoint2DDouble* pointsD = new wxPoint2DDouble[n]; + wxScopedArray pointsD(n); for( int i = 0; i < n; ++i) { wxPoint p = points[i]; @@ -846,8 +847,7 @@ 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, maxX + xoffset, maxY + yoffset); @@ -915,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 pointsD(n+(closeIt?1:0)); for( int i = 0; i < n; ++i) { wxPoint p = points[i]; @@ -930,8 +930,7 @@ 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, maxX + xoffset, maxY + yoffset); diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index b8a9869d47..bb65558b45 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -21,6 +21,7 @@ #endif #include "wx/fontutil.h" +#include "wx/scopedarray.h" #include "wx/gtk/private.h" #include "wx/gtk/private/object.h" @@ -723,12 +724,12 @@ void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset // GdkPoint and wxPoint have the same memory layout, so we can cast one to the other const GdkPoint* gpts = reinterpret_cast(points); - GdkPoint* gpts_alloc = NULL; + wxScopedArray gpts_alloc; if (doScale) { - gpts_alloc = new GdkPoint[n]; - gpts = gpts_alloc; + gpts_alloc.reset(new GdkPoint[n]); + gpts = gpts_alloc.get(); } for (int i = 0; i < n; i++) @@ -743,8 +744,6 @@ void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset if (m_gdkwindow) gdk_draw_lines(m_gdkwindow, m_penGC, const_cast(gpts), n); - - delete[] gpts_alloc; } void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], @@ -761,12 +760,12 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], // GdkPoint and wxPoint have the same memory layout, so we can cast one to the other const GdkPoint* gdkpoints = reinterpret_cast(points); - GdkPoint* gdkpoints_alloc = NULL; + wxScopedArray gdkpoints_alloc; if (doScale) { - gdkpoints_alloc = new GdkPoint[n]; - gdkpoints = gdkpoints_alloc; + gdkpoints_alloc.reset(new GdkPoint[n]); + gdkpoints = gdkpoints_alloc.get(); } int i; @@ -810,8 +809,6 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], } } - - delete[] gdkpoints_alloc; } void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) @@ -1010,11 +1007,11 @@ ScaleMask(GdkPixmap* mask, int x, int y, int w, int h, int dst_w, int dst_h, dou // convert black and white pixbuf back to a mono pixmap const unsigned out_rowstride = (dst_w + 7) / 8; const size_t data_size = out_rowstride * size_t(dst_h); - char* data = new char[data_size]; - char* out = data; + wxScopedArray data(data_size); + char* out = data.get(); const guchar* row = gdk_pixbuf_get_pixels(pixbuf); const int rowstride = gdk_pixbuf_get_rowstride(pixbuf); - memset(data, 0, data_size); + memset(data.get(), 0, data_size); for (int j = 0; j < dst_h; j++, row += rowstride, out += out_rowstride) { const guchar* in = row; @@ -1023,9 +1020,7 @@ ScaleMask(GdkPixmap* mask, int x, int y, int w, int h, int dst_w, int dst_h, dou out[i >> 3] |= 1 << (i & 7); } g_object_unref(pixbuf); - GdkPixmap* pixmap = gdk_bitmap_create_from_data(mask, data, dst_w, dst_h); - delete[] data; - return pixmap; + return gdk_bitmap_create_from_data(mask, data.get(), dst_w, dst_h); } // Make a new mask from part of a mask and a clip region. @@ -1632,13 +1627,12 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) if (req_dash && req_nb_dash) { - wxDash* real_req_dash = new wxDash[req_nb_dash]; + wxScopedArray real_req_dash(req_nb_dash); if (real_req_dash) { for (int i = 0; i < req_nb_dash; i++) real_req_dash[i] = req_dash[i] * width; - gdk_gc_set_dashes( m_penGC, 0, real_req_dash, req_nb_dash ); - delete[] real_req_dash; + gdk_gc_set_dashes( m_penGC, 0, real_req_dash.get(), req_nb_dash ); } else { diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index c949ae93ba..2031206ef9 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -21,6 +21,7 @@ #endif #include "wx/fontutil.h" +#include "wx/scopedarray.h" #include "wx/gtk1/win_gtk.h" #include "wx/gtk1/dcclient.h" @@ -651,7 +652,7 @@ void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset if (n <= 0) return; - GdkPoint * const gpts = new GdkPoint[n]; + wxScopedArray gpts(n); if ( !gpts ) { wxFAIL_MSG( wxT("Cannot allocate PolyLine") ); @@ -669,9 +670,7 @@ void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset gpts[i].y = YLOG2DEV(y); } - gdk_draw_lines( m_window, m_penGC, gpts, n); - - delete[] gpts; + gdk_draw_lines( m_window, m_penGC, gpts.get(), n); } void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode WXUNUSED(fillStyle) ) @@ -680,7 +679,7 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], wxCoord xoffs if (n <= 0) return; - GdkPoint * const gpts = new GdkPoint[n]; + wxScopedArray gpts(n); for (int i = 0 ; i < n ; i++) { @@ -695,7 +694,7 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], wxCoord xoffs if (m_brush.GetStyle() == wxBRUSHSTYLE_SOLID) { - gdk_draw_polygon( m_window, m_brushGC, TRUE, gpts, n ); + gdk_draw_polygon( m_window, m_brushGC, TRUE, gpts.get(), n ); } else if (m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT) { @@ -704,19 +703,19 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], wxCoord xoffs gdk_gc_set_ts_origin( m_textGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_polygon( m_window, m_textGC, TRUE, gpts, n ); + gdk_draw_polygon( m_window, m_textGC, TRUE, gpts.get(), n ); gdk_gc_set_ts_origin( m_textGC, 0, 0 ); } else if (IS_15_PIX_HATCH(m_brush.GetStyle())) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - gdk_draw_polygon( m_window, m_brushGC, TRUE, gpts, n ); + gdk_draw_polygon( m_window, m_brushGC, TRUE, gpts.get(), n ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else if (IS_16_PIX_HATCH(m_brush.GetStyle())) { gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - gdk_draw_polygon( m_window, m_brushGC, TRUE, gpts, n ); + gdk_draw_polygon( m_window, m_brushGC, TRUE, gpts.get(), n ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else if (m_brush.GetStyle() == wxBRUSHSTYLE_STIPPLE) @@ -724,22 +723,20 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], wxCoord xoffs gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % m_brush.GetStipple()->GetWidth(), m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_polygon( m_window, m_brushGC, TRUE, gpts, n ); + gdk_draw_polygon( m_window, m_brushGC, TRUE, gpts.get(), n ); gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); } else { - gdk_draw_polygon( m_window, m_brushGC, TRUE, gpts, n ); + gdk_draw_polygon( m_window, m_brushGC, TRUE, gpts.get(), n ); } } if (m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT) { - gdk_draw_polygon( m_window, m_penGC, FALSE, gpts, n ); + gdk_draw_polygon( m_window, m_penGC, FALSE, gpts.get(), n ); } - - delete[] gpts; } void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) @@ -1728,13 +1725,12 @@ void wxWindowDCImpl::SetPen( const wxPen &pen ) if (req_dash && req_nb_dash) { - wxGTKDash *real_req_dash = new wxGTKDash[req_nb_dash]; + wxScopedArray real_req_dash(req_nb_dash); if (real_req_dash) { for (int i = 0; i < req_nb_dash; i++) real_req_dash[i] = req_dash[i] * width; - gdk_gc_set_dashes( m_penGC, 0, real_req_dash, req_nb_dash ); - delete[] real_req_dash; + gdk_gc_set_dashes( m_penGC, 0, real_req_dash.get(), req_nb_dash ); } else { diff --git a/src/motif/dcclient.cpp b/src/motif/dcclient.cpp index 1cee3077fb..001f382075 100644 --- a/src/motif/dcclient.cpp +++ b/src/motif/dcclient.cpp @@ -48,6 +48,8 @@ #include "wx/dcclient.h" #endif +#include "wx/scopedarray.h" + #ifdef __VMS__ #pragma message disable nosimpint #endif @@ -438,7 +440,7 @@ void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset if (m_autoSetting) SetPen (m_pen); - XPoint *xpoints = new XPoint[n]; + wxScopedArray xpoints(n); int i; for (i = 0; i < n; i++) @@ -446,7 +448,7 @@ void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset xpoints[i].x = (short)XLOG2DEV (points[i].x + xoffset); xpoints[i].y = (short)YLOG2DEV (points[i].y + yoffset); } - XDrawLines ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints, n, 0); + XDrawLines ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints.get(), n, 0); if (m_window && m_window->GetBackingPixmap()) { @@ -455,9 +457,8 @@ void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset xpoints[i].x = (short)XLOG2DEV_2 (points[i].x + xoffset); xpoints[i].y = (short)YLOG2DEV_2 (points[i].y + yoffset); } - XDrawLines ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, xpoints, n, 0); + XDrawLines ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, xpoints.get(), n, 0); } - delete[]xpoints; } } @@ -466,8 +467,8 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], { wxCHECK_RET( IsOk(), "invalid dc" ); - XPoint *xpoints1 = new XPoint[n + 1]; - XPoint *xpoints2 = new XPoint[n + 1]; + wxScopedArray xpoints1(n + 1); + wxScopedArray xpoints2(n + 1); int i; for (i = 0; i < n; i++) { @@ -488,13 +489,13 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], { SetBrush (m_brush); XSetFillRule ((Display*) m_display, (GC) m_gc, fillStyle == wxODDEVEN_RULE ? EvenOddRule : WindingRule); - XFillPolygon ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints1, n, Complex, 0); + XFillPolygon ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints1.get(), n, Complex, 0); XSetFillRule ((Display*) m_display, (GC) m_gc, EvenOddRule); // default mode if (m_window && m_window->GetBackingPixmap()) { XSetFillRule ((Display*) m_display,(GC) m_gcBacking, fillStyle == wxODDEVEN_RULE ? EvenOddRule : WindingRule); - XFillPolygon ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, xpoints2, n, Complex, 0); + XFillPolygon ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, xpoints2.get(), n, Complex, 0); XSetFillRule ((Display*) m_display,(GC) m_gcBacking, EvenOddRule); // default mode } } @@ -503,14 +504,11 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], { if (m_autoSetting) SetPen (m_pen); - XDrawLines ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints1, n + 1, 0); + XDrawLines ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints1.get(), n + 1, 0); if (m_window && m_window->GetBackingPixmap()) - XDrawLines ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, xpoints2, n + 1, 0); + XDrawLines ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, xpoints2.get(), n + 1, 0); } - - delete[]xpoints1; - delete[]xpoints2; } void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 1c54f14a0e..c950b2b90b 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -37,6 +37,8 @@ #endif #include "wx/msw/dc.h" + +#include "wx/scopedarray.h" #include "wx/sysopt.h" #ifdef wxHAS_RAW_BITMAP @@ -621,11 +623,11 @@ void wxMSWDCImpl::SetClippingHrgn(WXHRGN hrgn, bool doRtlOffset) if ( GetLayoutDirection() == wxLayout_RightToLeft ) { DWORD bufLen = ::GetRegionData(hrgn, 0, NULL); // Get the storage size - char* pDataBuf = new char[bufLen]; // Buffer for the region data - if ( ::GetRegionData(hrgn, bufLen, reinterpret_cast(pDataBuf)) != bufLen ) + wxScopedArray pDataBuf(bufLen); + RGNDATA* const rgndata = reinterpret_cast(pDataBuf.get()); + if ( ::GetRegionData(hrgn, bufLen, rgndata) != bufLen ) { wxLogLastError("GetRegionData"); - delete[] pDataBuf; return; } int dcw, dch; @@ -644,8 +646,7 @@ void wxMSWDCImpl::SetClippingHrgn(WXHRGN hrgn, bool doRtlOffset) // shoulde be adjusted. tr.eDx = doRtlOffset ? dcw : dcw-1; // max X tr.eDy = 0; - hRgnRTL = ::ExtCreateRegion(&tr, bufLen, reinterpret_cast(pDataBuf)); - delete[] pDataBuf; + hRgnRTL = ::ExtCreateRegion(&tr, bufLen, rgndata); if ( !hRgnRTL ) { wxLogLastError("ExtCreateRegion"); @@ -1022,7 +1023,7 @@ void wxMSWDCImpl::DoDrawPolygon(int n, // Do things less efficiently if we have offsets if (xoffset != 0 || yoffset != 0) { - POINT *cpoints = new POINT[n]; + wxScopedArray cpoints(n); int i; for (i = 0; i < n; i++) { @@ -1032,9 +1033,8 @@ void wxMSWDCImpl::DoDrawPolygon(int n, CalcBoundingBox(cpoints[i].x, cpoints[i].y); } int prev = SetPolyFillMode(GetHdc(),fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING); - (void)Polygon(GetHdc(), cpoints, n); + (void)Polygon(GetHdc(), cpoints.get(), n); SetPolyFillMode(GetHdc(),prev); - delete[] cpoints; } else { @@ -1064,7 +1064,7 @@ wxMSWDCImpl::DoDrawPolyPolygon(int n, // Do things less efficiently if we have offsets if (xoffset != 0 || yoffset != 0) { - POINT *cpoints = new POINT[cnt]; + wxScopedArray cpoints(cnt); for (i = 0; i < cnt; i++) { cpoints[i].x = (int)(points[i].x + xoffset); @@ -1073,9 +1073,8 @@ wxMSWDCImpl::DoDrawPolyPolygon(int n, CalcBoundingBox(cpoints[i].x, cpoints[i].y); } int prev = SetPolyFillMode(GetHdc(),fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING); - (void)PolyPolygon(GetHdc(), cpoints, count, n); + (void)PolyPolygon(GetHdc(), cpoints.get(), count, n); SetPolyFillMode(GetHdc(),prev); - delete[] cpoints; } else { @@ -1093,7 +1092,7 @@ void wxMSWDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wx // Do things less efficiently if we have offsets if (xoffset != 0 || yoffset != 0) { - POINT *cpoints = new POINT[n]; + wxScopedArray cpoints(n); int i; for (i = 0; i < n; i++) { @@ -1102,8 +1101,7 @@ void wxMSWDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wx CalcBoundingBox(cpoints[i].x, cpoints[i].y); } - (void)Polyline(GetHdc(), cpoints, n); - delete[] cpoints; + (void)Polyline(GetHdc(), cpoints.get(), n); } else { @@ -1218,7 +1216,7 @@ void wxMSWDCImpl::DoDrawSpline(const wxPointList *points) wxCHECK_RET( n_points >= 2 , "incomplete list of spline points?" ); const size_t n_bezier_points = n_points * 3 + 1; - POINT *lppt = new POINT[n_bezier_points]; + wxScopedArray lppt(n_bezier_points); size_t bezier_pos = 0; wxCoord x1, y1, x2, y2, cx1, cy1; @@ -1279,9 +1277,7 @@ void wxMSWDCImpl::DoDrawSpline(const wxPointList *points) lppt[ bezier_pos ] = lppt[ bezier_pos-1 ]; bezier_pos++; - ::PolyBezier( GetHdc(), lppt, bezier_pos ); - - delete []lppt; + ::PolyBezier( GetHdc(), lppt.get(), bezier_pos ); } #endif // wxUSE_SPLINES diff --git a/src/x11/dcclient.cpp b/src/x11/dcclient.cpp index 5464eb16db..140f5c6a6e 100644 --- a/src/x11/dcclient.cpp +++ b/src/x11/dcclient.cpp @@ -22,6 +22,7 @@ #endif #include "wx/fontutil.h" +#include "wx/scopedarray.h" #include "wx/vector.h" #include "wx/x11/private.h" @@ -642,7 +643,7 @@ void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset if (m_pen.GetStyle() == wxPENSTYLE_TRANSPARENT) return; if (n <= 0) return; - XPoint *xpoints = new XPoint[n]; + wxScopedArray xpoints(n); for (int i = 0; i < n; i++) { xpoints[i].x = XLOG2DEV (points[i].x + xoffset); @@ -650,9 +651,7 @@ void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset ); } - XDrawLines( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xpoints, n, 0 ); - - delete[] xpoints; + XDrawLines( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xpoints.get(), n, 0 ); } void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], @@ -663,7 +662,7 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], if (n <= 0) return; - XPoint *xpoints = new XPoint[n + 1]; + wxScopedArray xpoints(n + 1); int i; for (i = 0; i < n; i++) { @@ -685,7 +684,7 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); XFillPolygon( (Display*) m_display, (Window) m_x11window, - (GC) m_textGC, xpoints, n, Complex, 0); + (GC) m_textGC, xpoints.get(), n, Complex, 0); XSetTSOrigin( (Display*) m_display, (GC) m_textGC, 0, 0 ); } else @@ -695,7 +694,7 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], m_deviceOriginX % 15, m_deviceOriginY % 15 ); XFillPolygon( (Display*) m_display, (Window) m_x11window, - (GC) m_brushGC, xpoints, n, Complex, 0); + (GC) m_brushGC, xpoints.get(), n, Complex, 0); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 ); } else @@ -705,7 +704,7 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], m_deviceOriginX % 16, m_deviceOriginY % 16 ); XFillPolygon( (Display*) m_display, (Window) m_x11window, - (GC) m_brushGC, xpoints, n, Complex, 0); + (GC) m_brushGC, xpoints.get(), n, Complex, 0); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 ); } else @@ -716,14 +715,14 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); XFillPolygon( (Display*) m_display, (Window) m_x11window, - (GC) m_brushGC, xpoints, n, Complex, 0); + (GC) m_brushGC, xpoints.get(), n, Complex, 0); XSetTSOrigin( (Display*) m_display, (GC) m_brushGC, 0, 0 ); } else { XFillPolygon( (Display*) m_display, (Window) m_x11window, - (GC) m_brushGC, xpoints, n, Complex, 0); + (GC) m_brushGC, xpoints.get(), n, Complex, 0); } } @@ -733,11 +732,9 @@ void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], xpoints[i].x = xpoints[0].x; xpoints[i].y = xpoints[0].y; - XDrawLines( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xpoints, n + 1, 0); + XDrawLines( (Display*) m_display, (Window) m_x11window, (GC) m_penGC, xpoints.get(), n + 1, 0); } } - - delete[] xpoints; } void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) From 5157a8a62caf63a72c6d27d35533481e1bf8d4bd Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Apr 2022 21:03:13 +0100 Subject: [PATCH 5/7] Hide private StretchBltModeChanger class in unnamed namespace No real changes, just put this non-wx-prefixed class in an unnamed namespace to avoid any clashes with user-defined classes (which would be possible when using wx as a static library). --- src/msw/dc.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index c950b2b90b..3a048895bf 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -404,6 +404,9 @@ private: wxDECLARE_NO_COPY_CLASS(wxBrushAttrsSetter); }; +namespace +{ + // this class sets the stretch blit mode to COLORONCOLOR during its lifetime class StretchBltModeChanger { @@ -434,6 +437,8 @@ private: wxDECLARE_NO_COPY_CLASS(StretchBltModeChanger); }; +} // anonymous namespace + // =========================================================================== // implementation // =========================================================================== From 4a56747e8d47d83475c8bd4c01e38740f4c24e8a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Apr 2022 21:07:08 +0100 Subject: [PATCH 6/7] Use helper PolyFillModeSetter in wxMSW wxDC code No real changes, just use RAII helper instead of manually setting and restoring the polygon fill mode. --- src/msw/dc.cpp | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 3a048895bf..1e7db55c1d 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -437,6 +437,30 @@ private: wxDECLARE_NO_COPY_CLASS(StretchBltModeChanger); }; +// This one changes polygon fill mode to the given one during its lifetime. +class PolyFillModeSetter +{ +public: + PolyFillModeSetter(HDC hdc, wxPolygonFillMode mode) + : m_hdc(hdc) + { + m_modeOld = ::SetPolyFillMode(m_hdc, mode == wxODDEVEN_RULE ? ALTERNATE + : WINDING); + } + + ~PolyFillModeSetter() + { + ::SetPolyFillMode(m_hdc, m_modeOld); + } + +private: + const HDC m_hdc; + + int m_modeOld; + + wxDECLARE_NO_COPY_CLASS(PolyFillModeSetter); +}; + } // anonymous namespace // =========================================================================== @@ -1025,6 +1049,8 @@ void wxMSWDCImpl::DoDrawPolygon(int n, { wxBrushAttrsSetter cc(*this); // needed for wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE handling + PolyFillModeSetter polyfillModeSetter(GetHdc(), fillStyle); + // Do things less efficiently if we have offsets if (xoffset != 0 || yoffset != 0) { @@ -1037,9 +1063,7 @@ void wxMSWDCImpl::DoDrawPolygon(int n, CalcBoundingBox(cpoints[i].x, cpoints[i].y); } - int prev = SetPolyFillMode(GetHdc(),fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING); (void)Polygon(GetHdc(), cpoints.get(), n); - SetPolyFillMode(GetHdc(),prev); } else { @@ -1047,9 +1071,7 @@ void wxMSWDCImpl::DoDrawPolygon(int n, for (i = 0; i < n; i++) CalcBoundingBox(points[i].x, points[i].y); - int prev = SetPolyFillMode(GetHdc(),fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING); Polygon(GetHdc(), reinterpret_cast(points), n); - SetPolyFillMode(GetHdc(),prev); } } @@ -1066,6 +1088,8 @@ wxMSWDCImpl::DoDrawPolyPolygon(int n, for (i = cnt = 0; i < n; i++) cnt += count[i]; + PolyFillModeSetter polyfillModeSetter(GetHdc(), fillStyle); + // Do things less efficiently if we have offsets if (xoffset != 0 || yoffset != 0) { @@ -1077,18 +1101,14 @@ wxMSWDCImpl::DoDrawPolyPolygon(int n, CalcBoundingBox(cpoints[i].x, cpoints[i].y); } - int prev = SetPolyFillMode(GetHdc(),fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING); (void)PolyPolygon(GetHdc(), cpoints.get(), count, n); - SetPolyFillMode(GetHdc(),prev); } else { for (i = 0; i < cnt; i++) CalcBoundingBox(points[i].x, points[i].y); - int prev = SetPolyFillMode(GetHdc(),fillStyle==wxODDEVEN_RULE?ALTERNATE:WINDING); PolyPolygon(GetHdc(), reinterpret_cast(points), count, n); - SetPolyFillMode(GetHdc(),prev); } } From e09a01068d8b75a52d788f8d834acc0dd3ed0abf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Apr 2022 21:19:01 +0100 Subject: [PATCH 7/7] Remove more unnecessary casts to int in wxMSW wxDC code There is no need to cast wxCoord to int, they're one and the same. --- src/msw/dc.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 1e7db55c1d..e43dba391b 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -1058,8 +1058,8 @@ void wxMSWDCImpl::DoDrawPolygon(int n, int i; for (i = 0; i < n; i++) { - cpoints[i].x = (int)(points[i].x + xoffset); - cpoints[i].y = (int)(points[i].y + yoffset); + cpoints[i].x = points[i].x + xoffset; + cpoints[i].y = points[i].y + yoffset; CalcBoundingBox(cpoints[i].x, cpoints[i].y); } @@ -1096,8 +1096,8 @@ wxMSWDCImpl::DoDrawPolyPolygon(int n, wxScopedArray cpoints(cnt); for (i = 0; i < cnt; i++) { - cpoints[i].x = (int)(points[i].x + xoffset); - cpoints[i].y = (int)(points[i].y + yoffset); + cpoints[i].x = points[i].x + xoffset; + cpoints[i].y = points[i].y + yoffset; CalcBoundingBox(cpoints[i].x, cpoints[i].y); }