diff options
author | Armin Le Grand (Collabora) <Armin.Le.Grand@me.com> | 2024-07-20 15:01:37 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2024-07-20 19:31:36 +0200 |
commit | 45c45e97e1b3a54689557644edd2ea6c3e6af149 (patch) | |
tree | 278c2748625083e48de3ce66f00bf3d5087d51ee /drawinglayer | |
parent | 0eb68857daef5b0fcda8bfe501d3f0a683590a1f (diff) |
CairoSDPR: make use of RGBA PolyPolygon in more cases
Change-Id: I7cd93e5452bce96eef295c766f4cb391ddd67250
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170792
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Tested-by: Jenkins
Diffstat (limited to 'drawinglayer')
3 files changed, 43 insertions, 42 deletions
diff --git a/drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx b/drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx index ea1b2a56942a..1377ff28ebf3 100644 --- a/drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx @@ -21,7 +21,7 @@ #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> #include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx> -#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx> +#include <drawinglayer/primitive2d/PolyPolygonRGBAPrimitive2D.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> @@ -43,19 +43,20 @@ namespace drawinglayer::primitive2d // create decompose geometry const basegfx::B2DPolygon aOutline(basegfx::utils::createPolygonFromRect(rViewInformation.getViewport())); - Primitive2DReference aDecompose(new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aOutline), getBColor())); - if(getTransparency() != 0.0) + if (basegfx::fTools::lessOrEqual(getTransparency(), 0.0)) { - // if used, embed decompose geometry to unified transparency - Primitive2DContainer aContent { aDecompose }; - aDecompose = - new UnifiedTransparencePrimitive2D( - std::move(aContent), - getTransparency()); + // no transparency + return Primitive2DReference { + new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aOutline), getBColor()) }; } - return aDecompose; + // if transparent, use PolyPolygonRGBAPrimitive2D + return Primitive2DReference { + new PolyPolygonRGBAPrimitive2D( + basegfx::B2DPolyPolygon(aOutline), + getBColor(), + getTransparency()) }; } BackgroundColorPrimitive2D::BackgroundColorPrimitive2D( diff --git a/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx b/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx index 24f979ce2c9d..3c6e7ab6b494 100644 --- a/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/svggradientprimitive2d.cxx @@ -27,6 +27,7 @@ #include <drawinglayer/primitive2d/transparenceprimitive2d.hxx> #include <drawinglayer/primitive2d/transformprimitive2d.hxx> #include <drawinglayer/primitive2d/maskprimitive2d.hxx> +#include <drawinglayer/primitive2d/PolyPolygonRGBAPrimitive2D.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> #include <osl/diagnose.h> #include <sal/log.hxx> @@ -65,39 +66,40 @@ namespace drawinglayer::primitive2d { Primitive2DReference SvgGradientHelper::createSingleGradientEntryFill() const { - const SvgGradientEntryVector& rEntries = getGradientEntries(); + const SvgGradientEntryVector& rEntries(getGradientEntries()); const sal_uInt32 nCount(rEntries.size()); - if(nCount) + if(0 == nCount) { - const SvgGradientEntry& rSingleEntry = rEntries[nCount - 1]; - const double fOpacity(rSingleEntry.getOpacity()); - - if(fOpacity > 0.0) - { - Primitive2DReference xRef( - new PolyPolygonColorPrimitive2D( - getPolyPolygon(), - rSingleEntry.getColor())); - - if(fOpacity < 1.0) - { - Primitive2DContainer aContent { xRef }; + // no entries, done + OSL_ENSURE(false, "Single gradient entry construction without entry (!)"); + return nullptr; + } - xRef = - new UnifiedTransparencePrimitive2D( - std::move(aContent), - 1.0 - fOpacity); - } + const SvgGradientEntry& rSingleEntry(rEntries[nCount - 1]); + const double fOpacity(rSingleEntry.getOpacity()); - return xRef; - } + if (basegfx::fTools::lessOrEqual(fOpacity, 0.0)) + { + // completely opaque, done + return nullptr; } - else + + if (basegfx::fTools::moreOrEqual(fOpacity, 1.0)) { - OSL_ENSURE(false, "Single gradient entry construction without entry (!)"); + // no opacity + return Primitive2DReference { + new PolyPolygonColorPrimitive2D( + getPolyPolygon(), + rSingleEntry.getColor()) }; } - return nullptr; + + // if transparent, use PolyPolygonRGBAPrimitive2D + return Primitive2DReference { + new PolyPolygonRGBAPrimitive2D( + getPolyPolygon(), + rSingleEntry.getColor(), + 1.0 - fOpacity) }; } void SvgGradientHelper::checkPreconditions() diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 9657fb4f0c41..55eadda06d9c 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -31,6 +31,7 @@ #include <wmfemfhelper.hxx> #include <drawinglayer/primitive2d/PolygonStrokeArrowPrimitive2D.hxx> #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx> +#include <drawinglayer/primitive2d/PolyPolygonRGBAPrimitive2D.hxx> #include <drawinglayer/primitive2d/PolyPolygonStrokePrimitive2D.hxx> #include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx> #include <drawinglayer/primitive2d/svggradientprimitive2d.hxx> @@ -683,14 +684,11 @@ namespace emfplushelper } else { - const drawinglayer::primitive2d::Primitive2DReference aPrimitive( - new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( - polygon, - color.getBColor())); - + // transparent mrTargetHolders.Current().append( - new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D( - drawinglayer::primitive2d::Primitive2DContainer { aPrimitive }, + new drawinglayer::primitive2d::PolyPolygonRGBAPrimitive2D( + polygon, + color.getBColor(), (255 - color.GetAlpha()) / 255.0)); } } |