summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-09-22 15:20:57 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-09-28 13:24:43 +0200
commit556df847ce677b6b32d15a153c5bbf400db27b75 (patch)
tree74aa355b1ccf0cf825c92fccdf872ccfc78672a1 /vcl
parent3de1b009bd187afa1dd49b10644c1920641e1596 (diff)
use vcl lin. gradient drawing in drawinglayer + cairo impl.
This adds a divert for drawing of linear gradients drawing, which can be implemented natively with a much higher quality and speed. This also adds a implementation of drawing linear gradients with cairo. Change-Id: I8c39915c3579e6eb88cdce8ae4ac9694ffdb4957 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103374 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com> (cherry picked from commit 20c09d351ee060bdde13d92d2bf86dd998cdb0cb) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103425 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/headless/svpgdi.cxx49
-rw-r--r--vcl/inc/headless/svpgdi.hxx3
2 files changed, 51 insertions, 1 deletions
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index feaaa671e67e..e196c3b8b2cc 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -1600,6 +1600,55 @@ bool SvpSalGraphics::drawPolyPolygon(
return true;
}
+bool SvpSalGraphics::drawGradient(const tools::PolyPolygon& rPolyPolygon, const Gradient& rGradient)
+{
+ cairo_t* cr = getCairoContext(true);
+ clipRegion(cr);
+
+ basegfx::B2DPolyPolygon aB2DPolyPolygon(rPolyPolygon.getB2DPolyPolygon());
+
+ for (auto const & rPolygon : aB2DPolyPolygon)
+ {
+ basegfx::B2DHomMatrix rObjectToDevice;
+ AddPolygonToPath(cr, rPolygon, rObjectToDevice, !getAntiAliasB2DDraw(), false);
+ }
+
+ Gradient aGradient(rGradient);
+
+ tools::Rectangle aInputRect(rPolyPolygon.GetBoundRect());
+ tools::Rectangle aBoundRect;
+ Point aCenter;
+
+ aGradient.SetAngle(aGradient.GetAngle() + 2700);
+ aGradient.GetBoundRect(aInputRect, aBoundRect, aCenter);
+
+ tools::Polygon aPoly(aBoundRect);
+ aPoly.Rotate(aCenter, aGradient.GetAngle() % 3600);
+
+ cairo_pattern_t* pattern;
+ pattern = cairo_pattern_create_linear(aPoly[0].X(), aPoly[0].Y(), aPoly[1].X(), aPoly[1].Y());
+
+ cairo_pattern_add_color_stop_rgba(pattern, aGradient.GetBorder() / 100.0,
+ aGradient.GetStartColor().GetRed() / 255.0,
+ aGradient.GetStartColor().GetGreen() / 255.0,
+ aGradient.GetStartColor().GetBlue() / 255.0,
+ 1.0);
+
+ cairo_pattern_add_color_stop_rgba(pattern, 1.0,
+ aGradient.GetEndColor().GetRed() / 255.0,
+ aGradient.GetEndColor().GetGreen() / 255.0,
+ aGradient.GetEndColor().GetBlue() / 255.0,
+ 1.0);
+ cairo_set_source(cr, pattern);
+
+ basegfx::B2DRange extents = getClippedFillDamage(cr);
+ cairo_fill_preserve(cr);
+
+ releaseCairoContext(cr, true, extents);
+
+ return true;
+}
+
bool SvpSalGraphics::implDrawGradient(basegfx::B2DPolyPolygon const & rPolyPolygon, SalGradient const & rGradient)
{
cairo_t* cr = getCairoContext(true);
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index ef64d5b241c9..21c1ebe64a54 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -234,7 +234,8 @@ public:
const sal_uInt32* pPoints,
const SalPoint* const* pPtAry,
const PolyFlags* const* pFlgAry ) override;
- virtual bool drawGradient( const tools::PolyPolygon&, const Gradient& ) override { return false; };
+
+ virtual bool drawGradient(tools::PolyPolygon const & rPolyPolygon, Gradient const & rGradient) override;
virtual bool implDrawGradient(basegfx::B2DPolyPolygon const & rPolyPolygon, SalGradient const & rGradient) override;