From 4ed8ccff955de741d3d110d2dd1d17cc3b1adc2d Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Sat, 9 Jan 2021 08:39:17 -0800 Subject: [PATCH] Use a better method of drawing a point in wxGCDC::DrawPoint() Drawing a circular point into a square pixel does not completely fill the pixel with the new color, resulting in an alpha-blended appearance. Instead, draw a square into the pixel. As a bonus, this is much faster, at least with Cairo. See #19037 --- src/common/dcgraph.cpp | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index 8b28360561..b5c242dd79 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -776,29 +776,11 @@ void wxGCDCImpl::DoDrawPoint( wxCoord x, wxCoord y ) if (!m_logicalFunctionSupported) return; - wxPen pointPen(m_pen.GetColour()); - wxDCPenChanger penChanger(*GetOwner(), pointPen); + wxDCBrushChanger brushChanger(*GetOwner(), wxBrush(m_pen.GetColour())); + wxDCPenChanger penChanger(*GetOwner(), *wxTRANSPARENT_PEN); -#if defined(__WXMSW__) && wxUSE_GRAPHICS_GDIPLUS - // single point path does not work with GDI+ - if (m_graphicContext->GetRenderer() == wxGraphicsRenderer::GetGDIPlusRenderer()) - { - const double dx = 0.25 / m_scaleX; - const double dy = 0.25 / m_scaleY; - m_graphicContext->StrokeLine(x - dx, y - dy, x + dx, y + dy); - } - else -#endif - { -#ifdef __WXOSX__ - m_graphicContext->StrokeLine(x, y, x, y); -#else - wxGraphicsPath path(m_graphicContext->CreatePath()); - path.MoveToPoint(x, y); - path.CloseSubpath(); - m_graphicContext->StrokePath(path); -#endif - } + // Raster-based DCs draw a single pixel regardless of scale + m_graphicContext->DrawRectangle(x, y, 1 / m_scaleX, 1 / m_scaleY); CalcBoundingBox(x, y); }