add bridge call native
This commit is contained in:
parent
fe1a556ad8
commit
b785685802
@ -3,13 +3,13 @@
|
||||
|
||||
#include "context.h"
|
||||
|
||||
class ContextHolder {
|
||||
|
||||
class ContextHolder : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Context *_context;
|
||||
|
||||
public:
|
||||
ContextHolder(Context *context) {
|
||||
ContextHolder(Context *context, QObject *parent = nullptr) : QObject(parent) {
|
||||
this->_context = context;
|
||||
}
|
||||
};
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "context_manager.h"
|
||||
#include "native_bridge.h"
|
||||
#include "plugin/shader_plugin.h"
|
||||
|
||||
Q_INVOKABLE void NativeBridge::function(int contextId, QString module, QString methodName, QString callbackId, QJSValue jsValue) {
|
||||
qDebug() << "contextId: " + QString::number(contextId) + ", " +
|
||||
@ -8,5 +9,11 @@ Q_INVOKABLE void NativeBridge::function(int contextId, QString module, QString m
|
||||
"callbackId: " + callbackId + ", " +
|
||||
"arguments: " + jsValue.toString();
|
||||
Context *context = ContextManager::getInstance()->getContext(contextId);
|
||||
context->driver->getRegistry();
|
||||
QString value = context->driver->getRegistry()->acquirePluginInfo(module);
|
||||
|
||||
qDebug() << value;
|
||||
if (value.contains("ShaderPlugin")) {
|
||||
ShaderPlugin shaderPlugin(context);
|
||||
QMetaObject::invokeMethod(&shaderPlugin, methodName.toStdString().c_str());
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,19 @@
|
||||
#ifndef SHADER_PLUGIN_H
|
||||
#define SHADER_PLUGIN_H
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "context_holder.h"
|
||||
|
||||
class ShaderPlugin : public ContextHolder {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ShaderPlugin(Context *context) : ContextHolder(context) {}
|
||||
|
||||
Q_INVOKABLE void render() {
|
||||
qDebug() << "render";
|
||||
}
|
||||
};
|
||||
|
||||
#endif // SHADER_PLUGIN_H
|
||||
|
@ -4,9 +4,14 @@
|
||||
#include "plugin/shader_plugin.h"
|
||||
|
||||
Registry::Registry() {
|
||||
registerNativePlugin(typeid(ShaderPlugin).name());
|
||||
registerNativePlugin("shader", typeid(ShaderPlugin).name());
|
||||
}
|
||||
|
||||
void Registry::registerNativePlugin(QString name) {
|
||||
qDebug() << name;
|
||||
void Registry::registerNativePlugin(QString key, QString value) {
|
||||
qDebug() << key + " " + value;
|
||||
pluginInfoMap.insert(key, value);
|
||||
}
|
||||
|
||||
QString Registry::acquirePluginInfo(QString key) {
|
||||
return pluginInfoMap.take(key);
|
||||
}
|
||||
|
@ -11,7 +11,9 @@ private:
|
||||
public:
|
||||
Registry();
|
||||
|
||||
void registerNativePlugin(QString name);
|
||||
void registerNativePlugin(QString key, QString value);
|
||||
|
||||
QString acquirePluginInfo(QString key);
|
||||
};
|
||||
|
||||
#endif // REGISTRY_H
|
||||
|
Reference in New Issue
Block a user