Implement 0-width pen consistently in wxGraphicsContext

Emulate a 1-pixel pen width as closely as possible.

This reverts:
334cf1cc91 (Take HiDPI scale into account for wxGCDC 0-width pen, 2021-04-03)
0d80050057 (Make wxGCDC behavior with 0-width wxPen consistent with MSW wxDC, 2021-03-02)

See #19077, #19115
This commit is contained in:
Paul Cornett
2021-04-05 09:56:28 -07:00
parent a2e4cb6cec
commit 52cc838b12
10 changed files with 190 additions and 130 deletions

View File

@@ -522,36 +522,10 @@ void wxGCDCImpl::SetFont( const wxFont &font )
void wxGCDCImpl::SetPen( const wxPen &pen )
{
m_pen = pen;
if (m_graphicContext == NULL)
return;
wxPenStyle style;
if (!pen.IsOk() || (style = pen.GetStyle()) == wxPENSTYLE_TRANSPARENT)
if ( m_graphicContext )
{
m_graphicContext->SetPen(wxGraphicsPen());
return;
m_graphicContext->SetPen( m_pen );
}
// 0-width pen is 1 pixel wide with MSW wxDC
const int w = pen.GetWidth();
const double width = w ? double(w) : 1 / (wxMin(m_scaleX, m_scaleY) * m_contentScaleFactor);
wxGraphicsPenInfo info(pen.GetColour(), width, style);
info.Join(pen.GetJoin()).Cap(pen.GetCap());
if (style == wxPENSTYLE_USER_DASH)
{
wxDash* dashes;
if (int n = pen.GetDashes(&dashes))
info.Dashes(n, dashes);
}
else if (style == wxPENSTYLE_STIPPLE)
{
if (const wxBitmap* stipple = pen.GetStipple())
info.Stipple(*stipple);
}
m_graphicContext->SetPen(m_graphicContext->CreatePen(info));
}
void wxGCDCImpl::SetBrush( const wxBrush &brush )