Toshihiro Shimizu 890ddd
#include <sstream> /* std::ostringstream */</sstream>
Toshihiro Shimizu 890ddd
#include "tfxparam.h"
Toshihiro Shimizu 890ddd
#include "tparamset.h" // TPointParamP
Toshihiro Shimizu 890ddd
#include "stdfx.h"
Toshihiro Shimizu 890ddd
#include "tparamuiconcept.h" //add 20140130
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "ino_common.h"
Toshihiro Shimizu 890ddd
#include "igs_radial_blur.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------
Toshihiro Shimizu 890ddd
namespace
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
const double ino_param_range = 100.0;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
class ino_radial_blur : public TStandardRasterFx
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	FX_PLUGIN_DECLARATION(ino_radial_blur)
Toshihiro Shimizu 890ddd
	TRasterFxPort m_input;
Toshihiro Shimizu 890ddd
	TRasterFxPort m_refer;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPointParamP m_center;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_blur;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_radius;
Toshihiro Shimizu 890ddd
	TDoubleParamP m_twist;
Toshihiro Shimizu 890ddd
	// TDoubleParamP m_twist_radius;
Toshihiro Shimizu 890ddd
	TBoolParamP m_alpha_rendering;
Toshihiro Shimizu 890ddd
	TBoolParamP m_anti_alias;
Toshihiro Shimizu 890ddd
	TIntEnumParamP m_ref_mode;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	ino_radial_blur()
Toshihiro Shimizu 890ddd
		: m_center(TPointD(0.0, 0.0)), m_blur(0.01 * ino_param_range), m_radius(0.0), m_twist(0.0)
Toshihiro Shimizu 890ddd
		  // ,m_twist_radius(0.0)
Toshihiro Shimizu 890ddd
		  ,
Toshihiro Shimizu 890ddd
		  m_alpha_rendering(true), m_anti_alias(false), m_ref_mode(new TIntEnumParam(0, "Red"))
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		this->m_center->getX()->setMeasureName("fxLength");
Toshihiro Shimizu 890ddd
		this->m_center->getY()->setMeasureName("fxLength");
Toshihiro Shimizu 890ddd
		this->m_radius->setMeasureName("fxLength");
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		addInputPort("Source", this->m_input);
Toshihiro Shimizu 890ddd
		addInputPort("Reference", this->m_refer);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		bindParam(this, "center", this->m_center);
Toshihiro Shimizu 890ddd
		bindParam(this, "blur", this->m_blur);
Toshihiro Shimizu 890ddd
		bindParam(this, "radius", this->m_radius);
Toshihiro Shimizu 890ddd
		bindParam(this, "twist", this->m_twist);
Toshihiro Shimizu 890ddd
		// bindParam(this,"twist_radius", this->m_twist_radius);
Toshihiro Shimizu 890ddd
		bindParam(this, "alpha_rendering",
Toshihiro Shimizu 890ddd
				  this->m_alpha_rendering);
Toshihiro Shimizu 890ddd
		bindParam(this, "anti_alias", this->m_anti_alias);
Toshihiro Shimizu 890ddd
		bindParam(this, "reference", this->m_ref_mode);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		this->m_radius->setValueRange(
Toshihiro Shimizu 890ddd
			0, (std::numeric_limits<double>::max)());</double>
Toshihiro Shimizu 890ddd
		/* 拡大のしすぎを防ぐためにMaxを制限する */
Toshihiro Shimizu 890ddd
		this->m_blur->setValueRange(0.0 * ino_param_range, 1.0 * ino_param_range);
Toshihiro Shimizu 890ddd
		this->m_twist->setValueRange(-180.0, 180.0);
Toshihiro Shimizu 890ddd
		// this->m_twist_radius->setValueRange(0.0,1000.0);
Toshihiro Shimizu 890ddd
		this->m_ref_mode->addItem(1, "Green");
Toshihiro Shimizu 890ddd
		this->m_ref_mode->addItem(2, "Blue");
