diff options
author | Armin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de> | 2022-10-17 19:26:33 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-10-18 08:10:01 +0200 |
commit | 008cf1285d8c9ab293ebf0de26317a9df9725742 (patch) | |
tree | 362574a8b7e1c07cb010e5f7e98ea835ed1bc3c4 /drawinglayer | |
parent | aa674ac4b5018c7e1ba8e60135ac5202fa67529a (diff) |
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 <vmiklos@collabora.com>
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx | 25 |
1 files changed, 22 insertions, 3 deletions
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( |