Fix 0-width pen scaling on wxOSX
Scaling got inverted in previous commit
52cc838b12
(Implement 0-width pen consistently in wxGraphicsContext, 2021-04-05)
This commit is contained in:
@@ -913,10 +913,10 @@ void wxMacCoreGraphicsPenData::Apply( wxGraphicsContext* context )
|
|||||||
double width = m_width;
|
double width = m_width;
|
||||||
if (width <= 0)
|
if (width <= 0)
|
||||||
{
|
{
|
||||||
const double scaleFactor = context->GetContentScaleFactor();
|
const double f = 1 / context->GetContentScaleFactor();
|
||||||
CGSize s = { scaleFactor, scaleFactor };
|
CGSize s = { f, f };
|
||||||
s = CGContextConvertSizeToUserSpace(cg, s);
|
s = CGContextConvertSizeToUserSpace(cg, s);
|
||||||
width = 1 / wxMin(fabs(s.width), fabs(s.height));
|
width = wxMax(fabs(s.width), fabs(s.height));
|
||||||
}
|
}
|
||||||
CGContextSetLineWidth( cg, width );
|
CGContextSetLineWidth( cg, width );
|
||||||
CGContextSetLineJoin( cg , m_join );
|
CGContextSetLineJoin( cg , m_join );
|
||||||
@@ -1484,10 +1484,10 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
// no offset if overall scale is not odd integer
|
// no offset if overall scale is not odd integer
|
||||||
const double scaleFactor = GetContentScaleFactor();
|
const wxGraphicsMatrix matrix(GetTransform());
|
||||||
CGSize s = { scaleFactor, scaleFactor };
|
double x = GetContentScaleFactor(), y = x;
|
||||||
s = CGContextConvertSizeToUserSpace(m_cgContext, s);
|
matrix.TransformDistance(&x, &y);
|
||||||
if (!wxIsSameDouble(fmod(wxMin(fabs(s.width), fabs(s.height)), 2.0), 1.0))
|
if (!wxIsSameDouble(fmod(wxMin(fabs(x), fabs(y)), 2.0), 1.0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// offset if pen width is odd integer
|
// offset if pen width is odd integer
|
||||||
@@ -1568,10 +1568,9 @@ public :
|
|||||||
m_offset = offset;
|
m_offset = offset;
|
||||||
if ( m_offset )
|
if ( m_offset )
|
||||||
{
|
{
|
||||||
const CGSize s = { scaleFactor, scaleFactor };
|
const double f = 0.5 / scaleFactor;
|
||||||
|
const CGSize s = { f, f };
|
||||||
m_userOffset = CGContextConvertSizeToUserSpace(m_cg, s);
|
m_userOffset = CGContextConvertSizeToUserSpace(m_cg, s);
|
||||||
m_userOffset.width = 0.5 / m_userOffset.width;
|
|
||||||
m_userOffset.height = 0.5 / m_userOffset.height;
|
|
||||||
CGContextTranslateCTM( m_cg, m_userOffset.width , m_userOffset.height );
|
CGContextTranslateCTM( m_cg, m_userOffset.width , m_userOffset.height );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user