Add support for affine transformation matrix in wxGCDC

Graphics renderers (exposed through wxGraphicsContext) support arbitrary affine transformations so it is possible to add support for affine transformations in wxGCDC by implementing all wxGCDC::*TransformMatrix() functions with calls to respective wxGraphicsContext functions.
Additionally, this implementation adds support for affine transformations in wxDC under wxGTK3 because in this port wxDC is equivalent to wxGCDC.
This commit is contained in:
Artur Wieczorek
2016-09-07 23:49:06 +02:00
parent 0bf38e11a3
commit 49000defcf
5 changed files with 63 additions and 9 deletions

View File

@@ -545,6 +545,47 @@ void wxGCDCImpl::SetLogicalFunction( wxRasterOperationMode function )
m_graphicContext->SetAntialiasMode(wxANTIALIAS_DEFAULT);
}
// ----------------------------------------------------------------------------
// Transform matrix
// ----------------------------------------------------------------------------
#if wxUSE_DC_TRANSFORM_MATRIX
bool wxGCDCImpl::CanUseTransformMatrix() const
{
return true;
}
bool wxGCDCImpl::SetTransformMatrix(const wxAffineMatrix2D &matrix)
{
wxGraphicsMatrix matGr = m_graphicContext->CreateMatrix(matrix);
m_graphicContext->SetTransform(matGr);
m_isClipBoxValid = false;
return true;
}
wxAffineMatrix2D wxGCDCImpl::GetTransformMatrix() const
{
wxMatrix2D mat2D;
wxPoint2DDouble tr;
wxGraphicsMatrix matGr = m_graphicContext->GetTransform();
matGr.Get(&mat2D.m_11, &mat2D.m_12, &mat2D.m_21, &mat2D.m_22, &tr.m_x, &tr.m_y);
wxAffineMatrix2D matrix;
matrix.Set(mat2D, tr);
return matrix;
}
void wxGCDCImpl::ResetTransformMatrix()
{
wxGraphicsMatrix matGr = m_graphicContext->CreateMatrix();
m_graphicContext->SetTransform(matGr);
m_isClipBoxValid = false;
}
#endif // wxUSE_DC_TRANSFORM_MATRIX
bool wxGCDCImpl::DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
const wxColour& WXUNUSED(col),
wxFloodFillStyle WXUNUSED(style))