Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonz/imagepainter.h"
Toshihiro Shimizu 890ddd
#include "toonz/glrasterpainter.h"
Toshihiro Shimizu 890ddd
#include "trastercm.h"
Toshihiro Shimizu 890ddd
#include "tropcm.h"
Toshihiro Shimizu 890ddd
#include "tpalette.h"
Toshihiro Shimizu 890ddd
#include "tgl.h"
Toshihiro Shimizu 890ddd
#include "tvectorimage.h"
Toshihiro Shimizu 890ddd
#include "tenv.h"
Toshihiro Shimizu 890ddd
#include "trop.h"
Toshihiro Shimizu 890ddd
#include "tvectorrenderdata.h"
Toshihiro Shimizu 890ddd
#include "tvectorgl.h"
Toshihiro Shimizu 890ddd
#include "trasterimage.h"
Toshihiro Shimizu 890ddd
#include "timagecache.h"
Toshihiro Shimizu 890ddd
#include "toonz/sceneproperties.h"
Toshihiro Shimizu 890ddd
#include "toonz/stage2.h"
Toshihiro Shimizu 890ddd
#include "toonz/preferences.h"
Toshihiro Shimizu 890ddd
#include "toonz/fill.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
using namespace ImagePainter;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TEnv::IntVar FlipBookWhiteBgToggle("FlipBookWhiteBgToggle", 1);
Toshihiro Shimizu 890ddd
TEnv::IntVar FlipBookBlackBgToggle("FlipBookBlackBgToggle", 0);
Toshihiro Shimizu 890ddd
TEnv::IntVar FlipBookCheckBgToggle("FlipBookCheckBgToggle", 0);
Shinya Kitaoka 120a6e
namespace {
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TRaster32P keepChannels(const TRasterP &rin, TPalette *palette, UCHAR channel) {
Shinya Kitaoka 120a6e
  TRaster32P rout(rin->getSize());
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if ((TRasterCM32P)rin)
Shinya Kitaoka 120a6e
    TRop::convert(rout, (TRasterCM32P)rin, TPaletteP(palette));
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    TRop::copy(rout, rin);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TPixel32 *pix = (TPixel32 *)rout->getRawData();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  assert(channel & TRop::MChan);
Shinya Kitaoka 120a6e
  int i;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  for (i = 0; i < rout->getLx() * rout->getLy(); i++, pix++) {
Shinya Kitaoka 120a6e
    if (!(channel & TRop::RChan)) pix->r = 0;
Shinya Kitaoka 120a6e
    if (!(channel & TRop::GChan)) pix->g = 0;
Shinya Kitaoka 120a6e
    if (!(channel & TRop::BChan)) pix->b = 0;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  return rout;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
inline void quickput(const TRasterP &rout, const TRasterP &rin,
Shinya Kitaoka 120a6e
                     const TPaletteP &palette, const TAffine &aff,
Shinya Kitaoka 120a6e
                     bool useChecks) {
Shinya Kitaoka 120a6e
  if (TRasterCM32P srcCM32 = rin) {
Shinya Kitaoka 120a6e
    if (useChecks) {
Shinya Kitaoka 120a6e
      bool inksOnly       = false;
Shinya Kitaoka 120a6e
      TPixel32 colorscale = TPixel32(0, 0, 0, 255);
Shinya Kitaoka 120a6e
      int tc              = ToonzCheck::instance()->getChecks();
Shinya Kitaoka 120a6e
      int index           = ToonzCheck::instance()->getColorIndex();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      if (tc & ToonzCheck::eGap) {
Shinya Kitaoka 120a6e
        srcCM32 = srcCM32->clone();
Shinya Kitaoka 120a6e
        AreaFiller(srcCM32).rectFill(srcCM32->getBounds(), 1, true, true,
Shinya Kitaoka 120a6e
                                     false);
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      if (tc == 0 || tc == ToonzCheck::eBlackBg)
Shinya Kitaoka 120a6e
        TRop::quickPut(rout, srcCM32, palette, aff, colorscale, inksOnly);
Shinya Kitaoka 120a6e
      else {
Shinya Kitaoka 120a6e
        TRop::CmappedQuickputSettings settings;
Shinya Kitaoka 120a6e
        settings.m_globalColorScale = colorscale;
Shinya Kitaoka 120a6e
        settings.m_inksOnly         = inksOnly;
Shinya Kitaoka 120a6e
        settings.m_transparencyCheck =
Shinya Kitaoka 120a6e
            tc & (ToonzCheck::eTransparency | ToonzCheck::eGap);
Shinya Kitaoka 120a6e
        settings.m_blackBgCheck = tc & ToonzCheck::eBlackBg;
Shinya Kitaoka 120a6e
        settings.m_inkIndex =
Shinya Kitaoka 120a6e
            tc & ToonzCheck::eInk ? index : (tc & ToonzCheck::eInk1 ? 1 : -1);
Shinya Kitaoka 120a6e
        settings.m_paintIndex = tc & ToonzCheck::ePaint ? index : -1;
Shinya Kitaoka 120a6e
        Preferences::instance()->getTranspCheckData(
Shinya Kitaoka 120a6e
            settings.m_transpCheckBg, settings.m_transpCheckInk,
Shinya Kitaoka 120a6e
            settings.m_transpCheckPaint);
Shinya Kitaoka 120a6e
        TRop::quickPut(rout, srcCM32, palette, aff, settings);
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
      srcCM32 = TRasterCM32P();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    } else
Shinya Kitaoka 120a6e
      TRop::quickPut(rout, rin, palette, aff);
Shinya Kitaoka 120a6e
  } else
Shinya Kitaoka 120a6e
    TRop::quickPut(rout, rin, aff);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TPixel32 *getBuffer(const TRect &rect) {
Shinya Kitaoka 120a6e
  static std::vector<char> buffer;</char>
Shinya Kitaoka 120a6e
  int size = rect.getLx() * rect.getLy() * 4;
Shinya Kitaoka 120a6e
  if (size > (int)buffer.size()) buffer.resize(size);
Shinya Kitaoka 120a6e
  return (TPixel32 *)&buffer[0];
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TRaster32P getCheckBoard(const TRect &rect, const TAffine &aff,
Shinya Kitaoka 120a6e
                         TSceneProperties *sprop) {
Shinya Kitaoka 120a6e
  double scale = sqrt(fabs(aff.det()));
Shinya Kitaoka 120a6e
  TPixel32 col1, col2;
Shinya Kitaoka 120a6e
  Preferences::instance()->getChessboardColors(col1, col2);
Shinya Kitaoka 120a6e
  TRaster32P ras(rect.getLx(), rect.getLy(), rect.getLx(), getBuffer(rect));
Shinya Kitaoka 120a6e
  TRop::checkBoard(ras, col1, col2, TDimensionD(50 * scale, 50 * scale),
Shinya Kitaoka 120a6e
                   TPointD(-aff.a13, -aff.a23));
Shinya Kitaoka 120a6e
  return ras;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void drawCompareLines(const TDimension &dim, double compareX, double compareY) {
Shinya Kitaoka 120a6e
  glPushMatrix();
Shinya Kitaoka 120a6e
  glLoadIdentity();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  glColor3d(0.0, 0.0, 0.0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  glBegin(GL_LINES);
Shinya Kitaoka 120a6e
  glVertex2d(dim.lx * compareX - 1, 0);
Shinya Kitaoka 120a6e
  glVertex2d(dim.lx * compareX - 1, dim.ly - 1);
Shinya Kitaoka 120a6e
  glVertex2d(dim.lx * compareX + 1, 0);
Shinya Kitaoka 120a6e
  glVertex2d(dim.lx * compareX + 1, dim.ly - 1);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  glVertex2d(0, dim.ly * compareY - 1);
Shinya Kitaoka 120a6e
  glVertex2d(dim.lx - 1, dim.ly * compareY - 1);
Shinya Kitaoka 120a6e
  glVertex2d(0, dim.ly * compareY + 1);
Shinya Kitaoka 120a6e
  glVertex2d(dim.lx - 1, dim.ly * compareY + 1);
Shinya Kitaoka 120a6e
  glEnd();
Shinya Kitaoka 120a6e
  glColor3d(1.0, 0.0, 0.0);
Shinya Kitaoka 120a6e
  glBegin(GL_LINES);
Shinya Kitaoka 120a6e
  glVertex2d(dim.lx * compareX, 0);
Shinya Kitaoka 120a6e
  glVertex2d(dim.lx * compareX, dim.ly - 1);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  glVertex2d(0, dim.ly * compareY);
Shinya Kitaoka 120a6e
  glVertex2d(dim.lx - 1, dim.ly * compareY);
Shinya Kitaoka 120a6e
  glEnd();
Shinya Kitaoka 120a6e
  glPopMatrix();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class Painter {
Shinya Kitaoka 120a6e
  TDimension m_dim;
Shinya Kitaoka 120a6e
  TDimension m_imageSize;
Shinya Kitaoka 120a6e
  TAffine m_aff;
Shinya Kitaoka 120a6e
  TAffine m_finalAff;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TPalette *m_palette;
Shinya Kitaoka 120a6e
  TRectD m_bbox;
Shinya Kitaoka 120a6e
  TRasterP m_raster;
Shinya Kitaoka 120a6e
  bool m_useTexture;
Shinya Kitaoka 120a6e
  bool m_drawExternalBG;
Shinya Kitaoka 120a6e
  VisualSettings m_vSettings;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  Painter(const TDimension &dim, const TDimension &imageSize,
Shinya Kitaoka 120a6e
          const TAffine &viewAff, TPalette *palette,
Shinya Kitaoka 120a6e
          const VisualSettings &visualSettings);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void flushRasterImages(const TRect &loadbox, double compareX, double compareY,
Shinya Kitaoka 120a6e
                         bool swapCompared);
Shinya Kitaoka 120a6e
  void doFlushRasterImages(const TRasterP &rin, int bg,
Shinya Kitaoka 120a6e
                           const TPointD &offs = TPointD());
Shinya Kitaoka 120a6e
  void onVectorImage(TVectorImage *vi);
Shinya Kitaoka 120a6e
  void onRasterImage(TRasterImage *ri);
Shinya Kitaoka 120a6e
  void onToonzImage(TToonzImage *ti);
Shinya Kitaoka 120a6e
  void drawBlank();
Shinya Kitaoka 120a6e
  TRaster32P buildCheckboard(int bg, const TDimension &dim);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
Painter::Painter(const TDimension &dim, const TDimension &imageSize,
Shinya Kitaoka 120a6e
                 const TAffine &viewAff, TPalette *palette,
Shinya Kitaoka 120a6e
                 const VisualSettings &visualSettings)
Shinya Kitaoka 120a6e
    : m_dim(dim)
Shinya Kitaoka 120a6e
    , m_imageSize(imageSize)
Shinya Kitaoka 120a6e
    , m_aff(viewAff)
Shinya Kitaoka 120a6e
    , m_palette(palette)
Shinya Kitaoka 120a6e
    , m_bbox()
Shinya Kitaoka 120a6e
    , m_raster()
Shinya Kitaoka 120a6e
    , m_vSettings(visualSettings)
Toshihiro Shimizu 890ddd
//, m_channel(visualSettings.m_colorMask)
Toshihiro Shimizu 890ddd
//, m_greytones(visualSettings.m_greytones)
Toshihiro Shimizu 890ddd
//, m_sceneProperties(visualSettings.m_sceneProperties)
Toshihiro Shimizu 890ddd
//, m_useTexture(visualSettings.m_useTexture)
Toshihiro Shimizu 890ddd
//, m_drawExternalBG(visualSettings.m_drawExternalBG)
Shinya Kitaoka 120a6e
{}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void Painter::flushRasterImages(const TRect &loadbox, double compareX,
Shinya Kitaoka 120a6e
                                double compareY, bool swapCompare) {
Shinya Kitaoka 120a6e
  if (!m_raster) return;
Shinya Kitaoka 120a6e
  glDisable(GL_DEPTH_TEST);
Shinya Kitaoka 120a6e
  glDisable(GL_DITHER);
Shinya Kitaoka 120a6e
  glDisable(GL_LOGIC_OP);
Shinya Kitaoka 120a6e
  glDisable(GL_STENCIL_TEST);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef GL_EXT_convolution
Shinya Kitaoka 120a6e
  glDisable(GL_CONVOLUTION_1D_EXT);
Shinya Kitaoka 120a6e
  glDisable(GL_CONVOLUTION_2D_EXT);
Shinya Kitaoka 120a6e
  glDisable(GL_SEPARABLE_2D_EXT);
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef GL_EXT_histogram
Shinya Kitaoka 120a6e
  glDisable(GL_HISTOGRAM_EXT);
Shinya Kitaoka 120a6e
  glDisable(GL_MINMAX_EXT);
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef GL_EXT_texture3D
Shinya Kitaoka 120a6e
  glDisable(GL_TEXTURE_3D_EXT);
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  UCHAR m = m_vSettings.m_colorMask;
Shinya Kitaoka 120a6e
  bool showBg =
Shinya Kitaoka 120a6e
      (m == 0 || (m & TRop::MChan && !m_vSettings.m_greytones &&
Shinya Kitaoka 120a6e
                  (m & TRop::RChan || m & TRop::GChan || m & TRop::BChan)));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int bg = showBg ? m_vSettings.m_bg : 0x40000;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_vSettings.m_drawExternalBG) {
Shinya Kitaoka 120a6e
    if (m_vSettings.m_colorMask != 0) {
Shinya Kitaoka 120a6e
      glClearColor(0, 0, 0, 1.0);
Shinya Kitaoka 120a6e
      glClear(GL_COLOR_BUFFER_BIT);
Shinya Kitaoka 120a6e
    } else {
Shinya Kitaoka 120a6e
      TPixel bgColor = Preferences::instance()->getPreviewBgColor();
Shinya Kitaoka 120a6e
      glClearColor(bgColor.r / 255.0f, bgColor.g / 255.0f, bgColor.b / 255.0f,
Shinya Kitaoka 120a6e
                   1.0);
Shinya Kitaoka 120a6e
      glClear(GL_COLOR_BUFFER_BIT);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  UCHAR chan = m_vSettings.m_colorMask;
Shinya Kitaoka 120a6e
  if (chan != 0 && !(chan & TRop::MChan) &&
Shinya Kitaoka 120a6e
      !(chan != TRop::MChan && chan & TRop::MChan) && !m_vSettings.m_greytones)
Shinya Kitaoka 120a6e
    glColorMask((chan & TRop::RChan) ? GL_TRUE : GL_FALSE,
Shinya Kitaoka 120a6e
                (chan & TRop::GChan) ? GL_TRUE : GL_FALSE,
Shinya Kitaoka 120a6e
                (chan & TRop::BChan) ? GL_TRUE : GL_FALSE, GL_TRUE);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (compareX != DefaultCompareValue || compareY != DefaultCompareValue) {
Shinya Kitaoka 120a6e
    glEnable(GL_SCISSOR_TEST);
Shinya Kitaoka 120a6e
    // draw right/down part of the screen...
Shinya Kitaoka 120a6e
    if (swapCompare)
Shinya Kitaoka 120a6e
      glScissor(0, 0,
Shinya Kitaoka 120a6e
                m_dim.lx * (compareX == DefaultCompareValue ? 1 : compareX),
Shinya Kitaoka 120a6e
                m_dim.ly * (compareY == DefaultCompareValue ? 1 : compareY));
Shinya Kitaoka 120a6e
    else
Shinya Kitaoka 120a6e
      glScissor(m_dim.lx * (compareX == DefaultCompareValue ? 0 : compareX),
Shinya Kitaoka 120a6e
                m_dim.ly * (compareY == DefaultCompareValue ? 0 : compareY),
Shinya Kitaoka 120a6e
                m_dim.lx, m_dim.ly);
Shinya Kitaoka 120a6e
    doFlushRasterImages(m_raster, bg, convert(loadbox.getP00()));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    TImageP refimg =
Shinya Kitaoka 120a6e
        TImageCache::instance()->get(QString("TnzCompareImg"), false);
Shinya Kitaoka 120a6e
    if ((TToonzImageP)refimg || (TRasterImageP)refimg) {
Shinya Kitaoka 120a6e
      // draw left/up part of the screen...
Shinya Kitaoka 120a6e
      TRasterP raux, rref;
Shinya Kitaoka 120a6e
      if ((TToonzImageP)refimg)
Shinya Kitaoka 120a6e
        rref = ((TToonzImageP)refimg)->getCMapped();
Shinya Kitaoka 120a6e
      else
Shinya Kitaoka 120a6e
        rref = ((TRasterImageP)refimg)->getRaster();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      TRect rect = loadbox;
Shinya Kitaoka 120a6e
      raux       = loadbox != TRect() ? rref->extract(rect) : rref;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      TPointD cmpOffs = TPointD(
Shinya Kitaoka 120a6e
          0.5 * (((m_imageSize.lx == 0) ? m_raster->getLx() : m_imageSize.lx) -
Shinya Kitaoka 120a6e
                 rref->getLx()),
Shinya Kitaoka 120a6e
          0.5 * (((m_imageSize.ly == 0) ? m_raster->getLy() : m_imageSize.ly) -
Shinya Kitaoka 120a6e
                 rref->getLy()));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      if (swapCompare)
Shinya Kitaoka 120a6e
        glScissor(m_dim.lx * (compareX == DefaultCompareValue ? 0 : compareX),
Shinya Kitaoka 120a6e
                  m_dim.ly * (compareY == DefaultCompareValue ? 0 : compareY),
Shinya Kitaoka 120a6e
                  m_dim.lx, m_dim.ly);
Shinya Kitaoka 120a6e
      else
Shinya Kitaoka 120a6e
        glScissor(0, 0,
Shinya Kitaoka 120a6e
                  m_dim.lx * (compareX == DefaultCompareValue ? 1 : compareX),
Shinya Kitaoka 120a6e
                  m_dim.ly * (compareY == DefaultCompareValue ? 1 : compareY));
Shinya Kitaoka 120a6e
      doFlushRasterImages(raux, bg, cmpOffs + convert(loadbox.getP00()));
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    glDisable(GL_SCISSOR_TEST);
Shinya Kitaoka 120a6e
  } else
Shinya Kitaoka 120a6e
    doFlushRasterImages(m_raster, bg, convert(loadbox.getP00()));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_raster  = TRasterP();
Shinya Kitaoka 120a6e
  m_palette = 0;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TRaster32P Painter::buildCheckboard(int bg, const TDimension &dim) {
Shinya Kitaoka 120a6e
  TRaster32P checkBoard = TRaster32P(100, 100);
Shinya Kitaoka 120a6e
  if (bg == 0x100000) {
Shinya Kitaoka 120a6e
    TPixel col1, col2;
Shinya Kitaoka 120a6e
    Preferences::instance()->getChessboardColors(col1, col2);
Shinya Kitaoka 120a6e
    TPointD p = TPointD(0, 0);
Shinya Kitaoka 120a6e
    if (m_vSettings.m_useTexture)
Shinya Kitaoka 120a6e
      p = TPointD(m_bbox.x0 > 0 ? 0 : -m_bbox.x0,
Shinya Kitaoka 120a6e
                  m_bbox.y0 > 0 ? 0 : -m_bbox.y0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    assert(checkBoard.getPointer());
Shinya Kitaoka 120a6e
    TRop::checkBoard(checkBoard, col1, col2, TDimensionD(50, 50), p);
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    TPixel pix = bg == 0x40000 ? TPixel::Black : TPixel::White;
Shinya Kitaoka 120a6e
    assert(checkBoard.getPointer());
Shinya Kitaoka 120a6e
    checkBoard->fill(pix);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // TRaster32P textureBackGround;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // if(m_vSettings.m_useTexture)
Shinya Kitaoka 120a6e
  //  textureBackGround = TRaster32P(dim.lx,dim.ly);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  assert(checkBoard.getPointer());
Shinya Kitaoka 120a6e
  int lx = (m_imageSize.lx == 0 ? dim.lx : m_imageSize.lx);
Shinya Kitaoka 120a6e
  int ly = (m_imageSize.ly == 0 ? dim.ly : m_imageSize.ly);
Shinya Kitaoka 120a6e
  int x, y;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TRaster32P checkBoardRas(lx, ly);
Shinya Kitaoka 120a6e
  for (y = 0; y < ly; y += 100) {
Shinya Kitaoka 120a6e
    for (x = 0; x < lx; x += 100) {
Shinya Kitaoka 120a6e
      // TAffine checkTrans = TTranslation(x,y);
Shinya Kitaoka 120a6e
      // if(m_vSettings.m_useTexture)
Shinya Kitaoka 120a6e
      //  quickput(textureBackGround, checkBoard, m_palette, checkTrans);
Shinya Kitaoka 120a6e
      // else
Shinya Kitaoka 120a6e
      quickput(checkBoardRas, checkBoard, m_palette, TTranslation(x, y), false);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  return checkBoardRas;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void Painter::doFlushRasterImages(const TRasterP &rin, int bg,
Shinya Kitaoka 120a6e
                                  const TPointD &offs) {
Shinya Kitaoka 120a6e
  if (!rin) return;
Shinya Kitaoka 120a6e
  TRectD viewRect(0.0, 0.0, m_dim.lx - 1, m_dim.ly - 1);
Shinya Kitaoka 120a6e
  TRectD bbox;
Shinya Kitaoka 120a6e
  if (m_vSettings.m_useTexture)
Shinya Kitaoka 120a6e
    bbox = m_bbox;
Shinya Kitaoka 120a6e
  else {
Shinya Kitaoka 120a6e
    double delta = sqrt(fabs(m_finalAff.det()));
Shinya Kitaoka 120a6e
    bbox         = m_bbox.enlarge(delta) * viewRect;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  UCHAR chan = m_vSettings.m_colorMask;
Shinya Kitaoka 120a6e
  TRect rect(tfloor(bbox.x0), tfloor(bbox.y0), tceil(bbox.x1), tceil(bbox.y1));
Shinya Kitaoka 120a6e
  if (rect.isEmpty()) return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TRaster32P ras;
Shinya Kitaoka 120a6e
  TRasterP _rin = rin;
Shinya Kitaoka 120a6e
  TAffine aff;
Shinya Kitaoka 120a6e
  if (m_vSettings.m_useTexture) {
Shinya Kitaoka 120a6e
    ras = _rin;
Shinya Kitaoka 120a6e
    aff = m_aff;
Shinya Kitaoka 120a6e
    // ras->clear();
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    int lx = rect.getLx(), ly = rect.getLy();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    // Following lines are used to solve a problem that occurs with some
Shinya Kitaoka 120a6e
    // graphics cards!
MCCCS a0ce32
    // It seems that the glReadPixels() function is very slow if the lx length
Shinya Kitaoka 120a6e
    // isn't a multiple of 8!
Shinya Kitaoka 120a6e
    TDimension backgroundDim(lx, ly);
Shinya Kitaoka 120a6e
    backgroundDim.lx = (lx & 0x7) == 0 ? lx : lx + 8 - (lx & 0x7);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    static std::vector<char> buffer;</char>
Shinya Kitaoka 120a6e
    int size = backgroundDim.lx * backgroundDim.ly * 4;
Shinya Kitaoka 120a6e
    if (size > (int)buffer.size()) buffer.resize(size);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    TRaster32P backgroundRas(backgroundDim.lx, backgroundDim.ly,
Shinya Kitaoka 120a6e
                             backgroundDim.lx, (TPixel32 *)&buffer[0]);
Shinya Kitaoka 120a6e
    glReadPixels(rect.x0, rect.y0, backgroundDim.lx, backgroundDim.ly, TGL_FMT,
Shinya Kitaoka 120a6e
                 TGL_TYPE, backgroundRas->getRawData());
Shinya Kitaoka 120a6e
    TRect r = rect - rect.getP00();
Shinya Kitaoka 120a6e
    ras     = backgroundRas->extract(r);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    aff = TTranslation(-rect.x0, -rect.y0) * m_finalAff;
Shinya Kitaoka 120a6e
    aff *= TTranslation(TPointD(0.5, 0.5));  // very quick and very dirty fix:
Shinya Kitaoka 120a6e
                                             // in camerastand the images seems
Shinya Kitaoka 120a6e
                                             // shifted of an half pixel...it's
Shinya Kitaoka 120a6e
                                             // a quickput approximation?
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  ras->lock();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool showChannelsOnMatte =
Shinya Kitaoka 120a6e
      (chan != TRop::MChan && chan != 0 && !m_vSettings.m_greytones);
Shinya Kitaoka 120a6e
  if ((!showChannelsOnMatte && !m_vSettings.m_useTexture && chan != 0) ||
Shinya Kitaoka 120a6e
      (!showChannelsOnMatte && m_vSettings.m_useTexture &&
Shinya Kitaoka 120a6e
       (chan == TRop::MChan || m_vSettings.m_greytones))) {
Shinya Kitaoka 120a6e
    TRasterP app = _rin->create(_rin->getLx(), _rin->getLy());
Shinya Kitaoka 120a6e
    try {
Shinya Kitaoka 120a6e
      TRop::setChannel(_rin, app, chan, m_vSettings.m_greytones);
Shinya Kitaoka 120a6e
      if (!m_vSettings.m_useTexture)
Shinya Kitaoka 120a6e
        _rin = app;
Shinya Kitaoka 120a6e
      else
Shinya Kitaoka 120a6e
        ras = app;
Shinya Kitaoka 120a6e
    } catch (...) {
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_vSettings.m_useTexture) {
Shinya Kitaoka 120a6e
    TRaster32P checkBoardRas = buildCheckboard(bg, _rin->getSize());
Shinya Kitaoka 120a6e
    GLRasterPainter::drawRaster(aff, checkBoardRas->getRawData(),
Shinya Kitaoka 120a6e
                                checkBoardRas->getWrap(), 4,
Shinya Kitaoka 120a6e
                                checkBoardRas->getSize(), true);
Shinya Kitaoka 120a6e
    if (showChannelsOnMatte) ras = keepChannels(_rin, m_palette, chan);
Shinya Kitaoka 120a6e
    GLRasterPainter::drawRaster(aff, ras->getRawData(), ras->getWrap(), 4,
Shinya Kitaoka 120a6e
                                ras->getSize(), true);
Shinya Kitaoka 120a6e
    ras->unlock();
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    if (bg == 0x100000)
Shinya Kitaoka 120a6e
      quickput(ras, buildCheckboard(bg, _rin->getSize()), m_palette, aff,
Shinya Kitaoka 120a6e
               false);
Shinya Kitaoka 120a6e
    else {
Shinya Kitaoka 120a6e
      int lx = (m_imageSize.lx == 0 ? _rin->getLx() : m_imageSize.lx);
Shinya Kitaoka 120a6e
      int ly = (m_imageSize.ly == 0 ? _rin->getLy() : m_imageSize.ly);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      TRect rect      = convert(aff * TRectD(0, 0, lx - 1, ly - 1));
Shinya Kitaoka 120a6e
      TRaster32P raux = ras->extract(rect);
Shinya Kitaoka 120a6e
      raux->fill(bg == 0x40000 ? TPixel::Black : TPixel::White);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (showChannelsOnMatte)
Shinya Kitaoka 120a6e
      quickput(ras, keepChannels(_rin, m_palette, chan), m_palette,
Shinya Kitaoka 120a6e
               m_vSettings.m_useTexture ? TAffine() : aff * TTranslation(offs),
Shinya Kitaoka 120a6e
               m_vSettings.m_useChecks);
Shinya Kitaoka 120a6e
    else
Shinya Kitaoka 120a6e
      quickput(ras, _rin, m_palette, aff * TTranslation(offs),
Shinya Kitaoka 120a6e
               m_vSettings.m_useChecks);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    glDisable(GL_BLEND);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    glPushMatrix();
Shinya Kitaoka 120a6e
    glLoadIdentity();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    glRasterPos2d(rect.x0, rect.y0);
Shinya Kitaoka 120a6e
    glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    glDrawPixels(ras->getWrap(), ras->getLy(), TGL_FMT, TGL_TYPE,
Shinya Kitaoka 120a6e
                 ras->getRawData());
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    CHECK_ERRORS_BY_GL
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    ras->unlock();
Shinya Kitaoka 120a6e
    glPopMatrix();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void Painter::onVectorImage(TVectorImage *vi) {
Shinya Kitaoka 120a6e
  TRect clipRect = m_dim;
Shinya Kitaoka 120a6e
  clipRect -= TPoint(m_dim.lx * 0.5, m_dim.ly * 0.5);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool thereIsColorFilter =
Shinya Kitaoka 120a6e
      (m_vSettings.m_colorMask != 0 && m_vSettings.m_colorMask != TRop::MChan);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_vSettings.m_bg == 0x100000 && !thereIsColorFilter) {
Shinya Kitaoka 120a6e
    TRaster32P check =
Shinya Kitaoka 120a6e
        getCheckBoard(clipRect, m_aff, m_vSettings.m_sceneProperties);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    glDisable(GL_BLEND);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    glPushMatrix();
Shinya Kitaoka 120a6e
    glLoadIdentity();
Shinya Kitaoka 120a6e
    glRasterPos2d(0, 0);
Shinya Kitaoka 120a6e
    glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    glDrawPixels(check->getLx(), check->getLy(), TGL_FMT, TGL_TYPE,
Shinya Kitaoka 120a6e
                 check->getRawData());
Shinya Kitaoka 120a6e
    glPopMatrix();
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    if (m_vSettings.m_bg == 0x40000 || thereIsColorFilter)
Shinya Kitaoka 120a6e
      glClearColor(0.0, 0.0, 0.0, 1.0);
Shinya Kitaoka 120a6e
    else if (m_vSettings.m_bg == 0x80000)
Shinya Kitaoka 120a6e
      glClearColor(1.0, 1.0, 1.0, 1.0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    glClear(GL_COLOR_BUFFER_BIT);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TVectorRenderData rd(m_aff, clipRect, vi->getPalette(), 0,
Shinya Kitaoka 120a6e
                       true  // alfa enabled
Shinya Kitaoka 120a6e
                       );
Shinya Kitaoka 120a6e
  if (m_vSettings.m_useChecks) {
Shinya Kitaoka 120a6e
    ToonzCheck *tc         = ToonzCheck::instance();
Shinya Kitaoka 120a6e
    int checks             = tc->getChecks();  // &ToonzCheck::eBlackBg
Shinya Kitaoka 120a6e
    rd.m_inkCheckEnabled   = checks & ToonzCheck::eInk;
Shinya Kitaoka 120a6e
    rd.m_paintCheckEnabled = checks & ToonzCheck::ePaint;
Shinya Kitaoka 120a6e
    rd.m_colorCheckIndex   = tc->getColorIndex();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  tglDraw(rd, vi);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void Painter::onRasterImage(TRasterImage *ri) {
Shinya Kitaoka 120a6e
  TDimension imageSize =
Shinya Kitaoka 120a6e
      (m_imageSize.lx == 0 ? ri->getRaster()->getSize() : m_imageSize);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_finalAff =
Shinya Kitaoka 120a6e
      m_vSettings.m_useTexture
Shinya Kitaoka 120a6e
          ? m_aff
Shinya Kitaoka 120a6e
          : TTranslation(m_dim.lx * 0.5, m_dim.ly * 0.5) * m_aff *
Shinya Kitaoka 120a6e
                TTranslation(-TPointD(0.5 * imageSize.lx, 0.5 * imageSize.ly));
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TRectD bbox = TRectD(0, 0, imageSize.lx - 1, imageSize.ly - 1);
Shinya Kitaoka 120a6e
  m_bbox      = m_vSettings.m_useTexture ? bbox : m_finalAff * bbox;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (!m_bbox.overlaps(TRectD(0, 0, m_dim.lx - 1, m_dim.ly - 1))) return;
Shinya Kitaoka 120a6e
  m_raster = ri->getRaster();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void Painter::onToonzImage(TToonzImage *ti) {
Shinya Kitaoka 120a6e
  TDimension imageSize =
Shinya Kitaoka 120a6e
      (m_imageSize.lx == 0 ? ti->getRaster()->getSize() : m_imageSize);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_finalAff =
Shinya Kitaoka 120a6e
      m_vSettings.m_useTexture
Shinya Kitaoka 120a6e
          ? m_aff
Shinya Kitaoka 120a6e
          : TTranslation(m_dim.lx * 0.5, m_dim.ly * 0.5) * m_aff *
Shinya Kitaoka 120a6e
                TTranslation(-TPointD(0.5 * imageSize.lx, 0.5 * imageSize.ly));
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TRectD bbox = TRectD(0, 0, imageSize.lx - 1, imageSize.ly - 1);
Shinya Kitaoka 120a6e
  m_bbox      = m_vSettings.m_useTexture ? bbox : m_finalAff * bbox;
Shinya Kitaoka 120a6e
  if (!m_bbox.overlaps(TRectD(0, 0, m_dim.lx - 1, m_dim.ly - 1))) return;
Shinya Kitaoka 120a6e
  m_raster = ti->getRaster();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void Painter::drawBlank() {
Shinya Kitaoka 120a6e
  TPixel bgColor = Preferences::instance()->getPreviewBgColor();
Shinya Kitaoka 120a6e
  glClearColor(bgColor.r / 255.0f, bgColor.g / 255.0f, bgColor.b / 255.0f, 1.0);
Shinya Kitaoka 120a6e
  glClear(GL_COLOR_BUFFER_BIT);
Shinya Kitaoka 120a6e
  glPushMatrix();
Shinya Kitaoka 120a6e
  glLoadIdentity();
Shinya Kitaoka 120a6e
  tglColor(m_vSettings.m_blankColor);
Shinya Kitaoka 120a6e
  tglFillRect(m_bbox);
Shinya Kitaoka 120a6e
  glPopMatrix();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
}  // namespace
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
ImagePainter::VisualSettings::VisualSettings()
Shinya Kitaoka 120a6e
    : m_colorMask(0)
Shinya Kitaoka 120a6e
    , m_greytones(false)
Shinya Kitaoka 120a6e
    , m_doCompare(false)
Shinya Kitaoka 120a6e
    , m_defineLoadbox(false)
Shinya Kitaoka 120a6e
    , m_useLoadbox(false)
Shinya Kitaoka 120a6e
    , m_blankColor(TPixel::Transparent)
Shinya Kitaoka 120a6e
    , m_useTexture(false)
Shinya Kitaoka 120a6e
    , m_drawExternalBG(false)
Shinya Kitaoka 120a6e
    , m_showBBox(false)
Shinya Kitaoka 120a6e
    , m_sceneProperties(0)
Shinya Kitaoka 120a6e
    , m_recomputeIfNeeded(true)
Shinya Kitaoka 120a6e
    , m_drawBlankFrame(false)
Shinya Kitaoka 120a6e
    , m_useChecks(false) {
Shinya Kitaoka 120a6e
  if (FlipBookBlackBgToggle) m_bg = 0x40000;
Shinya Kitaoka 120a6e
  if (FlipBookWhiteBgToggle) m_bg = 0x80000;
Shinya Kitaoka 120a6e
  if (FlipBookCheckBgToggle) m_bg = 0x100000;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool ImagePainter::VisualSettings::needRepaint(const VisualSettings &vs) const {
Shinya Kitaoka 120a6e
  return !(m_colorMask == vs.m_colorMask && m_greytones == vs.m_greytones &&
Shinya Kitaoka 120a6e
           m_bg == vs.m_bg && m_doCompare == vs.m_doCompare &&
Shinya Kitaoka 120a6e
           m_defineLoadbox == vs.m_defineLoadbox &&
Shinya Kitaoka 120a6e
           m_useLoadbox == vs.m_useLoadbox && m_useTexture == vs.m_useTexture &&
Shinya Kitaoka 120a6e
           m_drawExternalBG == vs.m_drawExternalBG);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
ImagePainter::CompareSettings::CompareSettings()
Shinya Kitaoka 120a6e
    : m_compareX(0.5)
Shinya Kitaoka 120a6e
    , m_compareY(DefaultCompareValue)
Shinya Kitaoka 120a6e
    , m_dragCompareX(false)
Shinya Kitaoka 120a6e
    , m_dragCompareY(false)
Shinya Kitaoka 120a6e
    , m_swapCompared(false) {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void ImagePainter::paintImage(const TImageP &image, const TDimension &imageSize,
Shinya Kitaoka 120a6e
                              const TDimension &viewerSize, const TAffine &aff,
Shinya Kitaoka 120a6e
                              const VisualSettings &visualSettings,
Shinya Kitaoka 120a6e
                              const CompareSettings &compareSettings,
Shinya Kitaoka 120a6e
                              const TRect &loadbox) {
Shinya Kitaoka 120a6e
  glDisable(GL_DEPTH_TEST);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (visualSettings.m_drawExternalBG) {
Shinya Kitaoka 120a6e
    glClearColor(0.0, 0.0, 0.0, 0.0);
Shinya Kitaoka 120a6e
    glClear(GL_COLOR_BUFFER_BIT);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  GLenum error = glGetError();
Shinya Kitaoka 120a6e
  // assert(error==GL_NO_ERROR);
Shinya Kitaoka 120a6e
  if (error != GL_NO_ERROR) {
Shinya Kitaoka 120a6e
    printf("ImagePainter::paintImage() gl_error:%d\n", error);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (!image) return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TRasterImageP rimg = (TRasterImageP)image;
Shinya Kitaoka 120a6e
  TVectorImageP vimg = (TVectorImageP)image;
Shinya Kitaoka 120a6e
  TToonzImageP timg  = (TToonzImageP)image;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TRect clipRect(viewerSize);
Shinya Kitaoka 120a6e
  clipRect -= TPoint(viewerSize.lx * 0.5, viewerSize.ly * 0.5);
Shinya Kitaoka 120a6e
  Painter painter(viewerSize, imageSize, aff, image->getPalette(),
Shinya Kitaoka 120a6e
                  visualSettings);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (rimg)
Shinya Kitaoka 120a6e
    painter.onRasterImage(rimg.getPointer());
Shinya Kitaoka 120a6e
  else if (vimg)
Shinya Kitaoka 120a6e
    painter.onVectorImage(vimg.getPointer());
Shinya Kitaoka 120a6e
  else if (timg)
Shinya Kitaoka 120a6e
    painter.onToonzImage(timg.getPointer());
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (visualSettings.m_blankColor != TPixel::Transparent) {
Shinya Kitaoka 120a6e
    painter.drawBlank();
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // if I have a color filter applied using a glmask, , drawing of images must
Shinya Kitaoka 120a6e
  // be done on black bg!
Shinya Kitaoka 120a6e
  if (!vimg)
Shinya Kitaoka 120a6e
    painter.flushRasterImages(
Shinya Kitaoka 120a6e
        loadbox, visualSettings.m_doCompare ? compareSettings.m_compareX
Shinya Kitaoka 120a6e
                                            : DefaultCompareValue,
Shinya Kitaoka 120a6e
        visualSettings.m_doCompare ? compareSettings.m_compareY
Shinya Kitaoka 120a6e
                                   : DefaultCompareValue,
Shinya Kitaoka 120a6e
        compareSettings.m_swapCompared);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (visualSettings.m_doCompare)
Shinya Kitaoka 120a6e
    drawCompareLines(viewerSize, compareSettings.m_compareX,
Shinya Kitaoka 120a6e
                     compareSettings.m_compareY);
Toshihiro Shimizu 890ddd
}