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