| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2017 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt WebGL module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 or (at your option) any later version |
| 20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
| 21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
| 22 | ** included in the packaging of this file. Please review the following |
| 23 | ** information to ensure the GNU General Public License requirements will |
| 24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 25 | ** |
| 26 | ** $QT_END_LICENSE$ |
| 27 | ** |
| 28 | ****************************************************************************/ |
| 29 | |
| 30 | #ifndef QWEBGLFUNCTIONCALL_H |
| 31 | #define QWEBGLFUNCTIONCALL_H |
| 32 | |
| 33 | #include <QtCore/qcoreevent.h> |
| 34 | #include <QtCore/qscopedpointer.h> |
| 35 | #include <QtCore/qvariant.h> |
| 36 | |
| 37 | #include <tuple> |
| 38 | |
| 39 | QT_BEGIN_NAMESPACE |
| 40 | |
| 41 | class QByteArray; |
| 42 | class QPlatformSurface; |
| 43 | class QString; |
| 44 | class QThread; |
| 45 | class QWebGLFunctionCallPrivate; |
| 46 | |
| 47 | class QWebGLFunctionCall : public QEvent |
| 48 | { |
| 49 | public: |
| 50 | QWebGLFunctionCall(const QString &functionName, QPlatformSurface *surface, bool wait = false); |
| 51 | ~QWebGLFunctionCall() override; |
| 52 | |
| 53 | static Type type(); |
| 54 | |
| 55 | int id() const; |
| 56 | QThread *thread() const; |
| 57 | bool isBlocking() const; |
| 58 | QPlatformSurface *surface() const; |
| 59 | |
| 60 | QString functionName() const; |
| 61 | |
| 62 | void addString(const QString &value); |
| 63 | void addInt(int value); |
| 64 | void addUInt(uint value); |
| 65 | void addFloat(float value); |
| 66 | void addData(const QByteArray &data); |
| 67 | void addList(const QVariantList &list); |
| 68 | void addNull(); |
| 69 | |
| 70 | void add(const QString &value) { addString(value); } |
| 71 | void add(const char *value) { addString(value: QString::fromLatin1(str: value)); } |
| 72 | void add(int value) { addInt(value); } |
| 73 | void add(uint value) { addUInt(value); } |
| 74 | void add(float value) { addFloat(value); } |
| 75 | void add(const QByteArray &data) { addData(data); } |
| 76 | void add(const QVariantList &list) { addList(list); } |
| 77 | void add(std::nullptr_t) { addNull(); } |
| 78 | |
| 79 | template<class...Ts> |
| 80 | void addParameters(Ts&&... arguments) |
| 81 | { |
| 82 | addImpl(arguments...); |
| 83 | } |
| 84 | |
| 85 | QVariantList parameters() const; |
| 86 | |
| 87 | protected: |
| 88 | template<typename T> |
| 89 | void addImpl(T first) |
| 90 | { |
| 91 | add(first); |
| 92 | } |
| 93 | |
| 94 | template<typename T, typename... Ts> |
| 95 | void addImpl(T first, Ts... rest) |
| 96 | { |
| 97 | add(first); |
| 98 | addImpl(rest...); |
| 99 | } |
| 100 | |
| 101 | private: |
| 102 | Q_DISABLE_COPY(QWebGLFunctionCall) |
| 103 | Q_DECLARE_PRIVATE(QWebGLFunctionCall) |
| 104 | QScopedPointer<QWebGLFunctionCallPrivate> d_ptr; |
| 105 | }; |
| 106 | |
| 107 | QT_END_NAMESPACE |
| 108 | |
| 109 | #endif // QWEBGLFUNCTIONCALL_H |
| 110 | |