diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-10-25 09:54:25 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-08 10:40:57 +0000 |
commit | f2beebbfe78bfd5dd26318ea269f49aeee6bd642 (patch) | |
tree | afd9820842752f252409590e323f72cdbd0a4c3c /drawinglayer/source/primitive2d/helplineprimitive2d.cxx | |
parent | ab731b192f40fde71c796ecab563adc8d7258da8 (diff) |
reduce copying when decomposing drawinglayer primitives
instead of returning a Primitive2DContainer from each method which we
are then going to immediately append to another container, pass down a
single container by reference which we can append to
Change-Id: I0f28a499d2ec54f7111a7044c30099767aa079e1
Reviewed-on: https://gerrit.libreoffice.org/30258
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'drawinglayer/source/primitive2d/helplineprimitive2d.cxx')
-rw-r--r-- | drawinglayer/source/primitive2d/helplineprimitive2d.cxx | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/drawinglayer/source/primitive2d/helplineprimitive2d.cxx b/drawinglayer/source/primitive2d/helplineprimitive2d.cxx index d51c4db65a52..b8cc0df1eafe 100644 --- a/drawinglayer/source/primitive2d/helplineprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/helplineprimitive2d.cxx @@ -33,10 +33,8 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DContainer HelplinePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const + void HelplinePrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const { - std::vector< BasePrimitive2D* > aTempPrimitiveTarget; - if(!rViewInformation.getViewport().isEmpty() && !getDirection().equalZero()) { // position to view coordinates, DashLen and DashLen in logic @@ -57,7 +55,7 @@ namespace drawinglayer aLineA.append(aEndA); aLineA.transform(rViewInformation.getInverseObjectToViewTransformation()); PolygonMarkerPrimitive2D* pNewA = new PolygonMarkerPrimitive2D(aLineA, getRGBColA(), getRGBColB(), getDiscreteDashLength()); - aTempPrimitiveTarget.push_back(pNewA); + rContainer.push_back(pNewA); const basegfx::B2DVector aPerpendicularNormalizedDirection(basegfx::getPerpendicular(aNormalizedDirection)); const basegfx::B2DPoint aStartB(aViewPosition - aPerpendicularNormalizedDirection); @@ -67,7 +65,7 @@ namespace drawinglayer aLineB.append(aEndB); aLineB.transform(rViewInformation.getInverseObjectToViewTransformation()); PolygonMarkerPrimitive2D* pNewB = new PolygonMarkerPrimitive2D(aLineB, getRGBColA(), getRGBColB(), getDiscreteDashLength()); - aTempPrimitiveTarget.push_back(pNewB); + rContainer.push_back(pNewB); break; } @@ -118,7 +116,7 @@ namespace drawinglayer basegfx::B2DPolygon aPart(aResult.getB2DPolygon(a)); aPart.transform(rViewInformation.getInverseObjectToViewTransformation()); PolygonMarkerPrimitive2D* pNew = new PolygonMarkerPrimitive2D(aPart, getRGBColA(), getRGBColB(), getDiscreteDashLength()); - aTempPrimitiveTarget.push_back(pNew); + rContainer.push_back(pNew); } } @@ -126,17 +124,6 @@ namespace drawinglayer } } } - - // prepare return value - Primitive2DContainer aRetval(aTempPrimitiveTarget.size()); - - for(size_t a(0); a < aTempPrimitiveTarget.size(); a++) - { - const Primitive2DReference xRef(aTempPrimitiveTarget[a]); - aRetval[a] = xRef; - } - - return aRetval; } HelplinePrimitive2D::HelplinePrimitive2D( @@ -175,7 +162,7 @@ namespace drawinglayer return false; } - Primitive2DContainer HelplinePrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const + void HelplinePrimitive2D::get2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const { ::osl::MutexGuard aGuard( m_aMutex ); @@ -196,7 +183,7 @@ namespace drawinglayer } // use parent implementation - return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); + BufferedDecompositionPrimitive2D::get2DDecomposition(rContainer, rViewInformation); } // provide unique ID |