summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesus Fernandez <jesus.fernandez@qt.io>2017-09-20 13:03:06 +0200
committerJesus Fernandez <Jesus.Fernandez@qt.io>2017-09-21 12:09:38 +0000
commit4340ee4b467ca5331bb5149a5f4b8eccfd49480b (patch)
tree5e934427353b5a0476e88671bf93aa2a0ca78681
parent7cd51e57b95bd91f698c28ad76e31be3fe4c506e (diff)
Remove identifier from messages not waiting for answer
Saves 4 bytes per message not waiting for answer. Combined with other optimizations can save a lot of bandwidth. Change-Id: I360ba88d3b75db9278d6aff6c397e3ef8c99b02e Reviewed-by: Michael Winkelmann <michael.winkelmann@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
-rw-r--r--src/plugins/platforms/webgl/qwebglfunctioncall.cpp3
-rw-r--r--src/plugins/platforms/webgl/qwebglwebsocketserver.cpp18
-rw-r--r--src/plugins/platforms/webgl/webqt.jsx10
3 files changed, 22 insertions, 9 deletions
diff --git a/src/plugins/platforms/webgl/qwebglfunctioncall.cpp b/src/plugins/platforms/webgl/qwebglfunctioncall.cpp
index 8e469ec..77134d8 100644
--- a/src/plugins/platforms/webgl/qwebglfunctioncall.cpp
+++ b/src/plugins/platforms/webgl/qwebglfunctioncall.cpp
@@ -63,7 +63,8 @@ QWebGLFunctionCall::QWebGLFunctionCall(const QString &functionName,
d->functionName = functionName;
d->surface = surface;
d->wait = wait;
- d->id = QWebGLFunctionCallPrivate::nextId.fetchAndAddOrdered(1);
+ if (wait)
+ d->id = QWebGLFunctionCallPrivate::nextId.fetchAndAddOrdered(1);
d->thread = QThread::currentThread();
}
diff --git a/src/plugins/platforms/webgl/qwebglwebsocketserver.cpp b/src/plugins/platforms/webgl/qwebglwebsocketserver.cpp
index e3a0642..57127fc 100644
--- a/src/plugins/platforms/webgl/qwebglwebsocketserver.cpp
+++ b/src/plugins/platforms/webgl/qwebglwebsocketserver.cpp
@@ -166,16 +166,21 @@ void QWebGLWebSocketServer::sendMessage(QWebSocket *socket,
qCDebug(lc) << "Sending connect to " << socket << values;
break;
case MessageType::GlCommand: {
- const quint32 id = values["id"].toUInt();
const auto functionName = values["function"].toString().toUtf8();
const auto parameters = values["parameters"].toList();
const quint32 parameterCount = parameters.size();
- qCDebug(lc, "Sending gl_command %s (%d) to %p with %d parameters",
- qPrintable(functionName), id, socket, parameterCount);
+ qCDebug(lc, "Sending gl_command %s to %p with %d parameters",
+ qPrintable(functionName), socket, parameterCount);
QByteArray data;
{
QDataStream stream(&data, QIODevice::WriteOnly);
- stream << id << functionName << parameterCount;
+ stream << functionName;
+ if (values.contains("id")) {
+ auto ok = false;
+ stream << quint32(values["id"].toUInt(&ok));
+ Q_ASSERT(ok);
+ }
+ stream << parameterCount;
for (const auto &value : qAsConst(parameters)) {
if (value.isNull()) {
stream << (quint8)'n';
@@ -251,11 +256,12 @@ bool QWebGLWebSocketServer::event(QEvent *event)
int type = event->type();
if (type == QWebGLFunctionCall::type()) {
auto e = static_cast<QWebGLFunctionCall *>(event);
- const QVariantMap values {
+ QVariantMap values {
{ "function", e->functionName() },
- { "id", e->id() },
{ "parameters", e->parameters() }
};
+ if (e->id() != -1)
+ values.insert("id", e->id());
auto integrationPrivate = QWebGLIntegrationPrivate::instance();
auto clientData = integrationPrivate->findClientData(e->surface());
if (clientData && clientData->socket) {
diff --git a/src/plugins/platforms/webgl/webqt.jsx b/src/plugins/platforms/webgl/webqt.jsx
index fa5b64c..a96e8cd 100644
--- a/src/plugins/platforms/webgl/webqt.jsx
+++ b/src/plugins/platforms/webgl/webqt.jsx
@@ -895,6 +895,7 @@ window.onload = function () {
}
var commandsNeedingResponse = [
+ "swapBuffers",
"checkFramebufferStatus",
"createProgram",
"createShader",
@@ -1000,12 +1001,17 @@ window.onload = function () {
var offset = 0;
var obj = { "parameters" : [] };
- obj["id"] = view.getUint32(offset);
- offset += 4;
obj["functionNameSize"] = view.getUint32(offset);
offset += 4;
obj["function"] = textDecoder.decode(new Uint8Array(buffer, offset, obj.functionNameSize));
offset += obj.functionNameSize;
+ for (var i in commandsNeedingResponse) {
+ if (commandsNeedingResponse[i] === obj.function) {
+ obj["id"] = view.getUint32(offset);
+ offset += 4;
+ break;
+ }
+ }
obj["parameterCount"] = view.getUint32(offset);
offset += 4;
for (var i = 0; i < obj.parameterCount; ++i) {