diff options
Diffstat (limited to 'src/gui/painting')
| -rw-r--r-- | src/gui/painting/qcolor.cpp | 30 | ||||
| -rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 1 | ||||
| -rw-r--r-- | src/gui/painting/qpdf.cpp | 1 | ||||
| -rw-r--r-- | src/gui/painting/qstroker.cpp | 6 |
4 files changed, 22 insertions, 16 deletions
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index fe79490f54b..d63da38b747 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -2196,29 +2196,27 @@ QColor QColor::toHsv() const noexcept color.ct.ahsv.alpha = ct.argb.alpha; color.ct.ahsv.pad = 0; - const float r = ct.argb.red / float(USHRT_MAX); - const float g = ct.argb.green / float(USHRT_MAX); - const float b = ct.argb.blue / float(USHRT_MAX); - const float max = Q_MAX_3(r, g, b); - const float min = Q_MIN_3(r, g, b); - const float delta = max - min; - color.ct.ahsv.value = qRound(max * USHRT_MAX); - if (qFuzzyIsNull(delta)) { + const ushort r = ct.argb.red; + const ushort g = ct.argb.green; + const ushort b = ct.argb.blue; + const auto [min, max] = std::minmax({r, g, b}); + color.ct.ahsv.value = max; + if (max == min) { // achromatic case, hue is undefined color.ct.ahsv.hue = USHRT_MAX; color.ct.ahsv.saturation = 0; } else { // chromatic case - float hue = 0; + const float delta = max - min; // cannot overflow + float hue; color.ct.ahsv.saturation = qRound((delta / max) * USHRT_MAX); - if (qFuzzyCompare(r, max)) { - hue = ((g - b) /delta); - } else if (qFuzzyCompare(g, max)) { - hue = (2.0f + (b - r) / delta); - } else if (qFuzzyCompare(b, max)) { - hue = (4.0f + (r - g) / delta); + if (max == r) { + hue = 0 + (g - b) / delta; + } else if (max == g) { + hue = 2 + (b - r) / delta; } else { - Q_ASSERT_X(false, "QColor::toHsv", "internal error"); + Q_ASSERT(max == b); // max({r,g,b}) must be one of r, g, and b! + hue = 4 + (r - g) / delta; } hue *= 60.0f; if (hue < 0.0f) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 047be5f1c3d..8e815394849 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -2881,6 +2881,7 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, /*! + * \internal * Returns \c true if the rectangle is completely within the current clip * state of the paint engine. */ diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 908051a477c..b1ea3f240f1 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -3192,6 +3192,7 @@ static inline bool is_monochrome(const QList<QRgb> &colorTable) } /*! + * \internal * Adds an image to the pdf and return the pdf-object id. Returns -1 if adding the image failed. */ int QPdfEnginePrivate::addImage(const QImage &img, bool *bitmap, bool lossless, qint64 serial_no) diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index 0d435c95048..08128c30a70 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -145,6 +145,11 @@ static inline qreal adapted_angle_on_x(const QLineF &line) return QLineF(0, 0, 1, 0).angleTo(line); } +/*! + \class QStrokerOps + \inmodule QtGui + \internal +*/ QStrokerOps::QStrokerOps() : m_elements(0) , m_curveThreshold(qt_real_to_fixed(0.25)) @@ -373,6 +378,7 @@ QStroker::LineJoinMode QStroker::joinModeForJoin(Qt::PenJoinStyle joinStyle) /*! + \internal This function is called to stroke the currently built up subpath. The subpath is cleared when the function completes. */ |
