summaryrefslogtreecommitdiff
path: root/svx/source/sdr
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2020-05-12 20:05:54 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2020-05-13 23:29:29 +0200
commitcbc13ac0624685582ebd4634812681274db803aa (patch)
treef9a5e856161f4ea5290cc31ea892843a75d8bcc0 /svx/source/sdr
parent4907531966880f2bb4bb14b1c159865909000842 (diff)
tdf#49247: draw soft edges
This factors out the common code for blurring used both in glow and soft edges into ProcessAndBlurAlphaMask. Also this reverts commit a98bdbae459ad7341bf7f484c402e77e4062cd16, since its use was removed from VclPixelProcessor2D. Change-Id: Icd7fdb06bef3932ff3b9ce7e283b515b15d246a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94087 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'svx/source/sdr')
-rw-r--r--svx/source/sdr/attribute/sdreffectstextattribute.cxx15
-rw-r--r--svx/source/sdr/attribute/sdrlineeffectstextattribute.cxx5
-rw-r--r--svx/source/sdr/attribute/sdrlinefilleffectstextattribute.cxx5
-rw-r--r--svx/source/sdr/primitive2d/sdrattributecreator.cxx25
-rw-r--r--svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx7
-rw-r--r--svx/source/sdr/primitive2d/sdrdecompositiontools.cxx11
-rw-r--r--svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx7
7 files changed, 59 insertions, 16 deletions
diff --git a/svx/source/sdr/attribute/sdreffectstextattribute.cxx b/svx/source/sdr/attribute/sdreffectstextattribute.cxx
index 05775f0beffa..acf9a2ee5daf 100644
--- a/svx/source/sdr/attribute/sdreffectstextattribute.cxx
+++ b/svx/source/sdr/attribute/sdreffectstextattribute.cxx
@@ -26,10 +26,12 @@ namespace drawinglayer::attribute
SdrEffectsTextAttribute::SdrEffectsTextAttribute(
const SdrShadowAttribute& rShadow,
const SdrTextAttribute& rTextAttribute,
- const SdrGlowAttribute& rGlow)
+ const SdrGlowAttribute& rGlow,
+ sal_Int32 nSoftEdgeRadius)
: maShadow(rShadow),
maTextAttribute(rTextAttribute),
- maGlow(rGlow)
+ maGlow(rGlow),
+ mnSoftEdgeRadius(nSoftEdgeRadius)
{
}
@@ -42,7 +44,8 @@ namespace drawinglayer::attribute
SdrEffectsTextAttribute::SdrEffectsTextAttribute(const SdrEffectsTextAttribute& rCandidate)
: maShadow(rCandidate.getShadow()),
maTextAttribute(rCandidate.getText()),
- maGlow(rCandidate.maGlow)
+ maGlow(rCandidate.maGlow),
+ mnSoftEdgeRadius(rCandidate.mnSoftEdgeRadius)
{
}
@@ -51,6 +54,7 @@ namespace drawinglayer::attribute
maShadow = rCandidate.getShadow();
maTextAttribute = rCandidate.getText();
maGlow = rCandidate.maGlow;
+ mnSoftEdgeRadius = rCandidate.mnSoftEdgeRadius;
return *this;
}
@@ -58,14 +62,15 @@ namespace drawinglayer::attribute
bool SdrEffectsTextAttribute::isDefault() const
{
return (getShadow().isDefault()
- && getText().isDefault() && maGlow.isDefault());
+ && getText().isDefault() && maGlow.isDefault() && getSoftEdgeRadius() == 0);
}
bool SdrEffectsTextAttribute::operator==(const SdrEffectsTextAttribute& rCandidate) const
{
return (getShadow() == rCandidate.getShadow()
&& getText() == rCandidate.getText()
- && getGlow() == rCandidate.getGlow());
+ && getGlow() == rCandidate.getGlow()
+ && getSoftEdgeRadius() == rCandidate.getSoftEdgeRadius());
}
} // end of namespace
diff --git a/svx/source/sdr/attribute/sdrlineeffectstextattribute.cxx b/svx/source/sdr/attribute/sdrlineeffectstextattribute.cxx
index a7a5e265427c..d2add96388f2 100644
--- a/svx/source/sdr/attribute/sdrlineeffectstextattribute.cxx
+++ b/svx/source/sdr/attribute/sdrlineeffectstextattribute.cxx
@@ -28,8 +28,9 @@ namespace drawinglayer::attribute
const SdrLineStartEndAttribute& rLineStartEnd,
const SdrShadowAttribute& rShadow,
const SdrTextAttribute& rTextAttribute,
- const SdrGlowAttribute& rGlow)
- : SdrEffectsTextAttribute(rShadow, rTextAttribute, rGlow),
+ const SdrGlowAttribute& rGlow,
+ sal_Int32 nSoftEdgeRadius)
+ : SdrEffectsTextAttribute(rShadow, rTextAttribute, rGlow, nSoftEdgeRadius),
maLine(rLine),
maLineStartEnd(rLineStartEnd)
{
diff --git a/svx/source/sdr/attribute/sdrlinefilleffectstextattribute.cxx b/svx/source/sdr/attribute/sdrlinefilleffectstextattribute.cxx
index 6200b7b51308..c9199435fed4 100644
--- a/svx/source/sdr/attribute/sdrlinefilleffectstextattribute.cxx
+++ b/svx/source/sdr/attribute/sdrlinefilleffectstextattribute.cxx
@@ -30,8 +30,9 @@ namespace drawinglayer::attribute
const SdrShadowAttribute& rShadow,
const FillGradientAttribute& rFillFloatTransGradient,
const SdrTextAttribute& rTextAttribute,
- const SdrGlowAttribute& rGlow)
- : SdrLineEffectsTextAttribute(rLine, rLineStartEnd, rShadow, rTextAttribute, rGlow),
+ const SdrGlowAttribute& rGlow,
+ sal_Int32 nSoftEdgeRadius)
+ : SdrLineEffectsTextAttribute(rLine, rLineStartEnd, rShadow, rTextAttribute, rGlow, nSoftEdgeRadius),
maFill(rFill),
maFillFloatTransGradient(rFillFloatTransGradient)
{
diff --git a/svx/source/sdr/primitive2d/sdrattributecreator.cxx b/svx/source/sdr/primitive2d/sdrattributecreator.cxx
index 5f036976d90a..41452ecf4826 100644
--- a/svx/source/sdr/primitive2d/sdrattributecreator.cxx
+++ b/svx/source/sdr/primitive2d/sdrattributecreator.cxx
@@ -227,6 +227,11 @@ namespace drawinglayer
attribute::SdrGlowAttribute glowAttr{ nRadius, aColor };
return glowAttr;
}
+
+ sal_Int32 getSoftEdgeRadius(const SfxItemSet& rSet)
+ {
+ return rSet.Get(SDRATTR_SOFTEDGE_RAD).GetValue();
+ }
} // end of anonymous namespace
} // end of namespace drawinglayer
@@ -748,8 +753,9 @@ namespace drawinglayer::primitive2d
// try shadow
const attribute::SdrShadowAttribute aShadow(createNewSdrShadowAttribute(rSet));
const attribute::SdrGlowAttribute aGlow(createNewSdrGlowAttribute(rSet));
+ const sal_Int32 nSoftEdgeRadius(getSoftEdgeRadius(rSet));
- return attribute::SdrEffectsTextAttribute(aShadow, aText, aGlow);
+ return attribute::SdrEffectsTextAttribute(aShadow, aText, aGlow, nSoftEdgeRadius);
}
attribute::SdrLineEffectsTextAttribute createNewSdrLineEffectsTextAttribute(
@@ -792,9 +798,11 @@ namespace drawinglayer::primitive2d
{
// try shadow
const attribute::SdrShadowAttribute aShadow(createNewSdrShadowAttribute(rSet));
- attribute::SdrGlowAttribute aGlow = createNewSdrGlowAttribute(rSet);
+ const attribute::SdrGlowAttribute aGlow = createNewSdrGlowAttribute(rSet);
+ const sal_Int32 nSoftEdgeRadius(getSoftEdgeRadius(rSet));
- return attribute::SdrLineEffectsTextAttribute(aLine, aLineStartEnd, aShadow, aText, aGlow);
+ return attribute::SdrLineEffectsTextAttribute(aLine, aLineStartEnd, aShadow, aText,
+ aGlow, nSoftEdgeRadius);
}
return attribute::SdrLineEffectsTextAttribute();
@@ -853,13 +861,16 @@ namespace drawinglayer::primitive2d
if(bHasContent || !aLine.isDefault() || !aFill.isDefault() || !aText.isDefault())
{
// try shadow
- attribute::SdrShadowAttribute aShadow = createNewSdrShadowAttribute(rSet);
+ const attribute::SdrShadowAttribute aShadow = createNewSdrShadowAttribute(rSet);
// glow
- attribute::SdrGlowAttribute aGlow = createNewSdrGlowAttribute(rSet);
+ const attribute::SdrGlowAttribute aGlow = createNewSdrGlowAttribute(rSet);
+
+ const sal_Int32 nSoftEdgeRadius(getSoftEdgeRadius(rSet));
- return attribute::SdrLineFillEffectsTextAttribute(
- aLine, aFill, aLineStartEnd, aShadow, aFillFloatTransGradient, aText, aGlow);
+ return attribute::SdrLineFillEffectsTextAttribute(aLine, aFill, aLineStartEnd,
+ aShadow, aFillFloatTransGradient,
+ aText, aGlow, nSoftEdgeRadius);
}
return attribute::SdrLineFillEffectsTextAttribute();
diff --git a/svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx
index 5de10ebe523a..f237369e3562 100644
--- a/svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx
+++ b/svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx
@@ -37,6 +37,13 @@ namespace drawinglayer::primitive2d
{
Primitive2DContainer aRetval(getSubPrimitives());
+ // Soft edges should be before text, since text is not affected by soft edges
+ if (!aRetval.empty() && getSdrSTAttribute().getSoftEdgeRadius())
+ {
+ aRetval = createEmbeddedSoftEdgePrimitive(aRetval,
+ getSdrSTAttribute().getSoftEdgeRadius());
+ }
+
// add text
if(!getSdrSTAttribute().getText().isDefault())
{
diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
index c5d0d6c0bdc4..59b38300d375 100644
--- a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
+++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
@@ -23,6 +23,7 @@
#include <drawinglayer/primitive2d/PolyPolygonHatchPrimitive2D.hxx>
#include <drawinglayer/primitive2d/PolyPolygonGraphicPrimitive2D.hxx>
#include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx>
+#include <drawinglayer/primitive2d/softedgeprimitive2d.hxx>
#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
#include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
@@ -558,6 +559,16 @@ namespace drawinglayer::primitive2d
return aRetval;
}
+ Primitive2DContainer createEmbeddedSoftEdgePrimitive(const Primitive2DContainer& rContent,
+ sal_Int32 nRadius)
+ {
+ if (rContent.empty() || !nRadius)
+ return rContent;
+ Primitive2DContainer aRetval(1);
+ aRetval[0] = Primitive2DReference(new SoftEdgePrimitive2D(nRadius, rContent));
+ return aRetval;
+ }
+
} // end of namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx
index f4b1848eb31e..8f8925201e26 100644
--- a/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx
+++ b/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx
@@ -97,6 +97,13 @@ namespace drawinglayer::primitive2d
}
}
+ // Soft edges should be before text, since text is not affected by soft edges
+ if (!aRetval.empty() && getSdrLFSTAttribute().getSoftEdgeRadius())
+ {
+ aRetval = createEmbeddedSoftEdgePrimitive(
+ aRetval, getSdrLFSTAttribute().getSoftEdgeRadius());
+ }
+
// add text
if(!getSdrLFSTAttribute().getText().isDefault())
{