Shinya Kitaoka 810553
#pragma once
Shinya Kitaoka 810553
Toshihiro Shimizu 890ddd
/*------------------------------------
Toshihiro Shimizu 890ddd
 Iwa_GradientWarpFx
Toshihiro Shimizu 890ddd
 参照画像の勾配方向にWarpするエフェクト
Toshihiro Shimizu 890ddd
------------------------------------*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef IWA_GRADIENT_WARP_H
Toshihiro Shimizu 890ddd
#define IWA_GRADIENT_WARP_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tfxparam.h"
Toshihiro Shimizu 890ddd
#include "stdfx.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
struct float2 {
Toshihiro Shimizu 890ddd
	float x, y;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
struct float4 {
Toshihiro Shimizu 890ddd
	float x, y, z, w;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
struct int2 {
Toshihiro Shimizu 890ddd
	int x, y;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class Iwa_GradientWarpFx : public TStandardRasterFx
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	FX_PLUGIN_DECLARATION(Iwa_GradientWarpFx)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
	TRasterFxPort m_source; /*- 入力画像 -*/
Toshihiro Shimizu 890ddd
	TRasterFxPort m_warper; /*- 参照画像 -*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TDoubleParamP m_h_maxlen;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_v_maxlen;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_scale; /*- ワープ量を増やすスカラー値。この値はマージン値には影響しない -*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void get_render_real_hv(const double frame,
Toshihiro Shimizu 890ddd
							const TAffine affine,
Toshihiro Shimizu 890ddd
							double &h_maxlen,
Toshihiro Shimizu 890ddd
							double &v_maxlen);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void get_render_enlarge(const double frame,
Toshihiro Shimizu 890ddd
							const TAffine affine,
Toshihiro Shimizu 890ddd
							TRectD &bBox);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*- タイルの画像を0〜1に正規化してホストメモリに読み込む -*/
Toshihiro Shimizu 890ddd
	template <typename pixel="" raster,="" typename=""></typename>
Toshihiro Shimizu 890ddd
	void setSourceRaster(const RASTER srcRas,
Toshihiro Shimizu 890ddd
						 float4 *dstMem,
Toshihiro Shimizu 890ddd
						 TDimensionI dim);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*- タイルの画像の輝度値を0〜1に正規化してホストメモリに読み込む -*/
Toshihiro Shimizu 890ddd
	template <typename pixel="" raster,="" typename=""></typename>
Toshihiro Shimizu 890ddd
	void setWarperRaster(const RASTER srcRas,
Toshihiro Shimizu 890ddd
						 float *dstMem,
Toshihiro Shimizu 890ddd
						 TDimensionI dim);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*- 出力結果をChannel値に変換して格納 -*/
Toshihiro Shimizu 890ddd
	template <typename pixel="" raster,="" typename=""></typename>
Toshihiro Shimizu 890ddd
	void setOutputRaster(float4 *srcMem,
Toshihiro Shimizu 890ddd
						 const RASTER dstRas,
Toshihiro Shimizu 890ddd
						 TDimensionI dim,
Toshihiro Shimizu 890ddd
						 int2 margin);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void doCompute_CPU(TTile &tile,
Toshihiro Shimizu 890ddd
					   const double frame,
Toshihiro Shimizu 890ddd
					   const TRenderSettings &settings,
Toshihiro Shimizu 890ddd
					   double hLength,
Toshihiro Shimizu 890ddd
					   double vLength,
Toshihiro Shimizu 890ddd
					   int margin,
Toshihiro Shimizu 890ddd
					   TDimensionI &enlargedDim,
Toshihiro Shimizu 890ddd
					   float4 *source_host,
Toshihiro Shimizu 890ddd
					   float *warper_host,
Toshihiro Shimizu 890ddd
					   float4 *result_host);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	float4 getSourceVal_CPU(float4 *source_host,
Toshihiro Shimizu 890ddd
							TDimensionI &enlargedDim,
Toshihiro Shimizu 890ddd
							int pos_x, int pos_y);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	float4 interp_CPU(float4 val1, float4 val2, float ratio);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	Iwa_GradientWarpFx();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void doCompute(TTile &tile,
Toshihiro Shimizu 890ddd
				   double frame,
Toshihiro Shimizu 890ddd
				   const TRenderSettings &settings);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool doGetBBox(double frame,
Toshihiro Shimizu 890ddd
				   TRectD &bBox,
Toshihiro Shimizu 890ddd
				   const TRenderSettings &info);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool canHandle(const TRenderSettings &info,
Toshihiro Shimizu 890ddd
				   double frame);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif