From 1015919e8e828f886fbd15e7929fb634363ddc35 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 17 Jun 2021 08:59:51 +0200 Subject: Add Qt7 TODOs for reducing the size of QColor It could fit into QVariant's inline storage if we didn't waste so much space. Change-Id: Ie9e592a49c955b0a97a202e0bd875183396af993 Reviewed-by: Fabian Kosmale --- src/gui/painting/qcolor.cpp | 6 ++++++ src/gui/painting/qcolor.h | 2 ++ 2 files changed, 8 insertions(+) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 8e5f6e31c7..d4725829aa 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -54,6 +54,12 @@ QT_BEGIN_NAMESPACE +// QColor fits into QVariant's internal storage on 64bit systems. +// It could also fit on 32bit systems, but we cannot make it happen in Qt6, due to BC. +#if QT_VERSION >= QT_VERSION_CHECK(7,0,0) || QT_POINTER_SIZE > 4 +static_assert(sizeof(QColor) <= QVariant::Private::MaxInternalSize); +#endif + /*! \internal If s[0..n] is a valid hex number, returns its integer value, diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index 06b264eacf..edeba6fe61 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -66,6 +66,8 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QColor &); class Q_GUI_EXPORT QColor { public: + // ### Qt7: make this "enum Spec: quint8 {...}" and reorder the members below for tighter + // struct packing. QColor could fit into the inline storage of a QVariant on 32bit. enum Spec { Invalid, Rgb, Hsv, Cmyk, Hsl, ExtendedRgb }; enum NameFormat { HexRgb, HexArgb }; -- cgit v1.2.3