reduce Primitive2DContainer copying

Change-Id: I418b17034c1949ddda1de7025821ca51f4cdb018
Reviewed-on: https://gerrit.libreoffice.org/78579
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2019-09-04 09:17:42 +02:00
parent 5bfa8b8d5e
commit 2340c2ffe4
11 changed files with 22 additions and 20 deletions

View File

@@ -124,10 +124,12 @@ public:
// add Gluepoints (if available) // add Gluepoints (if available)
virtual drawinglayer::primitive2d::Primitive2DContainer createGluePointPrimitive2DSequence() const; virtual drawinglayer::primitive2d::Primitive2DContainer createGluePointPrimitive2DSequence() const;
// allow embedding if needed (e.g. for SdrObjects, evtl. Name, Title and description get added). This // Allow embedding if needed (e.g. for SdrObjects, evtl. Name, Title and description get added). This
// is a helper normally used from getViewIndependentPrimitive2DContainer(), but there is one exception // is a helper normally used from getViewIndependentPrimitive2DContainer(), but there is one exception
// for 3D scenes // for 3D scenes.
virtual drawinglayer::primitive2d::Primitive2DContainer embedToObjectSpecificInformation(const drawinglayer::primitive2d::Primitive2DContainer& rSource) const; // We take the param by value, since, for the common case, we can just std::move into the param, and
// std::move the result out, avoiding copying.
virtual drawinglayer::primitive2d::Primitive2DContainer embedToObjectSpecificInformation(drawinglayer::primitive2d::Primitive2DContainer rSource) const;
virtual basegfx::B2DRange getRange( const drawinglayer::geometry::ViewInformation2D& rViewInfo2D ) const; virtual basegfx::B2DRange getRange( const drawinglayer::geometry::ViewInformation2D& rViewInfo2D ) const;

View File

@@ -77,7 +77,7 @@ public:
// allow embedding if needed (e.g. for SdrObjects, evtl. Name, Title and description get added). This // allow embedding if needed (e.g. for SdrObjects, evtl. Name, Title and description get added). This
// is a helper normally used from getViewIndependentPrimitive2DContainer(), but there is one exception // is a helper normally used from getViewIndependentPrimitive2DContainer(), but there is one exception
// for 3D scenes // for 3D scenes
virtual drawinglayer::primitive2d::Primitive2DContainer embedToObjectSpecificInformation(const drawinglayer::primitive2d::Primitive2DContainer& rSource) const override; virtual drawinglayer::primitive2d::Primitive2DContainer embedToObjectSpecificInformation(drawinglayer::primitive2d::Primitive2DContainer aSource) const override;
}; };
}} }}

View File

