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
|
|
|
|
2021-02-19 15:43:09 +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] {
|
2021-02-24 15:47:57 +08:00
|
|
|
try {
|
2021-04-06 17:58:23 +08:00
|
|
|
QJsonDocument document =
|
|
|
|
QJsonDocument::fromJson(jsValueString.toUtf8());
|
|
|
|
QJsonValue jsValue = document.object();
|
|
|
|
|
|
|
|
QString viewId = jsValue["id"].toString();
|
2021-02-24 15:47:57 +08:00
|
|
|
DoricRootNode *rootNode = getContext()->getRootNode();
|
2021-02-19 15:43:09 +08:00
|
|
|
|
2021-02-24 15:47:57 +08:00
|
|
|
if (rootNode->getId().isEmpty() &&
|
2021-04-06 17:58:23 +08:00
|
|
|
jsValue["type"].toString() == "Root") {
|
2021-02-24 15:47:57 +08:00
|
|
|
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();
|
2021-02-24 15:47:57 +08:00
|
|
|
} 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();
|
2021-02-24 15:47:57 +08:00
|
|
|
}
|
2021-02-23 18:26:00 +08:00
|
|
|
}
|
2021-02-24 15:47:57 +08:00
|
|
|
} catch (...) {
|
|
|
|
qCritical() << "render exception";
|
2021-02-19 15:43:09 +08:00
|
|
|
}
|
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;
|
|
|
|
}
|