tahoma2d/toonz/sources/stdfx/ino_common.h

119 lines
4.5 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef ino_common_h
#define ino_common_h
#include "trop.h"
#include "trasterfx.h"
#include "stdfx.h"
2016-06-15 18:43:10 +12:00
namespace ino {
2016-03-19 06:57:51 +13:00
/* 一時バッファとの変換機能 */
2016-06-15 18:43:10 +12:00
void ras_to_arr(const TRasterP in_ras, const int channels,
unsigned char* out_arr);
2022-02-16 17:49:00 +13:00
void ras_to_float_arr(const TRasterP in_ras, const int channels,
float* out_arr);
void arr_to_ras(const unsigned char* in_arr, const int channels,
2016-06-15 18:43:10 +12:00
TRasterP out_ras, const int margin);
2022-02-16 17:49:00 +13:00
void float_arr_to_ras(const unsigned char* in_arr, const int channels,
TRasterP out_ras, const int margin);
2016-06-15 18:43:10 +12:00
void ras_to_vec(const TRasterP ras, const int channels,
std::vector<unsigned char>& vec);
void vec_to_ras(std::vector<unsigned char>& vec, const int channels,
2016-06-15 18:43:10 +12:00
TRasterP ras, const int margin = 0);
2022-02-16 17:49:00 +13:00
void ras_to_ref_float_arr(const TRasterP in_ras, float* out_arr,
const int refer_mode);
2016-03-19 06:57:51 +13:00
// void Lx_to_wrap( TRasterP ras );
/* logのserverアクセスON/OFF,install時設定をするための機能 */
/* TEnv::getConfigDir() + "fx_ino_no_log.setup"
2016-06-15 18:43:10 +12:00
trueを返す */
2016-03-19 06:57:51 +13:00
bool log_enable_sw(void);
/* toonz6.0.x専用の固定値を返すinline(埋め込み)関数 */
2016-06-15 18:43:10 +12:00
inline double param_range(void) { return 1.0; } // 1 or 100%
inline int channels(void) { return 4; } // RGBM is 4 channels
inline int bits(const TRasterP ras) {
return ((TRaster64P)ras) ? (std::numeric_limits<unsigned short>::digits)
: (std::numeric_limits<unsigned char>::digits);
2016-03-19 06:57:51 +13:00
}
2016-06-15 18:43:10 +12:00
inline int pixel_bits(const TRasterP ras) {
return ino::channels() * ino::bits(ras);
2016-03-19 06:57:51 +13:00
}
2016-06-15 18:43:10 +12:00
// inline double pixel_per_mm(void) { return 640. / 12. / 25.4; }
2016-03-19 06:57:51 +13:00
inline double pixel_per_mm(void) { return 1.; }
// inline double pixel_per_inch(void) { return 640. / 12.; }
} // namespace ino
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
class TBlendForeBackRasterFx : public TRasterFx {
protected:
TRasterFxPort m_up;
TRasterFxPort m_down;
TDoubleParamP m_opacity;
TBoolParamP m_clipping_mask;
TBoolParamP m_linear;
TDoubleParamP m_gamma;
// If the pixel is premultiplied, divide color data by the alpha before
// converting from the colorspace, and then multiply by the alpha afterwards.
// This will correct the color of the semi-transparent pixels in most cases.
TBoolParamP m_premultiplied;
TBoolParamP m_alpha_rendering; // optional
void dryComputeUpAndDown(TRectD& rect, double frame,
2021-09-13 15:20:16 +12:00
const TRenderSettings& rs,
bool upComputesWholeTile = false);
void doComputeFx(TRasterP& dn_ras_out, const TRasterP& up_ras,
2021-09-13 15:20:16 +12:00
const TPoint& pos, const double up_opacity,
const double gamma);
template <class T, class Q>
void nonlinearTmpl(TRasterPT<T> dn_ras_out, const TRasterPT<T>& up_ras,
2021-09-13 15:20:16 +12:00
const double up_opacity);
template <class T, class Q>
void linearTmpl(TRasterPT<T> dn_ras_out, const TRasterPT<T>& up_ras,
2021-09-13 15:20:16 +12:00
const double up_opacity, const double gamma);
2021-09-13 15:20:16 +12:00
// when compute in xyz color space, do not clamp channel values in the kernel
virtual void brendKernel(double& dnr, double& dng, double& dnb, double& dna,
2021-09-13 15:20:16 +12:00
const double up_, double upg, double upb, double upa,
const double upopacity,
const bool alpha_rendering_sw = true,
const bool is_xyz = false) = 0;
void computeUpAndDown(TTile& tile, double frame, const TRenderSettings& rs,
2021-09-13 15:20:16 +12:00
TRasterP& dn_ras, TRasterP& up_ras,
bool upComputesWholeTile = false);
2016-03-19 06:57:51 +13:00
public:
TBlendForeBackRasterFx(bool clipping_mask, bool has_alpha_option = false);
bool canHandle(const TRenderSettings& rs, double frame) override {
return true;
}
bool doGetBBox(double frame, TRectD& bBox,
const TRenderSettings& rs) override;
int getMemoryRequirement(const TRectD& rect, double frame,
const TRenderSettings& rs) override {
return TRasterFx::memorySize(rect, rs.m_bpp);
}
void doDryCompute(TRectD& rect, double frame,
const TRenderSettings& rs) override {
this->dryComputeUpAndDown(rect, frame, rs, false);
}
void doCompute(TTile& tile, double frame, const TRenderSettings& rs) override;
2016-06-15 18:43:10 +12:00
/* FX nodeが無効のときの、表示port番号 */
2016-06-19 20:06:29 +12:00
int getPreferredInputPort() override { return 1; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
std::string getPluginId() const override { return PLUGIN_PREFIX; }
2016-03-19 06:57:51 +13:00
};
#endif /* !ino_common_h */