2016-05-17 03:04:11 +12:00
|
|
|
#pragma once
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
#ifndef IMAGE_BUILDERS_H
|
|
|
|
#define IMAGE_BUILDERS_H
|
|
|
|
|
|
|
|
#include "tfilepath.h"
|
|
|
|
|
|
|
|
#include "toonz/imagemanager.h"
|
|
|
|
|
|
|
|
//======================================================
|
|
|
|
|
|
|
|
// Forward declarations
|
|
|
|
|
|
|
|
class TImageInfo;
|
|
|
|
class TXshSimpleLevel;
|
|
|
|
|
|
|
|
//======================================================
|
|
|
|
|
|
|
|
//***************************************************************************************
|
|
|
|
// ImageLoader class declaration
|
|
|
|
//***************************************************************************************
|
|
|
|
|
|
|
|
/*!
|
|
|
|
ImageLoader is the specialized ImageBuilder class used to automatically load
|
|
|
|
images from a level file on hard disk.
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
Refer to ImageLoader::BuildExtData for a description of the allowed options
|
|
|
|
for
|
2016-03-19 06:57:51 +13:00
|
|
|
image loading.
|
|
|
|
*/
|
2016-06-29 18:17:12 +12:00
|
|
|
class ImageLoader final : public ImageBuilder {
|
2016-03-19 06:57:51 +13:00
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
struct BuildExtData {
|
|
|
|
const TXshSimpleLevel *m_sl; //!< TXshSimpleLevel instance associated to an
|
2016-06-20 14:23:05 +12:00
|
|
|
//! image loading request
|
2016-06-15 18:43:10 +12:00
|
|
|
TFrameId m_fid; //!< m_sl's fid at which the image will be loaded
|
|
|
|
|
|
|
|
int m_subs; //!< The subsampling factor for image loading (0 meaning either
|
|
|
|
//!< 'the currently stored one' if an image is already cached, or
|
|
|
|
//!< m_sl's subsampling property otherwise)
|
|
|
|
bool m_icon; //!< Whether the icon (if any) should be loaded instead
|
|
|
|
|
|
|
|
public:
|
|
|
|
BuildExtData(const TXshSimpleLevel *sl, const TFrameId &fid, int subs = 0,
|
|
|
|
bool icon = false)
|
|
|
|
: m_sl(sl), m_fid(fid), m_subs(subs), m_icon(icon) {}
|
|
|
|
};
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
ImageLoader(const TFilePath &path, const TFrameId &fid);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
bool isImageCompatible(int imFlags, void *extData) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
/*--
|
|
|
|
* ImageBuilder仮想関数の実装。アイコン、画像をLoad時に全てキャッシュに格納する
|
|
|
|
* --*/
|
|
|
|
void buildAllIconsAndPutInCache(TXshSimpleLevel *level,
|
|
|
|
std::vector<TFrameId> fids,
|
|
|
|
std::vector<std::string> iconIds,
|
2016-06-19 20:06:29 +12:00
|
|
|
bool cacheImagesAsWell) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2017-10-02 23:30:28 +13:00
|
|
|
/* Exposed to allow Fid to be updated due to a renumber operation
|
|
|
|
*/
|
2020-09-16 09:49:57 +12:00
|
|
|
void setFid(const TFrameId &fid) override;
|
2017-10-02 23:30:28 +13:00
|
|
|
|
2016-03-19 06:57:51 +13:00
|
|
|
protected:
|
2016-06-19 20:06:29 +12:00
|
|
|
bool getInfo(TImageInfo &info, int imFlags, void *extData) override;
|
|
|
|
TImageP build(int imFlags, void *extData) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
void invalidate() override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
inline int buildSubsampling(int imFlags, BuildExtData *data);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
private:
|
2016-06-15 18:43:10 +12:00
|
|
|
TFilePath m_path; //!< Level path to load images from
|
|
|
|
TFrameId m_fid; //!< Frame of the level to load
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool m_64bitCompatible; //!< Whether current image is 64-bit compatible
|
|
|
|
int m_subsampling; //!< Current image subsampling
|
|
|
|
//!< NOTE: Should this be replaced by requests to the TImageCache?
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class ImageRasterizer final : public ImageBuilder {
|
2016-03-19 06:57:51 +13:00
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
ImageRasterizer() {}
|
|
|
|
~ImageRasterizer() {}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
bool isImageCompatible(int imFlags, void *extData) override { return true; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
protected:
|
2016-06-19 20:06:29 +12:00
|
|
|
bool getInfo(TImageInfo &info, int imFlags, void *extData) override;
|
|
|
|
TImageP build(int imFlags, void *extData) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class ImageFiller final : public ImageBuilder {
|
2016-03-19 06:57:51 +13:00
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
ImageFiller() {}
|
|
|
|
~ImageFiller() {}
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
bool isImageCompatible(int imFlags, void *extData) override { return true; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
protected:
|
2016-06-19 20:06:29 +12:00
|
|
|
bool getInfo(TImageInfo &info, int imFlags, void *extData) override;
|
|
|
|
TImageP build(int imFlags, void *extData) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
#endif // IMAGE_BUILDERS_H
|