|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
#include "tfxparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "stdfx.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "ino_common.h"
|
|
Toshihiro Shimizu |
890ddd |
/* tnzbase --> Source Files --> tfx --> binaryFx.cppを参照 */
|
|
Toshihiro Shimizu |
890ddd |
class ino_blend_soft_light : public TBlendForeBackRasterFx
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_DECLARATION(ino_blend_soft_light)
|
|
Toshihiro Shimizu |
890ddd |
TRasterFxPort m_up;
|
|
Toshihiro Shimizu |
890ddd |
TRasterFxPort m_down;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_opacity;
|
|
Toshihiro Shimizu |
890ddd |
TBoolParamP m_clipping_mask;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
ino_blend_soft_light()
|
|
Toshihiro Shimizu |
890ddd |
: m_opacity(1.0 * ino::param_range()), m_clipping_mask(true)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
addInputPort("Fore", this->m_up);
|
|
Toshihiro Shimizu |
890ddd |
addInputPort("Back", this->m_down);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "opacity", this->m_opacity);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "clipping_mask", this->m_clipping_mask);
|
|
Toshihiro Shimizu |
890ddd |
this->m_opacity->setValueRange(0, 1.0 * ino::param_range());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
~ino_blend_soft_light() {}
|
|
Toshihiro Shimizu |
890ddd |
bool canHandle(const TRenderSettings &rs, double frame)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
bool doGetBBox(
|
|
Toshihiro Shimizu |
890ddd |
double frame, TRectD &bBox, const TRenderSettings &rs)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TRectD up_bx;
|
|
Toshihiro Shimizu |
890ddd |
const bool up_sw = (m_up.isConnected() ? m_up->doGetBBox(frame, up_bx, rs) : false);
|
|
Toshihiro Shimizu |
890ddd |
TRectD dn_bx;
|
|
Toshihiro Shimizu |
890ddd |
const bool dn_sw = (m_down.isConnected() ? m_down->doGetBBox(frame, dn_bx, rs) : false);
|
|
Toshihiro Shimizu |
890ddd |
if (up_sw && dn_sw) {
|
|
Toshihiro Shimizu |
890ddd |
bBox = up_bx + dn_bx;
|
|
Toshihiro Shimizu |
890ddd |
return !bBox.isEmpty();
|
|
Toshihiro Shimizu |
890ddd |
} else if (up_sw) {
|
|
Toshihiro Shimizu |
890ddd |
bBox = up_bx;
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
} else if (dn_sw) {
|
|
Toshihiro Shimizu |
890ddd |
bBox = dn_bx;
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
bBox = TRectD();
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//TRect getInvalidRect(const TRect &max) {return max;}
|
|
Shinya Kitaoka |
3bfa54 |
//void doSetParam(const std::string &name, const TParamP ¶m) {}
|
|
Toshihiro Shimizu |
890ddd |
int getMemoryRequirement(
|
|
Toshihiro Shimizu |
890ddd |
const TRectD &rect, double frame, const TRenderSettings &rs)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TRasterFx::memorySize(rect, rs.m_bpp);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void doDryCompute(
|
|
Toshihiro Shimizu |
890ddd |
TRectD &rect, double frame, const TRenderSettings &rs)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
this->dryComputeUpAndDown(rect, frame, rs, false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void doCompute(
|
|
Toshihiro Shimizu |
890ddd |
TTile &tile, double frame, const TRenderSettings &rs);
|
|
Toshihiro Shimizu |
890ddd |
void computeUpAndDown(
|
|
Toshihiro Shimizu |
890ddd |
TTile &tile, double frame, const TRenderSettings &rs, TRasterP &dn_ras, TRasterP &up_ras, bool upComputesWholeTile = false);
|
|
Toshihiro Shimizu |
890ddd |
void dryComputeUpAndDown(
|
|
Toshihiro Shimizu |
890ddd |
TRectD &rect, double frame, const TRenderSettings &rs, bool upComputesWholeTile = false
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
upComputesWholeTile は Screen, Min, Blendでtrueにして使用している。
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_IDENTIFIER(ino_blend_soft_light, "inoSoftLightFx");
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
/* より大きな四角エリアにPixel整数値で密着する */
|
|
Toshihiro Shimizu |
890ddd |
void makeRectCoherent(TRectD &rect, const TPointD &pos)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
rect -= pos;
|
|
Toshihiro Shimizu |
890ddd |
rect.x0 = tfloor(rect.x0); /* ((x)<(int)(x)? (int)(x)-1: (int)(x))*/
|
|
Toshihiro Shimizu |
890ddd |
rect.y0 = tfloor(rect.y0);
|
|
Toshihiro Shimizu |
890ddd |
rect.x1 = tceil(rect.x1); /* ((int)(x)<(x)? (int)(x)+1: (int)(x))*/
|
|
Toshihiro Shimizu |
890ddd |
rect.y1 = tceil(rect.y1);
|
|
Toshihiro Shimizu |
890ddd |
rect += pos;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void ino_blend_soft_light::computeUpAndDown(
|
|
Toshihiro Shimizu |
890ddd |
TTile &tile, double frame, const TRenderSettings &rs, TRasterP &dn_ras, TRasterP &up_ras, bool upComputesWholeTile)
|
|
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 |
m_down,m_upは繋がっている方があればそれを表示する
|
|
Toshihiro Shimizu |
890ddd |
両方とも接続していれば合成処理する
|
|
Toshihiro Shimizu |
890ddd |
表示スイッチを切ってあるならm_upを表示する
|
|
Toshihiro Shimizu |
890ddd |
fxをreplaceすると、
|
|
Toshihiro Shimizu |
890ddd |
m_source --> m_up (=port0)
|
|
Toshihiro Shimizu |
890ddd |
m_refernce --> m_down(=port1)
|
|
Toshihiro Shimizu |
890ddd |
となる
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
const bool up_is = (this->m_up.isConnected() &&
|
|
Toshihiro Shimizu |
890ddd |
this->m_up.getFx()->getTimeRegion().contains(frame));
|
|
Toshihiro Shimizu |
890ddd |
const bool down_is = (this->m_down.isConnected() &&
|
|
Toshihiro Shimizu |
890ddd |
this->m_down.getFx()->getTimeRegion().contains(frame));
|
|
Toshihiro Shimizu |
890ddd |
/* ------ 両方とも切断の時処理しない ---------------------- */
|
|
Toshihiro Shimizu |
890ddd |
if (!up_is && !down_is) {
|
|
Toshihiro Shimizu |
890ddd |
tile.getRaster()->clear();
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
/* ------ up接続かつdown切断の時 -------------------------- */
|
|
Toshihiro Shimizu |
890ddd |
if (up_is && !down_is) {
|
|
Toshihiro Shimizu |
890ddd |
this->m_up->compute(tile, frame, rs);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
/* ------ down接続時 downのみ描画して... ------------------ */
|
|
Toshihiro Shimizu |
890ddd |
if (down_is) {
|
|
Toshihiro Shimizu |
890ddd |
this->m_down->compute(tile, frame, rs);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
/* ------ up切断時 ---------------------------------------- */
|
|
Toshihiro Shimizu |
890ddd |
if (!up_is) {
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* upと重なる部分を描画する */
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* ------ tileの範囲 -------------------------------------- */
|
|
Toshihiro Shimizu |
890ddd |
const TDimension tsz(tile.getRaster()->getSize()); /* 整数 */
|
|
Toshihiro Shimizu |
890ddd |
const TRectD tileRect(tile.m_pos, TDimensionD(tsz.lx, tsz.ly));
|
|
Toshihiro Shimizu |
890ddd |
TRectD upBBox;
|
|
Toshihiro Shimizu |
890ddd |
if (upComputesWholeTile) {
|
|
Toshihiro Shimizu |
890ddd |
upBBox = tileRect;
|
|
Toshihiro Shimizu |
890ddd |
} /* tile全体を得る */
|
|
Toshihiro Shimizu |
890ddd |
else { /* 厳密なエリア... */
|
|
Toshihiro Shimizu |
890ddd |
this->m_up->getBBox(frame, upBBox, rs);
|
|
Toshihiro Shimizu |
890ddd |
upBBox *= tileRect; /* upとtileの交差エリア */
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* より大きな四角エリアにPixel整数値で密着する */
|
|
Toshihiro Shimizu |
890ddd |
makeRectCoherent(upBBox, tile.m_pos); // double-->int grid
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TDimensionI upSize( /* TRectDをTDimensionIに変換 */
|
|
Toshihiro Shimizu |
890ddd |
tround(upBBox.getLx()) // getLx() = "x1>=x0?x1-x0:0"
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
tround(upBBox.getLy()) // getLy() = "y1>=y0?y1-y0:0"
|
|
Toshihiro Shimizu |
890ddd |
);
|
|
Toshihiro Shimizu |
890ddd |
if ((upSize.lx <= 0) || (upSize.ly <= 0)) {
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* ------ upのメモリ確保と描画 ---------------------------- */
|
|
Toshihiro Shimizu |
890ddd |
TTile upTile;
|
|
Toshihiro Shimizu |
890ddd |
this->m_up->allocateAndCompute(
|
|
Toshihiro Shimizu |
890ddd |
upTile, upBBox.getP00(), upSize, tile.getRaster() /* 32/64bitsの判定に使う */
|
|
Toshihiro Shimizu |
890ddd |
,
|
|
Toshihiro Shimizu |
890ddd |
frame, rs);
|
|
Toshihiro Shimizu |
890ddd |
/* ------ upとdownのTRasterを得る ------------------------- */
|
|
Toshihiro Shimizu |
890ddd |
TRectI dnRect(upTile.getRaster()->getSize()); //TDimensionI(-)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
dnRect += convert(upTile.m_pos - tile.m_pos); /* uptile->tile原点 */
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
ここで問題はdoubleの位置を、四捨五入して整数値にしていること
|
|
Toshihiro Shimizu |
890ddd |
移動してから四捨五入ではないの???
|
|
Toshihiro Shimizu |
890ddd |
dnRectの元位置が整数位置なので、問題ないか...
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
dn_ras = upComputesWholeTile ? tile.getRaster() : tile.getRaster()->extract(dnRect);
|
|
Toshihiro Shimizu |
890ddd |
up_ras = upTile.getRaster();
|
|
Toshihiro Shimizu |
890ddd |
assert(dn_ras->getSize() == up_ras->getSize());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void ino_blend_soft_light::dryComputeUpAndDown(
|
|
Toshihiro Shimizu |
890ddd |
TRectD &rect, double frame, const TRenderSettings &rs, bool upComputesWholeTile)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
const bool up_is = (this->m_up.isConnected() &&
|
|
Toshihiro Shimizu |
890ddd |
this->m_up.getFx()->getTimeRegion().contains(frame));
|
|
Toshihiro Shimizu |
890ddd |
const bool down_is = (this->m_down.isConnected() &&
|
|
Toshihiro Shimizu |
890ddd |
this->m_down.getFx()->getTimeRegion().contains(frame));
|
|
Toshihiro Shimizu |
890ddd |
/* ------ 両方とも切断の時処理しない ---------------------- */
|
|
Toshihiro Shimizu |
890ddd |
if (!up_is && !down_is) {
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
/* ------ up接続かつdown切断の時 -------------------------- */
|
|
Toshihiro Shimizu |
890ddd |
if (up_is && !down_is) {
|
|
Toshihiro Shimizu |
890ddd |
this->m_up->dryCompute(rect, frame, rs);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
/* ------ down接続時 -------------------------------------- */
|
|
Toshihiro Shimizu |
890ddd |
if (down_is) {
|
|
Toshihiro Shimizu |
890ddd |
this->m_down->dryCompute(rect, frame, rs);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
/* ------ up切断時 ---------------------------------------- */
|
|
Toshihiro Shimizu |
890ddd |
if (!up_is) {
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* ------ tileのgeometryを計算する ------------------------ */
|
|
Toshihiro Shimizu |
890ddd |
TRectD upBBox;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (upComputesWholeTile) {
|
|
Toshihiro Shimizu |
890ddd |
upBBox = rect;
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
this->m_up->getBBox(frame, upBBox, rs);
|
|
Toshihiro Shimizu |
890ddd |
upBBox *= rect;
|
|
Toshihiro Shimizu |
890ddd |
makeRectCoherent(upBBox, rect.getP00());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if ((upBBox.getLx() > 0.5) && (upBBox.getLy() > 0.5)) {
|
|
Toshihiro Shimizu |
890ddd |
this->m_up->dryCompute(upBBox, frame, rs);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
#include <sstream> /* std::ostringstream */</sstream>
|
|
Toshihiro Shimizu |
890ddd |
#include "igs_color_blend.h"
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
template <class class="" q="" t,=""></class>
|
|
Toshihiro Shimizu |
890ddd |
void tmpl_(
|
|
Toshihiro Shimizu |
890ddd |
TRasterPT<t> dn_ras_out, const TRasterPT<t> &up_ras, const double up_opacity, const bool clipping_mask_sw)</t></t>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
double maxi = static_cast<double>(T::maxChannelValue); //255or65535</double>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
assert(dn_ras_out->getSize() == up_ras->getSize());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for (int yy = 0; yy < dn_ras_out->getLy(); ++yy) {
|
|
Toshihiro Shimizu |
890ddd |
T *out_pix = dn_ras_out->pixels(yy);
|
|
Toshihiro Shimizu |
890ddd |
const T *const out_end = out_pix + dn_ras_out->getLx();
|
|
Toshihiro Shimizu |
890ddd |
const T *up_pix = up_ras->pixels(yy);
|
|
Toshihiro Shimizu |
890ddd |
for (; out_pix < out_end; ++out_pix, ++up_pix) {
|
|
Toshihiro Shimizu |
890ddd |
double upr = static_cast<double>(up_pix->r) / maxi;</double>
|
|
Toshihiro Shimizu |
890ddd |
double upg = static_cast<double>(up_pix->g) / maxi;</double>
|
|
Toshihiro Shimizu |
890ddd |
double upb = static_cast<double>(up_pix->b) / maxi;</double>
|
|
Toshihiro Shimizu |
890ddd |
double upa = static_cast<double>(up_pix->m) / maxi;</double>
|
|
Toshihiro Shimizu |
890ddd |
double dnr = static_cast<double>(out_pix->r) / maxi;</double>
|
|
Toshihiro Shimizu |
890ddd |
double dng = static_cast<double>(out_pix->g) / maxi;</double>
|
|
Toshihiro Shimizu |
890ddd |
double dnb = static_cast<double>(out_pix->b) / maxi;</double>
|
|
Toshihiro Shimizu |
890ddd |
double dna = static_cast<double>(out_pix->m) / maxi;</double>
|
|
Toshihiro Shimizu |
890ddd |
igs::color::soft_light(
|
|
Toshihiro Shimizu |
890ddd |
dnr, dng, dnb, dna, upr, upg, upb, upa, clipping_mask_sw ? up_opacity * dna : up_opacity);
|
|
Toshihiro Shimizu |
890ddd |
out_pix->r = static_cast<q>(dnr * (maxi + 0.999999));</q>
|
|
Toshihiro Shimizu |
890ddd |
out_pix->g = static_cast<q>(dng * (maxi + 0.999999));</q>
|
|
Toshihiro Shimizu |
890ddd |
out_pix->b = static_cast<q>(dnb * (maxi + 0.999999));</q>
|
|
Toshihiro Shimizu |
890ddd |
out_pix->m = static_cast<q>(dna * (maxi + 0.999999));</q>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void fx_(
|
|
Toshihiro Shimizu |
890ddd |
TRasterP &dn_ras_out, const TRasterP &up_ras, const TPoint &pos, const double up_opacity, const bool clipping_mask_sw)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
/* 交差したエリアを処理するようにする、いるのか??? */
|
|
Toshihiro Shimizu |
890ddd |
TRect outRect(dn_ras_out->getBounds());
|
|
Toshihiro Shimizu |
890ddd |
TRect upRect(up_ras->getBounds() + pos);
|
|
Toshihiro Shimizu |
890ddd |
TRect intersection = outRect * upRect;
|
|
Toshihiro Shimizu |
890ddd |
if (intersection.isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRasterP cRout = dn_ras_out->extract(intersection);
|
|
Toshihiro Shimizu |
890ddd |
TRect rr = intersection - pos;
|
|
Toshihiro Shimizu |
890ddd |
TRasterP cRup = up_ras->extract(rr);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P rout32 = cRout, rup32 = cRup;
|
|
Toshihiro Shimizu |
890ddd |
TRaster64P rout64 = cRout, rup64 = cRup;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (rout32 && rup32) {
|
|
Toshihiro Shimizu |
890ddd |
tmpl_<tpixel32, uchar="">(</tpixel32,>
|
|
Toshihiro Shimizu |
890ddd |
rout32, rup32, up_opacity, clipping_mask_sw);
|
|
Toshihiro Shimizu |
890ddd |
} else if (rout64 && rup64) {
|
|
Toshihiro Shimizu |
890ddd |
tmpl_<tpixel64, ushort="">(</tpixel64,>
|
|
Toshihiro Shimizu |
890ddd |
rout64, rup64, up_opacity, clipping_mask_sw);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
throw TRopException("unsupported pixel type");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void ino_blend_soft_light::doCompute(
|
|
Toshihiro Shimizu |
890ddd |
TTile &tile, double frame, const TRenderSettings &rs)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
/* ------ 画像生成 ---------------------------------------- */
|
|
Toshihiro Shimizu |
890ddd |
TRasterP dn_ras, up_ras;
|
|
Toshihiro Shimizu |
890ddd |
this->computeUpAndDown(tile, frame, rs, dn_ras, up_ras);
|
|
Toshihiro Shimizu |
890ddd |
if (!dn_ras || !up_ras) {
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
/* ------ 動作パラメータを得る ---------------------------- */
|
|
Toshihiro Shimizu |
890ddd |
const double up_opacity = this->m_opacity->getValue(frame) / ino::param_range();
|
|
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 |
<< " up_opacity " << up_opacity
|
|
Toshihiro Shimizu |
890ddd |
<< " dn_tile w " << dn_ras->getLx()
|
|
Toshihiro Shimizu |
890ddd |
<< " wrap " << dn_ras->getWrap()
|
|
Toshihiro Shimizu |
890ddd |
<< " h " << dn_ras->getLy()
|
|
Toshihiro Shimizu |
890ddd |
<< " pixbits " << ino::pixel_bits(dn_ras)
|
|
Toshihiro Shimizu |
890ddd |
<< " up_tile w " << up_ras->getLx()
|
|
Toshihiro Shimizu |
890ddd |
<< " wrap " << up_ras->getWrap()
|
|
Toshihiro Shimizu |
890ddd |
<< " h " << up_ras->getLy()
|
|
Toshihiro Shimizu |
890ddd |
<< " pixbits " << ino::pixel_bits(up_ras)
|
|
Toshihiro Shimizu |
890ddd |
<< " frame " << frame;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
/* ------ fx処理 ------------------------------------------ */
|
|
Toshihiro Shimizu |
890ddd |
try {
|
|
Toshihiro Shimizu |
890ddd |
if (dn_ras) {
|
|
Toshihiro Shimizu |
890ddd |
dn_ras->lock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (up_ras) {
|
|
Toshihiro Shimizu |
890ddd |
up_ras->lock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
fx_(dn_ras, up_ras, TPoint(), up_opacity, this->m_clipping_mask->getValue());
|
|
Toshihiro Shimizu |
890ddd |
if (up_ras) {
|
|
Toshihiro Shimizu |
890ddd |
up_ras->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (dn_ras) {
|
|
Toshihiro Shimizu |
890ddd |
dn_ras->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
/* ------ error処理 --------------------------------------- */
|
|
Toshihiro Shimizu |
890ddd |
catch (std::exception &e) {
|
|
Toshihiro Shimizu |
890ddd |
if (up_ras) {
|
|
Toshihiro Shimizu |
890ddd |
up_ras->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (dn_ras) {
|
|
Toshihiro Shimizu |
890ddd |
dn_ras->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
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 |
if (up_ras) {
|
|
Toshihiro Shimizu |
890ddd |
up_ras->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
if (dn_ras) {
|
|
Toshihiro Shimizu |
890ddd |
dn_ras->unlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
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 |
}
|