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/example/doric/plugin/DoricShaderPlugin.cpp
2021-07-21 19:03:29 +08:00

41 lines
1.3 KiB
C++

#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
#include "../shader/DoricRootNode.h"
#include "DoricShaderPlugin.h"
void DoricShaderPlugin::render(QString jsValueString, QString callbackId) {
getContext()->getDriver()->asyncCall(
[this, jsValueString] {
try {
QJsonDocument document =
QJsonDocument::fromJson(jsValueString.toUtf8());
QJsonValue jsValue = document.object();
QString viewId = jsValue["id"].toString();
DoricRootNode *rootNode = getContext()->getRootNode();
if (rootNode->getId().isEmpty() &&
jsValue["type"].toString() == "Root") {
rootNode->setId(viewId);
rootNode->blend(jsValue["props"]);
rootNode->requestLayout();
} else {
DoricViewNode *viewNode = getContext()->targetViewNode(viewId);
if (viewNode != nullptr) {
viewNode->blend(jsValue["props"]);
viewNode->requestLayout();
}
}
} catch (...) {
qCritical() << "render exception";
}
},
DoricThreadMode::UI);
}
void DoricShaderPlugin::command(QString jsValueString, QString callbackId) {
qCritical() << "command: " << jsValueString << " " << callbackId;
}