QVulkan{Layer,Extension}: various fixes

- don't export simple structs
- make op== non-member
- add op!= (required by EqualityComparable)
- add qHash() (should be defined by Qt for every EqualityComparable class)
- add Q_DECLARE_TYPEINFO

Change-Id: Ia14ac3fea48a6a0ad1d8993c9408afe77bbe6c1a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Marc Mutz 2017-04-04 18:52:35 +02:00
parent fdd32329ab
commit 84b114e4f3
2 changed files with 84 additions and 16 deletions

View File

@ -429,12 +429,32 @@ QVulkanInstance::~QVulkanInstance()
*/
/*!
\fn bool QVulkanLayer::operator==(const QVulkanLayer &other) const
\fn bool operator==(const QVulkanLayer &lhs, const QVulkanLayer &rhs)
\since 5.10
\relates QVulkanLayer
Returns true if this Vulkan layer and the \a other Vulkan layer have
Returns \c true if Vulkan layers \a lhs and \a rhs have
the same name, version, and spec version.
*/
/*!
\fn bool operator!=(const QVulkanLayer &lhs, const QVulkanLayer &rhs)
\since 5.10
\relates QVulkanLayer
Returns \c true if Vulkan layers \a lhs and \a rhs have
different name, version, or spec version.
*/
/*!
\fn uint qHash(const QVulkanLayer &key, uint seed)
\since 5.10
\relates QVulkanLayer
Returns the hash value for the \a key, using \a seed to seed the
calculation.
*/
/*!
\class QVulkanExtension
\brief Represents information about a Vulkan extension.
@ -452,10 +472,30 @@ QVulkanInstance::~QVulkanInstance()
*/
/*!
\fn bool QVulkanExtension::operator==(const QVulkanExtension &other) const
\fn bool operator==(const QVulkanExtension &lhs, const QVulkanExtension &rhs)
\since 5.10
\relates QVulkanExtension
Returns true if the name and version of this Vulkan extension are the same
as the name and version of the \a other Vulkan extension.
Returns \c true if Vulkan extensions \a lhs and \a rhs are have the
same name and version.
*/
/*!
\fn bool operator!=(const QVulkanExtension &lhs, const QVulkanExtension &rhs)
\since 5.10
\relates QVulkanExtension
Returns \c true if Vulkan extensions \a lhs and \a rhs are have different
name or version.
*/
/*!
\fn uint qHash(const QVulkanExtension &key, uint seed)
\since 5.10
\relates QVulkanExtension
Returns the hash value for the \a key, using \a seed to seed the
calculation.
*/
/*!

View File

@ -56,6 +56,7 @@ typedef unsigned long VkImage;
typedef unsigned long VkImageView;
#endif
#include <QtCore/qhashfunctions.h>
#include <QtCore/qscopedpointer.h>
#include <QtCore/qvector.h>
#include <QtCore/qbytearraylist.h>
@ -70,25 +71,52 @@ class QVulkanFunctions;
class QVulkanDeviceFunctions;
class QWindow;
struct Q_GUI_EXPORT QVulkanLayer
struct QVulkanLayer
{
QByteArray name;
uint32_t version;
QVersionNumber specVersion;
QByteArray description;
bool operator==(const QVulkanLayer &other) const {
return name == other.name && version == other.version && specVersion == other.specVersion;
}
};
Q_DECLARE_TYPEINFO(QVulkanLayer, Q_MOVABLE_TYPE);
struct Q_GUI_EXPORT QVulkanExtension
inline bool operator==(const QVulkanLayer &lhs, const QVulkanLayer &rhs) Q_DECL_NOTHROW
{
return lhs.name == rhs.name && lhs.version == rhs.version && lhs.specVersion == rhs.specVersion;
}
inline bool operator!=(const QVulkanLayer &lhs, const QVulkanLayer &rhs) Q_DECL_NOTHROW
{ return !(lhs == rhs); }
inline uint qHash(const QVulkanLayer &key, uint seed = 0) Q_DECL_NOTHROW
{
QtPrivate::QHashCombine hash;
seed = hash(seed, key.name);
seed = hash(seed, key.version);
seed = hash(seed, key.specVersion);
return seed;
}
struct QVulkanExtension
{
QByteArray name;
uint32_t version;
bool operator==(const QVulkanExtension &other) const {
return name == other.name && version == other.version;
}
};
Q_DECLARE_TYPEINFO(QVulkanExtension, Q_MOVABLE_TYPE);
inline bool operator==(const QVulkanExtension &lhs, const QVulkanExtension &rhs) Q_DECL_NOTHROW
{
return lhs.name == rhs.name && lhs.version == rhs.version;
}
inline bool operator!=(const QVulkanExtension &lhs, const QVulkanExtension &rhs) Q_DECL_NOTHROW
{ return !(lhs == rhs); }
inline uint qHash(const QVulkanExtension &key, uint seed = 0) Q_DECL_NOTHROW
{
QtPrivate::QHashCombine hash;
seed = hash(seed, key.name);
seed = hash(seed, key.version);
return seed;
}
#ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug, const QVulkanLayer &);