48
48
#include < QtWebSockets/qwebsocket.h>
49
49
50
50
#include < cstring>
51
+ #include < limits>
51
52
52
53
QT_BEGIN_NAMESPACE
53
54
@@ -286,7 +287,6 @@ static T queryValue(int id, const T &defaultValue = T())
286
287
return variant.value <T>();
287
288
}
288
289
289
- struct GLFunction ;
290
290
template <typename T>
291
291
struct ParameterTypeTraits {
292
292
static int typeId () { return qMetaTypeId<T>(); }
@@ -320,6 +320,7 @@ struct GLFunction
320
320
};
321
321
322
322
static QHash<QString, const GLFunction *> byName;
323
+ static QStringList remoteFunctionNames;
323
324
using ParameterList = QVector<Parameter>;
324
325
325
326
GLFunction (const QString &remoteName,
@@ -331,18 +332,23 @@ struct GLFunction
331
332
{
332
333
Q_ASSERT (!byName.contains (localName));
333
334
byName.insert (localName, this );
335
+ id = remoteFunctionNames.size ();
336
+ Q_ASSERT (remoteFunctionNames.size () <= std::numeric_limits<quint8>::max ());
337
+ remoteFunctionNames.append (remoteName);
338
+ Q_ASSERT (byName.size () == remoteFunctionNames.size ());
334
339
}
335
340
336
341
GLFunction (const QString &name) : GLFunction(name, name, nullptr )
337
342
{}
338
-
343
+ quint8 id;
339
344
const QString remoteName;
340
345
const QString localName;
341
346
const QFunctionPointer functionPointer;
342
347
const ParameterList parameters;
343
348
};
344
349
345
350
QHash<QString, const GLFunction *> GLFunction::byName;
351
+ QStringList GLFunction::remoteFunctionNames;
346
352
347
353
template <const GLFunction *Function>
348
354
static QWebGLFunctionCall *createEventImpl (bool wait)
@@ -355,7 +361,7 @@ static QWebGLFunctionCall *createEventImpl(bool wait)
355
361
if (!clientData || !clientData->socket
356
362
|| clientData->socket ->state () != QAbstractSocket::ConnectedState)
357
363
return nullptr ;
358
- return new QWebGLFunctionCall (Function->remoteName , handle->currentSurface (), wait);
364
+ return new QWebGLFunctionCall (Function->localName , handle->currentSurface (), wait);
359
365
}
360
366
361
367
static void postEventImpl (QWebGLFunctionCall *event)
@@ -667,7 +673,7 @@ QWEBGL_FUNCTION(disableVertexAttribArray, void, glDisableVertexAttribArray,
667
673
QWEBGL_FUNCTION (drawArrays, void , glDrawArrays,
668
674
(GLenum) mode, (GLint) first, (GLsizei) count)
669
675
{
670
- auto event = currentContext ()->createEvent (QStringLiteral (" drawArrays " ));
676
+ auto event = currentContext ()->createEvent (QStringLiteral (" glDrawArrays " ));
671
677
if (!event)
672
678
return ;
673
679
event->addParameters (mode, first, count);
@@ -681,7 +687,7 @@ QWEBGL_FUNCTION(drawArrays, void, glDrawArrays,
681
687
QWEBGL_FUNCTION (drawElements, void , glDrawElements,
682
688
(GLenum) mode, (GLsizei) count, (GLenum) type, (const void *) indices)
683
689
{
684
- auto event = currentContext ()->createEvent (QStringLiteral (" drawElements " ));
690
+ auto event = currentContext ()->createEvent (QStringLiteral (" glDrawElements " ));
685
691
if (!event)
686
692
return ;
687
693
event->addParameters (mode, count, type);
@@ -1177,7 +1183,7 @@ QWEBGL_FUNCTION(shaderSource, void, glShaderSource,
1177
1183
(GLuint) shader, (GLsizei) count,
1178
1184
(const GLchar *const *) string, (const GLint *) length)
1179
1185
{
1180
- auto event = currentContext ()->createEvent (QStringLiteral (" shaderSource " ));
1186
+ auto event = currentContext ()->createEvent (QStringLiteral (" glShaderSource " ));
1181
1187
if (!event)
1182
1188
return ;
1183
1189
event->addParameters (shader, count);
@@ -1578,4 +1584,16 @@ QVariant QWebGLContext::queryValue(int id)
1578
1584
return variant;
1579
1585
}
1580
1586
1587
+ QStringList QWebGLContext::supportedFunctions ()
1588
+ {
1589
+ return GLFunction::remoteFunctionNames;
1590
+ }
1591
+
1592
+ quint8 QWebGLContext::functionIndex (const QString &functionName)
1593
+ {
1594
+ const auto it = GLFunction::byName.find (functionName);
1595
+ Q_ASSERT (it != GLFunction::byName.end ());
1596
+ return (*it)->id ;
1597
+ }
1598
+
1581
1599
QT_END_NAMESPACE
0 commit comments