From 7923cb222e88bf0e9499e38a4d8ae7a450f24d8d Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Thu, 26 May 2016 17:55:33 +0200 Subject: [PATCH] Fixed cloning wxD2DPathData. In addition to copying the underlying geometry sink itself also auxiliary data, like collection of transformed geometries and positional data have to copied the the new wxD2DPathData instance. --- src/msw/graphicsd2d.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/msw/graphicsd2d.cpp b/src/msw/graphicsd2d.cpp index b69b9b5f6e..601cf40b99 100644 --- a/src/msw/graphicsd2d.cpp +++ b/src/msw/graphicsd2d.cpp @@ -1136,8 +1136,8 @@ wxD2DPathData::wxGraphicsObjectRefData* wxD2DPathData::Clone() const newPathData->EnsureGeometryOpen(); - // Only geometry with closed sink (immutable) - // can be transferred to another geometry object with + // Only geometry with closed sink can be + // transferred to another geometry object with // ID2D1PathGeometry::Stream() so we have to check // if actual transfer succeeded. @@ -1149,10 +1149,23 @@ wxD2DPathData::wxGraphicsObjectRefData* wxD2DPathData::Clone() const delete newPathData; return NULL; } - // Copy auxiliary data. - newPathData->m_currentPoint = m_currentPoint; - newPathData->m_figureOpened = m_figureOpened; - newPathData->m_figureStart = m_figureStart; + + // Copy the collection of transformed geometries. + ID2D1TransformedGeometry* pTransformedGeometry; + for ( size_t i = 0; i < m_pTransformedGeometries.size(); i++ ) + { + pTransformedGeometry = NULL; + hr = m_direct2dfactory->CreateTransformedGeometry( + m_pTransformedGeometries[i], + D2D1::Matrix3x2F::Identity(), &pTransformedGeometry); + wxASSERT_MSG( SUCCEEDED(hr), wxFAILED_HRESULT_MSG(hr) ); + newPathData->m_pTransformedGeometries.push_back(pTransformedGeometry); + } + + // Copy positional data. + GeometryStateData curState; + SaveGeometryState(curState); + newPathData->RestoreGeometryState(curState); return newPathData; }