@@ -1563,7 +1563,7 @@ void CustomAnimationEffect::updatePathFromSdrPathObj( const SdrPathObj& rPathObj
{ {
::tools::Rectangle aBoundRect(0,0,0,0); ::tools::Rectangle aBoundRect(0,0,0,0);
const drawinglayer::primitive2d::Primitive2DContainer xPrimitives(pObj->GetViewContact().getViewIndependentPrimitive2DContainer()); const drawinglayer::primitive2d::Primitive2DContainer& xPrimitives(pObj->GetViewContact().getViewIndependentPrimitive2DContainer());
const drawinglayer::geometry::ViewInformation2D aViewInformation2D; const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
const basegfx::B2DRange aRange(xPrimitives.getB2DRange(aViewInformation2D)); const basegfx::B2DRange aRange(xPrimitives.getB2DRange(aViewInformation2D));

View File

@@ -124,7 +124,7 @@ Impl3DMirrorConstructOverlay::Impl3DMirrorConstructOverlay(const E3dView& rView)
{ {
// use the view-independent primitive representation (without // use the view-independent primitive representation (without
// evtl. GridOffset, that may be applied to the DragEntry individually) // evtl. GridOffset, that may be applied to the DragEntry individually)
const drawinglayer::primitive2d::Primitive2DContainer aNewSequence( const drawinglayer::primitive2d::Primitive2DContainer& aNewSequence(
pObject->GetViewContact().getViewIndependentPrimitive2DContainer()); pObject->GetViewContact().getViewIndependentPrimitive2DContainer());
maFullOverlay.append(aNewSequence); maFullOverlay.append(aNewSequence);
} }

View File

@@ -235,13 +235,13 @@ drawinglayer::primitive2d::Primitive2DContainer const & ViewContact::getViewInde
if(!xNew.empty()) if(!xNew.empty())
{ {
// allow evtl. embedding in object-specific infos, e.g. Name, Title, Description // allow evtl. embedding in object-specific infos, e.g. Name, Title, Description
xNew = embedToObjectSpecificInformation(xNew); xNew = embedToObjectSpecificInformation(std::move(xNew));
} }
if(mxViewIndependentPrimitive2DSequence != xNew) if(mxViewIndependentPrimitive2DSequence != xNew)
{ {
// has changed, copy content // has changed, copy content
const_cast< ViewContact* >(this)->mxViewIndependentPrimitive2DSequence = xNew; const_cast< ViewContact* >(this)->mxViewIndependentPrimitive2DSequence = std::move(xNew);
} }
// return current Primitive2DContainer // return current Primitive2DContainer
@@ -255,10 +255,10 @@ drawinglayer::primitive2d::Primitive2DContainer ViewContact::createGluePointPrim
return drawinglayer::primitive2d::Primitive2DContainer(); return drawinglayer::primitive2d::Primitive2DContainer();
} }
drawinglayer::primitive2d::Primitive2DContainer ViewContact::embedToObjectSpecificInformation(const drawinglayer::primitive2d::Primitive2DContainer& rSource) const drawinglayer::primitive2d::Primitive2DContainer ViewContact::embedToObjectSpecificInformation(drawinglayer::primitive2d::Primitive2DContainer aSource) const
{ {
// nothing to do for default // nothing to do for default
return rSource; return aSource;
} }
basegfx::B2DRange ViewContact::getRange( const drawinglayer::geometry::ViewInformation2D& /*rViewInfo2D*/ ) const basegfx::B2DRange ViewContact::getRange( const drawinglayer::geometry::ViewInformation2D& /*rViewInfo2D*/ ) const

View File

@@ -174,16 +174,16 @@ drawinglayer::primitive2d::Primitive2DContainer ViewContactOfSdrObj::createGlueP
return xRetval; return xRetval;
} }
drawinglayer::primitive2d::Primitive2DContainer ViewContactOfSdrObj::embedToObjectSpecificInformation(const drawinglayer::primitive2d::Primitive2DContainer& rSource) const drawinglayer::primitive2d::Primitive2DContainer ViewContactOfSdrObj::embedToObjectSpecificInformation(drawinglayer::primitive2d::Primitive2DContainer aSource) const
{ {
if(!rSource.empty() && if(!aSource.empty() &&
(!GetSdrObject().GetName().isEmpty() || (!GetSdrObject().GetName().isEmpty() ||
!GetSdrObject().GetTitle().isEmpty() || !GetSdrObject().GetTitle().isEmpty() ||
!GetSdrObject().GetDescription().isEmpty())) !GetSdrObject().GetDescription().isEmpty()))
{ {
const drawinglayer::primitive2d::Primitive2DReference xRef( const drawinglayer::primitive2d::Primitive2DReference xRef(
new drawinglayer::primitive2d::ObjectInfoPrimitive2D( new drawinglayer::primitive2d::ObjectInfoPrimitive2D(
rSource, aSource,
GetSdrObject().GetName(), GetSdrObject().GetName(),
GetSdrObject().GetTitle(), GetSdrObject().GetTitle(),
GetSdrObject().GetDescription())); GetSdrObject().GetDescription()));
@@ -191,7 +191,7 @@ drawinglayer::primitive2d::Primitive2DContainer ViewContactOfSdrObj::embedToObje
return drawinglayer::primitive2d::Primitive2DContainer { xRef }; return drawinglayer::primitive2d::Primitive2DContainer { xRef };
} }
return rSource; return aSource;
} }
}} }}

View File

