summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2014-08-03 02:46:00 +0200
committerOswald Buddenhagen <oswald.buddenhagen@digia.com>2014-08-09 09:05:24 +0200
commit2431bf1b20e2815e0da3d294cce129de775b8f39 (patch)
tree88f6620ca52c95068f7dfc5a348f3c8c94c67907 /src
parent184fd8aa6c61d642b99391487e11985478a2cb5b (diff)
QPixelFormat: don't inherit it
Instead of abusing inheritance to provide convenience constructors, use simple inline constructor functions. The name got a lower-case q to indicate a free function. The usual fromXYZ() static methods were deemed not fitting in this case in the initial round of review, since they implied some kind of conversion while these functions are simply constructors of formsts, which contain no data. This also solves the problem that some of these ctors could have been called with just one argument and were therefore candidates for hidden QPixelFormat temporary injection. QPixelFormatRgb was renamed to qPixelFormatRgba to explain the third argument at the call site better. There seem to be no users of this class in qt5.git at this time. Change-Id: Ib4fe8ceb2d30744127b116a748724a3406400eb8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qpixelformat.cpp157
-rw-r--r--src/gui/kernel/qpixelformat.h280
2 files changed, 155 insertions, 282 deletions
diff --git a/src/gui/kernel/qpixelformat.cpp b/src/gui/kernel/qpixelformat.cpp
index 6368e9c83e..441707791f 100644
--- a/src/gui/kernel/qpixelformat.cpp
+++ b/src/gui/kernel/qpixelformat.cpp
@@ -253,29 +253,18 @@ QT_BEGIN_NAMESPACE
YUV type The default value is 0.
*/
-Q_STATIC_ASSERT(sizeof(QPixelFormatRgb) == sizeof(QPixelFormat));
-
/*!
- \class QPixelFormatRgb
- \inmodule QtGui
- \since 5.4
- \brief QPixelFormatRgb is a helper class for creating pixel formats with
- the rgb color model
-
- The size of QPixelFormatRgb is guaranteed to be the size of QPixelFormat.
-*/
-
-/*!
- \fn QPixelFormatRgb::QPixelFormatRgb(uchar redSize,
- uchar greenSize,
- uchar blueSize,
- uchar alphaSize,
- AlphaUsage alphaUsage,
- AlphaPosition alphaPosition,
- AlphaPremultiplied premultiplied = NotPremultiplied,
- TypeInterpretation typeInterpretation = UnsignedInteger)
-
- Constructor making an RGB pixelformat. \a redSize \a greenSize \a
+ \fn QPixelFormat qPixelFormatRgba(uchar redSize,
+ uchar greenSize,
+ uchar blueSize,
+ uchar alphaSize,
+ QPixelFormat::AlphaUsage alphaUsage,
+ QPixelFormat::AlphaPosition alphaPosition,
+ QPixelFormat::AlphaPremultiplied premultiplied = QPixelFormat::NotPremultiplied,
+ QPixelFormat::TypeInterpretation typeInterpretation = QPixelFormat::UnsignedInteger)
+ \relates QPixelFormat
+
+ Constructor function making an RGB pixelformat. \a redSize \a greenSize \a
blueSize represent the size of each color channel. \a alphaSize describes
the alpha channel size and its position is described with \a alphaPosition.
\a alphaUsage is used to determine if the alpha channel is used or not.
@@ -284,79 +273,49 @@ Q_STATIC_ASSERT(sizeof(QPixelFormatRgb) == sizeof(QPixelFormat));
bits combined. \a premultiplied \a typeInterpretation are
accessible with accessors with the same name.
- \sa TypeInterpretation
+ \sa QPixelFormat::TypeInterpretation
*/
-Q_STATIC_ASSERT(sizeof(QPixelFormatGrayscale) == sizeof(QPixelFormat));
/*!
- \class QPixelFormatGrayscale
- \inmodule QtGui
- \since 5.4
- \brief QPixelFormatGrayscale is a helper class for creating pixel formats with
- the gray scale color model.
+ \fn QPixelFormat qPixelFormatGrayscale(uchar channelSize,
+ QPixelFormat::TypeInterpretation typeInterpretation = QPixelFormat::UnsignedInteger)
+ \relates QPixelFormat
- The size of QPixelFormatGrayscale is guaranteed to be the size of QPixelFormat.
-*/
-
-/*!
- \fn QPixelFormatGrayscale::QPixelFormatGrayscale(uchar channelSize,
- TypeInterpretation typeInterpretation = UnsignedInteger)
-
- Constructor for creating a Grayscale format. Monochrome formats can be
+ Constructor function for creating a Grayscale format. Monochrome formats can be
described by passing 1 to \a channelSize. Its also possible to define very
accurate greyscale formats using doubles to describe each pixel by passing 8
as \a channelSize and FloatingPoint as \a typeInterpretation.
- \sa TypeInterpretation
+ \sa QPixelFormat::TypeInterpretation
*/
-Q_STATIC_ASSERT(sizeof(QPixelFormatCmyk) == sizeof(QPixelFormat));
/*!
- \class QPixelFormatCmyk
- \inmodule QtGui
- \since 5.4
- \brief QPixelFormatCmyk is a helper class for creating pixel formats with
- the CMYK color model
+ \fn QPixelFormat qPixelFormatCmyk(uchar channelSize,
+ uchar alphaSize = 0,
+ QPixelFormat::AlphaUsage alphaUsage = QPixelFormat::IgnoresAlpha,
+ QPixelFormat::AlphaPosition alphaPosition = QPixelFormat::AtBeginning,
+ QPixelFormat::TypeInterpretation typeInterpretation = QPixelFormat::UnsignedInteger)
+ \relates QPixelFormat
- The size of QPixelFormatCmyk is guaranteed to be the size of QPixelFormat.
-*/
-
-/*!
- \fn QPixelFormatCmyk::QPixelFormatCmyk(uchar channelSize,
- uchar alphaSize = 0,
- AlphaUsage alphaUsage = IgnoresAlpha,
- AlphaPosition alphaPosition = AtBeginning,
- TypeInterpretation typeInterpretation = UnsignedInteger)
-
- Constructor for creating CMYK formats. The channel count will be 4 or
+ Constructor function for creating CMYK formats. The channel count will be 4 or
5 depending on if \a alphaSize is bigger than zero or not. The CMYK color
channels will all be set to the value of \a channelSize.
\a alphaUsage \a alphaPosition and \a typeInterpretation are all accessible with
the accessors with the same name.
- \sa TypeInterpretation
-*/
-
-Q_STATIC_ASSERT(sizeof(QPixelFormatHsl) == sizeof(QPixelFormat));
-/*!
- \class QPixelFormatHsl
- \inmodule QtGui
- \since 5.4
- \brief QPixelFormatHsl is a helper class for creating pixel formats with
- the HSL color model.
-
- The size of QPixelFormatHsl is guaranteed to be the size of QPixelFormat.
+ \sa QPixelFormat::TypeInterpretation
*/
/*!
- \fn QPixelFormatHsl::QPixelFormatHsl(uchar channelSize,
- uchar alphaSize = 0,
- AlphaUsage alphaUsage = IgnoresAlpha,
- AlphaPosition alphaPosition = AtBeginning,
- TypeInterpretation typeInterpretation = FloatingPoint)
+ \fn QPixelFormat qPixelFormatHsl(uchar channelSize,
+ uchar alphaSize = 0,
+ QPixelFormat::AlphaUsage alphaUsage = QPixelFormat::IgnoresAlpha,
+ QPixelFormat::AlphaPosition alphaPosition = QPixelFormat::AtBeginning,
+ QPixelFormat::TypeInterpretation typeInterpretation = QPixelFormat::FloatingPoint)
+ \relates QPixelFormat
- Constructor for creating HSL formats. The channel count will be 3 or 4
+ Constructor function for creating HSL formats. The channel count will be 3 or 4
depending on if \a alphaSize is bigger than 0.
\a channelSize will set the hueSize saturationSize and lightnessSize to the same value.
@@ -365,25 +324,15 @@ Q_STATIC_ASSERT(sizeof(QPixelFormatHsl) == sizeof(QPixelFormat));
the accessors with the same name.
*/
-Q_STATIC_ASSERT(sizeof(QPixelFormatHsv) == sizeof(QPixelFormat));
-/*!
- \class QPixelFormatHsv
- \inmodule QtGui
- \since 5.4
- \brief QPixelFormatHsv is a helper class for creating pixel formats with
- the HSV color model.
-
- The size of QPixelFormatHsv is guaranteed to be the size of QPixelFormat.
-*/
-
/*!
- \fn QPixelFormatHsv::QPixelFormatHsv(uchar channelSize,
- uchar alphaSize = 0,
- AlphaUsage alphaUsage = IgnoresAlpha,
- AlphaPosition alphaPosition = AtBeginning,
- TypeInterpretation typeInterpretation = FloatingPoint)
+ \fn QPixelFormat qPixelFormatHsv(uchar channelSize,
+ uchar alphaSize = 0,
+ QPixelFormat::AlphaUsage alphaUsage = QPixelFormat::IgnoresAlpha,
+ QPixelFormat::AlphaPosition alphaPosition = QPixelFormat::AtBeginning,
+ QPixelFormat::TypeInterpretation typeInterpretation = QPixelFormat::FloatingPoint)
+ \relates QPixelFormat
- Constructor for creating HSV formats. The channel count will be 3 or 4
+ Constructor function for creating HSV formats. The channel count will be 3 or 4
depending on if \a alphaSize is bigger than 0.
\a channelSize will set the hueSize saturationSize and brightnessSize to the same value.
@@ -392,27 +341,17 @@ Q_STATIC_ASSERT(sizeof(QPixelFormatHsv) == sizeof(QPixelFormat));
the accessors with the same name.
*/
-Q_STATIC_ASSERT(sizeof(QPixelFormatYuv) == sizeof(QPixelFormat));
-/*!
- \class QPixelFormatYuv
- \inmodule QtGui
- \since 5.4
- \brief QPixelFormatYuv is a helper class for creating pixel formats with
- the YUV color model.
-
- The size of QPixelFormatYuv is guaranteed to be the size of QPixelFormat.
-*/
-
/*!
- \fn QPixelFormatYuv::QPixelFormatYuv(YUVLayout yuvLayout,
- uchar alphaSize = 0,
- AlphaUsage alphaUsage = IgnoresAlpha,
- AlphaPosition alphaPosition = AtBeginning,
- AlphaPremultiplied premultiplied = NotPremultiplied,
- TypeInterpretation typeInterpretation = UnsignedByte,
- ByteOrder byteOrder = LittleEndian)
+ \fn QPixelFormat qPixelFormatYuv(QPixelFormat::YUVLayout yuvLayout,
+ uchar alphaSize = 0,
+ QPixelFormat::AlphaUsage alphaUsage = QPixelFormat::IgnoresAlpha,
+ QPixelFormat::AlphaPosition alphaPosition = QPixelFormat::AtBeginning,
+ QPixelFormat::AlphaPremultiplied premultiplied = QPixelFormat::NotPremultiplied,
+ QPixelFormat::TypeInterpretation typeInterpretation = QPixelFormat::UnsignedByte,
+ QPixelFormat::ByteOrder byteOrder = QPixelFormat::LittleEndian)
+ \relates QPixelFormat
- Constructor for creating a QPixelFormat describing a YUV format with
+ Constructor function for creating a QPixelFormat describing a YUV format with
\a yuvLayout. \a alphaSize describes the size of a potential alpha channel
and is position is described with \a alphaPosition. The "first" "second" ..
"fifth" channels are all set to 0. \a alphaUsage \a premultiplied \a
diff --git a/src/gui/kernel/qpixelformat.h b/src/gui/kernel/qpixelformat.h
index 2b8d23736d..d11002cbc9 100644
--- a/src/gui/kernel/qpixelformat.h
+++ b/src/gui/kernel/qpixelformat.h
@@ -230,60 +230,6 @@ private:
Q_STATIC_ASSERT(sizeof(QPixelFormat) == sizeof(quint64));
Q_DECLARE_TYPEINFO(QPixelFormat, Q_PRIMITIVE_TYPE);
-class QPixelFormatRgb : public QPixelFormat
-{
-public:
- Q_DECL_CONSTEXPR
- inline QPixelFormatRgb(uchar redSize,
- uchar greenSize,
- uchar blueSize,
- uchar alphaSize,
- AlphaUsage alphaUsage,
- AlphaPosition alphaPosition,
- AlphaPremultiplied premultiplied = NotPremultiplied,
- TypeInterpretation typeInterpretation = UnsignedInteger) Q_DECL_NOTHROW;
-};
-
-class QPixelFormatGrayscale : public QPixelFormat
-{
-public:
- Q_DECL_CONSTEXPR
- inline QPixelFormatGrayscale(uchar bufferSize,
- TypeInterpretation typeInterpretation = UnsignedInteger) Q_DECL_NOTHROW;
-};
-
-class QPixelFormatCmyk : public QPixelFormat
-{
-public:
- Q_DECL_CONSTEXPR
- inline QPixelFormatCmyk(uchar channelSize,
- uchar alphaSize = 0,
- AlphaUsage alphaUsage = IgnoresAlpha,
- AlphaPosition alphaPosition = AtBeginning,
- TypeInterpretation typeInterpretation = UnsignedInteger) Q_DECL_NOTHROW;
-};
-
-class QPixelFormatHsl : public QPixelFormat
-{
-public:
- Q_DECL_CONSTEXPR
- inline QPixelFormatHsl(uchar channelSize,
- uchar alphaSize = 0,
- AlphaUsage alphaUsage = IgnoresAlpha,
- AlphaPosition alphaPosition = AtBeginning,
- TypeInterpretation typeInterpretation = FloatingPoint) Q_DECL_NOTHROW;
-};
-
-class QPixelFormatHsv : public QPixelFormat
-{
-public:
- Q_DECL_CONSTEXPR
- inline QPixelFormatHsv(uchar channelSize,
- uchar alphaSize = 0,
- AlphaUsage alphaUsage = IgnoresAlpha,
- AlphaPosition alphaPosition = AtBeginning,
- TypeInterpretation typeInterpretation = FloatingPoint) Q_DECL_NOTHROW;
-};
namespace QtPrivate {
QPixelFormat Q_GUI_EXPORT QPixelFormat_createYUV(QPixelFormat::YUVLayout yuvLayout,
@@ -295,18 +241,6 @@ namespace QtPrivate {
QPixelFormat::ByteOrder byteOrder);
}
-class QPixelFormatYuv : public QPixelFormat
-{
-public:
- inline QPixelFormatYuv(YUVLayout yuvLayout,
- uchar alphaSize = 0,
- AlphaUsage alphaUsage = IgnoresAlpha,
- AlphaPosition alphaPosition = AtBeginning,
- AlphaPremultiplied premultiplied = NotPremultiplied,
- TypeInterpretation typeInterpretation = UnsignedByte,
- ByteOrder byteOrder = LittleEndian);
-};
-
Q_DECL_CONSTEXPR
QPixelFormat::QPixelFormat(ColorModel mdl,
uchar firstSize,
@@ -338,117 +272,117 @@ QPixelFormat::QPixelFormat(ColorModel mdl,
{
}
-Q_DECL_CONSTEXPR
-QPixelFormatRgb::QPixelFormatRgb(uchar red,
- uchar green,
- uchar blue,
- uchar alfa,
- AlphaUsage usage,
- AlphaPosition position,
- AlphaPremultiplied pmul,
- TypeInterpretation typeInt) Q_DECL_NOTHROW
- : QPixelFormat(RGB,
- red,
- green,
- blue,
- 0,
- 0,
- alfa,
- usage,
- position,
- pmul,
- typeInt)
-{ }
+Q_DECL_CONSTEXPR inline QPixelFormat qPixelFormatRgba(uchar red,
+ uchar green,
+ uchar blue,
+ uchar alfa,
+ QPixelFormat::AlphaUsage usage,
+ QPixelFormat::AlphaPosition position,
+ QPixelFormat::AlphaPremultiplied pmul=QPixelFormat::NotPremultiplied,
+ QPixelFormat::TypeInterpretation typeInt=QPixelFormat::UnsignedInteger) Q_DECL_NOTHROW
+{
+ return QPixelFormat(QPixelFormat::RGB,
+ red,
+ green,
+ blue,
+ 0,
+ 0,
+ alfa,
+ usage,
+ position,
+ pmul,
+ typeInt);
+}
-Q_DECL_CONSTEXPR
-QPixelFormatGrayscale::QPixelFormatGrayscale(uchar channelSize,
- TypeInterpretation typeInt) Q_DECL_NOTHROW
- : QPixelFormat(Grayscale,
- channelSize,
- 0,
- 0,
- 0,
- 0,
- 0,
- IgnoresAlpha,
- AtBeginning,
- NotPremultiplied,
- typeInt)
-{ }
+Q_DECL_CONSTEXPR inline QPixelFormat qPixelFormatGrayscale(uchar channelSize,
+ QPixelFormat::TypeInterpretation typeInt=QPixelFormat::UnsignedInteger) Q_DECL_NOTHROW
+{
+ return QPixelFormat(QPixelFormat::Grayscale,
+ channelSize,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ QPixelFormat::IgnoresAlpha,
+ QPixelFormat::AtBeginning,
+ QPixelFormat::NotPremultiplied,
+ typeInt);
+}
-Q_DECL_CONSTEXPR
-QPixelFormatCmyk::QPixelFormatCmyk(uchar channelSize,
- uchar alfa,
- AlphaUsage usage,
- AlphaPosition position,
- TypeInterpretation typeInt) Q_DECL_NOTHROW
- : QPixelFormat(CMYK,
- channelSize,
- channelSize,
- channelSize,
- channelSize,
- 0,
- alfa,
- usage,
- position,
- NotPremultiplied,
- typeInt)
-{ }
+Q_DECL_CONSTEXPR inline QPixelFormat qPixelFormatCmyk(uchar channelSize,
+ uchar alfa=0,
+ QPixelFormat::AlphaUsage usage=QPixelFormat::IgnoresAlpha,
+ QPixelFormat::AlphaPosition position=QPixelFormat::AtBeginning,
+ QPixelFormat::TypeInterpretation typeInt=QPixelFormat::UnsignedInteger) Q_DECL_NOTHROW
+{
+ return QPixelFormat(QPixelFormat::CMYK,
+ channelSize,
+ channelSize,
+ channelSize,
+ channelSize,
+ 0,
+ alfa,
+ usage,
+ position,
+ QPixelFormat::NotPremultiplied,
+ typeInt);
+}
-Q_DECL_CONSTEXPR
-QPixelFormatHsl::QPixelFormatHsl(uchar channelSize,
- uchar alfa,
- AlphaUsage usage,
- AlphaPosition position,
- TypeInterpretation typeInt) Q_DECL_NOTHROW
- : QPixelFormat(HSL,
- channelSize,
- channelSize,
- channelSize,
- 0,
- 0,
- alfa,
- usage,
- position,
- NotPremultiplied,
- typeInt)
-{ }
+Q_DECL_CONSTEXPR inline QPixelFormat qPixelFormatHsl(uchar channelSize,
+ uchar alfa=0,
+ QPixelFormat::AlphaUsage usage=QPixelFormat::IgnoresAlpha,
+ QPixelFormat::AlphaPosition position=QPixelFormat::AtBeginning,
+ QPixelFormat::TypeInterpretation typeInt=QPixelFormat::FloatingPoint) Q_DECL_NOTHROW
+{
+ return QPixelFormat(QPixelFormat::HSL,
+ channelSize,
+ channelSize,
+ channelSize,
+ 0,
+ 0,
+ alfa,
+ usage,
+ position,
+ QPixelFormat::NotPremultiplied,
+ typeInt);
+}
-Q_DECL_CONSTEXPR
-QPixelFormatHsv::QPixelFormatHsv(uchar channelSize,
- uchar alfa,
- AlphaUsage usage,
- AlphaPosition position,
- TypeInterpretation typeInt) Q_DECL_NOTHROW
- : QPixelFormat(HSV,
- channelSize,
- channelSize,
- channelSize,
- 0,
- 0,
- alfa,
- usage,
- position,
- NotPremultiplied,
- typeInt)
-{ }
-
-QPixelFormatYuv::QPixelFormatYuv(YUVLayout layout,
- uchar alfa,
- AlphaUsage usage,
- AlphaPosition position,
- AlphaPremultiplied p_mul,
- TypeInterpretation typeInt,
- ByteOrder b_order)
- : QPixelFormat(QtPrivate::QPixelFormat_createYUV(layout,
- alfa,
- usage,
- position,
- p_mul,
- typeInt,
- b_order))
-
-{ }
+Q_DECL_CONSTEXPR inline QPixelFormat qPixelFormatHsv(uchar channelSize,
+ uchar alfa=0,
+ QPixelFormat::AlphaUsage usage=QPixelFormat::IgnoresAlpha,
+ QPixelFormat::AlphaPosition position=QPixelFormat::AtBeginning,
+ QPixelFormat::TypeInterpretation typeInt=QPixelFormat::FloatingPoint) Q_DECL_NOTHROW
+{
+ return QPixelFormat(QPixelFormat::HSV,
+ channelSize,
+ channelSize,
+ channelSize,
+ 0,
+ 0,
+ alfa,
+ usage,
+ position,
+ QPixelFormat::NotPremultiplied,
+ typeInt);
+}
+
+inline QPixelFormat qPixelFormatYuv(QPixelFormat::YUVLayout layout,
+ uchar alfa=0,
+ QPixelFormat::AlphaUsage usage=QPixelFormat::IgnoresAlpha,
+ QPixelFormat::AlphaPosition position=QPixelFormat::AtBeginning,
+ QPixelFormat::AlphaPremultiplied p_mul=QPixelFormat::NotPremultiplied,
+ QPixelFormat::TypeInterpretation typeInt=QPixelFormat::UnsignedByte,
+ QPixelFormat::ByteOrder b_order=QPixelFormat::LittleEndian)
+{
+ return QtPrivate::QPixelFormat_createYUV(layout,
+ alfa,
+ usage,
+ position,
+ p_mul,
+ typeInt,
+ b_order);
+}
QT_END_NAMESPACE