Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/TextureConverter.h
Show All 19 Lines | |||||
#include "lib/file/vfs/vfs.h" | #include "lib/file/vfs/vfs.h" | ||||
#include "TextureManager.h" | #include "TextureManager.h" | ||||
#if CONFIG2_NVTT | #if CONFIG2_NVTT | ||||
#include "ps/Future.h" | #include "ps/Future.h" | ||||
#include <exception> | |||||
#include <memory> | #include <memory> | ||||
#include <queue> | #include <queue> | ||||
#endif | #endif | ||||
class MD5; | class MD5; | ||||
/** | /** | ||||
* The exception which is thrown if the conversion fails. | |||||
*/ | |||||
class ConversionError : public std::exception | |||||
{ | |||||
public: | |||||
ConversionError(CTexturePtr tex) : | |||||
texture{std::move(tex)} | |||||
{} | |||||
CTexturePtr GetTexture() | |||||
{ | |||||
return texture; | |||||
} | |||||
private: | |||||
CTexturePtr texture; | |||||
}; | |||||
/** | |||||
* Texture conversion helper class. | * Texture conversion helper class. | ||||
* Provides an asynchronous API to convert input image files into compressed DDS, | * Provides an asynchronous API to convert input image files into compressed DDS, | ||||
* given various conversion settings. | * given various conversion settings. | ||||
* (The (potentially very slow) compression is a performed asynchronously, so | * (The (potentially very slow) compression is a performed asynchronously, so | ||||
* the game can remain responsive). | * the game can remain responsive). | ||||
* Also provides an API to load conversion settings from XML files. | * Also provides an API to load conversion settings from XML files. | ||||
* | * | ||||
* XML files are of the form: | * XML files are of the form: | ||||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | public: | ||||
* Returns the result of a successful ConvertTexture call. | * Returns the result of a successful ConvertTexture call. | ||||
* If no result is available yet, returns false. | * If no result is available yet, returns false. | ||||
* Otherwise, if the conversion succeeded, it sets ok to true and sets | * Otherwise, if the conversion succeeded, it sets ok to true and sets | ||||
* texture and dest to the corresponding values passed into ConvertTexture(), | * texture and dest to the corresponding values passed into ConvertTexture(), | ||||
* then returns true. | * then returns true. | ||||
* If the conversion failed, it sets ok to false and doesn't touch the other arguments, | * If the conversion failed, it sets ok to false and doesn't touch the other arguments, | ||||
* then returns true. | * then returns true. | ||||
*/ | */ | ||||
bool Poll(CTexturePtr& texture, VfsPath& dest, bool& ok); | bool Poll(CTexturePtr& texture, VfsPath& dest); | ||||
/** | /** | ||||
* The TextureConverter schouldn't utilize the CPU/TaskManager fully, so | * The TextureConverter schouldn't utilize the CPU/TaskManager fully, so | ||||
* ConvertTexture schouldn't be called when IsBusy returns true. | * ConvertTexture schouldn't be called when IsBusy returns true. | ||||
*/ | */ | ||||
bool IsBusy() const; | bool IsBusy() const; | ||||
private: | private: | ||||
Show All 12 Lines |
Wildfire Games · Phabricator