Remove public d_func from QColorSpace

Replaced with getter in private.

Change-Id: I968eb45052a80b45750213cf6a0c08b5973dfc4d
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
Allan Sandfeld Jensen 2019-07-12 10:33:07 +02:00
parent aa4470943d
commit 181e96cae2
6 changed files with 22 additions and 26 deletions

View File

@ -607,7 +607,8 @@ bool QPngHandlerPrivate::readPngHeader()
#endif
png_uint_32 profLen;
png_get_iCCP(png_ptr, info_ptr, &name, &compressionType, &profileData, &profLen);
if (!QIcc::fromIccProfile(QByteArray::fromRawData((const char *)profileData, profLen), &colorSpace)) {
colorSpace = QColorSpace::fromIccProfile(QByteArray::fromRawData((const char *)profileData, profLen));
if (!colorSpace.isValid()) {
qWarning() << "QPngHandler: Failed to parse ICC profile";
} else {
colorSpaceState = Icc;
@ -677,7 +678,7 @@ bool QPngHandlerPrivate::readPngImage(QImage *outImage)
// This configuration forces gamma correction and
// thus changes the output colorspace
png_set_gamma(png_ptr, 1.0f / gamma, fileGamma);
QColorSpacePrivate *csPrivate = colorSpace.d_func();
QColorSpacePrivate *csPrivate = QColorSpacePrivate::getWritable(colorSpace);
csPrivate->transferFunction = QColorSpace::TransferFunction::Gamma;
csPrivate->gamma = gamma;
csPrivate->setTransferFunction();

View File

@ -683,20 +683,6 @@ QColorTransform QColorSpace::transformationToColorSpace(const QColorSpace &color
return d_ptr->transformationToColorSpace(colorspace.d_ptr.constData());
}
/*!
\internal
*/
QColorSpacePrivate *QColorSpace::d_func()
{
d_ptr.detach();
return d_ptr.data();
}
/*!
\fn const QColorSpacePrivate* QColorSpacePrivate::d_func() const
\internal
*/
/*****************************************************************************
QColorSpace stream functions
*****************************************************************************/

View File

@ -113,11 +113,9 @@ public:
QColorTransform transformationToColorSpace(const QColorSpace &colorspace) const;
QColorSpacePrivate *d_func();
inline const QColorSpacePrivate *d_func() const { return d_ptr.constData(); }
private:
friend class QColorSpacePrivate;
Q_DECLARE_PRIVATE(QColorSpace)
QExplicitlySharedDataPointer<QColorSpacePrivate> d_ptr;
};

View File

@ -95,6 +95,17 @@ public:
QColorSpacePrivate(const QColorSpacePrimaries &primaries, QColorSpace::TransferFunction fun, float gamma);
QColorSpacePrivate(const QColorSpacePrivate &other) = default;
static QColorSpacePrivate *getWritable(QColorSpace &colorSpace)
{
colorSpace.d_ptr.detach();
return colorSpace.d_ptr.data();
}
static const QColorSpacePrivate *get(const QColorSpace &colorSpace)
{
return colorSpace.d_ptr.data();
}
void initialize();
void setToXyzMatrix();
void setTransferFunction();

View File

@ -288,7 +288,7 @@ QByteArray toIccProfile(const QColorSpace &space)
if (!space.isValid())
return QByteArray();
const QColorSpacePrivate *spaceDPtr = space.d_func();
const QColorSpacePrivate *spaceDPtr = QColorSpacePrivate::get(space);
constexpr int tagCount = 9;
constexpr uint profileDataOffset = 128 + 4 + 12 * tagCount;
@ -569,7 +569,7 @@ bool fromIccProfile(const QByteArray &data, QColorSpace *colorSpace)
qCWarning(lcIcc) << "fromIccProfile: Bad XYZ data type";
return false;
}
QColorSpacePrivate *colorspaceDPtr = colorSpace->d_func();
QColorSpacePrivate *colorspaceDPtr = QColorSpacePrivate::getWritable(*colorSpace);
colorspaceDPtr->toXyz.r = fromXyzData(rXyz);
colorspaceDPtr->toXyz.g = fromXyzData(gXyz);

View File

@ -304,11 +304,11 @@ void tst_QColorSpace::primariesXyz()
QColorSpace bt2020 = QColorSpace::Bt2020;
// Check if our calculated matrices, match the precalculated ones.
QCOMPARE(sRgb.d_func()->toXyz, QColorMatrix::toXyzFromSRgb());
QCOMPARE(adobeRgb.d_func()->toXyz, QColorMatrix::toXyzFromAdobeRgb());
QCOMPARE(displayP3.d_func()->toXyz, QColorMatrix::toXyzFromDciP3D65());
QCOMPARE(proPhotoRgb.d_func()->toXyz, QColorMatrix::toXyzFromProPhotoRgb());
QCOMPARE(bt2020.d_func()->toXyz, QColorMatrix::toXyzFromBt2020());
QCOMPARE(QColorSpacePrivate::get(sRgb)->toXyz, QColorMatrix::toXyzFromSRgb());
QCOMPARE(QColorSpacePrivate::get(adobeRgb)->toXyz, QColorMatrix::toXyzFromAdobeRgb());
QCOMPARE(QColorSpacePrivate::get(displayP3)->toXyz, QColorMatrix::toXyzFromDciP3D65());
QCOMPARE(QColorSpacePrivate::get(proPhotoRgb)->toXyz, QColorMatrix::toXyzFromProPhotoRgb());
QCOMPARE(QColorSpacePrivate::get(bt2020)->toXyz, QColorMatrix::toXyzFromBt2020());
}
void tst_QColorSpace::primaries2_data()