2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
|
|
|
|
#include "tbasefx.h"
|
|
|
|
#include "trop.h"
|
|
|
|
#include "tdoubleparam.h"
|
|
|
|
#include "tnotanimatableparam.h"
|
|
|
|
#include "trasterfx.h"
|
|
|
|
#include "tflash.h"
|
|
|
|
#include "tfxparam.h"
|
|
|
|
|
|
|
|
//#define ALLOW_SHEAR
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TGeometryFx::TGeometryFx() { setName(L"Geometry"); }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
//--------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void TGeometryFx::compute(TFlash &flash, int frame) {
|
|
|
|
flash.multMatrix(getPlacement(frame));
|
|
|
|
TRasterFx::compute(flash, frame);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void TGeometryFx::doCompute(TTile &tile, double frame,
|
|
|
|
const TRenderSettings &ri) {
|
|
|
|
TRasterFxPort *input = dynamic_cast<TRasterFxPort *>(getInputPort(0));
|
|
|
|
assert(input);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (!input->isConnected()) return;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (!getActiveTimeRegion().contains(frame)) {
|
|
|
|
TRasterFxP(input->getFx())->compute(tile, frame, ri);
|
|
|
|
return;
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
if (!TRaster32P(tile.getRaster()) && !TRaster64P(tile.getRaster()))
|
|
|
|
throw TException("AffineFx unsupported pixel type");
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TAffine aff1 = getPlacement(frame);
|
|
|
|
TRenderSettings ri2(ri);
|
|
|
|
ri2.m_affine = ri2.m_affine * aff1;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TRasterFxP src = getInputPort("source")->getFx();
|
|
|
|
src->compute(tile, frame, ri2);
|
|
|
|
return;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool TGeometryFx::doGetBBox(double frame, TRectD &bBox,
|
|
|
|
const TRenderSettings &info) {
|
|
|
|
TRasterFxPort *input = dynamic_cast<TRasterFxPort *>(getInputPort(0));
|
|
|
|
assert(input);
|
|
|
|
|
|
|
|
if (input->isConnected()) {
|
|
|
|
TRasterFxP fx = input->getFx();
|
|
|
|
assert(fx);
|
|
|
|
bool ret = fx->doGetBBox(frame, bBox, info);
|
|
|
|
if (getActiveTimeRegion().contains(frame))
|
|
|
|
bBox = getPlacement(frame) * bBox;
|
|
|
|
return ret;
|
|
|
|
} else {
|
|
|
|
bBox = TRectD();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
std::string TGeometryFx::getAlias(double frame,
|
|
|
|
const TRenderSettings &info) const {
|
|
|
|
TGeometryFx *tthis = const_cast<TGeometryFx *>(this);
|
|
|
|
TAffine affine = tthis->getPlacement(frame);
|
|
|
|
|
|
|
|
std::string alias = getFxType();
|
|
|
|
alias += "[";
|
|
|
|
|
|
|
|
// alias degli effetti connessi alle porte di input separati da virgole
|
|
|
|
// una porta non connessa da luogo a un alias vuoto (stringa vuota)
|
|
|
|
|
|
|
|
for (int i = 0; i < getInputPortCount(); ++i) {
|
|
|
|
TFxPort *port = getInputPort(i);
|
|
|
|
if (port->isConnected()) {
|
|
|
|
TRasterFxP ifx = port->getFx();
|
|
|
|
assert(ifx);
|
|
|
|
alias += ifx->getAlias(frame, info);
|
|
|
|
}
|
|
|
|
alias += ",";
|
|
|
|
}
|
|
|
|
|
|
|
|
return alias +
|
|
|
|
(areAlmostEqual(affine.a11, 0) ? "0" : ::to_string(affine.a11, 5)) +
|
|
|
|
"," +
|
|
|
|
(areAlmostEqual(affine.a12, 0) ? "0" : ::to_string(affine.a12, 5)) +
|
|
|
|
"," +
|
|
|
|
(areAlmostEqual(affine.a13, 0) ? "0" : ::to_string(affine.a13, 5)) +
|
|
|
|
"," +
|
|
|
|
(areAlmostEqual(affine.a21, 0) ? "0" : ::to_string(affine.a21, 5)) +
|
|
|
|
"," +
|
|
|
|
(areAlmostEqual(affine.a22, 0) ? "0" : ::to_string(affine.a22, 5)) +
|
|
|
|
"," +
|
|
|
|
(areAlmostEqual(affine.a23, 0) ? "0" : ::to_string(affine.a23, 5)) +
|
|
|
|
"]";
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void TGeometryFx::transform(double frame, int port, const TRectD &rectOnOutput,
|
|
|
|
const TRenderSettings &infoOnOutput,
|
|
|
|
TRectD &rectOnInput, TRenderSettings &infoOnInput) {
|
|
|
|
rectOnInput = rectOnOutput;
|
|
|
|
TAffine aff = getPlacement(frame);
|
|
|
|
|
|
|
|
infoOnInput = infoOnOutput;
|
|
|
|
infoOnInput.m_affine = infoOnInput.m_affine * aff;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//==================================================
|
|
|
|
|
|
|
|
NaAffineFx::NaAffineFx(bool isDpiAffine)
|
2016-06-15 18:43:10 +12:00
|
|
|
: m_aff(TAffine()), m_isDpiAffine(isDpiAffine) {
|
|
|
|
addInputPort("source", m_port);
|
|
|
|
setName(L"Geometry-NaAffineFx");
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
TFx *NaAffineFx::clone(bool recursive) const {
|
|
|
|
NaAffineFx *clonedFx = dynamic_cast<NaAffineFx *>(TFx::clone(recursive));
|
|
|
|
assert(clonedFx);
|
|
|
|
clonedFx->m_aff = m_aff;
|
|
|
|
clonedFx->m_isDpiAffine = m_isDpiAffine;
|
|
|
|
return clonedFx;
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void NaAffineFx::compute(TFlash &flash, int frame) {
|
|
|
|
TGeometryFx::compute(flash, frame);
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//==================================================
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void TRasterFx::compute(TFlash &flash, int frame) {
|
|
|
|
for (int i = getInputPortCount() - 1; i >= 0; i--) {
|
|
|
|
TFxPort *port = getInputPort(i);
|
|
|
|
|
|
|
|
if (port->isConnected() && !port->isaControlPort()) {
|
|
|
|
flash.pushMatrix();
|
|
|
|
((TRasterFxP)(port->getFx()))->compute(flash, frame);
|
|
|
|
flash.popMatrix();
|
|
|
|
}
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------
|
|
|
|
|
|
|
|
FX_IDENTIFIER_IS_HIDDEN(NaAffineFx, "naAffineFx")
|
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
// Geometric Fx
|
|
|
|
//==================================================================
|
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class InvertFx final : public TBaseRasterFx {
|
2016-06-15 18:43:10 +12:00
|
|
|
FX_DECLARATION(InvertFx)
|
|
|
|
TRasterFxPort m_input;
|
|
|
|
TBoolParamP m_redChan, m_greenChan, m_blueChan, m_alphaChan;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
InvertFx()
|
|
|
|
: m_redChan(true)
|
|
|
|
, m_greenChan(true)
|
|
|
|
, m_blueChan(true)
|
|
|
|
, m_alphaChan(false) {
|
|
|
|
addInputPort("source", m_input);
|
|
|
|
// bindParam(this, "red_channel" , m_redChan);
|
|
|
|
// bindParam(this, "green_channel", m_greenChan);
|
|
|
|
// bindParam(this, "blue_channel" , m_blueChan);
|
|
|
|
// bindParam(this, "alpha_channel", m_alphaChan);
|
|
|
|
setName(L"InvertFx");
|
|
|
|
};
|
|
|
|
|
|
|
|
~InvertFx(){};
|
|
|
|
|
2016-06-20 14:23:05 +12:00
|
|
|
bool canHandle(const TRenderSettings &info, double frame) override {
|
|
|
|
return true;
|
|
|
|
}
|
2016-06-15 18:43:10 +12:00
|
|
|
|
2016-06-20 14:23:05 +12:00
|
|
|
bool doGetBBox(double frame, TRectD &bBox,
|
|
|
|
const TRenderSettings &info) override {
|
2016-06-15 18:43:10 +12:00
|
|
|
if (m_input.isConnected()) {
|
|
|
|
bool ret = m_input->doGetBBox(frame, bBox, info);
|
|
|
|
return ret;
|
|
|
|
} else {
|
|
|
|
bBox = TRectD();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-06-20 14:23:05 +12:00
|
|
|
void doCompute(TTile &tile, double frame,
|
|
|
|
const TRenderSettings &ri) override {
|
2016-06-15 18:43:10 +12:00
|
|
|
if (!m_input.isConnected()) return;
|
|
|
|
|
|
|
|
m_input->compute(tile, frame, ri);
|
|
|
|
|
|
|
|
TRop::invert(tile.getRaster(), m_redChan->getValue(),
|
|
|
|
m_greenChan->getValue(), m_blueChan->getValue(),
|
|
|
|
m_alphaChan->getValue());
|
|
|
|
}
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
// Video Fx
|
|
|
|
//==================================================================
|
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
|
|
|
|
//===
|
|
|
|
|
|
|
|
// Geometric
|
2016-06-15 18:43:10 +12:00
|
|
|
// FX_IDENTIFIER(ScaleFx, "scaleFx")
|
|
|
|
// FX_IDENTIFIER(MoveFx, "moveFx")
|
|
|
|
// FX_IDENTIFIER(AffineFx, "affineFx")
|
|
|
|
// FX_IDENTIFIER(CropFx, "cropFx")
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
// Color
|
|
|
|
FX_IDENTIFIER(InvertFx, "invertFx")
|
|
|
|
|
|
|
|
// Video
|
2016-06-15 18:43:10 +12:00
|
|
|
// FX_IDENTIFIER(FieldFx, "fieldFx")
|
|
|
|
// FX_IDENTIFIER(SwapFieldsFx, "swapFieldsFx")
|
|
|
|
// FX_IDENTIFIER(DeInterlaceFx, "deInterlaceFx")
|
|
|
|
// FX_IDENTIFIER(InterlaceFx, "interlaceFx")
|