summaryrefslogtreecommitdiff
path: root/drawinglayer/source/primitive2d
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2024-02-03 14:54:12 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-02-05 12:10:58 +0100
commit1ae7a81e542c9b072e519d0ea0d4773ed26ca251 (patch)
tree161a33259d409891faa9bf663098e35662fb4487 /drawinglayer/source/primitive2d
parent4259b451c26eec782eb15c7603f6fbb06fc3787e (diff)
tdf#108037 Reduce time and memory consumed exporting to PDF
by avoiding making multiple copies of the Primitive2D container that we pass to TransformPrimitive2D. Instead, make TransformPrimitive2D store its children using a GroupPrimitive2D, which means we can share the GroupPrimitive2D among all the TransformPrimitive2D instances we create. Change-Id: I8a4398f9db6a6ab013ee24ad53836975fba6f3df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162951 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'drawinglayer/source/primitive2d')
-rw-r--r--drawinglayer/source/primitive2d/fillgraphicprimitive2d.cxx3
-rw-r--r--drawinglayer/source/primitive2d/transformprimitive2d.cxx18
2 files changed, 16 insertions, 5 deletions
diff --git a/drawinglayer/source/primitive2d/fillgraphicprimitive2d.cxx b/drawinglayer/source/primitive2d/fillgraphicprimitive2d.cxx
index 8c50993e6033..bc9158687481 100644
--- a/drawinglayer/source/primitive2d/fillgraphicprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/fillgraphicprimitive2d.cxx
@@ -70,11 +70,12 @@ namespace drawinglayer::primitive2d
rGraphic,
basegfx::B2DHomMatrix());
+ rtl::Reference<GroupPrimitive2D> xGroup = new GroupPrimitive2D(std::move(xSeq));
for(const auto &a : aMatrices)
{
rContainer.push_back(new TransformPrimitive2D(
getTransformation() * a,
- Primitive2DContainer(xSeq)));
+ *xGroup));
}
}
else
diff --git a/drawinglayer/source/primitive2d/transformprimitive2d.cxx b/drawinglayer/source/primitive2d/transformprimitive2d.cxx
index 0442cd68aa62..8c36fa9a73b9 100644
--- a/drawinglayer/source/primitive2d/transformprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/transformprimitive2d.cxx
@@ -19,6 +19,7 @@
#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/Tools.hxx>
#include <utility>
@@ -30,18 +31,27 @@ namespace drawinglayer::primitive2d
TransformPrimitive2D::TransformPrimitive2D(
basegfx::B2DHomMatrix aTransformation,
Primitive2DContainer&& aChildren)
- : GroupPrimitive2D(std::move(aChildren)),
- maTransformation(std::move(aTransformation))
+ : maTransformation(std::move(aTransformation)),
+ mxChildren(new GroupPrimitive2D(std::move(aChildren)))
+ {
+ }
+
+ TransformPrimitive2D::TransformPrimitive2D(
+ basegfx::B2DHomMatrix aTransformation,
+ GroupPrimitive2D& rChildren)
+ : maTransformation(std::move(aTransformation)),
+ mxChildren(&rChildren)
{
}
bool TransformPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
{
- if(GroupPrimitive2D::operator==(rPrimitive))
+ if(BasePrimitive2D::operator==(rPrimitive))
{
const TransformPrimitive2D& rCompare = static_cast< const TransformPrimitive2D& >(rPrimitive);
- return (getTransformation() == rCompare.getTransformation());
+ return maTransformation == rCompare.maTransformation
+ && arePrimitive2DReferencesEqual(mxChildren, rCompare.mxChildren);
}
return false;