X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/eb4083ef0b3abab6cb4b4ca33f9aa1ea58e1f5c9..e6a8416274252fb6ea33800cfce0e4ba0a0542f1:/src/msw/graphics.cpp diff --git a/src/msw/graphics.cpp b/src/msw/graphics.cpp index 142c2f60e8..a637adf8c4 100644 --- a/src/msw/graphics.cpp +++ b/src/msw/graphics.cpp @@ -303,6 +303,7 @@ public: virtual void GetTextExtent( const wxString &str, wxDouble *width, wxDouble *height, wxDouble *descent, wxDouble *externalLeading ) const; virtual void GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const; + virtual bool ShouldOffset() const; private: void Init(); @@ -667,7 +668,7 @@ void wxGDIPlusPathData::GetCurrentPoint( wxDouble* x, wxDouble* y) const void wxGDIPlusPathData::AddArc( wxDouble x, wxDouble y, wxDouble r, double startAngle, double endAngle, bool clockwise ) { double sweepAngle = endAngle - startAngle ; - if( abs(sweepAngle) >= 2*M_PI) + if( fabs(sweepAngle) >= 2*M_PI) { sweepAngle = 2 * M_PI; } @@ -1185,6 +1186,18 @@ void wxGDIPlusContext::GetPartialTextExtents(const wxString& text, wxArrayDouble } } +bool wxGDIPlusContext::ShouldOffset() const +{ + int penwidth = 0 ; + if ( !m_pen.IsNull() ) + { + penwidth = (int)((wxGDIPlusPenData*)m_pen.GetRefData())->GetWidth(); + if ( penwidth == 0 ) + penwidth = 1; + } + return ( penwidth % 2 ) == 1; +} + void* wxGDIPlusContext::GetNativeContext() { return m_context; @@ -1273,6 +1286,7 @@ protected : void EnsureIsLoaded(); void Load(); void Unload(); + friend class wxGDIPlusRendererModule; private : bool m_loaded; @@ -1313,7 +1327,11 @@ void wxGDIPlusRenderer::Load() void wxGDIPlusRenderer::Unload() { if ( m_gditoken ) + { GdiplusShutdown(m_gditoken); + m_gditoken = NULL; + } + m_loaded = false; } wxGraphicsContext * wxGDIPlusRenderer::CreateContext( const wxWindowDC& dc) @@ -1445,4 +1463,17 @@ wxGraphicsFont wxGDIPlusRenderer::CreateFont( const wxFont &font , const wxColou return wxNullGraphicsFont; } +// Shutdown GDI+ at app exit, before possible dll unload +class wxGDIPlusRendererModule : public wxModule +{ +public: + virtual bool OnInit() { return true; } + virtual void OnExit() { gs_GDIPlusRenderer.Unload(); } + +private: + DECLARE_DYNAMIC_CLASS(wxGDIPlusRendererModule) +}; + +IMPLEMENT_DYNAMIC_CLASS(wxGDIPlusRendererModule, wxModule) + #endif // wxUSE_GRAPHICS_CONTEXT