canvas->push(move(picture1));
canvas->push(move(picture2));
+
+ free(data);
}
}
picture2->composite(move(circle), tvg::CompositeMethod::ClipPath);
canvas->push(move(picture2));
+
+ free(data);
}
//Terminate ThorVG Engine
tvg::Initializer::term(tvg::CanvasEngine::Sw);
- if (data) free(data);
-
} else {
cout << "engine is not supported" << endl;
}
}
-unique_ptr<Loader> LoaderMgr::loader(const string& path)
+shared_ptr<Loader> LoaderMgr::loader(const string& path)
{
if (auto loader = _find(path)) {
- if (loader->open(path)) return unique_ptr<Loader>(loader);
+ if (loader->open(path)) return shared_ptr<Loader>(loader);
else delete(loader);
}
return nullptr;
}
-unique_ptr<Loader> LoaderMgr::loader(const char* data, uint32_t size)
+shared_ptr<Loader> LoaderMgr::loader(const char* data, uint32_t size)
{
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)) return unique_ptr<Loader>(loader);
+ if (loader->open(data, size)) return shared_ptr<Loader>(loader);
else delete(loader);
}
}
}
-unique_ptr<Loader> LoaderMgr::loader(const uint32_t *data, uint32_t w, uint32_t h, bool copy)
+shared_ptr<Loader> 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 unique_ptr<Loader>(loader);
+ if (loader->open(data, w, h, copy)) return shared_ptr<Loader>(loader);
else delete(loader);
}
}
{
static bool init();
static bool term();
- static unique_ptr<Loader> loader(const string& path);
- static unique_ptr<Loader> loader(const char* data, uint32_t size);
- static unique_ptr<Loader> loader(const uint32_t* data, uint32_t w, uint32_t h, bool copy);
+ static shared_ptr<Loader> loader(const string& path);
+ static shared_ptr<Loader> loader(const char* data, uint32_t size);
+ static shared_ptr<Loader> loader(const uint32_t* data, uint32_t w, uint32_t h, bool copy);
};
#endif //_TVG_LOADER_MGR_H_
struct Picture::Impl
{
- unique_ptr<Loader> loader = nullptr;
+ shared_ptr<Loader> loader = nullptr;
Paint* paint = nullptr;
uint32_t *pixels = nullptr;
Picture *picture = nullptr;
}
if (!pixels) {
pixels = const_cast<uint32_t*>(loader->pixels());
+ loader->close();
if (pixels) return RenderUpdateFlag::Image;
}
}
{
reload();
- if (!paint) return nullptr;
auto ret = Picture::gen();
if (!ret) return nullptr;
+
auto dup = ret.get()->pImpl;
- dup->paint = paint->duplicate();
+ if (paint) dup->paint = paint->duplicate();
+
+ dup->loader = loader;
+ dup->pixels = pixels;
+ dup->w = w;
+ dup->h = h;
+ dup->resizing = resizing;
return ret.release();
}