Port QColorTransform to QESDP

Remove the hand-rolled refcount management code, and
cleanup the existing constructors.

Change-Id: I1b91dbf888feff25d67310637d42dcdc3acaac13
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
bb10
Giuseppe D'Angelo 2020-10-02 16:17:45 +02:00
parent 35c565e965
commit 56475926e6
3 changed files with 8 additions and 17 deletions

View File

@ -339,7 +339,6 @@ QColorTransform QColorSpacePrivate::transformationToColorSpace(const QColorSpace
QColorTransform combined;
auto ptr = new QColorTransformPrivate;
combined.d = ptr;
combined.d->ref.ref();
ptr->colorSpaceIn = this;
ptr->colorSpaceOut = out;
ptr->colorMatrix = out->toXyz.inverted() * toXyz;

View File

@ -134,19 +134,11 @@ void QColorTransformPrivate::updateLutsOut() const
*/
QColorTransform::QColorTransform(const QColorTransform &colorTransform) noexcept
: d(colorTransform.d)
{
if (d)
d->ref.ref();
}
QColorTransform::QColorTransform(const QColorTransform &colorTransform) noexcept = default;
QColorTransform::~QColorTransform() = default;
QColorTransform::~QColorTransform()
{
if (d && !d->ref.deref())
delete d;
}
QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QColorTransformPrivate)
/*!
Applies the color transformation on the QRgb value \a argb.

View File

@ -42,6 +42,7 @@
#include <QtGui/qtguiglobal.h>
#include <QtGui/qrgb.h>
#include <QtCore/qshareddata.h>
QT_BEGIN_NAMESPACE
@ -49,16 +50,15 @@ class QColor;
class QRgba64;
class QColorSpacePrivate;
class QColorTransformPrivate;
QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QColorTransformPrivate, Q_GUI_EXPORT)
class QColorTransform
{
public:
QColorTransform() noexcept : d(nullptr) { }
QColorTransform() noexcept = default;
Q_GUI_EXPORT ~QColorTransform();
Q_GUI_EXPORT QColorTransform(const QColorTransform &colorTransform) noexcept;
QColorTransform(QColorTransform &&colorTransform) noexcept
: d{qExchange(colorTransform.d, nullptr)}
{ }
QColorTransform(QColorTransform &&colorTransform) = default;
QColorTransform &operator=(const QColorTransform &other) noexcept
{
QColorTransform{other}.swap(*this);
@ -77,7 +77,7 @@ private:
friend class QColorSpacePrivate;
friend class QImage;
const QColorTransformPrivate *d;
QExplicitlySharedDataPointer<QColorTransformPrivate> d;
};
Q_DECLARE_SHARED(QColorTransform)