1 #pragma once 2 3 #ifndef IMAGE_BUILDERS_H 4 #define IMAGE_BUILDERS_H 5 6 #include "tfilepath.h" 7 8 #include "toonz/imagemanager.h" 9 10 //====================================================== 11 12 // Forward declarations 13 14 class TImageInfo; 15 class TXshSimpleLevel; 16 17 //====================================================== 18 19 //*************************************************************************************** 20 // ImageLoader class declaration 21 //*************************************************************************************** 22 23 /*! 24 ImageLoader is the specialized ImageBuilder class used to automatically load 25 images from a level file on hard disk. 26 27 Refer to ImageLoader::BuildExtData for a description of the allowed options 28 for 29 image loading. 30 */ 31 class ImageLoader final : public ImageBuilder { 32 public: 33 struct BuildExtData { 34 const TXshSimpleLevel *m_sl; //!< TXshSimpleLevel instance associated to an 35 //! image loading request 36 TFrameId m_fid; //!< m_sl's fid at which the image will be loaded 37 38 int m_subs; //!< The subsampling factor for image loading (0 meaning either 39 //!< 'the currently stored one' if an image is already cached, or 40 //!< m_sl's subsampling property otherwise) 41 bool m_icon; //!< Whether the icon (if any) should be loaded instead 42 43 public: 44 BuildExtData(const TXshSimpleLevel *sl, const TFrameId &fid, int subs = 0, 45 bool icon = false) m_slBuildExtData46 : m_sl(sl), m_fid(fid), m_subs(subs), m_icon(icon) {} 47 }; 48 49 public: 50 ImageLoader(const TFilePath &path, const TFrameId &fid); 51 52 bool isImageCompatible(int imFlags, void *extData) override; 53 54 /*-- 55 * ImageBuilder仮想関数の実装。アイコン、画像をLoad時に全てキャッシュに格納する 56 * --*/ 57 void buildAllIconsAndPutInCache(TXshSimpleLevel *level, 58 std::vector<TFrameId> fids, 59 std::vector<std::string> iconIds, 60 bool cacheImagesAsWell) override; 61 62 /* Exposed to allow Fid to be updated due to a renumber operation 63 */ 64 void setFid(const TFrameId &fid) override; 65 66 protected: 67 bool getInfo(TImageInfo &info, int imFlags, void *extData) override; 68 TImageP build(int imFlags, void *extData) override; 69 70 void invalidate() override; 71 72 inline int buildSubsampling(int imFlags, BuildExtData *data); 73 74 private: 75 TFilePath m_path; //!< Level path to load images from 76 TFrameId m_fid; //!< Frame of the level to load 77 78 bool m_64bitCompatible; //!< Whether current image is 64-bit compatible 79 int m_subsampling; //!< Current image subsampling 80 //!< NOTE: Should this be replaced by requests to the TImageCache? 81 }; 82 83 //----------------------------------------------------------------------------- 84 85 class ImageRasterizer final : public ImageBuilder { 86 public: ImageRasterizer()87 ImageRasterizer() {} ~ImageRasterizer()88 ~ImageRasterizer() {} 89 isImageCompatible(int imFlags,void * extData)90 bool isImageCompatible(int imFlags, void *extData) override { return true; } 91 92 protected: 93 bool getInfo(TImageInfo &info, int imFlags, void *extData) override; 94 TImageP build(int imFlags, void *extData) override; 95 }; 96 97 //----------------------------------------------------------------------------- 98 99 class ImageFiller final : public ImageBuilder { 100 public: ImageFiller()101 ImageFiller() {} ~ImageFiller()102 ~ImageFiller() {} 103 isImageCompatible(int imFlags,void * extData)104 bool isImageCompatible(int imFlags, void *extData) override { return true; } 105 106 protected: 107 bool getInfo(TImageInfo &info, int imFlags, void *extData) override; 108 TImageP build(int imFlags, void *extData) override; 109 }; 110 111 #endif // IMAGE_BUILDERS_H 112