summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2023-03-22 11:44:52 +0100
committerArmin Le Grand <Armin.Le.Grand@me.com>2023-03-22 14:28:19 +0000
commit9331d2d333feb911e16f20ce899f2de220bee2f1 (patch)
tree586696998f20a4ad6d8e3b1e9400c845267534b0 /drawinglayer
parent3545c0c0b991e5b9438d890f48dd10c4a60f2090 (diff)
MCGR: Corrected error with Case16 wrong gradient shortcut
Also simplified using the test cases, these now depend on an ENV VAR called MCGR_TEST. Fallback is no test. For seeing a multi-color gradient use 1, for Case16 use 16. If active, all gradients are replaced with the one active for the test, 2D and 3D. This is temporary but also for pro build to check for speed there. Change-Id: I90f3c7e59d9d0a3e070a849af3f9ea1c9e5462a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149316 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/source/attribute/fillgradientattribute.cxx35
-rw-r--r--drawinglayer/source/processor2d/vclpixelprocessor2d.cxx63
2 files changed, 61 insertions, 37 deletions
diff --git a/drawinglayer/source/attribute/fillgradientattribute.cxx b/drawinglayer/source/attribute/fillgradientattribute.cxx
index 62bde03a29f6..b25a4dab2f25 100644
--- a/drawinglayer/source/attribute/fillgradientattribute.cxx
+++ b/drawinglayer/source/attribute/fillgradientattribute.cxx
@@ -154,6 +154,41 @@ namespace drawinglayer::attribute
return mpFillGradientAttribute->hasSingleColor();
}
+ // MCGR: Check if rendering cannot be handled by old vcl stuff
+ bool FillGradientAttribute::cannotBeHandledByVCL() const
+ {
+ // MCGR: If GradientStops are used, use decomposition since vcl is not able
+ // to render multi-color gradients
+ if (getColorStops().size() != 2)
+ {
+ return true;
+ }
+
+ // MCGR: If GradientStops do not start and stop at traditional Start/EndColor,
+ // use decomposition since vcl is not able to render this
+ if (!getColorStops().empty())
+ {
+ if (!basegfx::fTools::equalZero(getColorStops().front().getStopOffset())
+ || !basegfx::fTools::equal(getColorStops().back().getStopOffset(), 1.0))
+ {
+ return true;
+ }
+ }
+
+ // VCL should be able to handle all styles, but for tdf#133477 the VCL result
+ // is different from processing the gradient manually by drawinglayer
+ // (and the Writer unittest for it fails). Keep using the drawinglayer code
+ // until somebody founds out what's wrong and fixes it.
+ if (getStyle() != drawinglayer::attribute::GradientStyle::Linear
+ && getStyle() != drawinglayer::attribute::GradientStyle::Axial
+ && getStyle() != drawinglayer::attribute::GradientStyle::Radial)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
FillGradientAttribute& FillGradientAttribute::operator=(const FillGradientAttribute&) = default;
FillGradientAttribute& FillGradientAttribute::operator=(FillGradientAttribute&&) = default;
diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index c49deaf3f369..9f0875e2f489 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -497,16 +497,30 @@ void VclPixelProcessor2D::processBitmapPrimitive2D(
void VclPixelProcessor2D::processPolyPolygonGradientPrimitive2D(
const primitive2d::PolyPolygonGradientPrimitive2D& rPolygonCandidate)
{
- // direct draw of gradient
+ basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon());
+
+ // no geometry, no need to render, done
+ if (!aLocalPolyPolygon.count())
+ return;
+
+ // *try* direct draw (AKA using old VCL stuff) to render gradient
const attribute::FillGradientAttribute& rGradient(rPolygonCandidate.getFillGradient());
+
+ // MCGR: *many* - and not only GradientStops - cases cannot be handled by VCL
+ // so use decomposition
+ // NOTE: There may be even more reasons to detect, e.g. a ViewTransformation
+ // that uses shear/rotate/mirror (what VCL cannot handle at all), see
+ // other checks already in processFillGradientPrimitive2D
+ if (rGradient.cannotBeHandledByVCL())
+ {
+ process(rPolygonCandidate);
+ return;
+ }
+
basegfx::BColor aStartColor(
maBColorModifierStack.getModifiedColor(rGradient.getColorStops().front().getStopColor()));
basegfx::BColor aEndColor(
maBColorModifierStack.getModifiedColor(rGradient.getColorStops().back().getStopColor()));
- basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon());
-
- if (!aLocalPolyPolygon.count())
- return;
if (aStartColor == aEndColor)
{
@@ -515,12 +529,11 @@ void VclPixelProcessor2D::processPolyPolygonGradientPrimitive2D(
mpOutputDevice->SetLineColor();
mpOutputDevice->SetFillColor(Color(aStartColor));
mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
+ return;
}
- else
- {
- // use the primitive decomposition of the metafile
- process(rPolygonCandidate);
- }
+
+ // use the primitive decomposition
+ process(rPolygonCandidate);
}
void VclPixelProcessor2D::processPolyPolygonColorPrimitive2D(
@@ -938,33 +951,9 @@ void VclPixelProcessor2D::processFillGradientPrimitive2D(
{
const attribute::FillGradientAttribute& rFillGradient = rPrimitive.getFillGradient();
- // MCGR: If GradientStops are used, use decomposition since vcl is not able
- // to render multi-color gradients
- if (rFillGradient.getColorStops().size() != 2)
- {
- process(rPrimitive);
- return;
- }
-
- // MCGR: If GradientStops do not start and stop at traditional Start/EndColor,
- // use decomposition since vcl is not able to render this
- if (!rFillGradient.getColorStops().empty())
- {
- if (!basegfx::fTools::equalZero(rFillGradient.getColorStops().front().getStopOffset())
- || !basegfx::fTools::equal(rFillGradient.getColorStops().back().getStopOffset(), 1.0))
- {
- process(rPrimitive);
- return;
- }
- }
-
- // VCL should be able to handle all styles, but for tdf#133477 the VCL result
- // is different from processing the gradient manually by drawinglayer
- // (and the Writer unittest for it fails). Keep using the drawinglayer code
- // until somebody founds out what's wrong and fixes it.
- if (rFillGradient.getStyle() != drawinglayer::attribute::GradientStyle::Linear
- && rFillGradient.getStyle() != drawinglayer::attribute::GradientStyle::Axial
- && rFillGradient.getStyle() != drawinglayer::attribute::GradientStyle::Radial)
+ // MCGR: *many* - and not only GradientStops - cases cannot be handled by VCL
+ // so use decomposition
+ if (rFillGradient.cannotBeHandledByVCL())
{
process(rPrimitive);
return;