From 9ffe487812bf69f66f3e748b54795b16a5920708 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Fri, 30 Jul 2021 12:34:56 +0900 Subject: [PATCH] common loader: lookup in the numberic order. --- src/lib/tvgLoader.cpp | 32 ++++++++++++++++---------------- src/loaders/tvg/tvgTvgLoader.cpp | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/lib/tvgLoader.cpp b/src/lib/tvgLoader.cpp index 6073510..5e68ecb 100644 --- a/src/lib/tvgLoader.cpp +++ b/src/lib/tvgLoader.cpp @@ -46,15 +46,15 @@ static LoadModule* _find(FileType type) { switch(type) { - case FileType::Svg: { -#ifdef THORVG_SVG_LOADER_SUPPORT - return new SvgLoader; + case FileType::Tvg: { +#ifdef THORVG_TVG_LOADER_SUPPORT + return new TvgLoader; #endif break; } - case FileType::Png: { -#ifdef THORVG_PNG_LOADER_SUPPORT - return new PngLoader; + case FileType::Svg: { +#ifdef THORVG_SVG_LOADER_SUPPORT + return new SvgLoader; #endif break; } @@ -62,9 +62,9 @@ static LoadModule* _find(FileType type) return new RawLoader; break; } - case FileType::Tvg: { -#ifdef THORVG_TVG_LOADER_SUPPORT - return new TvgLoader; + case FileType::Png: { +#ifdef THORVG_PNG_LOADER_SUPPORT + return new PngLoader; #endif break; } @@ -82,20 +82,20 @@ static LoadModule* _find(FileType type) #ifdef THORVG_LOG_ENABLED const char *format; switch(type) { - case FileType::Svg: { - format = "SVG"; + case FileType::Tvg: { + format = "TVG"; break; } - case FileType::Png: { - format = "PNG"; + case FileType::Svg: { + format = "SVG"; break; } case FileType::Raw: { format = "RAW"; break; } - case FileType::Tvg: { - format = "TVG"; + case FileType::Png: { + format = "PNG"; break; } case FileType::Jpg: { @@ -116,9 +116,9 @@ static LoadModule* _find(FileType type) static LoadModule* _find(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("png")) return _find(FileType::Png); - if (!ext.compare("tvg")) return _find(FileType::Tvg); if (!ext.compare("jpg")) return _find(FileType::Jpg); return nullptr; } diff --git a/src/loaders/tvg/tvgTvgLoader.cpp b/src/loaders/tvg/tvgTvgLoader.cpp index 5b83442..593187e 100644 --- a/src/loaders/tvg/tvgTvgLoader.cpp +++ b/src/loaders/tvg/tvgTvgLoader.cpp @@ -158,4 +158,4 @@ unique_ptr TvgLoader::paint() this->done(); if (root) return move(root); return nullptr; -} +} \ No newline at end of file -- 2.7.4