summaryrefslogtreecommitdiff
path: root/drawinglayer
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 /drawinglayer
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 'drawinglayer')
-rw-r--r--drawinglayer/source/processor2d/vclpixelprocessor2d.cxx72
-rw-r--r--drawinglayer/source/processor2d/vclpixelprocessor2d.hxx2
2 files changed, 74 insertions, 0 deletions
diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index 0cc87e6eaa20..10d8e69e51fa 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -36,6 +36,7 @@
#include <drawinglayer/primitive2d/controlprimitive2d.hxx>
#include <drawinglayer/primitive2d/borderlineprimitive2d.hxx>
#include <com/sun/star/awt/XWindow2.hpp>
+#include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
#include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx>
#include "helperwrongspellrenderer.hxx"
@@ -58,6 +59,13 @@
#include <com/sun/star/table/BorderLineStyle.hpp>
+#include <vcl/window.hxx>
+#include <vcl/gradient.hxx>
+#include <svtools/borderhelper.hxx>
+#include <editeng/borderline.hxx>
+
+#include <com/sun/star/table/BorderLineStyle.hpp>
+
using namespace com::sun::star;
namespace drawinglayer
@@ -213,6 +221,30 @@ namespace drawinglayer
/* false bBypassAACheck, default*/);
}
+namespace
+{
+GradientStyle convertGradientStyle(drawinglayer::attribute::GradientStyle eGradientStyle)
+{
+ switch (eGradientStyle)
+ {
+ case drawinglayer::attribute::GradientStyle::Axial:
+ return GradientStyle::Axial;
+ case drawinglayer::attribute::GradientStyle::Radial:
+ return GradientStyle::Radial;
+ case drawinglayer::attribute::GradientStyle::Elliptical:
+ return GradientStyle::Elliptical;
+ case drawinglayer::attribute::GradientStyle::Square:
+ return GradientStyle::Square;
+ case drawinglayer::attribute::GradientStyle::Rect:
+ return GradientStyle::Rect;
+ case drawinglayer::attribute::GradientStyle::Linear:
+ default:
+ return GradientStyle::Linear;
+ }
+}
+
+} // end anonymous namespace
+
void VclPixelProcessor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate)
{
switch(rCandidate.getPrimitive2DID())
@@ -373,6 +405,12 @@ namespace drawinglayer
processBorderLinePrimitive2D(static_cast<const drawinglayer::primitive2d::BorderLinePrimitive2D&>(rCandidate));
break;
}
+ case PRIMITIVE2D_ID_FILLGRADIENTPRIMITIVE2D:
+ {
+ processFillGradientPrimitive2D(
+ static_cast<const drawinglayer::primitive2d::FillGradientPrimitive2D&>(rCandidate));
+ break;
+ }
default :
{
SAL_INFO("drawinglayer", "default case for " << drawinglayer::primitive2d::idToString(rCandidate.getPrimitive2DID()));
@@ -857,6 +895,40 @@ namespace drawinglayer
mpOutputDevice->SetAntialiasing(nOldAntiAliase);
}
}
+
+ void VclPixelProcessor2D::processFillGradientPrimitive2D(
+ const primitive2d::FillGradientPrimitive2D& rPrimitive)
+ {
+ const attribute::FillGradientAttribute& rFillGradient = rPrimitive.getFillGradient();
+
+ if (rFillGradient.getSteps() > 0
+ || rFillGradient.getStyle() != drawinglayer::attribute::GradientStyle::Linear)
+ {
+ process(rPrimitive);
+ return;
+ }
+
+ GradientStyle eGradientStyle = convertGradientStyle(rFillGradient.getStyle());
+
+ basegfx::B2DRange aRange(rPrimitive.getOutputRange());
+ aRange.transform(maCurrentTransformation);
+
+ const tools::Rectangle aRectangle(
+ sal_Int32(std::floor(aRange.getMinX())), sal_Int32(std::floor(aRange.getMinY())),
+ sal_Int32(std::ceil(aRange.getMaxX())), sal_Int32(std::ceil(aRange.getMaxY())));
+
+ Gradient aGradient(eGradientStyle, Color(rFillGradient.getStartColor()),
+ Color(rFillGradient.getEndColor()));
+
+ aGradient.SetAngle(rFillGradient.getAngle() / F_PI1800);
+ aGradient.SetBorder(rFillGradient.getBorder() * 100);
+ aGradient.SetOfsX(rFillGradient.getOffsetX() * 100.0);
+ aGradient.SetOfsY(rFillGradient.getOffsetY() * 100.0);
+ aGradient.SetSteps(rFillGradient.getSteps());
+
+ mpOutputDevice->DrawGradient(aRectangle, aGradient);
+ }
+
} // end of namespace processor2d
} // end of namespace drawinglayer
diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx
index 1111943a62c8..7fbcd7954dca 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.hxx
@@ -44,6 +44,7 @@ namespace drawinglayer { namespace primitive2d {
class FillHatchPrimitive2D;
class BackgroundColorPrimitive2D;
class BorderLinePrimitive2D;
+ class FillGradientPrimitive2D;
}}
namespace drawinglayer
@@ -86,6 +87,7 @@ namespace drawinglayer
void processBorderLinePrimitive2D(const drawinglayer::primitive2d::BorderLinePrimitive2D& rBorder);
void processInvertPrimitive2D(const primitive2d::BasePrimitive2D& rCandidate);
void processMetaFilePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate);
+ void processFillGradientPrimitive2D(const primitive2d::FillGradientPrimitive2D& rPrimitive);
public:
/// constructor/destructor