@@ -135,7 +135,7 @@ namespace sdr
// only visible when transparency involved, but runtime-expensive). // only visible when transparency involved, but runtime-expensive).
// Thus: Just do not iterate, will check behaviour deeply. // Thus: Just do not iterate, will check behaviour deeply.
b3DShape = (nullptr != dynamic_cast< const E3dObject* >(pSdrObjRepresentation)); b3DShape = (nullptr != dynamic_cast< const E3dObject* >(pSdrObjRepresentation));
const drawinglayer::primitive2d::Primitive2DContainer xNew( const drawinglayer::primitive2d::Primitive2DContainer& xNew(
pSdrObjRepresentation->GetViewContact().getViewIndependentPrimitive2DContainer()); pSdrObjRepresentation->GetViewContact().getViewIndependentPrimitive2DContainer());
xGroup.insert(xGroup.end(), xNew.begin(), xNew.end()); xGroup.insert(xGroup.end(), xNew.begin(), xNew.end());
} }

View File

@@ -72,7 +72,7 @@ drawinglayer::primitive2d::Primitive2DContainer ViewContactOfVirtObj::createView
} }
// use method from referenced object to get the Primitive2DContainer // use method from referenced object to get the Primitive2DContainer
const drawinglayer::primitive2d::Primitive2DContainer xSequenceVirtual( const drawinglayer::primitive2d::Primitive2DContainer& xSequenceVirtual(
GetVirtObj().GetReferencedObj().GetViewContact().getViewIndependentPrimitive2DContainer()); GetVirtObj().GetReferencedObj().GetViewContact().getViewIndependentPrimitive2DContainer());
if(!xSequenceVirtual.empty()) if(!xSequenceVirtual.empty())

View File

@@ -1543,7 +1543,7 @@ namespace sdr { namespace contact {
// use the default mechanism. This will create a ControlPrimitive2D without // use the default mechanism. This will create a ControlPrimitive2D without
// handing over a XControl. If not even a XControlModel exists, it will // handing over a XControl. If not even a XControlModel exists, it will
// create the SdrObject fallback visualisation // create the SdrObject fallback visualisation
drawinglayer::primitive2d::Primitive2DContainer aTmp = rViewContactOfUnoControl.getViewIndependentPrimitive2DContainer(); const drawinglayer::primitive2d::Primitive2DContainer& aTmp = rViewContactOfUnoControl.getViewIndependentPrimitive2DContainer();
rContainer.insert(rContainer.end(), aTmp.begin(), aTmp.end()); rContainer.insert(rContainer.end(), aTmp.begin(), aTmp.end());
return; return;
} }

View File

@@ -906,7 +906,7 @@ void SdrObject::RecalcBoundRect()
{ {
// Use view-independent data - we do not want any connections // Use view-independent data - we do not want any connections
// to e.g. GridOffset in SdrObject-level // to e.g. GridOffset in SdrObject-level
const drawinglayer::primitive2d::Primitive2DContainer xPrimitives(GetViewContact().getViewIndependentPrimitive2DContainer()); const drawinglayer::primitive2d::Primitive2DContainer& xPrimitives(GetViewContact().getViewIndependentPrimitive2DContainer());
if(!xPrimitives.empty()) if(!xPrimitives.empty())
{ {
@@ -2328,7 +2328,7 @@ SdrObject* SdrObject::ImpConvertToContourObj(bool bForceLineDash)
{ {
basegfx::B2DPolyPolygon aMergedLineFillPolyPolygon; basegfx::B2DPolyPolygon aMergedLineFillPolyPolygon;
basegfx::B2DPolyPolygon aMergedHairlinePolyPolygon; basegfx::B2DPolyPolygon aMergedHairlinePolyPolygon;
const drawinglayer::primitive2d::Primitive2DContainer xSequence(GetViewContact().getViewIndependentPrimitive2DContainer()); const drawinglayer::primitive2d::Primitive2DContainer & xSequence(GetViewContact().getViewIndependentPrimitive2DContainer());
if(!xSequence.empty()) if(!xSequence.empty())
{ {

View File

@@ -298,7 +298,7 @@ SdrObject* SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const
} }
// get primitives // get primitives
const drawinglayer::primitive2d::Primitive2DContainer xSequence(GetViewContact().getViewIndependentPrimitive2DContainer()); const drawinglayer::primitive2d::Primitive2DContainer & xSequence(GetViewContact().getViewIndependentPrimitive2DContainer());
if(!xSequence.empty()) if(!xSequence.empty())
{ {