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

41 lines
1.3 KiB
C++
Raw Permalink 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"]);
2021-04-13 21:14:17 +08:00
rootNode->requestLayout();
} else {
DoricViewNode *viewNode = getContext()->targetViewNode(viewId);
if (viewNode != nullptr) {
2021-04-06 17:58:23 +08:00
viewNode->blend(jsValue["props"]);
2021-04-13 21:14:17 +08:00
viewNode->requestLayout();
}
}
} catch (...) {
qCritical() << "render exception";
}
2021-02-09 10:38:27 +08:00
},
DoricThreadMode::UI);
2021-02-04 16:59:58 +08:00
}
2021-06-01 10:50:39 +08:00
void DoricShaderPlugin::command(QString jsValueString, QString callbackId) {
qCritical() << "command: " << jsValueString << " " << callbackId;
}