diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-09-23 16:55:19 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-09-27 08:27:04 +0200 |
commit | 1f8687d2261082d1a76527c41bc1010ebcf0ddd1 (patch) | |
tree | 0a269391ff1183441e30235426b64a862d073d8f /drawinglayer | |
parent | 2b96bf1fd8f4287a06b79dbec14114ca6c035731 (diff) |
Related: tdf#144091 svx: fix interaction of transp cell fill and transp shadow
This is a follow-up to commit 37a52d30bbfcf1d073779b50139c4dafa507be4b
(tdf#144091 svx: fix unwanted blur of shadow from table cell fill,
2021-09-20), where it turned out that the original bugdoc was just a
special case of almost full transparency (80%), that's why avoiding the
blur fixed the problem.
A more general approach instead is to multiply the alpha or the cell
fill of table shapes and the alpha of the shadow itself. The end result
is the same (80% transparency) for the first bugdoc, but this gives back
the blur on the second bugdoc.
(cherry picked from commit 00fa364a2403dc23a786d3f91fde06e10b3a4a9a)
Conflicts:
drawinglayer/source/primitive2d/shadowprimitive2d.cxx
drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
include/drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx
svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
Change-Id: I63560e3a73473c70157ecee8365ec7154217f269
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122565
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/primitive2d/shadowprimitive2d.cxx | 71 | ||||
-rw-r--r-- | drawinglayer/source/processor2d/vclpixelprocessor2d.cxx | 12 | ||||
-rw-r--r-- | drawinglayer/source/tools/primitive2dxmldump.cxx | 4 |
3 files changed, 19 insertions, 68 deletions
diff --git a/drawinglayer/source/primitive2d/shadowprimitive2d.cxx b/drawinglayer/source/primitive2d/shadowprimitive2d.cxx index 516cc0c0bd4a..f0efd64c7bdc 100644 --- a/drawinglayer/source/primitive2d/shadowprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/shadowprimitive2d.cxx @@ -30,27 +30,6 @@ using namespace com::sun::star; namespace drawinglayer::primitive2d { -namespace -{ -void get2DDecompositionOfChildren(const ShadowPrimitive2D& rPrimitive, - Primitive2DDecompositionVisitor& rVisitor, - const Primitive2DContainer& rChildren) -{ - if (rChildren.empty()) - return; - - // create a modifiedColorPrimitive containing the shadow color and the content - const basegfx::BColorModifierSharedPtr aBColorModifier - = std::make_shared<basegfx::BColorModifier_replace>(rPrimitive.getShadowColor()); - const Primitive2DReference xRefA(new ModifiedColorPrimitive2D(rChildren, aBColorModifier)); - Primitive2DContainer aSequenceB{ xRefA }; - - // build transformed primitiveVector with shadow offset and add to target - rVisitor.append( - new TransformPrimitive2D(rPrimitive.getShadowTransform(), std::move(aSequenceB))); -} -} - ShadowPrimitive2D::ShadowPrimitive2D( const basegfx::B2DHomMatrix& rShadowTransform, const basegfx::BColor& rShadowColor, @@ -87,41 +66,21 @@ void get2DDecompositionOfChildren(const ShadowPrimitive2D& rPrimitive, void ShadowPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& /*rViewInformation*/) const { - get2DDecompositionOfChildren(*this, rVisitor, getChildren()); - } - - void ShadowPrimitive2D::get2DDecompositionWithoutBlur( - Primitive2DDecompositionVisitor& rVisitor, - const geometry::ViewInformation2D& /*rViewInformation*/) const - { - Primitive2DContainer aChildren; - // Only decompose children which are not blurred (they opted in for this). - std::copy_if(getChildren().begin(), getChildren().end(), std::back_inserter(aChildren), - [](const Primitive2DReference& xChild) { - auto pChild - = dynamic_cast<primitive2d::BufferedDecompositionPrimitive2D*>( - xChild.get()); - return pChild && pChild->getExcludeFromBlur(); - }); - - get2DDecompositionOfChildren(*this, rVisitor, aChildren); - } - - void ShadowPrimitive2D::get2DDecompositionWithBlur( - Primitive2DDecompositionVisitor& rVisitor, - const geometry::ViewInformation2D& /*rViewInformation*/) const - { - // Only decompose children which are blurred (which is the default). - Primitive2DContainer aChildren; - std::copy_if(getChildren().begin(), getChildren().end(), std::back_inserter(aChildren), - [](const Primitive2DReference& xChild) { - auto pChild - = dynamic_cast<primitive2d::BufferedDecompositionPrimitive2D*>( - xChild.get()); - return !pChild || !pChild->getExcludeFromBlur(); - }); - - get2DDecompositionOfChildren(*this, rVisitor, aChildren); + if(getChildren().empty()) + return; + + // create a modifiedColorPrimitive containing the shadow color and the content + const basegfx::BColorModifierSharedPtr aBColorModifier = + std::make_shared<basegfx::BColorModifier_replace>( + getShadowColor()); + const Primitive2DReference xRefA( + new ModifiedColorPrimitive2D( + getChildren(), + aBColorModifier)); + const Primitive2DContainer aSequenceB { xRefA }; + + // build transformed primitiveVector with shadow offset and add to target + rVisitor.append(new TransformPrimitive2D(getShadowTransform(), aSequenceB)); } // provide unique ID diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index 5e50d1ee2f81..5e6c6a73cd60 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -1037,7 +1037,7 @@ void VclPixelProcessor2D::processGlowPrimitive2D(const primitive2d::GlowPrimitiv const sal_uInt8 nAlpha = rCandidate.getGlowColor().GetAlpha(); impBufferDevice aBufferDevice(*mpOutputDevice, aRange); - if (aBufferDevice.isVisible()) + if (aBufferDevice.isVisible() && !aRange.isEmpty()) { // remember last OutDev and set to content OutputDevice* pLastOutputDevice = mpOutputDevice; @@ -1160,18 +1160,10 @@ void VclPixelProcessor2D::processShadowPrimitive2D(const primitive2d::ShadowPrim impBufferDevice aBufferDevice(*mpOutputDevice, aRange); if (aBufferDevice.isVisible()) { - // Process children which don't want blur. - primitive2d::Primitive2DContainer aContainer; - rCandidate.get2DDecompositionWithoutBlur(aContainer, getViewInformation2D()); - process(aContainer); - - // Process children which want blur. OutputDevice* pLastOutputDevice = mpOutputDevice; mpOutputDevice = &aBufferDevice.getContent(); - aContainer.clear(); - rCandidate.get2DDecompositionWithBlur(aContainer, getViewInformation2D()); - process(aContainer); + process(rCandidate); const tools::Rectangle aRect(static_cast<tools::Long>(std::floor(aRange.getMinX())), static_cast<tools::Long>(std::floor(aRange.getMinY())), diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx b/drawinglayer/source/tools/primitive2dxmldump.cxx index da6cb41fea69..1e99ac91ed54 100644 --- a/drawinglayer/source/tools/primitive2dxmldump.cxx +++ b/drawinglayer/source/tools/primitive2dxmldump.cxx @@ -601,8 +601,8 @@ void Primitive2dXmlDump::decomposeAndWrite( if (pBufferedDecomposition) { rWriter.attribute( - "excludeFromBlur", - OString::boolean(pBufferedDecomposition->getExcludeFromBlur())); + "transparenceForShadow", + OString::number(pBufferedDecomposition->getTransparenceForShadow())); } drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer; |