diff --git a/src/gui/painting/qcolormatrix_p.h b/src/gui/painting/qcolormatrix_p.h index 70d2137119..edb2d32258 100644 --- a/src/gui/painting/qcolormatrix_p.h +++ b/src/gui/painting/qcolormatrix_p.h @@ -62,17 +62,16 @@ class QColorVector { public: QColorVector() = default; - Q_DECL_CONSTEXPR QColorVector(float x, float y, float z) : x(x), y(y), z(z), _unused(0.0f) { } + Q_DECL_CONSTEXPR QColorVector(float x, float y, float z) : x(x), y(y), z(z) { } explicit Q_DECL_CONSTEXPR QColorVector(const QPointF &chr) // from XY chromaticity : x(chr.x() / chr.y()) , y(1.0f) , z((1.0 - chr.x() - chr.y()) / chr.y()) - , _unused(0.0f) { } - float x; // X, x or red - float y; // Y, y or green - float z; // Z, Y or blue - float _unused; + float x = 0.0f; // X, x or red + float y = 0.0f; // Y, y or green + float z = 0.0f; // Z, Y or blue + float _unused = 0.0f; friend inline bool operator==(const QColorVector &v1, const QColorVector &v2); friend inline bool operator!=(const QColorVector &v1, const QColorVector &v2); @@ -81,7 +80,6 @@ public: return !x && !y && !z; } - static Q_DECL_CONSTEXPR QColorVector null() { return QColorVector(0.0f, 0.0f, 0.0f); } static bool isValidChromaticity(const QPointF &chr) { if (chr.x() < qreal(0.0) || chr.x() > qreal(1.0)) @@ -187,10 +185,6 @@ public: { r.z, g.z, b.z } }; } - static QColorMatrix null() - { - return { QColorVector::null(), QColorVector::null(), QColorVector::null() }; - } static QColorMatrix identity() { return { { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f } }; diff --git a/src/gui/painting/qcolorspace.cpp b/src/gui/painting/qcolorspace.cpp index 720c531e3f..937bb505c9 100644 --- a/src/gui/painting/qcolorspace.cpp +++ b/src/gui/painting/qcolorspace.cpp @@ -146,17 +146,11 @@ QColorMatrix QColorSpacePrimaries::toXyzMatrix() const } QColorSpacePrivate::QColorSpacePrivate() - : primaries(QColorSpace::Primaries::Custom) - , transferFunction(QColorSpace::TransferFunction::Custom) - , gamma(0.0f) - , whitePoint(QColorVector::null()) - , toXyz(QColorMatrix::null()) { } QColorSpacePrivate::QColorSpacePrivate(QColorSpace::NamedColorSpace namedColorSpace) : namedColorSpace(namedColorSpace) - , gamma(0.0f) { switch (namedColorSpace) { case QColorSpace::SRgb: @@ -282,7 +276,7 @@ void QColorSpacePrivate::initialize() void QColorSpacePrivate::setToXyzMatrix() { if (primaries == QColorSpace::Primaries::Custom) { - toXyz = QColorMatrix::null(); + toXyz = QColorMatrix(); whitePoint = QColorVector::D50(); return; } diff --git a/src/gui/painting/qcolorspace_p.h b/src/gui/painting/qcolorspace_p.h index c06681df6b..e7add19ed3 100644 --- a/src/gui/painting/qcolorspace_p.h +++ b/src/gui/painting/qcolorspace_p.h @@ -124,9 +124,9 @@ public: static constexpr QColorSpace::NamedColorSpace Unknown = QColorSpace::NamedColorSpace(0); QColorSpace::NamedColorSpace namedColorSpace = Unknown; - QColorSpace::Primaries primaries; - QColorSpace::TransferFunction transferFunction; - float gamma; + QColorSpace::Primaries primaries = QColorSpace::Primaries::Custom; + QColorSpace::TransferFunction transferFunction = QColorSpace::TransferFunction::Custom; + float gamma = 0.0f; QColorVector whitePoint; QColorTrc trc[3]; diff --git a/src/gui/painting/qcolortransform.cpp b/src/gui/painting/qcolortransform.cpp index 53fd1dfbaa..10ccefed74 100644 --- a/src/gui/painting/qcolortransform.cpp +++ b/src/gui/painting/qcolortransform.cpp @@ -612,6 +612,15 @@ static void storeOpaque(QRgba64 *dst, const QRgba64 *src, const QColorVector *bu static constexpr qsizetype WorkBlockSize = 256; +template +class QUninitialized +{ +public: + operator T*() { return reinterpret_cast(this); } +private: + alignas(T) char data[sizeof(T) * Count]; +}; + template void QColorTransformPrivate::apply(T *dst, const T *src, qsizetype count, TransformFlags flags) const { @@ -623,7 +632,8 @@ void QColorTransformPrivate::apply(T *dst, const T *src, qsizetype count, Transf bool doApplyMatrix = (colorMatrix != QColorMatrix::identity()); - QColorVector buffer[WorkBlockSize]; + QUninitialized buffer; + qsizetype i = 0; while (i < count) { const qsizetype len = qMin(count - i, WorkBlockSize);