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