mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
common loader: enable lottie loader
json/lottie extensions are recognized as Lottie file format.
This commit is contained in:
parent
60f81b7da7
commit
7e7a561d9f
2 changed files with 18 additions and 1 deletions
|
@ -62,7 +62,7 @@ using namespace tvg;
|
|||
#define TVG_CLASS_ID_LINEAR 4
|
||||
#define TVG_CLASS_ID_RADIAL 5
|
||||
|
||||
enum class FileType { Tvg = 0, Svg, Raw, Png, Jpg, Webp, Unknown };
|
||||
enum class FileType { Tvg = 0, Svg, Lottie, Raw, Png, Jpg, Webp, Unknown };
|
||||
|
||||
#ifdef THORVG_LOG_ENABLED
|
||||
constexpr auto ErrorColor = "\033[31m"; //red
|
||||
|
|
|
@ -42,6 +42,10 @@
|
|||
#include "tvgWebpLoader.h"
|
||||
#endif
|
||||
|
||||
#ifdef THORVG_LOTTIE_LOADER_SUPPORT
|
||||
#include "tvgLottieLoader.h"
|
||||
#endif
|
||||
|
||||
#include "tvgRawLoader.h"
|
||||
|
||||
/************************************************************************/
|
||||
|
@ -60,6 +64,12 @@ static LoadModule* _find(FileType type)
|
|||
case FileType::Svg: {
|
||||
#ifdef THORVG_SVG_LOADER_SUPPORT
|
||||
return new SvgLoader;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case FileType::Lottie: {
|
||||
#ifdef THORVG_LOTTIE_LOADER_SUPPORT
|
||||
return new LottieLoader;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
@ -101,6 +111,10 @@ static LoadModule* _find(FileType type)
|
|||
format = "SVG";
|
||||
break;
|
||||
}
|
||||
case FileType::Lottie: {
|
||||
format = "lottie(json)";
|
||||
break;
|
||||
}
|
||||
case FileType::Raw: {
|
||||
format = "RAW";
|
||||
break;
|
||||
|
@ -133,6 +147,8 @@ static LoadModule* _findByPath(const string& path)
|
|||
auto ext = path.substr(path.find_last_of(".") + 1);
|
||||
if (!ext.compare("tvg")) return _find(FileType::Tvg);
|
||||
if (!ext.compare("svg")) return _find(FileType::Svg);
|
||||
if (!ext.compare("json")) return _find(FileType::Lottie);
|
||||
if (!ext.compare("lottie")) return _find(FileType::Lottie);
|
||||
if (!ext.compare("png")) return _find(FileType::Png);
|
||||
if (!ext.compare("jpg")) return _find(FileType::Jpg);
|
||||
if (!ext.compare("webp")) return _find(FileType::Webp);
|
||||
|
@ -148,6 +164,7 @@ static LoadModule* _findByType(const string& mimeType)
|
|||
|
||||
if (mimeType == "tvg") type = FileType::Tvg;
|
||||
else if (mimeType == "svg" || mimeType == "svg+xml") type = FileType::Svg;
|
||||
else if (mimeType == "lottie" || mimeType == "json") type = FileType::Lottie;
|
||||
else if (mimeType == "raw") type = FileType::Raw;
|
||||
else if (mimeType == "png") type = FileType::Png;
|
||||
else if (mimeType == "jpg" || mimeType == "jpeg") type = FileType::Jpg;
|
||||
|
|
Loading…
Add table
Reference in a new issue