Kaydet (Commit) 90368a2e authored tarafından Noel Grandin's avatar Noel Grandin

no need to store B2DPolyPolygon on the heap here

it's a COW type internally, so only one pointer big

Change-Id: I478f5aa6f84c87bedf6f450526e7f8f7c297e7c4
Reviewed-on: https://gerrit.libreoffice.org/65529
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 6ba8d653
...@@ -169,10 +169,6 @@ void FuMorph::DoExecute( SfxRequest& ) ...@@ -169,10 +169,6 @@ void FuMorph::DoExecute( SfxRequest& )
mpView->BegUndo(aString); mpView->BegUndo(aString);
ImpInsertPolygons(aPolyPolyList, pDlg->IsAttributeFade(), pObj1, pObj2); ImpInsertPolygons(aPolyPolyList, pDlg->IsAttributeFade(), pObj1, pObj2);
mpView->EndUndo(); mpView->EndUndo();
for(basegfx::B2DPolyPolygon * p : aPolyPolyList) {
delete p;
}
} }
} }
SdrObject::Free( pCloneObj1 ); SdrObject::Free( pCloneObj1 );
...@@ -396,7 +392,7 @@ void FuMorph::ImpInsertPolygons( ...@@ -396,7 +392,7 @@ void FuMorph::ImpInsertPolygons(
for ( size_t i = 0; i < nCount; i++, fFactor += fStep ) for ( size_t i = 0; i < nCount; i++, fFactor += fStep )
{ {
const ::basegfx::B2DPolyPolygon& rPolyPoly3D = *rPolyPolyList3D[ i ]; const ::basegfx::B2DPolyPolygon& rPolyPoly3D = rPolyPolyList3D[ i ];
SdrPathObj* pNewObj = new SdrPathObj( SdrPathObj* pNewObj = new SdrPathObj(
mpView->getSdrModelFromSdrView(), mpView->getSdrModelFromSdrView(),
OBJ_POLY, OBJ_POLY,
...@@ -446,13 +442,13 @@ void FuMorph::ImpInsertPolygons( ...@@ -446,13 +442,13 @@ void FuMorph::ImpInsertPolygons(
/** /**
* create single morphed PolyPolygon * create single morphed PolyPolygon
*/ */
::basegfx::B2DPolyPolygon* FuMorph::ImpCreateMorphedPolygon( ::basegfx::B2DPolyPolygon FuMorph::ImpCreateMorphedPolygon(
const ::basegfx::B2DPolyPolygon& rPolyPolyStart, const ::basegfx::B2DPolyPolygon& rPolyPolyStart,
const ::basegfx::B2DPolyPolygon& rPolyPolyEnd, const ::basegfx::B2DPolyPolygon& rPolyPolyEnd,
double fMorphingFactor double fMorphingFactor
) )
{ {
::basegfx::B2DPolyPolygon* pNewPolyPolygon = new ::basegfx::B2DPolyPolygon(); ::basegfx::B2DPolyPolygon aNewPolyPolygon;
const double fFactor = 1.0 - fMorphingFactor; const double fFactor = 1.0 - fMorphingFactor;
for(sal_uInt32 a(0); a < rPolyPolyStart.count(); a++) for(sal_uInt32 a(0); a < rPolyPolyStart.count(); a++)
...@@ -470,10 +466,10 @@ void FuMorph::ImpInsertPolygons( ...@@ -470,10 +466,10 @@ void FuMorph::ImpInsertPolygons(
} }
aNewPolygon.setClosed(aPolyStart.isClosed() && aPolyEnd.isClosed()); aNewPolygon.setClosed(aPolyStart.isClosed() && aPolyEnd.isClosed());
pNewPolyPolygon->append(aNewPolygon); aNewPolyPolygon.append(aNewPolygon);
} }
return pNewPolyPolygon; return aNewPolyPolygon;
} }
/** /**
...@@ -499,15 +495,15 @@ void FuMorph::ImpMorphPolygons( ...@@ -499,15 +495,15 @@ void FuMorph::ImpMorphPolygons(
for(sal_uInt16 i(0); i < nSteps; i++) for(sal_uInt16 i(0); i < nSteps; i++)
{ {
fValue += fFactor; fValue += fFactor;
::basegfx::B2DPolyPolygon* pNewPolyPoly2D = ImpCreateMorphedPolygon(rPolyPoly1, rPolyPoly2, fValue); ::basegfx::B2DPolyPolygon aNewPolyPoly2D = ImpCreateMorphedPolygon(rPolyPoly1, rPolyPoly2, fValue);
const ::basegfx::B2DRange aNewPolySize(::basegfx::utils::getRange(*pNewPolyPoly2D)); const ::basegfx::B2DRange aNewPolySize(::basegfx::utils::getRange(aNewPolyPoly2D));
const ::basegfx::B2DPoint aNewS(aNewPolySize.getCenter()); const ::basegfx::B2DPoint aNewS(aNewPolySize.getCenter());
const ::basegfx::B2DPoint aRealS(aStartCenter + (aDelta * fValue)); const ::basegfx::B2DPoint aRealS(aStartCenter + (aDelta * fValue));
const ::basegfx::B2DPoint aDiff(aRealS - aNewS); const ::basegfx::B2DPoint aDiff(aRealS - aNewS);
pNewPolyPoly2D->transform(basegfx::utils::createTranslateB2DHomMatrix(aDiff)); aNewPolyPoly2D.transform(basegfx::utils::createTranslateB2DHomMatrix(aDiff));
rPolyPolyList3D.push_back( pNewPolyPoly2D ); rPolyPolyList3D.push_back( std::move(aNewPolyPoly2D) );
} }
} }
} }
......
...@@ -41,7 +41,7 @@ public: ...@@ -41,7 +41,7 @@ public:
virtual void DoExecute( SfxRequest& rReq ) override; virtual void DoExecute( SfxRequest& rReq ) override;
private: private:
typedef ::std::vector< ::basegfx::B2DPolyPolygon* > B2DPolyPolygonList_impl; typedef ::std::vector< ::basegfx::B2DPolyPolygon > B2DPolyPolygonList_impl;
FuMorph ( FuMorph (
ViewShell* pViewSh, ViewShell* pViewSh,
...@@ -57,7 +57,7 @@ private: ...@@ -57,7 +57,7 @@ private:
const SdrObject* pObj2 const SdrObject* pObj2
); );
static ::basegfx::B2DPolyPolygon* ImpCreateMorphedPolygon( static ::basegfx::B2DPolyPolygon ImpCreateMorphedPolygon(
const ::basegfx::B2DPolyPolygon& rPolyPolyStart, const ::basegfx::B2DPolyPolygon& rPolyPolyStart,
const ::basegfx::B2DPolyPolygon& rPolyPolyEnd, const ::basegfx::B2DPolyPolygon& rPolyPolyEnd,
double fMorphingFactor double fMorphingFactor
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment