summaryrefslogtreecommitdiff
path: root/drawinglayer/source/primitive2d/texteffectprimitive2d.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2024-02-04 13:15:01 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-02-12 11:36:05 +0100
commit3b83c6ac804cf7adcea036d1fb7dda113a72f457 (patch)
tree8f1af5f06f236a1dcb9ca313f3dedd3aa8c16390 /drawinglayer/source/primitive2d/texteffectprimitive2d.cxx
parent582ef812702413dbe7fb0f132bca3e3e4c2e1d40 (diff)
make BufferedDecompositionPrimitive2D store a Primitive2DReference..
.. instead of a Primitive2DContainer. The container very frequently contains only a single item, since the decomposition method often sticks only a single top-level node in there, so it turns out to be a net loss overall, memory consumption-wise. Also, if we return a single Primitive2DReference from a BufferedDecomposition, that maximises the sharing of data between the BufferedDecomposition objects at the bottom of the decomposed tree, and objects higher up. Change-Id: Iaf272e60e2997299cc35a1bd209c51b6b79e9a8b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162976 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'drawinglayer/source/primitive2d/texteffectprimitive2d.cxx')
-rw-r--r--drawinglayer/source/primitive2d/texteffectprimitive2d.cxx39
1 files changed, 20 insertions, 19 deletions
diff --git a/drawinglayer/source/primitive2d/texteffectprimitive2d.cxx b/drawinglayer/source/primitive2d/texteffectprimitive2d.cxx
index dae397e1abd8..df4ea9a692a3 100644
--- a/drawinglayer/source/primitive2d/texteffectprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/texteffectprimitive2d.cxx
@@ -28,8 +28,8 @@ namespace drawinglayer::primitive2d
{
const double fDiscreteSize(1.1);
-void TextEffectPrimitive2D::create2DDecomposition(
- Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const
+Primitive2DReference TextEffectPrimitive2D::create2DDecomposition(
+ const geometry::ViewInformation2D& rViewInformation) const
{
// get the distance of one discrete units from target display. Use between 1.0 and sqrt(2) to
// have good results on rotated objects, too
@@ -37,6 +37,7 @@ void TextEffectPrimitive2D::create2DDecomposition(
* basegfx::B2DVector(fDiscreteSize, fDiscreteSize));
const basegfx::B2DVector aDiagonalDistance(aDistance * (1.0 / 1.44));
+ Primitive2DContainer aContainer;
switch (getTextEffectStyle2D())
{
case TextEffectStyle2D::ReliefEmbossed:
@@ -84,14 +85,14 @@ void TextEffectPrimitive2D::create2DDecomposition(
const Primitive2DReference xModifiedColor(new ModifiedColorPrimitive2D(
Primitive2DContainer(getTextContent()), aBColorModifierToGray));
- rContainer.push_back(
+ aContainer.push_back(
new TransformPrimitive2D(aTransform, Primitive2DContainer{ xModifiedColor }));
// add original, too
const basegfx::BColorModifierSharedPtr aBColorModifierToWhite
= std::make_shared<basegfx::BColorModifier_replace>(basegfx::BColor(1.0));
- rContainer.push_back(new ModifiedColorPrimitive2D(
+ aContainer.push_back(new ModifiedColorPrimitive2D(
Primitive2DContainer(getTextContent()), aBColorModifierToWhite));
}
else
@@ -103,11 +104,11 @@ void TextEffectPrimitive2D::create2DDecomposition(
const Primitive2DReference xModifiedColor(new ModifiedColorPrimitive2D(
Primitive2DContainer(getTextContent()), aBColorModifierToGray));
- rContainer.push_back(
+ aContainer.push_back(
new TransformPrimitive2D(aTransform, Primitive2DContainer{ xModifiedColor }));
// add original, too
- rContainer.push_back(new GroupPrimitive2D(Primitive2DContainer(getTextContent())));
+ aContainer.push_back(new GroupPrimitive2D(Primitive2DContainer(getTextContent())));
}
break;
@@ -119,53 +120,54 @@ void TextEffectPrimitive2D::create2DDecomposition(
aTransform.set(0, 2, aDistance.getX());
aTransform.set(1, 2, 0.0);
- rContainer.push_back(
+ aContainer.push_back(
new TransformPrimitive2D(aTransform, Primitive2DContainer(getTextContent())));
aTransform.set(0, 2, aDiagonalDistance.getX());
aTransform.set(1, 2, aDiagonalDistance.getY());
- rContainer.push_back(
+ aContainer.push_back(
new TransformPrimitive2D(aTransform, Primitive2DContainer(getTextContent())));
aTransform.set(0, 2, 0.0);
aTransform.set(1, 2, aDistance.getY());
- rContainer.push_back(
+ aContainer.push_back(
new TransformPrimitive2D(aTransform, Primitive2DContainer(getTextContent())));
aTransform.set(0, 2, -aDiagonalDistance.getX());
aTransform.set(1, 2, aDiagonalDistance.getY());
- rContainer.push_back(
+ aContainer.push_back(
new TransformPrimitive2D(aTransform, Primitive2DContainer(getTextContent())));
aTransform.set(0, 2, -aDistance.getX());
aTransform.set(1, 2, 0.0);
- rContainer.push_back(
+ aContainer.push_back(
new TransformPrimitive2D(aTransform, Primitive2DContainer(getTextContent())));
aTransform.set(0, 2, -aDiagonalDistance.getX());
aTransform.set(1, 2, -aDiagonalDistance.getY());
- rContainer.push_back(
+ aContainer.push_back(
new TransformPrimitive2D(aTransform, Primitive2DContainer(getTextContent())));
aTransform.set(0, 2, 0.0);
aTransform.set(1, 2, -aDistance.getY());
- rContainer.push_back(
+ aContainer.push_back(
new TransformPrimitive2D(aTransform, Primitive2DContainer(getTextContent())));
aTransform.set(0, 2, aDiagonalDistance.getX());
aTransform.set(1, 2, -aDiagonalDistance.getY());
- rContainer.push_back(
+ aContainer.push_back(
new TransformPrimitive2D(aTransform, Primitive2DContainer(getTextContent())));
// at last, place original over it, but force to white
const basegfx::BColorModifierSharedPtr aBColorModifierToWhite
= std::make_shared<basegfx::BColorModifier_replace>(basegfx::BColor(1.0, 1.0, 1.0));
- rContainer.push_back(new ModifiedColorPrimitive2D(
+ aContainer.push_back(new ModifiedColorPrimitive2D(
Primitive2DContainer(getTextContent()), aBColorModifierToWhite));
break;
}
}
+ return new GroupPrimitive2D(std::move(aContainer));
}
TextEffectPrimitive2D::TextEffectPrimitive2D(Primitive2DContainer&& rTextContent,
@@ -213,17 +215,16 @@ void TextEffectPrimitive2D::get2DDecomposition(
Primitive2DDecompositionVisitor& rVisitor,
const geometry::ViewInformation2D& rViewInformation) const
{
- if (!getBuffered2DDecomposition().empty())
+ if (getBuffered2DDecomposition())
{
if (maLastObjectToViewTransformation != rViewInformation.getObjectToViewTransformation())
{
// conditions of last local decomposition have changed, delete
- const_cast<TextEffectPrimitive2D*>(this)->setBuffered2DDecomposition(
- Primitive2DContainer());
+ const_cast<TextEffectPrimitive2D*>(this)->setBuffered2DDecomposition(nullptr);
}
}
- if (getBuffered2DDecomposition().empty())
+ if (!getBuffered2DDecomposition())
{
// remember ViewRange and ViewTransformation
const_cast<TextEffectPrimitive2D*>(this)->maLastObjectToViewTransformation