drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx | 25 ++++++++-- 1 file changed, 22 insertions(+), 3 deletions(-)
New commits: commit 008cf1285d8c9ab293ebf0de26317a9df9725742 Author: Armin Le Grand (allotropia) <armin.le.grand.ext...@allotropia.de> AuthorDate: Mon Oct 17 19:26:33 2022 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Oct 18 08:10:01 2022 +0200 Added handling of transparence to BackgroundColorPrimitive2D ...which was missing in ::create2DDecomposition. Change-Id: I585aa884e4d19bf6f34783d254f502a4c3dd6733 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141470 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx b/drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx index 8f68d9e73ba3..5fbb5dd06e2a 100644 --- a/drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx @@ -21,6 +21,7 @@ #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> #include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx> +#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> @@ -32,11 +33,29 @@ namespace drawinglayer::primitive2d { void BackgroundColorPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const { - if(!rViewInformation.getViewport().isEmpty()) + // transparency invalid or completely transparent, done + if(getTransparency() < 0.0 || getTransparency() >= 1.0) + return; + + // no viewport, not visible, done + if(rViewInformation.getViewport().isEmpty()) + return; + + // create decompose geometry + const basegfx::B2DPolygon aOutline(basegfx::utils::createPolygonFromRect(rViewInformation.getViewport())); + Primitive2DReference aDecompose(new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aOutline), getBColor())); + + if(getTransparency() != 0.0) { - const basegfx::B2DPolygon aOutline(basegfx::utils::createPolygonFromRect(rViewInformation.getViewport())); - rContainer.push_back(new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aOutline), getBColor())); + // if used, embed decompose geometry to unified transparency + Primitive2DContainer aContent { aDecompose }; + aDecompose = Primitive2DReference( + new UnifiedTransparencePrimitive2D( + std::move(aContent), + getTransparency())); } + + rContainer.push_back(aDecompose); } BackgroundColorPrimitive2D::BackgroundColorPrimitive2D(