Shinya Kitaoka 810553
#pragma once
Shinya Kitaoka 810553
Toshihiro Shimizu 890ddd
#ifndef TOONZ_HOSTIF_H__
Toshihiro Shimizu 890ddd
#define TOONZ_HOSTIF_H__
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <stdint.h></stdint.h>
Toshihiro Shimizu 890ddd
#include <stddef.h></stddef.h>
Toshihiro Shimizu 890ddd
#include "toonz_plugin.h"
Toshihiro Shimizu 890ddd
#include "toonz_params.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TOONZ_PLUGIN_CLASS_MODIFIER_MASK (0xffUL << (32 - 8))
Toshihiro Shimizu 890ddd
#define TOONZ_PLUGIN_CLASS_MODIFIER_GEOMETRIC (1UL << (32 - 1))
Toshihiro Shimizu 890ddd
#define TOONZ_PLUGIN_CLASS_POSTPROCESS_ (0x10UL)
Shinya Kitaoka 120a6e
#define TOONZ_PLUGIN_CLASS_POSTPROCESS_SLAB                                    \
Shinya Kitaoka 120a6e
  (TOONZ_PLUGIN_CLASS_POSTPROCESS_ | 0UL)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TOONZ_PORT_TYPE_RASTER (0)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#if defined(_MSC_VER)
Toshihiro Shimizu 890ddd
#pragma pack(push, 1)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
static const toonz_UUID toonz_uuid_node__ = {0xCC14EA21, 0x13D8, 0x4A3B, 0x9375,
Shinya Kitaoka 120a6e
                                             0xAA4F68C9DDDD};
Shinya Kitaoka 120a6e
static const toonz_UUID toonz_uuid_port__ = {0x2F89A423, 0x1D2D, 0x433F, 0xB93E,
Shinya Kitaoka 120a6e
                                             0xCFFD83745F6F};
Shinya Kitaoka 120a6e
static const toonz_UUID toonz_uuid_tile__ = {0x882BD525, 0x937E, 0x427C, 0x9D68,
Shinya Kitaoka 120a6e
                                             0x4ECA651F6562};
Shinya Kitaoka 120a6e
static const toonz_UUID toonz_uuid_fx_node__ = {0x26F9FC53, 0x632B, 0x422F,
Shinya Kitaoka 120a6e
                                                0x87A0, 0x8A4547F55474};
Shinya Kitaoka 120a6e
static const toonz_UUID toonz_uuid_param__ = {0x2E3E4A55, 0x8539, 0x4520,
Shinya Kitaoka 120a6e
                                              0xA266, 0x15D32189EC4D};
Shinya Kitaoka 120a6e
static const toonz_UUID toonz_uuid_setup__ = {0xcfde9107, 0xc59d, 0x414c,
Shinya Kitaoka 120a6e
                                              0xae4a, 0x3d115ba97933};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define TOONZ_UUID_NODE (&toonz_uuid_node__)