Toshihiro Shimizu 890ddd
		this->m_ref_mode->addItem(3, "Alpha");
Toshihiro Shimizu 890ddd
		this->m_ref_mode->addItem(4, "Luminance");
Toshihiro Shimizu 890ddd
		this->m_ref_mode->addItem(-1, "Nothing");
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	//------------------------------------------------------------
Toshihiro Shimizu 890ddd
	TPointD get_render_center(
Toshihiro Shimizu 890ddd
		const double frame, const TPointD &pos, const TAffine affine)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		/*--- 表示画像の中心をゼロとしたミリメートル単位の位置 ---*/
Toshihiro Shimizu 890ddd
		TPointD center = this->m_center->getValue(frame);
Toshihiro Shimizu 890ddd
		/*--- 単位変換(mm --> render用pixel) ---*/
Toshihiro Shimizu 890ddd
		center = center * ino::pixel_per_mm();
Toshihiro Shimizu 890ddd
		/*--- Affine変換(Geometry&Shrink&原点を中心から左下へ) ---*/
Toshihiro Shimizu 890ddd
		center = affine * center;
Toshihiro Shimizu 890ddd
		/*--- カメラ座標をrender画像座標の原点に ---*/
Toshihiro Shimizu 890ddd
		return center - pos;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	int get_render_int_margin(
Toshihiro Shimizu 890ddd
		const double frame, const TRectD &bBox, const TAffine affine, TPointD center)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		/*--- 単位変換(mm-->render用pixel)と長さ(scale)変換 ---*/
Toshihiro Shimizu 890ddd
		const double scale = ino::pixel_per_mm() * sqrt(fabs(affine.det()));
Toshihiro Shimizu 890ddd
		/*--- margin計算...Twist時正確でない ---*/
Toshihiro Shimizu 890ddd
		return igs::radial_blur::reference_margin(
Toshihiro Shimizu 890ddd
			static_cast<int>(ceil(bBox.getLy())), static_cast<int>(ceil(bBox.getLx())), center.x, center.y, this->m_twist->getValue(frame) * 3.14159265358979 / 180.0, 0.0 //this->m_twist_radius->getValue(frame) * scale</int></int>
Toshihiro Shimizu 890ddd
			,
Toshihiro Shimizu 890ddd
			this->m_blur->getValue(frame) / ino_param_range
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			//,this->m_radius->getValue(frame) * scale
Toshihiro Shimizu 890ddd
			,
Toshihiro Shimizu 890ddd
			0 /* debug:2012-02-01:ゼロ以上だとmarginが小さすぎになり画像が切れてしまう */
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			,
Toshihiro Shimizu 890ddd
			(this->m_anti_alias->getValue() ? 4 : 1));
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	void get_render_enlarge(
Toshihiro Shimizu 890ddd
		const double frame, const TAffine affine, TRectD &bBox)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		TPointD center(this->get_render_center(
Toshihiro Shimizu 890ddd
			frame, bBox.getP00(), affine));
Toshihiro Shimizu 890ddd
		int margin = this->get_render_int_margin(
Toshihiro Shimizu 890ddd
			frame, bBox, affine, center);
Toshihiro Shimizu 890ddd
		if (0 < margin) {
Toshihiro Shimizu 890ddd
			/* 拡大のしすぎを防ぐテキトーな制限 */
Toshihiro Shimizu 890ddd
			if (4096 < margin) {
Toshihiro Shimizu 890ddd
				margin = 4096;
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
			bBox = bBox.enlarge(margin);
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	//------------------------------------------------------------
Toshihiro Shimizu 890ddd
	bool doGetBBox(
Toshihiro Shimizu 890ddd
		double frame, TRectD &bBox, const TRenderSettings &info)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		if (!this->m_input.isConnected()) {
Toshihiro Shimizu 890ddd
			bBox = TRectD();
Toshihiro Shimizu 890ddd
			return false;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		const bool ret = this->m_input->doGetBBox(frame, bBox, info);
Toshihiro Shimizu 890ddd
		this->get_render_enlarge(frame, info.m_affine, bBox);
Toshihiro Shimizu 890ddd
		return ret;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	int getMemoryRequirement(
Toshihiro Shimizu 890ddd
		const TRectD &rect, double frame, const TRenderSettings &info)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		TRectD bBox(rect);
Toshihiro Shimizu 890ddd
		this->get_render_enlarge(frame, info.m_affine, bBox);
Toshihiro Shimizu 890ddd
		return TRasterFx::memorySize(bBox, info.m_bpp);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	void transform(
Toshihiro Shimizu 890ddd
		double frame, int port, const TRectD &rectOnOutput, const TRenderSettings &infoOnOutput, TRectD &rectOnInput, TRenderSettings &infoOnInput)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		rectOnInput = rectOnOutput;
Toshihiro Shimizu 890ddd
		infoOnInput = infoOnOutput;
Toshihiro Shimizu 890ddd
		this->get_render_enlarge(
Toshihiro Shimizu 890ddd
			frame, infoOnOutput.m_affine, rectOnInput);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	bool canHandle(const TRenderSettings &info, double frame)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		//return false; // toonz has geometry control
Toshihiro Shimizu 890ddd
		//return true;
Toshihiro Shimizu 890ddd
		/* 2012-11-14: trueのとき、Fx処理がジオメトリ変換の最後にまとめられてしまう。 */
Toshihiro Shimizu 890ddd
		return m_blur->getValue(frame) == 0 ? true : isAlmostIsotropic(info.m_affine);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	void doCompute(
Toshihiro Shimizu 890ddd
		TTile &tile, double frame, const TRenderSettings &ri);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//add 20140130
Toshihiro Shimizu 890ddd
	void getParamUIs(TParamUIConcept *&concepts, int &length)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		concepts = new TParamUIConcept[length = 2];
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		concepts[0].m_type = TParamUIConcept::POINT;
Toshihiro Shimizu 890ddd
		concepts[0].m_label = "Center";
Toshihiro Shimizu 890ddd
		concepts[0].m_params.push_back(m_center);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		concepts[1].m_type = TParamUIConcept::RADIUS;
Toshihiro Shimizu 890ddd
		concepts[1].m_label = "Radius";
Toshihiro Shimizu 890ddd
		concepts[1].m_params.push_back(m_radius);
Toshihiro Shimizu 890ddd
		concepts[1].m_params.push_back(m_center);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	//add 20140130
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
FX_PLUGIN_IDENTIFIER(ino_radial_blur, "inoRadialBlurFx");
Toshihiro Shimizu 890ddd
//--------------------------------------------------------------------
Toshihiro Shimizu 890ddd
namespace
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
void fx_(
Toshihiro Shimizu 890ddd
	const TRasterP in_ras // with margin
Toshihiro Shimizu 890ddd
	,
Toshihiro Shimizu 890ddd
	const int margin
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/* ここではinとrefは同サイズで使用している */
Toshihiro Shimizu 890ddd
	,
Toshihiro Shimizu 890ddd
	const TRasterP refer_ras // no margin
Toshihiro Shimizu 890ddd
	,
Toshihiro Shimizu 890ddd
	const int ref_mode
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	,
Toshihiro Shimizu 890ddd
	TRasterP out_ras // no margin
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	,
Toshihiro Shimizu 890ddd
	const double xp, const double yp, const double twist, const double twist_radius, const double blur, const double radius, const bool alpha_rendering_sw, const bool anti_alias_sw)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TRasterGR8P in_gr8(
Toshihiro Shimizu 890ddd
		in_ras->getLy(), in_ras->getLx() * ino::channels() *
Toshihiro Shimizu 890ddd
							 ((TRaster64P)in_ras ? sizeof(unsigned short) : sizeof(unsigned char)));
Toshihiro Shimizu 890ddd
	in_gr8->lock();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	igs::radial_blur::convert(
Toshihiro Shimizu 890ddd
		in_ras->getRawData() // BGRA
Toshihiro Shimizu 890ddd
		,
Toshihiro Shimizu 890ddd
		0 /* margin機能は使っていない、のでinとref画像は同サイズ */
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		,
Toshihiro Shimizu 890ddd
		(((0 <= ref_mode) && refer_ras) ? refer_ras->getRawData() : 0) // BGRA
Toshihiro Shimizu 890ddd
		,
Toshihiro Shimizu 890ddd
		(((0 <= ref_mode) && refer_ras) ? ino::bits(refer_ras) : 0), ref_mode
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		,
Toshihiro Shimizu 890ddd
		in_gr8->getRawData() // BGRA
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		,
Toshihiro Shimizu 890ddd
		in_ras->getLy(), in_ras->getLx(), ino::channels(), ino::bits(out_ras)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
															   ,
Toshihiro Shimizu 890ddd
		xp + margin, yp + margin, twist, twist_radius, blur, radius
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		,
Toshihiro Shimizu 890ddd
		(anti_alias_sw ? 4 : 1), alpha_rendering_sw);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	ino::arr_to_ras(
Toshihiro Shimizu 890ddd
		in_gr8->getRawData(), ino::channels(), out_ras, margin);
Toshihiro Shimizu 890ddd
	in_gr8->unlock();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
//------------------------------------------------------------
Toshihiro Shimizu 890ddd
void ino_radial_blur::doCompute(
Toshihiro Shimizu 890ddd
	TTile &tile, double frame, const TRenderSettings &ri)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	/*------ 接続していなければ処理しない ----------------------*/
Toshihiro Shimizu 890ddd
	if (!this->m_input.isConnected()) {
Toshihiro Shimizu 890ddd
		tile.getRaster()->clear(); /* 塗りつぶしクリア */
Toshihiro Shimizu 890ddd
		return;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	/*------ サポートしていないPixelタイプはエラーを投げる -----*/
Toshihiro Shimizu 890ddd
	if (!((TRaster32P)tile.getRaster()) &&
Toshihiro Shimizu 890ddd
		!((TRaster64P)tile.getRaster())) {
Toshihiro Shimizu 890ddd
		throw TRopException("unsupported input pixel type");
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	/*------ パラメータを得る ----------------------------------*/
Toshihiro Shimizu 890ddd
	const double scale = ino::pixel_per_mm() * sqrt(fabs(ri.m_affine.det()));
Toshihiro Shimizu 890ddd
	const double blur = this->m_blur->getValue(frame) / ino_param_range;
Toshihiro Shimizu 890ddd
	const double radius = this->m_radius->getValue(frame) * scale;
Toshihiro Shimizu 890ddd
	const double twist = this->m_twist->getValue(frame) *
Toshihiro Shimizu 890ddd
						 3.14159265358979 / 180.0;
Toshihiro Shimizu 890ddd
	// const double twist_radius = this->m_twist_radius->getValue(frame)*scale;
Toshihiro Shimizu 890ddd
	const bool alpha_rend_sw = this->m_alpha_rendering->getValue();
Toshihiro Shimizu 890ddd
	const bool anti_alias_sw = this->m_anti_alias->getValue();
Toshihiro Shimizu 890ddd
	const int ref_mode = this->m_ref_mode->getValue();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPointD center = this->m_center->getValue(frame);
Toshihiro Shimizu 890ddd
	TPointD render_center(this->get_render_center(
Toshihiro Shimizu 890ddd
		frame, tile.m_pos, ri.m_affine));
Toshihiro Shimizu 890ddd
	/*------ 入力画像の範囲を得る ------------------------------*/
Toshihiro Shimizu 890ddd
	TRectD tile_with_margin = TRectD(
Toshihiro Shimizu 890ddd
		tile.m_pos /* Render画像上(Pixel単位)の位置 */
Toshihiro Shimizu 890ddd
		,
Toshihiro Shimizu 890ddd
		TDimensionD(/* Render画像上(Pixel単位)のサイズ */
Toshihiro Shimizu 890ddd
					tile.getRaster()->getLx(), tile.getRaster()->getLy()));
Toshihiro Shimizu 890ddd
	/*------ 入力画像のエリアの拡大 ----------------------------*/
Toshihiro Shimizu 890ddd
	int margin = this->get_render_int_margin(
Toshihiro Shimizu 890ddd
		frame, tile_with_margin, ri.m_affine, render_center);
Toshihiro Shimizu 890ddd
	if (0 < margin) {
Toshihiro Shimizu 890ddd
		/* 拡大のしすぎを防ぐテキトーな制限 */
Toshihiro Shimizu 890ddd
		if (4096 < margin) {
Toshihiro Shimizu 890ddd
			margin = 4096;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		tile_with_margin = tile_with_margin.enlarge(margin);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	/*------ 入力画像生成 --------------------------------------*/
Toshihiro Shimizu 890ddd
	TTile tile_allocated;
Toshihiro Shimizu 890ddd
	this->m_input->allocateAndCompute(
Toshihiro Shimizu 890ddd
		tile_allocated, tile_with_margin.getP00(), TDimensionI(/* Pixel単位で四捨五入 */
Toshihiro Shimizu 890ddd
															   static_cast<int>(tile_with_margin.getLx() + 0.5), static_cast<int>(tile_with_margin.getLy() + 0.5)),</int></int>
Toshihiro Shimizu 890ddd
		tile.getRaster(), frame, ri);
Toshihiro Shimizu 890ddd
	/*------ 参照画像生成 --------------------------------------*/
Toshihiro Shimizu 890ddd
	TTile reference_tile;
Toshihiro Shimizu 890ddd
	bool reference_sw = false;
Toshihiro Shimizu 890ddd
	if (this->m_refer.isConnected()) {
Toshihiro Shimizu 890ddd
		reference_sw = true;
Toshihiro Shimizu 890ddd
		this->m_refer->allocateAndCompute(
Toshihiro Shimizu 890ddd
			reference_tile, tile_with_margin.getP00(), TDimensionI(/* Pixel単位で四捨五入 */
Toshihiro Shimizu 890ddd
																   static_cast<int>(tile_with_margin.getLx() + 0.5), static_cast<int>(tile_with_margin.getLy() + 0.5)),</int></int>
Toshihiro Shimizu 890ddd
			tile.getRaster(), frame, ri);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	/* ------ 保存すべき画像メモリを塗りつぶしクリア ---------- */
Toshihiro Shimizu 890ddd
	tile.getRaster()->clear(); /* 塗りつぶしクリア */
Toshihiro Shimizu 890ddd
	/* ------ (app_begin)log記憶 ------------------------------ */
Toshihiro Shimizu 890ddd
	const bool log_sw = ino::log_enable_sw();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	if (log_sw) {
Toshihiro Shimizu 890ddd
		std::ostringstream os;
Toshihiro Shimizu 890ddd
		os << "params"
Toshihiro Shimizu 890ddd
		   << "  cx " << center.x
Toshihiro Shimizu 890ddd
		   << "  cy " << center.y
Toshihiro Shimizu 890ddd
		   << "  blur " << blur
Toshihiro Shimizu 890ddd
		   << "  radius " << radius
Toshihiro Shimizu 890ddd
		   << "  twist " << twist
Toshihiro Shimizu 890ddd
		   // << "  twist_radius " << twist_radius
Toshihiro Shimizu 890ddd
		   << "  reference " << ref_mode
Toshihiro Shimizu 890ddd
		   << "  alpha_rendering " << alpha_rend_sw
Toshihiro Shimizu 890ddd
		   << "  anti_alias " << anti_alias_sw
Toshihiro Shimizu 890ddd
		   << "  render_center " << render_center
Toshihiro Shimizu 890ddd
		   << "  frame " << frame
Toshihiro Shimizu 890ddd
		   << "  pixbits " << ino::pixel_bits(tile.getRaster())
Toshihiro Shimizu 890ddd
		   << "  tile.m_pos " << tile.m_pos
Toshihiro Shimizu 890ddd
		   << "  tile_getLx " << tile.getRaster()->getLx()
Toshihiro Shimizu 890ddd
		   << "  y " << tile.getRaster()->getLy()
Toshihiro Shimizu 890ddd
		   << "  ri.m_cameraBox " << ri.m_cameraBox
Toshihiro Shimizu 890ddd
		   << "  ri.m_affine " << ri.m_affine
Toshihiro Shimizu 890ddd
		   << "  ri_m_affine_det " << ri.m_affine.det()
Toshihiro Shimizu 890ddd
		   << "  shrink_x " << ri.m_shrinkX
Toshihiro Shimizu 890ddd
		   << "  shrink_y " << ri.m_shrinkY
Toshihiro Shimizu 890ddd
		   << "  tile_with_margin " << tile_with_margin
Toshihiro Shimizu 890ddd
		   << "  tile_allocated.m_pos " << tile_allocated.m_pos
Toshihiro Shimizu 890ddd
		   << "  tile_allocated_getLx " << tile_allocated.getRaster()->getLx()
Toshihiro Shimizu 890ddd
		   << "  y " << tile_allocated.getRaster()->getLy();
Toshihiro Shimizu 890ddd
		if (reference_sw) {
Toshihiro Shimizu 890ddd
			os
Toshihiro Shimizu 890ddd
				<< "  reference_tile.m_pos " << reference_tile.m_pos
Toshihiro Shimizu 890ddd
				<< "  reference_tile_getLx " << reference_tile.getRaster()->getLx()
Toshihiro Shimizu 890ddd
				<< "  y " << reference_tile.getRaster()->getLy();
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	/* ------ fx処理 ------------------------------------------ */
Toshihiro Shimizu 890ddd
	try {
Toshihiro Shimizu 890ddd
		tile.getRaster()->lock();
Toshihiro Shimizu 890ddd
		fx_(
Toshihiro Shimizu 890ddd
			tile_allocated.getRaster(), margin
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			,
Toshihiro Shimizu 890ddd
			(reference_sw ? reference_tile.getRaster() : nullptr), ref_mode
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
			,
Toshihiro Shimizu 890ddd
			tile.getRaster()
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
				,
Toshihiro Shimizu 890ddd
			render_center.x, render_center.y, twist, 0.0 // twist_radius
Toshihiro Shimizu 890ddd
			,
Toshihiro Shimizu 890ddd
			blur, radius, alpha_rend_sw, anti_alias_sw);
Toshihiro Shimizu 890ddd
		tile.getRaster()->unlock();
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	/* ------ error処理 --------------------------------------- */
Toshihiro Shimizu 890ddd
	catch (std::bad_alloc &e) {
Toshihiro Shimizu 890ddd
		tile.getRaster()->unlock();
Toshihiro Shimizu 890ddd
		if (log_sw) {
Toshihiro Shimizu 890ddd
			std::string str("std::bad_alloc <");
Toshihiro Shimizu 890ddd
			str += e.what();
Toshihiro Shimizu 890ddd
			str += '>';
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		throw;
Toshihiro Shimizu 890ddd
	} catch (std::exception &e) {
Toshihiro Shimizu 890ddd
		tile.getRaster()->unlock();
Toshihiro Shimizu 890ddd
		if (log_sw) {
Toshihiro Shimizu 890ddd
			std::string str("exception <");
Toshihiro Shimizu 890ddd
			str += e.what();
Toshihiro Shimizu 890ddd
			str += '>';
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		throw;
Toshihiro Shimizu 890ddd
	} catch (...) {
Toshihiro Shimizu 890ddd
		tile.getRaster()->unlock();
Toshihiro Shimizu 890ddd
		if (log_sw) {
Toshihiro Shimizu 890ddd
			std::string str("other exception");
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
		throw;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}