Move init outside.
This commit is contained in:
parent
845a445fb4
commit
43f712c06f
|
@ -63,9 +63,6 @@ void ImageLoaderSVG::set_convert_colors(Dictionary *p_replace_color) {
|
|||
|
||||
void ImageLoaderSVG::create_image_from_string(Ref<Image> p_image, String p_string, float p_scale, bool p_upsample, bool p_convert_color) {
|
||||
ERR_FAIL_COND(Math::is_zero_approx(p_scale));
|
||||
if (tvg::Initializer::init(tvg::CanvasEngine::Sw, 1) != tvg::Result::Success) {
|
||||
return;
|
||||
}
|
||||
uint32_t bgColor = 0xffffffff;
|
||||
std::unique_ptr<tvg::Picture> picture = tvg::Picture::gen();
|
||||
float fw, fh;
|
||||
|
@ -124,7 +121,6 @@ void ImageLoaderSVG::create_image_from_string(Ref<Image> p_image, String p_strin
|
|||
|
||||
free(buffer);
|
||||
p_image->create(width, height, false, Image::FORMAT_RGBA8, image);
|
||||
tvg::Initializer::term(tvg::CanvasEngine::Sw);
|
||||
}
|
||||
|
||||
void ImageLoaderSVG::get_recognized_extensions(List<String> *p_extensions) const {
|
||||
|
|
|
@ -37,10 +37,17 @@
|
|||
static ImageLoaderSVG *image_loader_svg = nullptr;
|
||||
|
||||
void register_svg_types() {
|
||||
if (tvg::Initializer::init(tvg::CanvasEngine::Sw, 1) != tvg::Result::Success) {
|
||||
return;
|
||||
}
|
||||
image_loader_svg = memnew(ImageLoaderSVG);
|
||||
ImageLoader::add_image_format_loader(image_loader_svg);
|
||||
}
|
||||
|
||||
void unregister_svg_types() {
|
||||
if (!image_loader_svg) {
|
||||
return;
|
||||
}
|
||||
tvg::Initializer::term(tvg::CanvasEngine::Sw);
|
||||
memdelete(image_loader_svg);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue