| |
| |
| #include "tbasefx.h" |
| #include "trop.h" |
| #include "tdoubleparam.h" |
| #include "tnotanimatableparam.h" |
| #include "trasterfx.h" |
| #include "tflash.h" |
| #include "tfxparam.h" |
| |
| |
| |
| |
| |
| TGeometryFx::TGeometryFx() { setName(L"Geometry"); } |
| |
| |
| |
| void TGeometryFx::compute(TFlash &flash, int frame) { |
| flash.multMatrix(getPlacement(frame)); |
| TRasterFx::compute(flash, frame); |
| } |
| |
| |
| |
| void TGeometryFx::doCompute(TTile &tile, double frame, |
| const TRenderSettings &ri) { |
| TRasterFxPort *input = dynamic_cast<TRasterFxPort *>(getInputPort(0)); |
| assert(input); |
| |
| if (!input->isConnected()) return; |
| |
| if (!getActiveTimeRegion().contains(frame)) { |
| TRasterFxP(input->getFx())->compute(tile, frame, ri); |
| return; |
| } |
| |
| if (!TRaster32P(tile.getRaster()) && !TRaster64P(tile.getRaster())) |
| throw TException("AffineFx unsupported pixel type"); |
| |
| TAffine aff1 = getPlacement(frame); |
| TRenderSettings ri2(ri); |
| ri2.m_affine = ri2.m_affine * aff1; |
| |
| TRasterFxP src = getInputPort("source")->getFx(); |
| src->compute(tile, frame, ri2); |
| return; |
| } |
| |
| |
| |
| 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; |
| }; |
| |
| |
| |
| 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 += "["; |
| |
| |
| |
| |
| 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)) + |
| "]"; |
| } |
| |
| |
| |
| 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; |
| } |
| |
| |
| |
| NaAffineFx::NaAffineFx(bool isDpiAffine) |
| : m_aff(TAffine()), m_isDpiAffine(isDpiAffine) { |
| addInputPort("source", m_port); |
| setName(L"Geometry-NaAffineFx"); |
| } |
| |
| |
| |
| 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; |
| } |
| |
| |
| |
| void NaAffineFx::compute(TFlash &flash, int frame) { |
| TGeometryFx::compute(flash, frame); |
| } |
| |
| |
| |
| 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(); |
| } |
| } |
| } |
| |
| |
| |
| FX_IDENTIFIER_IS_HIDDEN(NaAffineFx, "naAffineFx") |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| class InvertFx final : public TBaseRasterFx { |
| FX_DECLARATION(InvertFx) |
| TRasterFxPort m_input; |
| TBoolParamP m_redChan, m_greenChan, m_blueChan, m_alphaChan; |
| |
| public: |
| InvertFx() |
| : m_redChan(true) |
| , m_greenChan(true) |
| , m_blueChan(true) |
| , m_alphaChan(false) { |
| addInputPort("source", m_input); |
| |
| |
| |
| |
| setName(L"InvertFx"); |
| }; |
| |
| ~InvertFx(){}; |
| |
| bool canHandle(const TRenderSettings &info, double frame) override { |
| return true; |
| } |
| |
| bool doGetBBox(double frame, TRectD &bBox, |
| const TRenderSettings &info) override { |
| if (m_input.isConnected()) { |
| bool ret = m_input->doGetBBox(frame, bBox, info); |
| return ret; |
| } else { |
| bBox = TRectD(); |
| return false; |
| } |
| }; |
| |
| void doCompute(TTile &tile, double frame, |
| const TRenderSettings &ri) override { |
| 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()); |
| } |
| }; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| FX_IDENTIFIER(InvertFx, "invertFx") |
| |
| |
| |
| |
| |
| |
| |