From b6d44d5329ef971458941f94fa11526f22242070 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 18 Sep 2016 23:06:13 +0200 Subject: [PATCH] Fix wxGraphicsMatrix concatenation (Direct2D) 1. Elements of resulting matrix are modified directly (in-place) in Matrix3x2F::SetProduct() so none of the multiplied matrices can be the instance of the resulting matrix. 2. The parameter matrix in wxGraphicsMatrixData::Concat() should be a multiplicand, not a multiplier. See #17670. --- interface/wx/graphics.h | 13 ++++++++++++- src/msw/graphicsd2d.cpp | 7 ++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/interface/wx/graphics.h b/interface/wx/graphics.h index cc6feb5d90..5a78b3434f 100644 --- a/interface/wx/graphics.h +++ b/interface/wx/graphics.h @@ -1525,10 +1525,21 @@ class wxGraphicsMatrix : public wxGraphicsObject public: /** Concatenates the matrix passed with the current matrix. + The effect of the resulting transformation is to first apply + the transformation in @a t to the coordinates and then apply + the transformation in the current matrix to the coordinates. + + @code + // matrix = t x matrix + @endcode + + @param t + The parameter matrix is the multiplicand. */ virtual void Concat(const wxGraphicsMatrix* t); + /** - Concatenates the matrix passed with the current matrix. + @overload */ void Concat(const wxGraphicsMatrix& t); diff --git a/src/msw/graphicsd2d.cpp b/src/msw/graphicsd2d.cpp index 916f047b5a..3f51a72e9d 100644 --- a/src/msw/graphicsd2d.cpp +++ b/src/msw/graphicsd2d.cpp @@ -915,7 +915,12 @@ wxD2DMatrixData::wxD2DMatrixData(wxGraphicsRenderer* renderer, const D2D1::Matri void wxD2DMatrixData::Concat(const wxGraphicsMatrixData* t) { - m_matrix.SetProduct(m_matrix, static_cast(t)->m_matrix); + // Elements of resulting matrix are modified in-place in SetProduct() + // so multiplied matrices cannot be the instances of the resulting matrix. + // Note that parameter matrix (t) is the multiplicand. + const D2D1::Matrix3x2F m1(static_cast(t)->m_matrix); + const D2D1::Matrix3x2F m2(m_matrix); + m_matrix.SetProduct(m1, m2); } void wxD2DMatrixData::Set(wxDouble a, wxDouble b, wxDouble c, wxDouble d, wxDouble tx, wxDouble ty)