Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef IMAGE_BUILDERS_H
Toshihiro Shimizu 890ddd
#define IMAGE_BUILDERS_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tfilepath.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonz/imagemanager.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//======================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//  Forward declarations
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TImageInfo;
Toshihiro Shimizu 890ddd
class TXshSimpleLevel;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//======================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//***************************************************************************************
Toshihiro Shimizu 890ddd
//    ImageLoader  class declaration
Toshihiro Shimizu 890ddd
//***************************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  ImageLoader is the specialized ImageBuilder class used to automatically load
Toshihiro Shimizu 890ddd
  images from a level file on hard disk.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  Refer to ImageLoader::BuildExtData for a description of the allowed options
Shinya Kitaoka 120a6e
  for
Toshihiro Shimizu 890ddd
  image loading.
Toshihiro Shimizu 890ddd
*/
Shinya Kitaoka d1f6c4
class ImageLoader final : public ImageBuilder {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  struct BuildExtData {
Shinya Kitaoka 120a6e
    const TXshSimpleLevel *m_sl;  //!< TXshSimpleLevel instance associated to an
Shinya Kitaoka 38fd86
                                  //! image loading request
Shinya Kitaoka 120a6e
    TFrameId m_fid;  //!< m_sl's fid at which the image will be loaded
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    int m_subs;  //!< The subsampling factor for image loading (0 meaning either
Shinya Kitaoka 120a6e
    //!< 'the currently stored one' if an image is already cached, or
Shinya Kitaoka 120a6e
    //!< m_sl's subsampling property otherwise)
Shinya Kitaoka 120a6e
    bool m_icon;  //!< Whether the icon (if any) should be loaded instead
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  public:
Shinya Kitaoka 120a6e
    BuildExtData(const TXshSimpleLevel *sl, const TFrameId &fid, int subs = 0,
Shinya Kitaoka 120a6e
                 bool icon = false)
Shinya Kitaoka 120a6e
        : m_sl(sl), m_fid(fid), m_subs(subs), m_icon(icon) {}
Shinya Kitaoka 120a6e
  };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ImageLoader(const TFilePath &path, const TFrameId &fid);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  bool isImageCompatible(int imFlags, void *extData) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*--
Shinya Kitaoka 120a6e
   * ImageBuilder仮想関数の実装。アイコン、画像をLoad時に全てキャッシュに格納する
Shinya Kitaoka 120a6e
   * --*/
Shinya Kitaoka 120a6e
  void buildAllIconsAndPutInCache(TXshSimpleLevel *level,
Shinya Kitaoka 120a6e
                                  std::vector<tframeid> fids,</tframeid>
Shinya Kitaoka 120a6e
                                  std::vector<std::string> iconIds,</std::string>
Shinya Kitaoka 473e70
                                  bool cacheImagesAsWell) override;
Toshihiro Shimizu 890ddd
manongjohn 88ffb4
  /* Exposed to allow Fid to be updated due to a renumber operation
shun-iwasawa ce90c2
   */
artisteacher fd1c1e
  void setFid(const TFrameId &fid) override;
manongjohn 88ffb4
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 473e70
  bool getInfo(TImageInfo &info, int imFlags, void *extData) override;
Shinya Kitaoka 473e70
  TImageP build(int imFlags, void *extData) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void invalidate() override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  inline int buildSubsampling(int imFlags, BuildExtData *data);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  TFilePath m_path;  //!< Level path to load images from
Shinya Kitaoka 120a6e
  TFrameId m_fid;    //!< Frame of the level to load
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool m_64bitCompatible;  //!< Whether current image is 64-bit compatible
Shinya Kitaoka 120a6e
  int m_subsampling;       //!< Current image subsampling
Shinya Kitaoka 120a6e
  //!< NOTE: Should this be replaced by requests to the TImageCache?
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class ImageRasterizer final : public ImageBuilder {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ImageRasterizer() {}
Shinya Kitaoka 120a6e
  ~ImageRasterizer() {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  bool isImageCompatible(int imFlags, void *extData) override { return true; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 473e70
  bool getInfo(TImageInfo &info, int imFlags, void *extData) override;
Shinya Kitaoka 473e70
  TImageP build(int imFlags, void *extData) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class ImageFiller final : public ImageBuilder {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ImageFiller() {}
Shinya Kitaoka 120a6e
  ~ImageFiller() {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  bool isImageCompatible(int imFlags, void *extData) override { return true; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 473e70
  bool getInfo(TImageInfo &info, int imFlags, void *extData) override;
Shinya Kitaoka 473e70
  TImageP build(int imFlags, void *extData) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // IMAGE_BUILDERS_H