diff options
author | Armin Le Grand (Collabora) <Armin.Le.Grand@me.com> | 2024-07-15 18:55:56 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2024-07-16 13:10:10 +0200 |
commit | a073b6133960734b809c1bc93e39a76fdf1e7c15 (patch) | |
tree | d75a5e2dbeea7e35e5d2c8c0d56526656c212028 /svx/source | |
parent | f10d51709d08bdafdbd5c92f73ddb62cb217b6dd (diff) |
CairoSDPR: Direct support for RGBA Gradients (I)
Detect where created when a RGBA gradient could be
used directly and create a primitive representing
that, a PolyPolygonRGBAGradientPrimitive2D.
That primitive decomposes to what was created before,
so no primitive renderer has to be touched, all will
work as before.
NOTE: That helper primitive just holds references to
what would be created anyways, so one depth step
added but not really any additional data.
This is the 1st step for direct support, the 2nd is
to then detect and use that primitive in SDPR
implementations directly.
Change-Id: I4f247636ce58a8a1fd1e0df32dabed0d6cc10d0e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170527
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/sdr/primitive2d/sdrdecompositiontools.cxx | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx index 2913f19b2548..10b48f851443 100644 --- a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx +++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx @@ -368,12 +368,10 @@ sal_uInt32 SlideBackgroundFillPrimitive2D::getPrimitive2DID() const }; // end of anonymous namespace - class TransparencePrimitive2D; - Primitive2DReference createPolyPolygonFillPrimitive( const basegfx::B2DPolyPolygon& rPolyPolygon, const attribute::SdrFillAttribute& rFill, - const attribute::FillGradientAttribute& rFillGradient) + const attribute::FillGradientAttribute& rAlphaGradient) { // when we have no given definition range, use the range of the given geometry // also for definition (simplest case) @@ -383,29 +381,53 @@ sal_uInt32 SlideBackgroundFillPrimitive2D::getPrimitive2DID() const rPolyPolygon, aRange, rFill, - rFillGradient); + rAlphaGradient); } Primitive2DReference createPolyPolygonFillPrimitive( const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::B2DRange& rDefinitionRange, const attribute::SdrFillAttribute& rFill, - const attribute::FillGradientAttribute& rFillGradient) + const attribute::FillGradientAttribute& rAlphaGradient) { if(basegfx::fTools::moreOrEqual(rFill.getTransparence(), 1.0)) { return Primitive2DReference(); } + const attribute::FillGradientAttribute& rFillGradient(rFill.getGradient()); + + // SDPR: check if RGB and A definitions of gradients are both + // used and equal, so that they could be combined to a single + // RGBA one + if (!rFillGradient.isDefault() + && 0.0 == rFill.getTransparence() + && !rAlphaGradient.isDefault() + && rFillGradient.sameDefinitionThanAlpha(rAlphaGradient)) + { + // if yes, create a primitive expressing that. That primitive's + // decomnpose will do the same as if the code below would be executed, + // so no primitive renderer who does not want to will have to handle + // it - but SDPR renderers that can directly render that may choose to + // do so. NOTE: That helper primitive just holds references to what + // would be created anyways, so one depth step added but not really any + // additional data + return new PolyPolygonRGBAGradientPrimitive2D( + rPolyPolygon, + rDefinitionRange, + rFillGradient, + rAlphaGradient); + } + // prepare fully scaled polygon rtl::Reference<BasePrimitive2D> pNewFillPrimitive; - if(!rFill.getGradient().isDefault()) + if(!rFillGradient.isDefault()) { pNewFillPrimitive = new PolyPolygonGradientPrimitive2D( rPolyPolygon, rDefinitionRange, - rFill.getGradient()); + rFillGradient); } else if(!rFill.getHatch().isDefault()) { @@ -442,7 +464,7 @@ sal_uInt32 SlideBackgroundFillPrimitive2D::getPrimitive2DID() const Primitive2DContainer aContent { pNewFillPrimitive }; return new UnifiedTransparencePrimitive2D(std::move(aContent), rFill.getTransparence()); } - else if(!rFillGradient.isDefault()) + else if(!rAlphaGradient.isDefault()) { // create sequence with created fill primitive Primitive2DContainer aContent { pNewFillPrimitive }; @@ -453,7 +475,7 @@ sal_uInt32 SlideBackgroundFillPrimitive2D::getPrimitive2DID() const new FillGradientPrimitive2D( basegfx::utils::getRange(rPolyPolygon), rDefinitionRange, - rFillGradient) + rAlphaGradient) }; // create TransparencePrimitive2D using alpha and content |