|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Shinya Kitaoka |
810553 |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TOONZ_STDFX_PLUGIN_HOST_H__
|
|
Toshihiro Shimizu |
890ddd |
#define TOONZ_STDFX_PLUGIN_HOST_H__
|
|
Toshihiro Shimizu |
890ddd |
#include <qthread></qthread>
|
|
Toshihiro Shimizu |
890ddd |
#include <string></string>
|
|
Toshihiro Shimizu |
890ddd |
#include <memory></memory>
|
|
Toshihiro Shimizu |
890ddd |
#include "tzeraryfx.h"
|
|
Toshihiro Shimizu |
890ddd |
#if defined(_WIN32) || defined(_CYGWIN_)
|
|
Toshihiro Shimizu |
890ddd |
#include <windows.h></windows.h>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz_plugin.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz_hostif.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
namespace toonz {
|
|
Toshihiro Shimizu |
890ddd |
struct nodal_rasterfx_handler_t;
|
|
Toshihiro Shimizu |
890ddd |
struct host_interface_t;
|
|
Toshihiro Shimizu |
890ddd |
struct plugin_probe_t;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* probe で得られる静的な plugin 情報 */
|
|
Toshihiro Shimizu |
890ddd |
class PluginDescription
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
std::string name_;
|
|
Toshihiro Shimizu |
890ddd |
std::string vendor_;
|
|
Toshihiro Shimizu |
890ddd |
std::string id_;
|
|
Toshihiro Shimizu |
890ddd |
std::string note_;
|
|
Toshihiro Shimizu |
890ddd |
std::string url_;
|
|
Toshihiro Shimizu |
890ddd |
std::string fullname_;
|
|
Toshihiro Shimizu |
890ddd |
int clss_;
|
|
Toshihiro Shimizu |
890ddd |
toonz_plugin_version_t plugin_ver_;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
PluginDescription(const toonz::plugin_probe_t *const probe);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* 'geometric' is known as 'Zerary' on toonz. we avoid using the word because nobody did not understand a meaning of the word */
|
|
Toshihiro Shimizu |
890ddd |
bool is_geometric() const { return clss_ & TOONZ_PLUGIN_CLASS_MODIFIER_GEOMETRIC; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class PluginInformation;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* エフェクトのインスタンスを構築するためのクラス */
|
|
Toshihiro Shimizu |
890ddd |
struct PluginDeclaration : public TFxDeclaration {
|
|
Toshihiro Shimizu |
890ddd |
PluginDeclaration(PluginInformation *pi);
|
|
Toshihiro Shimizu |
890ddd |
TPersist *create() const final override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
PluginInformation *pi_;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class UIPage;
|
|
Toshihiro Shimizu |
890ddd |
class Param;
|
|
Toshihiro Shimizu |
890ddd |
class ParamView;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class ParamsPageSet;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
struct port_description_t {
|
|
Toshihiro Shimizu |
890ddd |
bool input_;
|
|
Toshihiro Shimizu |
890ddd |
std::string name_;
|
|
Toshihiro Shimizu |
890ddd |
int type_;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
port_description_t(bool input, const char *nm, int type) : input_(input), name_(nm), type_(type)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if defined(_WIN32) || defined(_CYGWIN_)
|
|
Toshihiro Shimizu |
890ddd |
typedef std::shared_ptr<std::remove_pointer<hmodule>::type> library_t;</std::remove_pointer<hmodule>
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
typedef std::shared_ptr<void> library_t;</void>
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class PluginInformation
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
PluginDeclaration *decl_;
|
|
Toshihiro Shimizu |
890ddd |
PluginDescription *desc_;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
library_t library_;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
toonz::nodal_rasterfx_handler_t *handler_;
|
|
Toshihiro Shimizu |
890ddd |
toonz::host_interface_t *host_;
|
|
Toshihiro Shimizu |
890ddd |
int (*ini_)(toonz::host_interface_t *);
|
|
Toshihiro Shimizu |
890ddd |
void (*fin_)(void);
|
|
Toshihiro Shimizu |
890ddd |
int ref_count_;
|
|
Toshihiro Shimizu |
890ddd |
int param_page_num_;
|
|
Shinya Kitaoka |
79e39b |
std::unique_ptr<toonz_param_page_t[]> param_pages_;</toonz_param_page_t[]>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::vector<uipage *=""> ui_pages_;</uipage>
|
|
Toshihiro Shimizu |
890ddd |
std::vector<paramview *=""> param_views_;</paramview>
|
|
Toshihiro Shimizu |
890ddd |
std::map<std::string, port_description_t=""> port_mapper_;</std::string,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::vector<std::shared_ptr<void>> param_resources_; /* deep-copy に使う scratch area */</std::shared_ptr<void>
|
|
Toshihiro Shimizu |
890ddd |
std::vector<std::shared_ptr<std::string>> param_string_tbl_; /* shared_ptr< void > では non-virtual destructor が呼ばれないので */</std::shared_ptr<std::string>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
79e39b |
PluginInformation() : desc_(NULL), library_(NULL), handler_(NULL), host_(NULL), ini_(NULL), fin_(NULL), ref_count_(1), param_page_num_(0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
~PluginInformation();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void add_ref();
|
|
Toshihiro Shimizu |
890ddd |
void release();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class Loader : public QObject
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Q_OBJECT;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
Loader();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
void doLoad(const QString &file);
|
|
Toshihiro Shimizu |
890ddd |
void walkDirectory_(const QString &file);
|
|
Toshihiro Shimizu |
890ddd |
public slots:
|
|
Toshihiro Shimizu |
890ddd |
void walkDirectory(const QString &file);
|
|
Toshihiro Shimizu |
890ddd |
void walkDictionary(const QString &file);
|
|
Toshihiro Shimizu |
890ddd |
signals:
|
|
Toshihiro Shimizu |
890ddd |
void load_finished(PluginInformation *pi);
|
|
Toshihiro Shimizu |
890ddd |
void fixup();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class PluginLoadController : public QObject
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Q_OBJECT;
|
|
Toshihiro Shimizu |
890ddd |
QThread work_entity;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
PluginLoadController(const std::string &basedir, QObject *listener);
|
|
Toshihiro Shimizu |
890ddd |
bool wait(int timeout_in_ms) { return work_entity.wait(timeout_in_ms); };
|
|
Toshihiro Shimizu |
890ddd |
public slots:
|
|
Toshihiro Shimizu |
890ddd |
void result(PluginInformation *pi);
|
|
Toshihiro Shimizu |
890ddd |
void finished();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
signals:
|
|
Toshihiro Shimizu |
890ddd |
void start(const QString &filepath);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class RasterFxPluginHost : public TZeraryFx, public TPluginInterface
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
PluginInformation *pi_;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
std::vector<std::shared_ptr<tfxport>> inputs_;</std::shared_ptr<tfxport>
|
|
Shinya Kitaoka |
0b19cb |
std::vector<std::shared_ptr<param>> params_;</std::shared_ptr<param>
|
|
Toshihiro Shimizu |
890ddd |
void *user_data_;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static bool validateKeyName(const char *name);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
virtual RasterFxPluginHost *newInstance(PluginInformation *pi) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
RasterFxPluginHost(PluginInformation *pinfo);
|
|
Toshihiro Shimizu |
890ddd |
~RasterFxPluginHost();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void notify();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
const TPersistDeclaration *getDeclaration() const;
|
|
Toshihiro Shimizu |
890ddd |
std::string getPluginId() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool doGetBBox(double frame, TRectD &bbox, const TRenderSettings &info);
|
|
Toshihiro Shimizu |
890ddd |
void doCompute(TTile &tile, double frame, const TRenderSettings &info);
|
|
Toshihiro Shimizu |
890ddd |
int getMemoryRequirement(const TRectD &rect, double frame, const TRenderSettings &info);
|
|
Toshihiro Shimizu |
890ddd |
bool canHandle(const TRenderSettings &info, double frame);
|
|
Toshihiro Shimizu |
890ddd |
bool addInputPort(const std::string &nm, std::shared_ptr<tfxport> port);</tfxport>
|
|
Toshihiro Shimizu |
890ddd |
bool addOutputPort(const std::string &nm, TRasterFxPort *port);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFx *clone(bool recursive) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// UIPage
|
|
Toshihiro Shimizu |
890ddd |
UIPage *createUIPage(const char *name);
|
|
Toshihiro Shimizu |
890ddd |
void build(ParamsPageSet *);
|
|
Toshihiro Shimizu |
890ddd |
std::string getUrl() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// setup
|
|
Toshihiro Shimizu |
890ddd |
bool setParamStructure(int n, toonz_param_page_t *descs, int &err, void *&pos);
|
|
Toshihiro Shimizu |
890ddd |
bool addPortDesc(port_description_t &&);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
f91c5a |
Param *createParam(const toonz_param_desc_t *);
|
|
Shinya Kitaoka |
f91c5a |
Param *createParam(const char *name, toonz_param_type_enum e);
|
|
Toshihiro Shimizu |
890ddd |
Param *getParam(const char *name) const;
|
|
Toshihiro Shimizu |
890ddd |
ParamView *createParamView();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool isPlugin() const { return true; }
|
|
Toshihiro Shimizu |
890ddd |
bool isPluginZerary() const { return pi_->desc_->is_geometric(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool isZerary() const { return isPluginZerary(); };
|
|
Toshihiro Shimizu |
890ddd |
void callStartRenderHandler();
|
|
Toshihiro Shimizu |
890ddd |
void callEndRenderHandler();
|
|
Toshihiro Shimizu |
890ddd |
void callStartRenderFrameHandler(const TRenderSettings *rs, double frame);
|
|
Toshihiro Shimizu |
890ddd |
void callEndRenderFrameHandler(const TRenderSettings *rs, double frame);
|
|
Toshihiro Shimizu |
890ddd |
void *getUserData();
|
|
Toshihiro Shimizu |
890ddd |
void setUserData(void *user_data);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void createParamsByDesc();
|
|
Toshihiro Shimizu |
890ddd |
void createPortsByDesc();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|