aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorMichael Brasser <mbrasser@ford.com>2017-10-26 21:52:00 -0500
committerMichael Brasser <michael.brasser@live.com>2018-05-03 14:04:58 +0000
commit9506f274faf75f48b2d6639647603feab401eb8b (patch)
treec76a7c14f9f3067b21ee3bde8e320c0d93f179fc /src/plugins
parent96bb8ff5dd133a00bff6a7a713c59736441e1c78 (diff)
Add support for horizontal gradients in Rectangle
[ChangeLog][QtQuick] Added support for horizontal gradients in Rectangle. Change-Id: I4feee8ec93d9fe75a9f91a7afbe33c8d4756cedb Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp14
-rw-r--r--src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h2
2 files changed, 12 insertions, 4 deletions
diff --git a/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp
index 0bd51cbf46..d728686248 100644
--- a/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp
+++ b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp
@@ -176,6 +176,12 @@ void QSGOpenVGInternalRectangleNode::setGradientStops(const QGradientStops &stop
m_fillDirty = true;
}
+void QSGOpenVGInternalRectangleNode::setGradientVertical(bool vertical)
+{
+ m_vertical = vertical;
+ m_fillDirty = true;
+}
+
void QSGOpenVGInternalRectangleNode::setRadius(qreal radius)
{
m_radius = radius;
@@ -242,13 +248,13 @@ void QSGOpenVGInternalRectangleNode::render()
} else {
// Linear Gradient
vgSetParameteri(m_rectanglePaint, VG_PAINT_TYPE, VG_PAINT_TYPE_LINEAR_GRADIENT);
- const VGfloat verticalLinearGradient[] = {
- 0.0f,
+ const VGfloat linearGradient[] = {
0.0f,
0.0f,
- static_cast<VGfloat>(m_rect.height())
+ m_vertical ? 0.0f : static_cast<VGfloat>(m_rect.width()),
+ m_vertical ? static_cast<VGfloat>(m_rect.height()) : 0.0f
};
- vgSetParameterfv(m_rectanglePaint, VG_PAINT_LINEAR_GRADIENT, 4, verticalLinearGradient);
+ vgSetParameterfv(m_rectanglePaint, VG_PAINT_LINEAR_GRADIENT, 4, linearGradient);
vgSetParameteri(m_rectanglePaint, VG_PAINT_COLOR_RAMP_SPREAD_MODE, VG_COLOR_RAMP_SPREAD_PAD);
vgSetParameteri(m_rectanglePaint, VG_PAINT_COLOR_RAMP_PREMULTIPLIED, false);
diff --git a/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h
index e8d25c94f8..86d2c3318c 100644
--- a/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h
+++ b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h
@@ -59,6 +59,7 @@ public:
void setPenColor(const QColor &color) override;
void setPenWidth(qreal width) override;
void setGradientStops(const QGradientStops &stops) override;
+ void setGradientVertical(bool vertical) override;
void setRadius(qreal radius) override;
void setAligned(bool aligned) override;
void update() override;
@@ -85,6 +86,7 @@ private:
qreal m_penWidth = 0.0;
qreal m_radius = 0.0;
bool m_aligned = false;
+ bool m_vertical = true;
QGradientStops m_gradientStops;
VGPath m_rectanglePath;