summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2019-02-08 09:28:00 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2019-02-08 12:31:02 +0100
commitfbfacd33be482fa3cf0aa5cffaf7006d538a2f92 (patch)
tree92da72786b3740e37004623612c4fc1c9640d30f /src/gui/painting
parentc1f4286a5cbc1794fe7be5bdbbd6a0bf29ef84d4 (diff)
parent74e04d6ace7aa949db97ae2e46c38a4dc0d4d36a (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts: src/android/templates/AndroidManifest.xml src/network/ssl/qsslsocket_mac.cpp src/widgets/styles/qstylesheetstyle.cpp tests/auto/corelib/kernel/qtimer/BLACKLIST tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp tests/auto/testlib/selftests/expected_blacklisted.lightxml tests/auto/testlib/selftests/expected_blacklisted.tap tests/auto/testlib/selftests/expected_blacklisted.teamcity tests/auto/testlib/selftests/expected_blacklisted.txt tests/auto/testlib/selftests/expected_blacklisted.xml tests/auto/testlib/selftests/expected_blacklisted.xunitxml tests/auto/testlib/selftests/expected_float.tap tests/auto/testlib/selftests/expected_float.teamcity tests/auto/testlib/selftests/expected_float.txt tests/auto/testlib/selftests/expected_float.xunitxml Done-With: Christian Ehrlicher <ch.ehrlicher@gmx.de> Done-With: Edward Welbourne <edward.welbourne@qt.io> Done-With: Timur Pocheptsov <timur.pocheptsov@qt.io> Change-Id: If93cc432a56ae3ac1b6533d0028e4dc497415a52
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qcolor.cpp105
-rw-r--r--src/gui/painting/qpathsimplifier.cpp2
-rw-r--r--src/gui/painting/qpathsimplifier_p.h2
-rw-r--r--src/gui/painting/qstroker.cpp27
4 files changed, 75 insertions, 61 deletions
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index b3fa1eedde..07202f5b1c 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -541,7 +541,15 @@ static QStringList get_colornames()
\section1 The HSL Color Model
HSL is similar to HSV, however instead of the Value parameter, HSL
- specifies a Lightness parameter.
+ specifies a Lightness parameter which maps somewhat differently to the
+ brightness of the color.
+
+ Similarly, the HSL saturation value is not in general the same as the HSV
+ saturation value for the same color. hslSaturation() provides the color's
+ HSL saturation value, while saturation() and hsvSaturation() provides the
+ HSV saturation value.
+
+ The hue value is defined to be the same in HSL and HSV.
\section1 The CMYK Color Model
@@ -1098,7 +1106,7 @@ void QColor::setHsv(int h, int s, int v, int a)
These components can be retrieved individually using the hslHueF(),
hslSaturationF(), lightnessF() and alphaF() functions.
- \sa setHsl()
+ \sa getHsl(), setHslF(), {QColor#The HSL Color Model}{The HSL Color Model}
*/
void QColor::getHslF(qreal *h, qreal *s, qreal *l, qreal *a) const
{
@@ -1128,7 +1136,7 @@ void QColor::getHslF(qreal *h, qreal *s, qreal *l, qreal *a) const
These components can be retrieved individually using the hslHue(),
hslSaturation(), lightness() and alpha() functions.
- \sa setHsl()
+ \sa getHslF(), setHsl(), {QColor#The HSL Color Model}{The HSL Color Model}
*/
void QColor::getHsl(int *h, int *s, int *l, int *a) const
{
@@ -1619,11 +1627,11 @@ void QColor::setBlueF(qreal blue)
}
/*!
- Returns the hue color component of this color.
+ Returns the HSV hue color component of this color.
The color is implicitly converted to HSV.
- \sa hsvHue(), hueF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model}
+ \sa hsvHue(), hslHue(), hueF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model}
*/
int QColor::hue() const Q_DECL_NOTHROW
@@ -1632,9 +1640,9 @@ int QColor::hue() const Q_DECL_NOTHROW
}
/*!
- Returns the hue color component of this color.
+ Returns the HSV hue color component of this color.
- \sa hueF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model}
+ \sa hueF(), hslHue(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model}
*/
int QColor::hsvHue() const Q_DECL_NOTHROW
{
@@ -1644,11 +1652,11 @@ int QColor::hsvHue() const Q_DECL_NOTHROW
}
/*!
- Returns the saturation color component of this color.
+ Returns the HSV saturation color component of this color.
The color is implicitly converted to HSV.
- \sa hsvSaturation(), saturationF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color
+ \sa hsvSaturation(), hslSaturation(), saturationF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color
Model}
*/
@@ -1658,9 +1666,9 @@ int QColor::saturation() const Q_DECL_NOTHROW
}
/*!
- Returns the saturation color component of this color.
+ Returns the HSV saturation color component of this color.
- \sa saturationF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model}
+ \sa saturationF(), hslSaturation(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model}
*/
int QColor::hsvSaturation() const Q_DECL_NOTHROW
{
@@ -1682,11 +1690,11 @@ int QColor::value() const Q_DECL_NOTHROW
}
/*!
- Returns the hue color component of this color.
+ Returns the HSV hue color component of this color.
The color is implicitly converted to HSV.
- \sa hsvHueF(), hue(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color Model}
+ \sa hsvHueF(), hslHueF(), hue(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color Model}
*/
qreal QColor::hueF() const Q_DECL_NOTHROW
{
@@ -1696,7 +1704,7 @@ qreal QColor::hueF() const Q_DECL_NOTHROW
/*!
Returns the hue color component of this color.
- \sa hue(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color
+ \sa hue(), hslHueF(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color
Model}
*/
qreal QColor::hsvHueF() const Q_DECL_NOTHROW
@@ -1707,11 +1715,11 @@ qreal QColor::hsvHueF() const Q_DECL_NOTHROW
}
/*!
- Returns the saturation color component of this color.
+ Returns the HSV saturation color component of this color.
The color is implicitly converted to HSV.
- \sa hsvSaturationF(), saturation(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color
+ \sa hsvSaturationF(), hslSaturationF(), saturation(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color
Model}
*/
qreal QColor::saturationF() const Q_DECL_NOTHROW
@@ -1720,9 +1728,9 @@ qreal QColor::saturationF() const Q_DECL_NOTHROW
}
/*!
- Returns the saturation color component of this color.
+ Returns the HSV saturation color component of this color.
- \sa saturation(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color Model}
+ \sa saturation(), hslSaturationF(), getHsvF(), {QColor#The HSV Color Model}{The HSV Color Model}
*/
qreal QColor::hsvSaturationF() const Q_DECL_NOTHROW
{
@@ -1746,9 +1754,9 @@ qreal QColor::valueF() const Q_DECL_NOTHROW
/*!
\since 4.6
- Returns the hue color component of this color.
+ Returns the HSL hue color component of this color.
- \sa getHslF(), getHsl()
+ \sa hslHueF(), hsvHue(), getHsl(), {QColor#The HSL Color Model}{The HSL Color Model}
*/
int QColor::hslHue() const Q_DECL_NOTHROW
{
@@ -1760,9 +1768,9 @@ int QColor::hslHue() const Q_DECL_NOTHROW
/*!
\since 4.6
- Returns the saturation color component of this color.
+ Returns the HSL saturation color component of this color.
- \sa saturationF(), getHsv(), {QColor#The HSV Color Model}{The HSV Color Model}
+ \sa hslSaturationF(), hsvSaturation(), getHsl(), {QColor#The HSL Color Model}{The HSL Color Model}
*/
int QColor::hslSaturation() const Q_DECL_NOTHROW
{
@@ -1788,9 +1796,9 @@ int QColor::lightness() const Q_DECL_NOTHROW
/*!
\since 4.6
- Returns the hue color component of this color.
+ Returns the HSL hue color component of this color.
- \sa hue(), getHslF()
+ \sa hslHue(), hsvHueF(), getHslF()
*/
qreal QColor::hslHueF() const Q_DECL_NOTHROW
{
@@ -1802,9 +1810,9 @@ qreal QColor::hslHueF() const Q_DECL_NOTHROW
/*!
\since 4.6
- Returns the saturation color component of this color.
+ Returns the HSL saturation color component of this color.
- \sa saturationF(), getHslF()
+ \sa hslSaturation(), hsvSaturationF(), getHslF(), {QColor#The HSL Color Model}{The HSL Color Model}
*/
qreal QColor::hslSaturationF() const Q_DECL_NOTHROW
{
@@ -2124,7 +2132,7 @@ QColor QColor::toHsv() const Q_DECL_NOTHROW
/*!
Creates and returns an HSL QColor based on this color.
- \sa fromHsl(), convertTo(), isValid()
+ \sa fromHsl(), convertTo(), isValid(), {QColor#The HSL Color Model}{The HSL Color Model}
*/
QColor QColor::toHsl() const Q_DECL_NOTHROW
{
@@ -2193,27 +2201,32 @@ QColor QColor::toCmyk() const Q_DECL_NOTHROW
color.cspec = Cmyk;
color.ct.acmyk.alpha = ct.argb.alpha;
- // rgb -> cmy
- const qreal r = ct.argb.red / qreal(USHRT_MAX);
- const qreal g = ct.argb.green / qreal(USHRT_MAX);
- const qreal b = ct.argb.blue / qreal(USHRT_MAX);
- qreal c = qreal(1.0) - r;
- qreal m = qreal(1.0) - g;
- qreal y = qreal(1.0) - b;
-
- // cmy -> cmyk
- const qreal k = qMin(c, qMin(m, y));
-
- if (!qFuzzyIsNull(k - 1)) {
+ if (!ct.argb.red && !ct.argb.green && !ct.argb.blue) {
+ // Avoid div-by-0 below
+ color.ct.acmyk.cyan = 0;
+ color.ct.acmyk.magenta = 0;
+ color.ct.acmyk.yellow = 0;
+ color.ct.acmyk.black = USHRT_MAX;
+ } else {
+ // rgb -> cmy
+ const qreal r = ct.argb.red / qreal(USHRT_MAX);
+ const qreal g = ct.argb.green / qreal(USHRT_MAX);
+ const qreal b = ct.argb.blue / qreal(USHRT_MAX);
+ qreal c = qreal(1.0) - r;
+ qreal m = qreal(1.0) - g;
+ qreal y = qreal(1.0) - b;
+
+ // cmy -> cmyk
+ const qreal k = qMin(c, qMin(m, y));
c = (c - k) / (qreal(1.0) - k);
m = (m - k) / (qreal(1.0) - k);
y = (y - k) / (qreal(1.0) - k);
- }
- color.ct.acmyk.cyan = qRound(c * USHRT_MAX);
- color.ct.acmyk.magenta = qRound(m * USHRT_MAX);
- color.ct.acmyk.yellow = qRound(y * USHRT_MAX);
- color.ct.acmyk.black = qRound(k * USHRT_MAX);
+ color.ct.acmyk.cyan = qRound(c * USHRT_MAX);
+ color.ct.acmyk.magenta = qRound(m * USHRT_MAX);
+ color.ct.acmyk.yellow = qRound(y * USHRT_MAX);
+ color.ct.acmyk.black = qRound(k * USHRT_MAX);
+ }
return color;
}
@@ -2431,7 +2444,7 @@ QColor QColor::fromHsvF(qreal h, qreal s, qreal v, qreal a)
The value of \a s, \a l, and \a a must all be in the range 0-255; the value
of \a h must be in the range 0-359.
- \sa toHsl(), fromHslF(), isValid()
+ \sa toHsl(), fromHslF(), isValid(), {QColor#The HSL Color Model}{The HSL Color Model}
*/
QColor QColor::fromHsl(int h, int s, int l, int a)
{
@@ -2463,7 +2476,7 @@ QColor QColor::fromHsl(int h, int s, int l, int a)
All the values must be in the range 0.0-1.0.
- \sa toHsl(), fromHsl(), isValid()
+ \sa toHsl(), fromHsl(), isValid(), {QColor#The HSL Color Model}{The HSL Color Model}
*/
QColor QColor::fromHslF(qreal h, qreal s, qreal l, qreal a)
{
diff --git a/src/gui/painting/qpathsimplifier.cpp b/src/gui/painting/qpathsimplifier.cpp
index 40585ec502..4251840bbc 100644
--- a/src/gui/painting/qpathsimplifier.cpp
+++ b/src/gui/painting/qpathsimplifier.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
diff --git a/src/gui/painting/qpathsimplifier_p.h b/src/gui/painting/qpathsimplifier_p.h
index 6ef298f6bf..6c0062c592 100644
--- a/src/gui/painting/qpathsimplifier_p.h
+++ b/src/gui/painting/qpathsimplifier_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp
index 0a3d802b21..c01531caf2 100644
--- a/src/gui/painting/qstroker.cpp
+++ b/src/gui/painting/qstroker.cpp
@@ -456,12 +456,12 @@ void QStroker::joinPoints(qfixed focal_x, qfixed focal_y, const QLineF &nextLine
return;
}
#endif
+ QLineF prevLine(qt_fixed_to_real(m_back2X), qt_fixed_to_real(m_back2Y),
+ qt_fixed_to_real(m_back1X), qt_fixed_to_real(m_back1Y));
+ QPointF isect;
+ QLineF::IntersectType type = prevLine.intersect(nextLine, &isect);
if (join == FlatJoin) {
- QLineF prevLine(qt_fixed_to_real(m_back2X), qt_fixed_to_real(m_back2Y),
- qt_fixed_to_real(m_back1X), qt_fixed_to_real(m_back1Y));
- QPointF isect;
- QLineF::IntersectType type = prevLine.intersect(nextLine, &isect);
QLineF shortCut(prevLine.p2(), nextLine.p1());
qreal angle = shortCut.angleTo(prevLine);
if (type == QLineF::BoundedIntersection || (angle > 90 && !qFuzzyCompare(angle, (qreal)90))) {
@@ -473,12 +473,6 @@ void QStroker::joinPoints(qfixed focal_x, qfixed focal_y, const QLineF &nextLine
qt_real_to_fixed(nextLine.y1()));
} else {
- QLineF prevLine(qt_fixed_to_real(m_back2X), qt_fixed_to_real(m_back2Y),
- qt_fixed_to_real(m_back1X), qt_fixed_to_real(m_back1Y));
-
- QPointF isect;
- QLineF::IntersectType type = prevLine.intersect(nextLine, &isect);
-
if (join == MiterJoin) {
qreal appliedMiterLimit = qt_fixed_to_real(m_strokeWidth * m_miterLimit);
@@ -513,7 +507,11 @@ void QStroker::joinPoints(qfixed focal_x, qfixed focal_y, const QLineF &nextLine
qfixed offset = m_strokeWidth / 2;
QLineF l1(prevLine);
- l1.translate(l1.dx(), l1.dy());
+ qreal dp = QPointF::dotProduct(QPointF(prevLine.dx(), prevLine.dy()), QPointF(nextLine.dx(), nextLine.dy()));
+ if (dp > 0) // same direction, means that prevLine is from a bezier that has been "reversed" by shifting
+ l1 = QLineF(prevLine.p2(), prevLine.p1());
+ else
+ l1.translate(l1.dx(), l1.dy());
l1.setLength(qt_fixed_to_real(offset));
QLineF l2(nextLine.p2(), nextLine.p1());
l2.translate(l2.dx(), l2.dy());
@@ -571,7 +569,11 @@ void QStroker::joinPoints(qfixed focal_x, qfixed focal_y, const QLineF &nextLine
// first control line
QLineF l1 = prevLine;
- l1.translate(l1.dx(), l1.dy());
+ qreal dp = QPointF::dotProduct(QPointF(prevLine.dx(), prevLine.dy()), QPointF(nextLine.dx(), nextLine.dy()));
+ if (dp > 0) // same direction, means that prevLine is from a bezier that has been "reversed" by shifting
+ l1 = QLineF(prevLine.p2(), prevLine.p1());
+ else
+ l1.translate(l1.dx(), l1.dy());
l1.setLength(QT_PATH_KAPPA * offset);
// second control line, find through normal between prevLine and focal.
@@ -706,7 +708,6 @@ template <class Iterator> bool qt_stroke_side(Iterator *it,
QPointF(qt_fixed_to_real(e.x), qt_fixed_to_real(e.y)),
QPointF(qt_fixed_to_real(cp2.x), qt_fixed_to_real(cp2.y)),
QPointF(qt_fixed_to_real(ep.x), qt_fixed_to_real(ep.y)));
-
int count = bezier.shifted(offsetCurves,
MAX_OFFSET,
offset,