From cc1ea2bf47f386befff1a3a419588b5b422f0346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 30 Aug 2019 17:41:23 +0200 Subject: Simplify QColorSpace named presets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't need a getter for the 'preset' of a color-space, as color spaces can be compared to the presets directly. This allows us to remove the Undefined and Unknown values from the presets. Internally we still distinguish known presets from unknown or undefined presets via the magic 0-value. The validity of a QColorSpace is not based on this preset, but on its actual values. Fixes: QTBUG-77963 Change-Id: I1e0a2a4be83021b8c82b3c778019f680fd46455b Reviewed-by: Tor Arne Vestbø --- src/gui/painting/qcolorspace.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/gui/painting/qcolorspace.h') diff --git a/src/gui/painting/qcolorspace.h b/src/gui/painting/qcolorspace.h index 880f0ad4cf..11987b9a37 100644 --- a/src/gui/painting/qcolorspace.h +++ b/src/gui/painting/qcolorspace.h @@ -54,17 +54,15 @@ class Q_GUI_EXPORT QColorSpace { Q_GADGET public: - enum ColorSpaceId { - Undefined = 0, - Unknown = 1, - SRgb, + enum NamedColorSpace { + SRgb = 1, SRgbLinear, AdobeRgb, DisplayP3, ProPhotoRgb, Bt2020, }; - Q_ENUM(ColorSpaceId) + Q_ENUM(NamedColorSpace) enum class Primaries { Custom = 0, SRgb, @@ -84,7 +82,8 @@ public: }; Q_ENUM(TransferFunction) - QColorSpace(ColorSpaceId colorSpaceId = Undefined); + QColorSpace(); + QColorSpace(NamedColorSpace namedColorSpace); QColorSpace(Primaries primaries, TransferFunction fun, float gamma = 0.0f); QColorSpace(Primaries primaries, float gamma); QColorSpace(const QPointF &whitePoint, const QPointF &redPoint, @@ -108,7 +107,6 @@ public: void swap(QColorSpace &colorSpace) noexcept { qSwap(d_ptr, colorSpace.d_ptr); } - ColorSpaceId colorSpaceId() const noexcept; Primaries primaries() const noexcept; TransferFunction transferFunction() const noexcept; float gamma() const noexcept; @@ -133,7 +131,11 @@ public: private: Q_DECLARE_PRIVATE(QColorSpace) - QColorSpacePrivate *d_ptr; + QColorSpacePrivate *d_ptr = nullptr; + +#ifndef QT_NO_DEBUG_STREAM + friend Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QColorSpace &colorSpace); +#endif }; bool Q_GUI_EXPORT operator==(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2); -- cgit v1.2.3