Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef FXHISTOGRAMRENDER_H
Toshihiro Shimizu 890ddd
#define FXHISTOGRAMRENDER_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
#include <qwidget></qwidget>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tfx.h"
Toshihiro Shimizu 890ddd
#include "trenderer.h"
Toshihiro Shimizu 890ddd
#include "tthreadmessage.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TOONZQT_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// forward declaration
Toshihiro Shimizu 890ddd
class Histograms;
Toshihiro Shimizu 890ddd
class TFxHandle;
Toshihiro Shimizu 890ddd
class TFrameHandle;
Toshihiro Shimizu 890ddd
class TXsheetHandle;
Toshihiro Shimizu 890ddd
class TSceneHandle;
Toshihiro Shimizu 890ddd
class TXshLevelHandle;
Toshihiro Shimizu 890ddd
class ToonzScene;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
// FxHistogramRenderPort
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Shinya Kitaoka 120a6e
//! Implements the TRenderPort virtual class
Shinya Kitaoka 120a6e
//! This class receives and handles signals from the TThread::Runnable class
Shinya Kitaoka 120a6e
//! that make the render of frame.
Shinya Kitaoka d1f6c4
class FxHistogramRenderPort final : public QObject, public TRenderPort {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  FxHistogramRenderPort();
Shinya Kitaoka 120a6e
  ~FxHistogramRenderPort();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void onRenderRasterCompleted(const RenderData &renderData) override;
Shinya Kitaoka 38fd86
  void onRenderFailure(const RenderData &renderData, TException &e) override{};
Shinya Kitaoka 120a6e
  void onRenderFinished(){};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
signals:
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void renderCompleted(const TRasterP &, UINT);
Shinya Kitaoka 120a6e
  void renderFailure(double);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
// FxHistogramRender
Toshihiro Shimizu 890ddd
//---------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DVAPI FxHistogramRender final : public QObject {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  //! Stores some information about the frame to render needed to the
Shinya Kitaoka 120a6e
  //! PreviewFxManager class
Shinya Kitaoka 120a6e
  class FrameInfo {
Shinya Kitaoka 120a6e
  public:
Shinya Kitaoka 120a6e
    FrameInfo() : m_frame(-1), m_renderId((UINT)-1) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    TFxP m_fx;
Shinya Kitaoka 120a6e
    std::string m_fxAlias;
Shinya Kitaoka 120a6e
    int m_frame;
Shinya Kitaoka 120a6e
    //! renderId given from renderer
Shinya Kitaoka 120a6e
    UINT m_renderId;
Shinya Kitaoka 120a6e
  };
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  FxHistogramRenderPort *m_renderPort;
Shinya Kitaoka 120a6e
  TRenderer m_renderer;
Shinya Kitaoka 120a6e
  FrameInfo m_lastFrameInfo;
Shinya Kitaoka 120a6e
  TThread::Mutex m_mutex;
Shinya Kitaoka 120a6e
  QList<uint> m_abortedRendering;</uint>
Shinya Kitaoka 120a6e
  ToonzScene *m_scene;
Shinya Kitaoka 120a6e
  Histograms *m_histograms;
Shinya Kitaoka 120a6e
  bool m_isCameraViewMode;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  FxHistogramRender();
Shinya Kitaoka 120a6e
  ~FxHistogramRender();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  static FxHistogramRender *instance();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setScene(ToonzScene *scene);
Shinya Kitaoka 120a6e
  void setHistograms(Histograms *histograms);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setIsCameraViewMode(bool isCameraViewMode) {
Shinya Kitaoka 120a6e
    m_isCameraViewMode = isCameraViewMode;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  bool isCameraViewMode() { return m_isCameraViewMode; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void computeHistogram(TFxP fx, int frame);
Shinya Kitaoka 120a6e
  void invalidateFrame(int frame);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  void remakeRender();
Shinya Kitaoka 120a6e
  void updateRenderer(int frame);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected slots:
Shinya Kitaoka 120a6e
  void onRenderCompleted(const TRasterP &, UINT);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // FXHISTOGRAMRENDER_H