Toshihiro Shimizu 890ddd
#include <sstream> /* std::ostringstream */</sstream>
Toshihiro Shimizu 890ddd
#include "tfxparam.h"
Shinya Kitaoka 120a6e
#include "tparamset.h"  // TPointParamP
Toshihiro Shimizu 890ddd
#include "stdfx.h"
Shinya Kitaoka 120a6e
#include "tparamuiconcept.h"  //add 20140130
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "ino_common.h"
Toshihiro Shimizu 890ddd
#include "igs_rotate_blur.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------
Shinya Kitaoka d1f6c4
class ino_spin_blur final : public TStandardRasterFx {
Shinya Kitaoka 120a6e
  FX_PLUGIN_DECLARATION(ino_spin_blur)
Shinya Kitaoka 120a6e
  TRasterFxPort m_input;
Shinya Kitaoka 120a6e
  TRasterFxPort m_refer;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TPointParamP m_center;
Shinya Kitaoka 120a6e
  TDoubleParamP m_blur;
Shinya Kitaoka 120a6e
  TDoubleParamP m_radius;
Shinya Kitaoka 120a6e
  TIntEnumParamP m_type;
Shinya Kitaoka 120a6e
  TBoolParamP m_alpha_rendering;
Shinya Kitaoka 120a6e
  TBoolParamP m_anti_alias;
Shinya Kitaoka 120a6e
  TIntEnumParamP m_ref_mode;
shun-iwasawa 0e1837
  // elliptical shape
shun-iwasawa 0e1837
  TDoubleParamP m_ellipse_aspect_ratio;
shun-iwasawa 0e1837
  TDoubleParamP m_ellipse_angle;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ino_spin_blur()
Shinya Kitaoka 120a6e
      : m_center(TPointD(0.0, 0.0))
Shinya Kitaoka 120a6e
      , m_blur(1)
Shinya Kitaoka 120a6e
      , m_radius(0.0)
Shinya Kitaoka 120a6e
      , m_type(new TIntEnumParam(0, "Accelerator"))
Shinya Kitaoka 120a6e
      , m_alpha_rendering(true)
Shinya Kitaoka 120a6e
      , m_anti_alias(false)
shun-iwasawa 0e1837
      , m_ref_mode(new TIntEnumParam(0, "Red"))
shun-iwasawa 0e1837
      , m_ellipse_aspect_ratio(1.0)
shun-iwasawa 0e1837
      , m_ellipse_angle(0.0) {
Shinya Kitaoka 120a6e
    this->m_center->getX()->setMeasureName("fxLength");
Shinya Kitaoka 120a6e
    this->m_center->getY()->setMeasureName("fxLength");
Shinya Kitaoka 120a6e
    this->m_radius->setMeasureName("fxLength");
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    addInputPort("Source", this->m_input);
Shinya Kitaoka 120a6e
    addInputPort("Reference", this->m_refer);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    bindParam(this, "center", this->m_center);
Shinya Kitaoka 120a6e
    bindParam(this, "blur", this->m_blur);
Shinya Kitaoka 120a6e
    bindParam(this, "radius", this->m_radius);
Shinya Kitaoka 120a6e
    bindParam(this, "type", this->m_type);
Shinya Kitaoka 120a6e
    bindParam(this, "alpha_rendering", this->m_alpha_rendering);
Shinya Kitaoka 120a6e
    bindParam(this, "anti_alias", this->m_anti_alias);
Shinya Kitaoka 120a6e
    bindParam(this, "reference", this->m_ref_mode);
shun-iwasawa 0e1837
    bindParam(this, "ellipse_aspect_ratio", this->m_ellipse_aspect_ratio);
shun-iwasawa 0e1837
    bindParam(this, "ellipse_angle", this->m_ellipse_angle);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    this->m_radius->setValueRange(0, (std::numeric_limits<double>::max)());</double>
Shinya Kitaoka 120a6e
    /* 拡大のしすぎを防ぐためにMaxを制限する */
Shinya Kitaoka 120a6e
    this->m_blur->setValueRange(0.0, 180.0);
shun-iwasawa 0e1837
    this->m_ellipse_aspect_ratio->setValueRange(0.1, 10.0);
shun-iwasawa 0e1837
    this->m_ellipse_angle->setValueRange(-180.0, 180.0);
shun-iwasawa 0e1837
    this->m_type->addItem(1, "Uniform Angle");
shun-iwasawa 0e1837
    this->m_type->addItem(2, "Uniform Length");
Shinya Kitaoka 120a6e
    this->m_ref_mode->addItem(1, "Green");
Shinya Kitaoka 120a6e
    this->m_ref_mode->addItem(2, "Blue");
Shinya Kitaoka 120a6e
    this->m_ref_mode->addItem(3, "Alpha");
Shinya Kitaoka 120a6e
    this->m_ref_mode->addItem(4, "Luminance");
Shinya Kitaoka 120a6e
    this->m_ref_mode->addItem(-1, "Nothing");
shun-iwasawa 481b59
shun-iwasawa 481b59
    enableComputeInFloat(true);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  //------------------------------------------------------------
Shinya Kitaoka 120a6e
  TPointD get_render_center(const double frame, const TPointD &pos,
Shinya Kitaoka 120a6e
                            const TAffine affine) {
Shinya Kitaoka 120a6e
    /*--- 表示画像の中心をゼロとしたミリメートル単位の位置 ---*/
Shinya Kitaoka 120a6e
    TPointD center = this->m_center->getValue(frame);
Shinya Kitaoka 120a6e
    /*--- 単位変換(mm --> render用pixel) ---*/
Shinya Kitaoka 120a6e
    center = center * ino::pixel_per_mm();
Shinya Kitaoka 120a6e
    /*--- Affine変換(Geometry&Shrink&原点を中心から左下へ) ---*/
Shinya Kitaoka 120a6e
    center = affine * center;
Shinya Kitaoka 120a6e
    /*--- カメラ座標をrender画像座標の原点に ---*/
Shinya Kitaoka 120a6e
    return center - pos;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  int get_render_int_margin(const double frame, const TRectD &bBox,
Shinya Kitaoka 120a6e
                            const TAffine affine, TPointD center) {
Shinya Kitaoka 120a6e
    /*--- 単位変換(mm-->render用pixel)と長さ(scale)変換 ---*/
Shinya Kitaoka 120a6e
    const double scale = ino::pixel_per_mm() * sqrt(fabs(affine.det()));
Shinya Kitaoka 120a6e
    /*--- margin計算...Twist時正確でない ---*/
Shinya Kitaoka 120a6e
    return igs::rotate_blur::reference_margin(
Shinya Kitaoka 120a6e
        static_cast<int>(ceil(bBox.getLy())),</int>
shun-iwasawa 0e1837
        static_cast<int>(ceil(bBox.getLx())), center,</int>
Shinya Kitaoka 120a6e
        this->m_blur->getValue(frame), this->m_radius->getValue(frame) * scale,
shun-iwasawa 3b3431
        bBox.getLy() / 2.0, this->m_type->getValue(),
shun-iwasawa 3b3431
        this->m_ellipse_aspect_ratio->getValue(frame));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  void get_render_enlarge(const double frame, const TAffine affine,
Shinya Kitaoka 120a6e
                          TRectD &bBox) {
Shinya Kitaoka 120a6e
    TPointD center(this->get_render_center(frame, bBox.getP00(), affine));
Shinya Kitaoka 120a6e
    int margin = this->get_render_int_margin(frame, bBox, affine, center);
Shinya Kitaoka 120a6e
    if (0 < margin) {
Shinya Kitaoka 120a6e
      /* 拡大のしすぎを防ぐテキトーな制限 */
Shinya Kitaoka 120a6e
      if (4096 < margin) {
Shinya Kitaoka 120a6e
        margin = 4096;
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
      bBox = bBox.enlarge(margin);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  //------------------------------------------------------------
Shinya Kitaoka 38fd86
  bool doGetBBox(double frame, TRectD &bBox,
Shinya Kitaoka 38fd86
                 const TRenderSettings &info) override {
Shinya Kitaoka 120a6e
    if (!this->m_input.isConnected()) {
Shinya Kitaoka 120a6e
      bBox = TRectD();
Shinya Kitaoka 120a6e
      return false;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    const bool ret = this->m_input->doGetBBox(frame, bBox, info);
Shinya Kitaoka 120a6e
    this->get_render_enlarge(frame, info.m_affine, bBox);
Shinya Kitaoka 120a6e
    return ret;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  int getMemoryRequirement(const TRectD &rect, double frame,
Shinya Kitaoka 473e70
                           const TRenderSettings &info) override {
Shinya Kitaoka 120a6e
    TRectD bBox(rect);
Shinya Kitaoka 120a6e
    this->get_render_enlarge(frame, info.m_affine, bBox);
Shinya Kitaoka 120a6e
    return TRasterFx::memorySize(bBox, info.m_bpp);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  void transform(double frame, int port, const TRectD &rectOnOutput,
Shinya Kitaoka 120a6e
                 const TRenderSettings &infoOnOutput, TRectD &rectOnInput,
Shinya Kitaoka 473e70
                 TRenderSettings &infoOnInput) override {
Shinya Kitaoka 120a6e
    rectOnInput = rectOnOutput;
Shinya Kitaoka 120a6e
    infoOnInput = infoOnOutput;
Shinya Kitaoka 120a6e
    this->get_render_enlarge(frame, infoOnOutput.m_affine, rectOnInput);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 473e70
  bool canHandle(const TRenderSettings &info, double frame) override {
Shinya Kitaoka 120a6e
    // return false; // toonz has geometry control
Shinya Kitaoka 120a6e
    // return true;
Shinya Kitaoka 120a6e
    /* 2012-11-14:
Shinya Kitaoka 120a6e
     * trueのとき、Fx処理がジオメトリ変換の最後にまとめられてしまう。 */
Shinya Kitaoka 120a6e
    return m_blur->getValue(frame) == 0 ? true
Shinya Kitaoka 120a6e
                                        : isAlmostIsotropic(info.m_affine);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 473e70
  void doCompute(TTile &tile, double frame, const TRenderSettings &ri) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // add 20140130
Shinya Kitaoka 473e70
  void getParamUIs(TParamUIConcept *&concepts, int &length) override {
shun-iwasawa 0e1837
    concepts = new TParamUIConcept[length = 2];
Toshihiro Shimizu 890ddd
shun-iwasawa 0e1837
    concepts[0].m_type  = TParamUIConcept::ELLIPSE;
shun-iwasawa 0e1837
    concepts[0].m_label = "Radius";
shun-iwasawa 0e1837
    concepts[0].m_params.push_back(m_radius);
Shinya Kitaoka 120a6e
    concepts[0].m_params.push_back(m_center);
shun-iwasawa 0e1837
    concepts[0].m_params.push_back(m_ellipse_aspect_ratio);
shun-iwasawa 0e1837
    concepts[0].m_params.push_back(m_ellipse_angle);
Toshihiro Shimizu 890ddd
shun-iwasawa 0e1837
    concepts[1].m_type = TParamUIConcept::COMPASS_SPIN;
Shinya Kitaoka 120a6e
    concepts[1].m_params.push_back(m_center);
shun-iwasawa 0e1837
    concepts[1].m_params.push_back(m_ellipse_aspect_ratio);
shun-iwasawa 0e1837
    concepts[1].m_params.push_back(m_ellipse_angle);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  // add 20140130
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
FX_PLUGIN_IDENTIFIER(ino_spin_blur, "inoSpinBlurFx");
Toshihiro Shimizu 890ddd
//--------------------------------------------------------------------
Shinya Kitaoka 120a6e
namespace {
shun-iwasawa 0e1837
void fx_(const TRasterP in_ras,  // with margin
shun-iwasawa 0e1837
         const int margin, /* ここではinとrefは同サイズで使用している */
shun-iwasawa 0e1837
         const TRasterP refer_ras,  // no margin
shun-iwasawa 0e1837
         const int refer_mode,
shun-iwasawa 0e1837
         TRasterP out_ras,  // no margin
shun-iwasawa 0e1837
         const TPointD center, const int type, const double blur,
Shinya Kitaoka 120a6e
         const double radius, const bool alpha_rendering_sw,
shun-iwasawa 0e1837
         const bool anti_alias_sw, const double ellipse_aspect_ratio,
shun-iwasawa 0e1837
         const double ellipse_angle) {
shun-iwasawa 0e1837
  TRasterGR8P ref_gr8;
shun-iwasawa 0e1837
  if ((refer_ras != nullptr) && (0 <= refer_mode)) {
shun-iwasawa 0e1837
    ref_gr8 =
shun-iwasawa 0e1837
        TRasterGR8P(refer_ras->getLy(), refer_ras->getLx() * sizeof(float));
shun-iwasawa 0e1837
    ref_gr8->lock();
shun-iwasawa 0e1837
    ino::ras_to_ref_float_arr(refer_ras,
shun-iwasawa 0e1837
                              reinterpret_cast<float *="">(ref_gr8->getRawData()),</float>
shun-iwasawa 0e1837
                              refer_mode);
shun-iwasawa 0e1837
  }
shun-iwasawa 0e1837
Shinya Kitaoka 120a6e
  TRasterGR8P in_gr8(in_ras->getLy(),
shun-iwasawa 0e1837
                     in_ras->getLx() * ino::channels() * sizeof(float));
Shinya Kitaoka 120a6e
  in_gr8->lock();
shun-iwasawa 0e1837
  ino::ras_to_float_arr(in_ras, ino::channels(),
shun-iwasawa 0e1837
                        reinterpret_cast<float *="">(in_gr8->getRawData()));</float>
Toshihiro Shimizu 890ddd
shun-iwasawa 0e1837
  TRasterGR8P out_buffer(out_ras->getLy(),
shun-iwasawa 0e1837
                         out_ras->getLx() * ino::channels() * sizeof(float));
shun-iwasawa 0e1837
  out_buffer->lock();
Toshihiro Shimizu 890ddd
shun-iwasawa 0e1837
  igs::rotate_blur::convert(
shun-iwasawa 0e1837
      reinterpret_cast<float *="">(in_gr8->getRawData()),</float>
shun-iwasawa 0e1837
      reinterpret_cast<float *="">(out_buffer->getRawData()), margin,</float>
shun-iwasawa 0e1837
      out_ras->getSize(), ino::channels(),
shun-iwasawa 0e1837
      (ref_gr8) ? reinterpret_cast<float *="">(ref_gr8->getRawData()) : nullptr,</float>
shun-iwasawa 0e1837
      center + TPointD(margin, margin), blur, /*degree*/
shun-iwasawa 0e1837
      radius, (out_ras->getLy() / 2.0), type, anti_alias_sw, alpha_rendering_sw,
shun-iwasawa 0e1837
      ellipse_aspect_ratio, ellipse_angle);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  in_gr8->unlock();
shun-iwasawa 0e1837
  ino::float_arr_to_ras(out_buffer->getRawData(), ino::channels(), out_ras, 0);
shun-iwasawa 0e1837
  out_buffer->unlock();
shun-iwasawa 481b59
shun-iwasawa 0e1837
  if (ref_gr8) ref_gr8->unlock();
Toshihiro Shimizu 890ddd
}
shun-iwasawa 888af2
}  // namespace
Toshihiro Shimizu 890ddd
//------------------------------------------------------------
Shinya Kitaoka 120a6e
void ino_spin_blur::doCompute(TTile &tile, double frame,
Shinya Kitaoka 120a6e
                              const TRenderSettings &ri) {
Shinya Kitaoka 120a6e
  /*------ 接続していなければ処理しない ----------------------*/
Shinya Kitaoka 120a6e
  if (!this->m_input.isConnected()) {
Shinya Kitaoka 120a6e
    tile.getRaster()->clear(); /* 塗りつぶしクリア */
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*------ サポートしていないPixelタイプはエラーを投げる -----*/
shun-iwasawa 481b59
  if (!((TRaster32P)tile.getRaster()) && !((TRaster64P)tile.getRaster()) &&
shun-iwasawa 481b59
      !((TRasterFP)tile.getRaster())) {
Shinya Kitaoka 120a6e
    throw TRopException("unsupported input pixel type");
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*------ パラメータを得る ----------------------------------*/
Shinya Kitaoka 120a6e
  const double scale  = ino::pixel_per_mm() * sqrt(fabs(ri.m_affine.det()));
Shinya Kitaoka 120a6e
  const double blur   = this->m_blur->getValue(frame);
Shinya Kitaoka 120a6e
  const double radius = this->m_radius->getValue(frame) * scale;
Shinya Kitaoka 120a6e
  const int type      = this->m_type->getValue();
Shinya Kitaoka 120a6e
  const bool alpha_rend_sw = this->m_alpha_rendering->getValue();
Shinya Kitaoka 120a6e
  const bool anti_alias_sw = this->m_anti_alias->getValue();
masafumi-inoue 26f824
  const int refer_mode     = this->m_ref_mode->getValue();
shun-iwasawa 0e1837
  const double ellipse_aspect_ratio =
shun-iwasawa 0e1837
      this->m_ellipse_aspect_ratio->getValue(frame);
shun-iwasawa 0e1837
  const double ellipse_angle = this->m_ellipse_angle->getValue(frame);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TPointD center = this->m_center->getValue(frame);
Shinya Kitaoka 120a6e
  TPointD render_center(
Shinya Kitaoka 120a6e
      this->get_render_center(frame, tile.m_pos, ri.m_affine));
Shinya Kitaoka 120a6e
  /*------ 入力画像の範囲を得る ------------------------------*/
Shinya Kitaoka 120a6e
  TRectD bBox =
Shinya Kitaoka 120a6e
      TRectD(tile.m_pos /* Render画像上(Pixel単位)の位置 */
Shinya Kitaoka 120a6e
             ,
Shinya Kitaoka 120a6e
             TDimensionD(/* Render画像上(Pixel単位)のサイズ */
Shinya Kitaoka 120a6e
                         tile.getRaster()->getLx(), tile.getRaster()->getLy()));
Shinya Kitaoka 120a6e
  /*------ 入力画像のエリアの拡大 ----------------------------*/
Shinya Kitaoka 120a6e
  int margin =
Shinya Kitaoka 120a6e
      this->get_render_int_margin(frame, bBox, ri.m_affine, render_center);
Shinya Kitaoka 120a6e
  if (0 < margin) {
Shinya Kitaoka 120a6e
    /* 拡大のしすぎを防ぐテキトーな制限 */
Shinya Kitaoka 120a6e
    if (4096 < margin) {
Shinya Kitaoka 120a6e
      margin = 4096;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    bBox = bBox.enlarge(margin);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /*------ 入力画像生成 --------------------------------------*/
masafumi-inoue 26f824
  TTile enlarge_tile;
Shinya Kitaoka 120a6e
  this->m_input->allocateAndCompute(
masafumi-inoue 26f824
      enlarge_tile, bBox.getP00(),
Shinya Kitaoka 120a6e
      TDimensionI(/* Pixel単位で四捨五入 */
Shinya Kitaoka 120a6e
                  static_cast<int>(bBox.getLx() + 0.5),</int>
Shinya Kitaoka 120a6e
                  static_cast<int>(bBox.getLy() + 0.5)),</int>
Shinya Kitaoka 120a6e
      tile.getRaster(), frame, ri);
Shinya Kitaoka 120a6e
  /*------ 参照画像生成 --------------------------------------*/
masafumi-inoue 26f824
  TTile refer_tile;
masafumi-inoue 26f824
  bool refer_sw = false;
Shinya Kitaoka 120a6e
  if (this->m_refer.isConnected()) {
masafumi-inoue 26f824
    refer_sw = true;
shun-iwasawa 0e1837
    this->m_refer->allocateAndCompute(refer_tile, tile.m_pos,
shun-iwasawa 0e1837
                                      tile.getRaster()->getSize(),
shun-iwasawa 0e1837
                                      tile.getRaster(), frame, ri);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /* ------ 保存すべき画像メモリを塗りつぶしクリア ---------- */
Shinya Kitaoka 120a6e
  tile.getRaster()->clear(); /* 塗りつぶしクリア */
Shinya Kitaoka 120a6e
  /* ------ (app_begin)log記憶 ------------------------------ */
Shinya Kitaoka 120a6e
  const bool log_sw = ino::log_enable_sw();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (log_sw) {
Shinya Kitaoka 120a6e
    std::ostringstream os;
Shinya Kitaoka 120a6e
    os << "params"
Shinya Kitaoka 120a6e
       << "  cx " << center.x << "  cy " << center.y << "  blur " << blur
Shinya Kitaoka 120a6e
       << "  radius " << radius << "  type " << type << "  reference "
masafumi-inoue 26f824
       << refer_mode << "  alpha_rendering " << alpha_rend_sw << "  anti_alias "
Shinya Kitaoka 120a6e
       << anti_alias_sw << "  rend_cx " << render_center.x << "  rend_cy "
Shinya Kitaoka 120a6e
       << render_center.y << "  tx " << tile.m_pos.x << "  ty " << tile.m_pos.y
Shinya Kitaoka 120a6e
       << "  tw " << tile.getRaster()->getLx() << "  th "
Shinya Kitaoka 120a6e
       << tile.getRaster()->getLy() << "  tb "
Shinya Kitaoka 120a6e
       << ino::pixel_bits(tile.getRaster()) << "  margin " << margin << "  bx0 "
Shinya Kitaoka 120a6e
       << bBox.x0 << "  by0 " << bBox.y0 << "  bx1 " << bBox.x1 << "  by1 "
masafumi-inoue 26f824
       << bBox.y1 << "  ix " << enlarge_tile.m_pos.x << "  iy "
masafumi-inoue 26f824
       << enlarge_tile.m_pos.y << "  iw " << enlarge_tile.getRaster()->getLx()
masafumi-inoue 26f824
       << "  ih " << enlarge_tile.getRaster()->getLy();
masafumi-inoue 26f824
    if (refer_sw) {
masafumi-inoue 26f824
      os << "  rx " << refer_tile.m_pos.x << "  ry " << refer_tile.m_pos.y
masafumi-inoue 26f824
         << "  rw " << refer_tile.getRaster()->getLx() << "  rh "
masafumi-inoue 26f824
         << refer_tile.getRaster()->getLy();
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    os << "  frame " << frame << "  ri_aff_det " << ri.m_affine.det()
Shinya Kitaoka 120a6e
       << "  shrink_x " << ri.m_shrinkX << "  shrink_y " << ri.m_shrinkY;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /* ------ fx処理 ------------------------------------------ */
Shinya Kitaoka 120a6e
  try {
Shinya Kitaoka 120a6e
    tile.getRaster()->lock();
masafumi-inoue 26f824
    enlarge_tile.getRaster()->lock();
masafumi-inoue 26f824
    if (refer_tile.getRaster() != nullptr) {
masafumi-inoue 26f824
      refer_tile.getRaster()->lock();
masafumi-inoue 26f824
    }
shun-iwasawa 0e1837
    fx_(enlarge_tile.getRaster(), margin, refer_tile.getRaster(), refer_mode,
shun-iwasawa 0e1837
        tile.getRaster(), render_center, type, blur, radius, alpha_rend_sw,
shun-iwasawa 0e1837
        anti_alias_sw, ellipse_aspect_ratio, ellipse_angle);
masafumi-inoue 26f824
    if (refer_tile.getRaster() != nullptr) {
masafumi-inoue 26f824
      refer_tile.getRaster()->unlock();
masafumi-inoue 26f824
    }
masafumi-inoue 26f824
    enlarge_tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  /* ------ error処理 --------------------------------------- */
Shinya Kitaoka 120a6e
  catch (std::bad_alloc &e) {
masafumi-inoue 26f824
    if (refer_tile.getRaster() != nullptr) {
masafumi-inoue 26f824
      refer_tile.getRaster()->unlock();
masafumi-inoue 26f824
    }
masafumi-inoue 26f824
    enlarge_tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    if (log_sw) {
Shinya Kitaoka 120a6e
      std::string str("std::bad_alloc <");
Shinya Kitaoka 120a6e
      str += e.what();
Shinya Kitaoka 120a6e
      str += '>';
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    throw;
Shinya Kitaoka 120a6e
  } catch (std::exception &e) {
masafumi-inoue 26f824
    if (refer_tile.getRaster() != nullptr) {
masafumi-inoue 26f824
      refer_tile.getRaster()->unlock();
masafumi-inoue 26f824
    }
masafumi-inoue 26f824
    enlarge_tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    if (log_sw) {
Shinya Kitaoka 120a6e
      std::string str("exception <");
Shinya Kitaoka 120a6e
      str += e.what();
Shinya Kitaoka 120a6e
      str += '>';
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    throw;
Shinya Kitaoka 120a6e
  } catch (...) {
masafumi-inoue 26f824
    if (refer_tile.getRaster() != nullptr) {
masafumi-inoue 26f824
      refer_tile.getRaster()->unlock();
masafumi-inoue 26f824
    }
masafumi-inoue 26f824
    enlarge_tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    tile.getRaster()->unlock();
Shinya Kitaoka 120a6e
    if (log_sw) {
Shinya Kitaoka 120a6e
      std::string str("other exception");
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    throw;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}