diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-07-11 17:51:15 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-07-12 14:15:35 +0200 |
commit | 389988c42f901f2d8f75a023039d641cf5fba9de (patch) | |
tree | 8de2968ec5bee4fbff576d9689650f5de733e917 /src/gui/painting/qcolortransform.h | |
parent | 79f9adffc5158b906830dcd7dbdf0e5d44f7ba22 (diff) |
QColorTransform: make fit for release
- Unexport the value class, export only out-of-line public member functions
to give us more leeway in changing code later (otherwise, we'd be bound
by BC with MSVC debug builds, which call even inline methods from the DLL.
- Don't use QSharedPointer as the d_ptr. It's twice the size of a pointer.
Use a naked pointer-to-const. Derive Private from QSharedData. This
requires some changes in QColorSpace, and, as usual, an out-of-line copy
ctor.
- Add member-swap(), Q_DECLARE_SHARED().
- Drop noexcept from the dtor. It implicitly is, adding it explicitly looks
weird.
- Pass QRgb and QRgba64 by value, not by cref. They're trivially-copyable,
so passed in registers if passed by value. Passing by cref forces them
onto the stack.
Change-Id: I669643d219ede6b7d07f15afbf8728e16150b3b2
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/gui/painting/qcolortransform.h')
-rw-r--r-- | src/gui/painting/qcolortransform.h | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/gui/painting/qcolortransform.h b/src/gui/painting/qcolortransform.h index a83611d666..5fb51739a7 100644 --- a/src/gui/painting/qcolortransform.h +++ b/src/gui/painting/qcolortransform.h @@ -51,41 +51,42 @@ class QRgba64; class QColorSpacePrivate; class QColorTransformPrivate; -class Q_GUI_EXPORT QColorTransform +class QColorTransform { public: - QColorTransform() noexcept : d_ptr(nullptr) { } - ~QColorTransform() noexcept; - QColorTransform(const QColorTransform &colorTransform) noexcept - : d_ptr(colorTransform.d_ptr) - { } + QColorTransform() noexcept : d(nullptr) { } + Q_GUI_EXPORT ~QColorTransform(); + Q_GUI_EXPORT QColorTransform(const QColorTransform &colorTransform) noexcept; QColorTransform(QColorTransform &&colorTransform) noexcept - : d_ptr(std::move(colorTransform.d_ptr)) + : d{qExchange(colorTransform.d, nullptr)} { } QColorTransform &operator=(const QColorTransform &other) noexcept { - d_ptr = other.d_ptr; + QColorTransform{other}.swap(*this); return *this; } QColorTransform &operator=(QColorTransform &&other) noexcept { - d_ptr = std::move(other.d_ptr); + QColorTransform{std::move(other)}.swap(*this); return *this; } - QRgb map(const QRgb &argb) const; - QRgba64 map(const QRgba64 &rgba64) const; - QColor map(const QColor &color) const; + void swap(QColorTransform &other) noexcept { qSwap(d, other.d); } + + Q_GUI_EXPORT QRgb map(QRgb argb) const; + Q_GUI_EXPORT QRgba64 map(QRgba64 rgba64) const; + Q_GUI_EXPORT QColor map(const QColor &color) const; private: friend class QColorSpace; friend class QColorSpacePrivate; friend class QImage; - Q_DECLARE_PRIVATE(QColorTransform) - QSharedPointer<QColorTransformPrivate> d_ptr; + const QColorTransformPrivate *d; }; +Q_DECLARE_SHARED(QColorTransform) + QT_END_NAMESPACE #endif // QCOLORTRANSFORM_H |