This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-Qt/doric/plugin/DoricShaderPlugin.cpp

35 lines
1.0 KiB
C++
Raw Normal View History

2021-02-04 16:59:58 +08:00
#include <QDebug>
2021-04-06 17:58:23 +08:00
#include <QJsonDocument>
2021-04-02 20:47:15 +08:00
#include <QJsonObject>
2021-02-04 16:59:58 +08:00
#include "../shader/DoricRootNode.h"
#include "DoricShaderPlugin.h"
2021-04-06 17:58:23 +08:00
void DoricShaderPlugin::render(QString jsValueString, QString callbackId) {
2021-02-09 10:38:27 +08:00
getContext()->getDriver()->asyncCall(
2021-04-06 17:58:23 +08:00
[this, jsValueString] {
try {
2021-04-06 17:58:23 +08:00
QJsonDocument document =
QJsonDocument::fromJson(jsValueString.toUtf8());
QJsonValue jsValue = document.object();
QString viewId = jsValue["id"].toString();
DoricRootNode *rootNode = getContext()->getRootNode();
if (rootNode->getId().isEmpty() &&
2021-04-06 17:58:23 +08:00
jsValue["type"].toString() == "Root") {
rootNode->setId(viewId);
2021-04-06 17:58:23 +08:00
rootNode->blend(jsValue["props"]);
} else {
DoricViewNode *viewNode = getContext()->targetViewNode(viewId);
if (viewNode != nullptr) {
2021-04-06 17:58:23 +08:00
viewNode->blend(jsValue["props"]);
}
}
} catch (...) {
qCritical() << "render exception";
}
2021-02-09 10:38:27 +08:00
},
DoricThreadMode::UI);
2021-02-04 16:59:58 +08:00
}