Toshihiro Shimizu 890ddd
#define TOONZ_UUID_PORT (&toonz_uuid_port__)
Toshihiro Shimizu 890ddd
#define TOONZ_UUID_TILE (&toonz_uuid_tile__)
Toshihiro Shimizu 890ddd
#define TOONZ_UUID_FXNODE (&toonz_uuid_fx_node__)
Toshihiro Shimizu 890ddd
#define TOONZ_UUID_PARAM (&toonz_uuid_param__)
Toshihiro Shimizu 890ddd
#define TOONZ_UUID_SETUP (&toonz_uuid_setup__)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/* Host Interface */
Toshihiro Shimizu 890ddd
struct toonz_host_interface_t_ {
Shinya Kitaoka 120a6e
  toonz_if_version_t ver;
Shinya Kitaoka 120a6e
  int (*query_interface)(const toonz_UUID *, void **);
Shinya Kitaoka 120a6e
  void (*release_interface)(void *);
Toshihiro Shimizu 890ddd
} TOONZ_PACK;
Toshihiro Shimizu 890ddd
typedef toonz_host_interface_t_ toonz_host_interface_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
struct toonz_rect_t_ {
Shinya Kitaoka 120a6e
  double x0;
Shinya Kitaoka 120a6e
  double y0;
Shinya Kitaoka 120a6e
  double x1;
Shinya Kitaoka 120a6e
  double y1;
Toshihiro Shimizu 890ddd
} TOONZ_PACK;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef struct toonz_rect_t_ toonz_rect_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef void *toonz_param_handle_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
struct toonz_param_interface_t_ {
Shinya Kitaoka 120a6e
  toonz_if_version_t ver;
Shinya Kitaoka 120a6e
  int (*get_type)(toonz_param_handle_t param, double frame, int *type,
Shinya Kitaoka 120a6e
                  int *counts);
Shinya Kitaoka 120a6e
  int (*get_value)(toonz_param_handle_t param, double frame, int *pcounts,
Shinya Kitaoka 120a6e
                   void *pvalue);
Shinya Kitaoka 120a6e
  int (*set_value)(toonz_param_handle_t param, double frame, int counts,
Shinya Kitaoka 120a6e
                   const void *pvalue);
Shinya Kitaoka 120a6e
  int (*get_string_value)(toonz_param_handle_t param, int *wholesize,
Shinya Kitaoka 120a6e
                          int rcvbufsize, char *pvalue);
Shinya Kitaoka 120a6e
  int (*get_spectrum_value)(toonz_param_handle_t param, double frame, double x,
Shinya Kitaoka 120a6e
                            toonz_param_spectrum_t *pvalue);
Toshihiro Shimizu 890ddd
} TOONZ_PACK;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef toonz_param_interface_t_ toonz_param_interface_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef void *toonz_fxnode_handle_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef void *toonz_port_handle_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
struct toonz_port_interface_t_ {
Shinya Kitaoka 120a6e
  toonz_if_version_t ver;
Shinya Kitaoka 120a6e
  int (*is_connected)(toonz_port_handle_t port, int *is_connected);
Shinya Kitaoka 120a6e
  int (*get_fx)(toonz_port_handle_t port, toonz_fxnode_handle_t *fxnode);
Toshihiro Shimizu 890ddd
} TOONZ_PACK;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef toonz_port_interface_t_ toonz_port_interface_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef void *toonz_tile_handle_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
struct toonz_tile_interface_t_ {
Shinya Kitaoka 120a6e
  toonz_if_version_t ver;
Shinya Kitaoka 120a6e
  int (*get_raw_address_unsafe)(toonz_tile_handle_t handle, void **);
Shinya Kitaoka 120a6e
  int (*get_raw_stride)(toonz_tile_handle_t handle, int *stride);
Shinya Kitaoka 120a6e
  int (*get_element_type)(toonz_tile_handle_t handle, int *element);
Shinya Kitaoka 120a6e
  int (*copy_rect)(toonz_tile_handle_t handle, int left, int top, int width,
Shinya Kitaoka 120a6e
                   int height, void *dst, int dststride);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int (*create_from)(toonz_tile_handle_t handle,
Shinya Kitaoka 120a6e
                     toonz_tile_handle_t *newhandle);
Shinya Kitaoka 120a6e
  int (*create)(toonz_tile_handle_t *newhandle);
Shinya Kitaoka 120a6e
  int (*destroy)(toonz_tile_handle_t handle);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int (*get_rectangle)(toonz_tile_handle_t handle, toonz_rect_t *rect);
Shinya Kitaoka 120a6e
  int (*safen)(toonz_tile_handle_t handle);
Toshihiro Shimizu 890ddd
} TOONZ_PACK;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*	Pixel types of tile
Shinya Kitaoka 120a6e
        Correspond to TRaster32P/64P/GR8P/GR16P/GRDP/YUV422P
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
enum {
Shinya Kitaoka 120a6e
  TOONZ_TILE_TYPE_NONE,
Shinya Kitaoka 120a6e
  TOONZ_TILE_TYPE_32P,
Shinya Kitaoka 120a6e
  TOONZ_TILE_TYPE_64P,
Shinya Kitaoka 120a6e
  TOONZ_TILE_TYPE_GR8P,
Shinya Kitaoka 120a6e
  TOONZ_TILE_TYPE_GR16P,
Shinya Kitaoka 120a6e
  TOONZ_TILE_TYPE_GRDP,
Shinya Kitaoka 120a6e
  TOONZ_TILE_TYPE_YUV422P,
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef void *toonz_node_handle_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
struct toonz_node_interface_t_ {
Shinya Kitaoka 120a6e
  toonz_if_version_t ver;
Shinya Kitaoka 120a6e
  int (*get_input_port)(toonz_node_handle_t node, const char *name,
Shinya Kitaoka 120a6e
                        toonz_port_handle_t *port);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int (*get_rect)(toonz_rect_t *rect, double *x0, double *y0, double *x1,
Shinya Kitaoka 120a6e
                  double *y1);
Shinya Kitaoka 120a6e
  int (*set_rect)(toonz_rect_t *rect, double x0, double y0, double x1,
Shinya Kitaoka 120a6e
                  double y1);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int (*get_param)(toonz_node_handle_t node, const char *name,
Shinya Kitaoka 120a6e
                   toonz_param_handle_t *param);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int (*set_user_data)(toonz_node_handle_t node, void *user_data);
Shinya Kitaoka 120a6e
  int (*get_user_data)(toonz_node_handle_t node, void **user_data);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
} TOONZ_PACK;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef toonz_node_interface_t_ toonz_node_interface_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef void *toonz_handle_t;
Toshihiro Shimizu 890ddd
typedef toonz_tile_interface_t_ toonz_tile_interface_t;
Toshihiro Shimizu 890ddd
struct toonz_affine_t_ {
Shinya Kitaoka 120a6e
  double a11;
Shinya Kitaoka 120a6e
  double a12;
Shinya Kitaoka 120a6e
  double a13;
Shinya Kitaoka 120a6e
  double a21;
Shinya Kitaoka 120a6e
  double a22;
Shinya Kitaoka 120a6e
  double a23;
Toshihiro Shimizu 890ddd
} TOONZ_PACK;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef toonz_affine_t_ toonz_affine_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef void *toonz_node_handle_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
struct toonz_rendering_setting_t_ {
Shinya Kitaoka 120a6e
  toonz_if_version_t ver;
Shinya Kitaoka 120a6e
  /** コピー元の TRenderSettings のスタック上アドレス */
Shinya Kitaoka 120a6e
  const void *context;
Shinya Kitaoka 120a6e
  /** エフェクトが描画された後に適用されるアフィン変換 */
Shinya Kitaoka 120a6e
  toonz_affine_t affine;
Shinya Kitaoka 120a6e
  /**	出力フレームのためのガンマ修飾子 */
Shinya Kitaoka 120a6e
  double gamma;
Shinya Kitaoka 120a6e
  /** 入力の fps を変動させる変数 */
Shinya Kitaoka 120a6e
  double time_stretch_from;
Shinya Kitaoka 120a6e
  /** 出力の fps を変動させる変数 */
Shinya Kitaoka 120a6e
  double time_stretch_to;
Shinya Kitaoka 120a6e
  /** stereoscpy(ステレオ投影?)のためのカメラのx軸方向のシフト量 (単位は inch)
Shinya Kitaoka 120a6e
   */
Shinya Kitaoka 120a6e
  double stereo_scopic_shift;
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
  出力フレームで要求される bits per pixel の値。
Shinya Kitaoka 120a6e
  この値は適切なタイプのタイルと共に付随しなければならない。
Shinya Kitaoka 120a6e
  */
Shinya Kitaoka 120a6e
  int bpp;
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
  描画プロセスの間のタイルのキャッシュされる最大サイズ(MegaByte単位)。
Shinya Kitaoka 120a6e
  タイルのFxの計算の再分割のために予測キャッシュマネージャに用いられる(?)
Shinya Kitaoka 120a6e
  */
Shinya Kitaoka 120a6e
  int max_tile_size;
Shinya Kitaoka 120a6e
  /** アフィン変換におけるフィルタの品質 */
Shinya Kitaoka 120a6e
  int quality;
Shinya Kitaoka 120a6e
  /** ??? */
Shinya Kitaoka 120a6e
  int field_prevalence;
Shinya Kitaoka 120a6e
  /** ステレオ投影(3D効果)が用いられているかどうか */
Shinya Kitaoka 120a6e
  int stereoscopic;
Shinya Kitaoka 120a6e
  /** 描画インスタンスが swatch viewer から発生したものかどうか */
Shinya Kitaoka 120a6e
  int is_swatch;
Shinya Kitaoka 120a6e
  /** 描画リクエストの際にユーザーが手動でキャッシュするかどうか */
Shinya Kitaoka 120a6e
  int user_cachable;
Shinya Kitaoka 120a6e
  /** 縮小を必ず考慮しなければならないかどうか */
Shinya Kitaoka 120a6e
  int apply_shrink_to_viewer;
Shinya Kitaoka 120a6e
  /** カメラサイズ */
Shinya Kitaoka 120a6e
  toonz_rect_t camera_box;
Shinya Kitaoka 120a6e
  /** 途中で Preview の計算がキャンセルされた時のフラグ */
Shinya Kitaoka 120a6e
  volatile int *is_canceled;
Toshihiro Shimizu 890ddd
} TOONZ_PACK;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef toonz_rendering_setting_t_ toonz_rendering_setting_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
struct toonz_nodal_rasterfx_handler_t_ {
Shinya Kitaoka 120a6e
  toonz_if_version_t ver;
Shinya Kitaoka 120a6e
  void (*do_compute)(toonz_node_handle_t node,
Shinya Kitaoka 120a6e
                     const toonz_rendering_setting_t *, double frame,
Shinya Kitaoka 120a6e
                     toonz_tile_handle_t tile);
Shinya Kitaoka 120a6e
  int (*do_get_bbox)(toonz_node_handle_t node,
Shinya Kitaoka 120a6e
                     const toonz_rendering_setting_t *, double frame,
Shinya Kitaoka 120a6e
                     toonz_rect_t *rect);
Shinya Kitaoka 120a6e
  int (*can_handle)(toonz_node_handle_t node, const toonz_rendering_setting_t *,
Shinya Kitaoka 120a6e
                    double frame);
Shinya Kitaoka 120a6e
  size_t (*get_memory_requirement)(toonz_node_handle_t node,
Shinya Kitaoka 120a6e
                                   const toonz_rendering_setting_t *,
Shinya Kitaoka 120a6e
                                   double frame, const toonz_rect_t *rect);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void (*on_new_frame)(toonz_node_handle_t node,
Shinya Kitaoka 120a6e
                       const toonz_rendering_setting_t *, double frame);
Shinya Kitaoka 120a6e
  void (*on_end_frame)(toonz_node_handle_t node,
Shinya Kitaoka 120a6e
                       const toonz_rendering_setting_t *, double frame);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int (*create)(toonz_node_handle_t node);
Shinya Kitaoka 120a6e
  int (*destroy)(toonz_node_handle_t node);
Shinya Kitaoka 120a6e
  int (*setup)(toonz_node_handle_t node);
Shinya Kitaoka 120a6e
  int (*start_render)(toonz_node_handle_t node);
Shinya Kitaoka 120a6e
  int (*end_render)(toonz_node_handle_t node);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void *reserved_ptr_[5];
Toshihiro Shimizu 890ddd
} TOONZ_PACK;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef toonz_nodal_rasterfx_handler_t_ toonz_nodal_rasterfx_handler_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
struct toonz_fxnode_interface_t_ {
Shinya Kitaoka 120a6e
  toonz_if_version_t ver;
Shinya Kitaoka 120a6e
  /* TRasterFx の振る舞い */
Shinya Kitaoka 120a6e
  int (*get_bbox)(toonz_fxnode_handle_t fxnode,
Shinya Kitaoka 120a6e
                  const toonz_rendering_setting_t *, double frame,
Shinya Kitaoka 120a6e
                  toonz_rect_t *rect, int *get_bbox);
Shinya Kitaoka 120a6e
  int (*can_handle)(toonz_fxnode_handle_t fxnode,
Shinya Kitaoka 120a6e
                    const toonz_rendering_setting_t *, double frame,
Shinya Kitaoka 120a6e
                    int *can_handle);
Shinya Kitaoka 120a6e
  /* TFx の振る舞い */
Shinya Kitaoka 120a6e
  int (*get_input_port_count)(toonz_fxnode_handle_t fxnode, int *count);
Shinya Kitaoka 120a6e
  int (*get_input_port)(toonz_fxnode_handle_t fxnode, int index,
Shinya Kitaoka 120a6e
                        toonz_port_handle_t *port);
Shinya Kitaoka 120a6e
  int (*compute_to_tile)(toonz_fxnode_handle_t fxnode,
Shinya Kitaoka 120a6e
                         const toonz_rendering_setting_t *, double frame,
Shinya Kitaoka 120a6e
                         const toonz_rect_t *rect, toonz_tile_handle_t intile,
Shinya Kitaoka 120a6e
                         toonz_tile_handle_t outtile);
Toshihiro Shimizu 890ddd
} TOONZ_PACK;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef struct toonz_fxnode_interface_t_ toonz_fxnode_interface_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
struct toonz_setup_interface_t_ {
Shinya Kitaoka 120a6e
  toonz_if_version_t ver;
Shinya Kitaoka 120a6e
  int (*set_parameter_pages)(toonz_node_handle_t node, int num,
Shinya Kitaoka 120a6e
                             toonz_param_page_t *pages);
Shinya Kitaoka 120a6e
  int (*set_parameter_pages_with_error)(toonz_node_handle_t node, int num,
Shinya Kitaoka 120a6e
                                        toonz_param_page_t *pages, int *reason,
Shinya Kitaoka 120a6e
                                        void **position);
Shinya Kitaoka 120a6e
  int (*add_input_port)(toonz_node_handle_t node, const char *name, int type);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
} TOONZ_PACK;
Toshihiro Shimizu 890ddd
typedef struct toonz_setup_interface_t_ toonz_setup_interface_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#if defined(_MSC_VER)
Toshihiro Shimizu 890ddd
#pragma pack(pop)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#if defined(__cplusplus)
Shinya Kitaoka 120a6e
namespace toonz {
Toshihiro Shimizu 890ddd
typedef toonz_rendering_setting_t rendering_setting_t;
Toshihiro Shimizu 890ddd
typedef toonz_affine_t affine_t;
Toshihiro Shimizu 890ddd
typedef toonz_rect_t rect_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef toonz_param_handle_t param_handle_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef toonz_node_handle_t node_handle_t;
Toshihiro Shimizu 890ddd
typedef toonz_port_handle_t port_handle_t;
Toshihiro Shimizu 890ddd
typedef toonz_tile_handle_t tile_handle_t;
Toshihiro Shimizu 890ddd
typedef toonz_rendering_setting_t rendering_setting_t;
Toshihiro Shimizu 890ddd
typedef toonz_fxnode_handle_t fxnode_handle_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef toonz_param_interface_t param_interface_t;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef toonz_node_interface_t node_interface_t;
Toshihiro Shimizu 890ddd
typedef toonz_host_interface_t host_interface_t;
Toshihiro Shimizu 890ddd
typedef toonz_tile_interface_t tile_interface_t;
Toshihiro Shimizu 890ddd
typedef toonz_port_interface_t port_interface_t;
Toshihiro Shimizu 890ddd
typedef toonz_nodal_rasterfx_handler_t nodal_rasterfx_handler_t;
Toshihiro Shimizu 890ddd
typedef toonz_fxnode_interface_t fxnode_interface_t;
Toshihiro Shimizu 890ddd
typedef toonz_setup_interface_t setup_interface_t;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif