summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
authorArmin Le Grand (Allotropia) <Armin.Le.Grand@me.com>2023-03-31 16:05:28 +0200
committerArmin Le Grand <Armin.Le.Grand@me.com>2023-04-02 13:18:59 +0200
commit389f338da025aa7bc26556a7167cd272b64b77fd (patch)
treea91f1e446b228f207752c4dea21b6fc85bdf6738 /drawinglayer
parent24a374ebc9da56cc6721e8feaa1e15ba850bf41d (diff)
SDPR: Use currently added lambda to render Gradients
Change-Id: I9fba920c60690f136cae956dae17e2f5e5081f19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149839 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx86
1 files changed, 66 insertions, 20 deletions
diff --git a/drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx b/drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx
index 0670ad2febd8..783060c2be4c 100644
--- a/drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/d2dpixelprocessor2d.cxx
@@ -48,6 +48,7 @@
#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
#include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
#include <drawinglayer/primitive2d/invertprimitive2d.hxx>
+#include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
#include <drawinglayer/converters.hxx>
#include <basegfx/curve/b2dcubicbezier.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
@@ -817,19 +818,10 @@ void D2DPixelProcessor2D::processPolygonHairlinePrimitive2D(
increaseError();
}
-void D2DPixelProcessor2D::processPolyPolygonColorPrimitive2D(
- const primitive2d::PolyPolygonColorPrimitive2D& rPolyPolygonColorPrimitive2D)
+bool D2DPixelProcessor2D::drawPolyPolygonColorTransformed(
+ const basegfx::B2DHomMatrix& rTansformation, const basegfx::B2DPolyPolygon& rPolyPolygon,
+ const basegfx::BColor& rColor)
{
- const basegfx::B2DPolyPolygon& rPolyPolygon(rPolyPolygonColorPrimitive2D.getB2DPolyPolygon());
- const sal_uInt32 nCount(rPolyPolygon.count());
-
- if (!nCount)
- {
- // no geometry, done
- return;
- }
-
- bool bDone(false);
std::shared_ptr<SystemDependentData_ID2D1PathGeometry> pSystemDependentData_ID2D1PathGeometry(
getOrCreateFillGeometry(rPolyPolygon));
@@ -837,19 +829,18 @@ void D2DPixelProcessor2D::processPolyPolygonColorPrimitive2D(
{
sal::systools::COMReference<ID2D1TransformedGeometry> pTransformedGeometry;
const double fAAOffset(getViewInformation2D().getUseAntiAliasing() ? 0.5 : 0.0);
- const basegfx::B2DHomMatrix& rObjectToView(
- getViewInformation2D().getObjectToViewTransformation());
+ basegfx::B2DHomMatrix aTansformation(getViewInformation2D().getObjectToViewTransformation()
+ * rTansformation);
HRESULT hr(aID2D1GlobalFactoryProvider.getID2D1Factory()->CreateTransformedGeometry(
pSystemDependentData_ID2D1PathGeometry->getID2D1PathGeometry(),
- D2D1::Matrix3x2F(rObjectToView.a(), rObjectToView.b(), rObjectToView.c(),
- rObjectToView.d(), rObjectToView.e() + fAAOffset,
- rObjectToView.f() + fAAOffset),
+ D2D1::Matrix3x2F(aTansformation.a(), aTansformation.b(), aTansformation.c(),
+ aTansformation.d(), aTansformation.e() + fAAOffset,
+ aTansformation.f() + fAAOffset),
&pTransformedGeometry));
if (SUCCEEDED(hr) && pTransformedGeometry)
{
- const basegfx::BColor aFillColor(
- maBColorModifierStack.getModifiedColor(rPolyPolygonColorPrimitive2D.getBColor()));
+ const basegfx::BColor aFillColor(maBColorModifierStack.getModifiedColor(rColor));
const D2D1::ColorF aD2DColor(aFillColor.getRed(), aFillColor.getGreen(),
aFillColor.getBlue());
@@ -860,11 +851,29 @@ void D2DPixelProcessor2D::processPolyPolygonColorPrimitive2D(
{
getRenderTarget()->SetTransform(D2D1::Matrix3x2F::Identity());
getRenderTarget()->FillGeometry(pTransformedGeometry, pColorBrush);
- bDone = true;
+ return true;
}
}
}
+ return false;
+}
+
+void D2DPixelProcessor2D::processPolyPolygonColorPrimitive2D(
+ const primitive2d::PolyPolygonColorPrimitive2D& rPolyPolygonColorPrimitive2D)
+{
+ const basegfx::B2DPolyPolygon& rPolyPolygon(rPolyPolygonColorPrimitive2D.getB2DPolyPolygon());
+ const sal_uInt32 nCount(rPolyPolygon.count());
+
+ if (!nCount)
+ {
+ // no geometry, done
+ return;
+ }
+
+ const bool bDone(drawPolyPolygonColorTransformed(basegfx::B2DHomMatrix(), rPolyPolygon,
+ rPolyPolygonColorPrimitive2D.getBColor()));
+
if (!bDone)
increaseError();
}
@@ -1912,6 +1921,37 @@ void D2DPixelProcessor2D::processFillGraphicPrimitive2D(
increaseError();
}
+void D2DPixelProcessor2D::processFillGradientPrimitive2D(
+ const primitive2d::FillGradientPrimitive2D& rFillGradientPrimitive2D)
+{
+ // draw all-covering initial BG polygon 1st
+ bool bDone(drawPolyPolygonColorTransformed(
+ basegfx::B2DHomMatrix(),
+ basegfx::B2DPolyPolygon(
+ basegfx::utils::createPolygonFromRect(rFillGradientPrimitive2D.getOutputRange())),
+ rFillGradientPrimitive2D.getOuterColor()));
+
+ if (bDone)
+ {
+ const basegfx::B2DPolyPolygon aForm(rFillGradientPrimitive2D.getUnitPolygon());
+
+ // paint solid fill steps by providing callback as lambda
+ auto aCallback([&aForm, &bDone, this](const basegfx::B2DHomMatrix& rMatrix,
+ const basegfx::BColor& rColor) {
+ if (bDone)
+ {
+ bDone = drawPolyPolygonColorTransformed(rMatrix, aForm, rColor);
+ }
+ });
+
+ // call value generator to trigger callbacks
+ rFillGradientPrimitive2D.generateMatricesAndColors(aCallback);
+ }
+
+ if (!bDone)
+ increaseError();
+}
+
void D2DPixelProcessor2D::processInvertPrimitive2D(
const primitive2d::InvertPrimitive2D& rInvertPrimitive2D)
{
@@ -2124,6 +2164,12 @@ void D2DPixelProcessor2D::processBasePrimitive2D(const primitive2d::BasePrimitiv
static_cast<const primitive2d::FillGraphicPrimitive2D&>(rCandidate));
break;
}
+ case PRIMITIVE2D_ID_FILLGRADIENTPRIMITIVE2D:
+ {
+ processFillGradientPrimitive2D(
+ static_cast<const primitive2d::FillGradientPrimitive2D&>(rCandidate));
+ break;
+ }
// continue with decompose as fallback
default: