split project with app & doric module
This commit is contained in:
36
doric-Qt/example/doric/plugin/DoricShaderPlugin.cpp
Normal file
36
doric-Qt/example/doric/plugin/DoricShaderPlugin.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#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);
|
||||
}
|
Reference in New Issue
Block a user