Preserve wxGraphicsContext settings while resetting the clipping
To reset the clipping there is necessary to restore all CGContext settings so we need to set them back to the previous values based on the stored wxGraphicsContext attributes.
This commit is contained in:
@@ -1430,6 +1430,9 @@ public:
|
||||
private:
|
||||
bool EnsureIsValid();
|
||||
void CheckInvariants() const;
|
||||
bool DoSetAntialiasMode(wxAntialiasMode antialias);
|
||||
bool DoSetInterpolationQuality(wxInterpolationQuality interpolation);
|
||||
bool DoSetCompositionMode(wxCompositionMode op);
|
||||
|
||||
virtual void DoDrawText( const wxString &str, wxDouble x, wxDouble y ) wxOVERRIDE;
|
||||
virtual void DoDrawRotatedText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle ) wxOVERRIDE;
|
||||
@@ -1678,6 +1681,16 @@ bool wxMacCoreGraphicsContext::SetAntialiasMode(wxAntialiasMode antialias)
|
||||
|
||||
m_antialias = antialias;
|
||||
|
||||
if ( !DoSetAntialiasMode(antialias) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
CheckInvariants();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxMacCoreGraphicsContext::DoSetAntialiasMode(wxAntialiasMode antialias)
|
||||
{
|
||||
bool antialiasMode;
|
||||
switch (antialias)
|
||||
{
|
||||
@@ -1691,7 +1704,6 @@ bool wxMacCoreGraphicsContext::SetAntialiasMode(wxAntialiasMode antialias)
|
||||
return false;
|
||||
}
|
||||
CGContextSetShouldAntialias(m_cgContext, antialiasMode);
|
||||
CheckInvariants();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1704,6 +1716,17 @@ bool wxMacCoreGraphicsContext::SetInterpolationQuality(wxInterpolationQuality in
|
||||
return true;
|
||||
|
||||
m_interpolation = interpolation;
|
||||
|
||||
if ( !DoSetInterpolationQuality(interpolation) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
CheckInvariants();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxMacCoreGraphicsContext::DoSetInterpolationQuality(wxInterpolationQuality interpolation)
|
||||
{
|
||||
CGInterpolationQuality quality;
|
||||
|
||||
switch (interpolation)
|
||||
@@ -1727,7 +1750,6 @@ bool wxMacCoreGraphicsContext::SetInterpolationQuality(wxInterpolationQuality in
|
||||
return false;
|
||||
}
|
||||
CGContextSetInterpolationQuality(m_cgContext, quality);
|
||||
CheckInvariants();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1741,7 +1763,17 @@ bool wxMacCoreGraphicsContext::SetCompositionMode(wxCompositionMode op)
|
||||
|
||||
m_composition = op;
|
||||
|
||||
if (m_composition == wxCOMPOSITION_DEST)
|
||||
if ( !DoSetCompositionMode(op) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
CheckInvariants();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxMacCoreGraphicsContext::DoSetCompositionMode(wxCompositionMode op)
|
||||
{
|
||||
if (op == wxCOMPOSITION_DEST)
|
||||
return true;
|
||||
|
||||
// TODO REMOVE if we don't need it because of bugs in 10.5
|
||||
@@ -1833,7 +1865,6 @@ bool wxMacCoreGraphicsContext::SetCompositionMode(wxCompositionMode op)
|
||||
case wxCOMPOSITION_XOR:
|
||||
mode = kCGBlendModeExclusion; // Not kCGBlendModeXOR!
|
||||
break;
|
||||
|
||||
case wxCOMPOSITION_ADD:
|
||||
mode = kCGBlendModePlusLighter ;
|
||||
break;
|
||||
@@ -1842,8 +1873,6 @@ bool wxMacCoreGraphicsContext::SetCompositionMode(wxCompositionMode op)
|
||||
}
|
||||
CGContextSetBlendMode(m_cgContext, mode);
|
||||
}
|
||||
|
||||
CheckInvariants();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1939,6 +1968,12 @@ void wxMacCoreGraphicsContext::ResetClip()
|
||||
transformNew = CGAffineTransformInvert( transformNew ) ;
|
||||
CGContextConcatCTM( m_cgContext, transformNew);
|
||||
CGContextConcatCTM( m_cgContext, transform);
|
||||
// Retain antialiasing mode
|
||||
DoSetAntialiasMode(m_antialias);
|
||||
// Retain interpolation quality
|
||||
DoSetInterpolationQuality(m_interpolation);
|
||||
// Retain composition mode
|
||||
DoSetCompositionMode(m_composition);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user