From c9848e6318cdb8525574272ced74b0389e86319c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 15 Sep 2012 23:19:11 +0000 Subject: [PATCH] No real changes, just slightly simplify wxSVGFileDCImpl code. Move m_graphics_changed check inside NewGraphics() itself instead of checking whether it's true each time before calling it, it is better to both test the flag and reset it inside this function rather than do the first part in the caller and the second one in the callee. Also rename the function to NewGraphicsIfNeeded() to make its meaning more clear. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72493 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/dcsvg.h | 8 +++++--- src/common/dcsvg.cpp | 27 +++++++++++++++------------ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/include/wx/dcsvg.h b/include/wx/dcsvg.h index cae6308db4..dc541ae799 100644 --- a/include/wx/dcsvg.h +++ b/include/wx/dcsvg.h @@ -186,16 +186,18 @@ private: void Init (const wxString &filename, int width, int height, double dpi); - void NewGraphics(); - void write( const wxString &s ); private: + // If m_graphics_changed is true, close the current element and start a + // new one for the last pen/brush change. + void NewGraphicsIfNeeded(); + wxFileOutputStream *m_outfile; wxString m_filename; int m_sub_images; // number of png format images we have bool m_OK; - bool m_graphics_changed; + bool m_graphics_changed; // set by Set{Brush,Pen}() int m_width, m_height; double m_dpi; diff --git a/src/common/dcsvg.cpp b/src/common/dcsvg.cpp index 9aeb7e9530..6d922b3fae 100644 --- a/src/common/dcsvg.cpp +++ b/src/common/dcsvg.cpp @@ -195,7 +195,7 @@ wxSize wxSVGFileDCImpl::GetPPI() const void wxSVGFileDCImpl::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) { - if (m_graphics_changed) NewGraphics(); + NewGraphicsIfNeeded(); wxString s; s.Printf ( wxT(" \n"), x1,y1,x2,y2 ); if (m_OK) @@ -218,7 +218,7 @@ void wxSVGFileDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset , wxC void wxSVGFileDCImpl::DoDrawPoint (wxCoord x1, wxCoord y1) { wxString s; - if (m_graphics_changed) NewGraphics(); + NewGraphicsIfNeeded(); s = wxT(" ") + wxString(wxT("\n")); write(s); DoDrawLine ( x1,y1,x1,y1 ); @@ -239,7 +239,7 @@ void wxSVGFileDCImpl::DoDrawText(const wxString& text, wxCoord x1, wxCoord y1) void wxSVGFileDCImpl::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoord y, double angle) { //known bug; if the font is drawn in a scaled DC, it will not behave exactly as wxMSW - if (m_graphics_changed) NewGraphics(); + NewGraphicsIfNeeded(); wxString s, sTmp; // calculate bounding box @@ -303,7 +303,7 @@ void wxSVGFileDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoo void wxSVGFileDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius ) { - if (m_graphics_changed) NewGraphics(); + NewGraphicsIfNeeded(); wxString s; s.Printf ( wxT(" \n