'tvgBinaryDesc.h',
'tvgFill.h',
'tvgLoader.h',
- 'tvgLoaderMgr.h',
+ 'tvgLoadModule.h',
'tvgPictureImpl.h',
'tvgRender.h',
- 'tvgSaver.h',
+ 'tvgSaveModule.h',
'tvgSceneImpl.h',
'tvgShapeImpl.h',
'tvgTaskScheduler.h',
'tvgGlCanvas.cpp',
'tvgInitializer.cpp',
'tvgLinearGradient.cpp',
- 'tvgLoaderMgr.cpp',
+ 'tvgLoader.cpp',
'tvgPaint.cpp',
'tvgPicture.cpp',
'tvgRadialGradient.cpp',
*/
#include "tvgCommon.h"
#include "tvgTaskScheduler.h"
-#include "tvgLoaderMgr.h"
+#include "tvgLoader.h"
#ifdef THORVG_SW_RASTER_SUPPORT
#include "tvgSwRenderer.h"
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-#ifndef _TVG_LOADER_MGR_H_
-#define _TVG_LOADER_MGR_H_
+#ifndef _TVG_LOAD_MODULE_H_
+#define _TVG_LOAD_MODULE_H_
-#include "tvgLoader.h"
+#include "tvgCommon.h"
-struct LoaderMgr
+namespace tvg
{
- static bool init();
- static bool term();
- static shared_ptr<Loader> loader(const string& path, bool* invalid);
- static shared_ptr<Loader> loader(const char* data, uint32_t size, bool copy);
- static shared_ptr<Loader> loader(const uint32_t* data, uint32_t w, uint32_t h, bool copy);
+
+class LoadModule
+{
+public:
+ //default view box, if any.
+ float vx = 0;
+ float vy = 0;
+ float vw = 0;
+ float vh = 0;
+ float w = 0, h = 0; //default image size
+ bool preserveAspect = true; //keep aspect ratio by default.
+
+ virtual ~LoadModule() {}
+
+ virtual bool open(const string& path) { /* Not supported */ return false; };
+ virtual bool open(const char* data, uint32_t size, bool copy) { /* Not supported */ return false; };
+ virtual bool open(const uint32_t* data, uint32_t w, uint32_t h, bool copy) { /* Not supported */ return false; };
+ virtual bool read() = 0;
+ virtual bool close() = 0;
+ virtual const uint32_t* pixels() { return nullptr; };
+ virtual unique_ptr<Scene> scene() { return nullptr; };
};
-#endif //_TVG_LOADER_MGR_H_
+}
+
+#endif //_TVG_LOAD_MODULE_H_
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-#include "tvgLoaderMgr.h"
+#include "tvgLoader.h"
#ifdef THORVG_SVG_LOADER_SUPPORT
#include "tvgSvgLoader.h"
/* Internal Class Implementation */
/************************************************************************/
-static Loader* _find(FileType type)
+static LoadModule* _find(FileType type)
{
switch(type) {
case FileType::Svg: {
}
-static Loader* _find(const string& path)
+static LoadModule* _find(const string& path)
{
auto ext = path.substr(path.find_last_of(".") + 1);
if (!ext.compare("svg")) return _find(FileType::Svg);
}
-shared_ptr<Loader> LoaderMgr::loader(const string& path, bool* invalid)
+shared_ptr<LoadModule> LoaderMgr::loader(const string& path, bool* invalid)
{
*invalid = false;
if (auto loader = _find(path)) {
- if (loader->open(path)) return shared_ptr<Loader>(loader);
+ if (loader->open(path)) return shared_ptr<LoadModule>(loader);
else delete(loader);
*invalid = true;
}
}
-shared_ptr<Loader> LoaderMgr::loader(const char* data, uint32_t size, bool copy)
+shared_ptr<LoadModule> LoaderMgr::loader(const char* data, uint32_t size, bool copy)
{
for (int i = 0; i < static_cast<int>(FileType::Unknown); i++) {
auto loader = _find(static_cast<FileType>(i));
if (loader) {
- if (loader->open(data, size, copy)) return shared_ptr<Loader>(loader);
+ if (loader->open(data, size, copy)) return shared_ptr<LoadModule>(loader);
else delete(loader);
}
}
}
-shared_ptr<Loader> LoaderMgr::loader(const uint32_t *data, uint32_t w, uint32_t h, bool copy)
+shared_ptr<LoadModule> LoaderMgr::loader(const uint32_t *data, uint32_t w, uint32_t h, bool copy)
{
for (int i = 0; i < static_cast<int>(FileType::Unknown); i++) {
auto loader = _find(static_cast<FileType>(i));
if (loader) {
- if (loader->open(data, w, h, copy)) return shared_ptr<Loader>(loader);
+ if (loader->open(data, w, h, copy)) return shared_ptr<LoadModule>(loader);
else delete(loader);
}
}
#ifndef _TVG_LOADER_H_
#define _TVG_LOADER_H_
-#include "tvgCommon.h"
+#include "tvgLoadModule.h"
-namespace tvg
+struct LoaderMgr
{
-
-class Loader
-{
-public:
- //default view box, if any.
- float vx = 0;
- float vy = 0;
- float vw = 0;
- float vh = 0;
- float w = 0, h = 0; //default image size
- bool preserveAspect = true; //keep aspect ratio by default.
-
- virtual ~Loader() {}
-
- virtual bool open(const string& path) { /* Not supported */ return false; };
- virtual bool open(const char* data, uint32_t size, bool copy) { /* Not supported */ return false; };
- virtual bool open(const uint32_t* data, uint32_t w, uint32_t h, bool copy) { /* Not supported */ return false; };
- virtual bool read() = 0;
- virtual bool close() = 0;
- virtual const uint32_t* pixels() { return nullptr; };
- virtual unique_ptr<Scene> scene() { return nullptr; };
+ static bool init();
+ static bool term();
+ static shared_ptr<LoadModule> loader(const string& path, bool* invalid);
+ static shared_ptr<LoadModule> loader(const char* data, uint32_t size, bool copy);
+ static shared_ptr<LoadModule> loader(const uint32_t* data, uint32_t w, uint32_t h, bool copy);
};
-}
-
#endif //_TVG_LOADER_H_
#include <string>
#include "tvgPaint.h"
-#include "tvgLoaderMgr.h"
+#include "tvgLoader.h"
/************************************************************************/
/* Internal Class Implementation */
struct Picture::Impl
{
- shared_ptr<Loader> loader = nullptr;
+ shared_ptr<LoadModule> loader = nullptr;
Paint* paint = nullptr;
uint32_t *pixels = nullptr;
Picture *picture = nullptr;
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-#ifndef _TVG_SAVER_H_
-#define _TVG_SAVER_H_
+#ifndef _TVG_SAVE_MODULE_H_
+#define _TVG_SAVE_MODULE_H_
#include "tvgPaint.h"
}
-#endif //_TVG_SAVER_H_
\ No newline at end of file
+#endif //_TVG_SAVE_MODULE_H_
\ No newline at end of file
* SOFTWARE.
*/
#include "tvgCommon.h"
-#include "tvgSaver.h"
+#include "tvgSaveModule.h"
#ifdef THORVG_TVG_SAVER_SUPPORT
#include "tvgTvgSaver.h"
#include <memory.h>
#include <turbojpeg.h>
-#include "tvgLoaderMgr.h"
+#include "tvgLoader.h"
#include "tvgJpgLoader.h"
/************************************************************************/
using tjhandle = void*;
//TODO: Use Task?
-class JpgLoader : public Loader
+class JpgLoader : public LoadModule
{
public:
JpgLoader();
~JpgLoader();
- using Loader::open;
+ using LoadModule::open;
bool open(const string& path) override;
bool open(const char* data, uint32_t size, bool copy) override;
bool read() override;
* SOFTWARE.
*/
-#include "tvgLoaderMgr.h"
+#include "tvgLoader.h"
#include "tvgPngLoader.h"
PngLoader::PngLoader()
#include <png.h>
-//OPTIMIZE ME: Use Task?
-class PngLoader : public Loader
+class PngLoader : public LoadModule
{
public:
PngLoader();
~PngLoader();
- using Loader::open;
+ using LoadModule::open;
bool open(const string& path) override;
bool open(const char* data, uint32_t size, bool copy) override;
bool read() override;
*/
#include <fstream>
#include <string.h>
-#include "tvgLoaderMgr.h"
+#include "tvgLoader.h"
#include "tvgRawLoader.h"
/************************************************************************/
#ifndef _TVG_RAW_LOADER_H_
#define _TVG_RAW_LOADER_H_
-class RawLoader : public Loader
+class RawLoader : public LoadModule
{
public:
const uint32_t* content = nullptr;
~RawLoader();
- using Loader::open;
+ using LoadModule::open;
bool open(const uint32_t* data, uint32_t w, uint32_t h, bool copy) override;
bool read() override;
bool close() override;
#include <fstream>
#include <float.h>
#include <math.h>
-#include "tvgLoaderMgr.h"
+#include "tvgLoader.h"
#include "tvgXmlParser.h"
#include "tvgSvgLoader.h"
#include "tvgSvgSceneBuilder.h"
#include "tvgTaskScheduler.h"
#include "tvgSvgLoaderCommon.h"
-class SvgLoader : public Loader, public Task
+class SvgLoader : public LoadModule, public Task
{
public:
string filePath;
SvgLoader();
~SvgLoader();
- using Loader::open;
+ using LoadModule::open;
bool open(const string& path) override;
bool open(const char* data, uint32_t size, bool copy) override;
#include <fstream>
#include <memory.h>
-#include "tvgLoaderMgr.h"
+#include "tvgLoader.h"
#include "tvgTvgLoader.h"
#include "tvgTvgLoadParser.h"
#include "tvgTaskScheduler.h"
-class TvgLoader : public Loader, public Task
+class TvgLoader : public LoadModule, public Task
{
public:
const char* data = nullptr;
~TvgLoader();
- using Loader::open;
+ using LoadModule::open;
bool open(const string &path) override;
bool open(const char *data, uint32_t size, bool copy) override;
bool read() override;
#include <float.h>
#include <math.h>
#include <stdio.h>
-#include "tvgSaver.h"
+#include "tvgSaveModule.h"
#include "tvgTvgSaver.h"
#define SIZE(A) sizeof(A)