summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/opencl/qclworksize.cpp60
-rw-r--r--src/opencl/qclworksize.h11
2 files changed, 71 insertions, 0 deletions
diff --git a/src/opencl/qclworksize.cpp b/src/opencl/qclworksize.cpp
index 8a7c0fa..840dc39 100644
--- a/src/opencl/qclworksize.cpp
+++ b/src/opencl/qclworksize.cpp
@@ -41,6 +41,8 @@
#include "qclworksize.h"
#include "qcldevice.h"
+#include <QtCore/qdatastream.h>
+#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
@@ -271,4 +273,62 @@ QCLWorkSize QCLWorkSize::fromString(const QString &str)
}
}
+#ifndef QT_NO_DATASTREAM
+
+/*!
+ \fn QDataStream &operator<<(QDataStream &stream, const QCLWorkSize &size)
+ \relates QCLWorkSize
+
+ Writes the given \a size to the given \a stream, and returns a
+ reference to the stream.
+*/
+QDataStream &operator<<(QDataStream &stream, const QCLWorkSize &size)
+{
+ stream << int(size.dimensions());
+ stream << quint64(size.width());
+ stream << quint64(size.height());
+ stream << quint64(size.depth());
+ return stream;
+}
+
+/*!
+ \fn QDataStream &operator>>(QDataStream &stream, QCLWorkSize &size)
+ \relates QCLWorkSize
+
+ Reads a size from the given \a stream into the given \a size, and
+ returns a reference to the stream.
+*/
+QDataStream &operator>>(QDataStream &stream, QCLWorkSize &size)
+{
+ int dims;
+ quint64 width, height, depth;
+ stream >> dims;
+ stream >> width;
+ stream >> height;
+ stream >> depth;
+ if (dims >= 3)
+ size = QCLWorkSize(size_t(width), size_t(height), size_t(depth));
+ else if (dims >= 2)
+ size = QCLWorkSize(size_t(width), size_t(height));
+ else
+ size = QCLWorkSize(size_t(width));
+ return stream;
+}
+
+#endif // QT_NO_DATASTREAM
+
+#ifndef QT_NO_DEBUG_STREAM
+
+QDebug operator<<(QDebug dbg, const QCLWorkSize &s) {
+ if (s.dimensions() == 1)
+ dbg.nospace() << "QCLWorkSize(" << s.width() << ')';
+ else if (s.dimensions() == 2)
+ dbg.nospace() << "QCLWorkSize(" << s.width() << ", " << s.height() << ')';
+ else
+ dbg.nospace() << "QCLWorkSize(" << s.width() << ", " << s.height() << ", " << s.depth() << ')';
+ return dbg.space();
+}
+
+#endif
+
QT_END_NAMESPACE
diff --git a/src/opencl/qclworksize.h b/src/opencl/qclworksize.h
index e0c5b7f..290197c 100644
--- a/src/opencl/qclworksize.h
+++ b/src/opencl/qclworksize.h
@@ -90,6 +90,8 @@ private:
size_t m_sizes[3];
};
+Q_DECLARE_TYPEINFO(QCLWorkSize, Q_MOVABLE_TYPE);
+
inline bool QCLWorkSize::operator==(const QCLWorkSize &other) const
{
return m_dim == other.m_dim &&
@@ -106,6 +108,15 @@ inline bool QCLWorkSize::operator!=(const QCLWorkSize &other) const
m_sizes[2] != other.m_sizes[2];
}
+#ifndef QT_NO_DATASTREAM
+Q_CL_EXPORT QDataStream &operator<<(QDataStream &, const QCLWorkSize &);
+Q_CL_EXPORT QDataStream &operator>>(QDataStream &, QCLWorkSize &);
+#endif
+
+#ifndef QT_NO_DEBUG_STREAM
+Q_CL_EXPORT QDebug operator<<(QDebug, const QCLWorkSize &);
+#endif
+
QT_END_NAMESPACE
QT_END_HEADER