summaryrefslogtreecommitdiffstats
path: root/drawinglayer
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-09-20 11:26:53 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-09-28 19:19:19 +0200
commit52524e52e8f061aa3f0c63219d954d2d5aefd059 (patch)
tree4e1a6bfbe086aa1a0659f51f4b840b694c52f926 /drawinglayer
parentuse clang-cl's -Zc:dllexportInlines- for Skia (tdf#144598) (diff)
downloadcore-52524e52e8f061aa3f0c63219d954d2d5aefd059.tar.gz
core-52524e52e8f061aa3f0c63219d954d2d5aefd059.zip
tdf#144091 svx: fix unwanted blur of shadow from table cell fill
Initial render support for shadows of table shapes were added in commit a75bf43a8d6c5dec6dcc86908c142ceec541aa8c (tdf#129961 svx: add rendering for table shadow as direct format, 2020-12-02). That already noticed a trick with the shadow of table shapes: the shadow is generate from the cell fill and the border, but not from the text. An additional trick is that when blur is enabled for the table shape's shadow, then only the border should be blurred, not the cell fill. In the bug document's case, the effective cell background was gray, with a semi-transparent red shadow. We used to render cc0000 with blur and cccccc without blur, now we correctly render cca3a3, matching PowerPoint. (cherry picked from commit 37a52d30bbfcf1d073779b50139c4dafa507be4b) Conflicts: drawinglayer/source/primitive2d/shadowprimitive2d.cxx drawinglayer/source/tools/primitive2dxmldump.cxx include/drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx Change-Id: I7326a5f6254cf19b2d05181084c78e734ff7a7b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122383 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122760 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/source/primitive2d/shadowprimitive2d.cxx71
-rw-r--r--drawinglayer/source/processor2d/vclpixelprocessor2d.cxx10
-rw-r--r--drawinglayer/source/tools/primitive2dxmldump.cxx33
3 files changed, 97 insertions, 17 deletions
diff --git a/drawinglayer/source/primitive2d/shadowprimitive2d.cxx b/drawinglayer/source/primitive2d/shadowprimitive2d.cxx
index f0efd64c7bdc..516cc0c0bd4a 100644
--- a/drawinglayer/source/primitive2d/shadowprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/shadowprimitive2d.cxx
@@ -30,6 +30,27 @@ 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,
@@ -66,21 +87,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(
- getChildren(),
- aBColorModifier));
- const Primitive2DContainer aSequenceB { xRefA };
-
- // build transformed primitiveVector with shadow offset and add to target
- rVisitor.append(new TransformPrimitive2D(getShadowTransform(), 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 47f39e87bf8b..393c40c90842 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -1160,10 +1160,18 @@ 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();
- process(rCandidate);
+ aContainer.clear();
+ rCandidate.get2DDecompositionWithBlur(aContainer, getViewInformation2D());
+ process(aContainer);
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 203f6d008d15..1342fd39354f 100644
--- a/drawinglayer/source/tools/primitive2dxmldump.cxx
+++ b/drawinglayer/source/tools/primitive2dxmldump.cxx
@@ -517,11 +517,42 @@ 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());