diff options
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/primitive2d/shadowprimitive2d.cxx | 73 | ||||
-rw-r--r-- | drawinglayer/source/processor2d/vclpixelprocessor2d.cxx | 6 | ||||
-rw-r--r-- | drawinglayer/source/tools/primitive2dxmldump.cxx | 33 |
3 files changed, 95 insertions, 17 deletions
diff --git a/drawinglayer/source/primitive2d/shadowprimitive2d.cxx b/drawinglayer/source/primitive2d/shadowprimitive2d.cxx index 6ea066b35754..3d4bbdfecb92 100644 --- a/drawinglayer/source/primitive2d/shadowprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/shadowprimitive2d.cxx @@ -22,6 +22,7 @@ #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx> #include <drawinglayer/primitive2d/transformprimitive2d.hxx> #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> +#include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> #include <memory> @@ -30,6 +31,28 @@ 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(Primitive2DContainer(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, @@ -66,21 +89,41 @@ namespace drawinglayer::primitive2d void ShadowPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& /*rViewInformation*/) const { - 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( - Primitive2DContainer(getChildren()), - aBColorModifier)); - Primitive2DContainer aSequenceB { xRefA }; - - // build transformed primitiveVector with shadow offset and add to target - rVisitor.append(new TransformPrimitive2D(getShadowTransform(), std::move(aSequenceB))); + 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); } // provide unique ID diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index 58f5f2881402..be53d4712aa3 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -1166,10 +1166,14 @@ void VclPixelProcessor2D::processShadowPrimitive2D(const primitive2d::ShadowPrim impBufferDevice aBufferDevice(*mpOutputDevice, aRange); if (aBufferDevice.isVisible()) { + // Process children which don't want blur. + rCandidate.get2DDecompositionWithoutBlur(*this, getViewInformation2D()); + + // Process children which want blur. OutputDevice* pLastOutputDevice = mpOutputDevice; mpOutputDevice = &aBufferDevice.getContent(); - process(rCandidate); + rCandidate.get2DDecompositionWithBlur(*this, getViewInformation2D()); 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 d126b7100c3b..d0496b482669 100644 --- a/drawinglayer/source/tools/primitive2dxmldump.cxx +++ b/drawinglayer/source/tools/primitive2dxmldump.cxx @@ -608,12 +608,43 @@ void Primitive2dXmlDump::decomposeAndWrite( break; } + case PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D: + { + // ModifiedColorPrimitive2D. + rWriter.startElement("modifiedColor"); + drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer; + pBasePrimitive->get2DDecomposition(aPrimitiveContainer, + drawinglayer::geometry::ViewInformation2D()); + decomposeAndWrite(aPrimitiveContainer, rWriter); + rWriter.endElement(); + break; + } + default: { - rWriter.startElement("unhandled"); + OString aName("unhandled"); + switch (nId) + { + case PRIMITIVE2D_ID_RANGE_SVX | 14: // PRIMITIVE2D_ID_SDRCELLPRIMITIVE2D + { + aName = "sdrCell"; + break; + } + } + rWriter.startElement(aName); rWriter.attribute("id", OUStringToOString(sCurrentElementTag, RTL_TEXTENCODING_UTF8)); rWriter.attribute("idNumber", nId); + + auto pBufferedDecomposition + = dynamic_cast<const BufferedDecompositionPrimitive2D*>(pBasePrimitive); + if (pBufferedDecomposition) + { + rWriter.attribute( + "excludeFromBlur", + OString::boolean(pBufferedDecomposition->getExcludeFromBlur())); + } + drawinglayer::primitive2d::Primitive2DContainer aPrimitiveContainer; pBasePrimitive->get2DDecomposition(aPrimitiveContainer, drawinglayer::geometry::ViewInformation2D()); |