summaryrefslogtreecommitdiff
path: root/modules/svg
diff options
context:
space:
mode:
Diffstat (limited to 'modules/svg')
-rw-r--r--modules/svg/SCsub1
-rw-r--r--modules/svg/image_loader_svg.cpp6
-rw-r--r--modules/svg/image_loader_svg.h2
-rw-r--r--modules/svg/register_types.cpp14
-rw-r--r--modules/svg/register_types.h6
5 files changed, 20 insertions, 9 deletions
diff --git a/modules/svg/SCsub b/modules/svg/SCsub
index bb03147731..93262f4f87 100644
--- a/modules/svg/SCsub
+++ b/modules/svg/SCsub
@@ -34,6 +34,7 @@ thirdparty_sources = [
"src/loaders/svg/tvgSvgSceneBuilder.cpp",
"src/loaders/svg/tvgSvgPath.cpp",
"src/loaders/svg/tvgSvgLoader.cpp",
+ "src/loaders/svg/tvgSvgCssStyle.cpp",
"src/loaders/tvg/tvgTvgBinInterpreter.cpp",
"src/loaders/tvg/tvgTvgLoader.cpp",
"src/loaders/jpg/tvgJpgLoader.cpp",
diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp
index 96b83bf25a..dcb1f1d744 100644
--- a/modules/svg/image_loader_svg.cpp
+++ b/modules/svg/image_loader_svg.cpp
@@ -78,7 +78,7 @@ void ImageLoaderSVG::create_image_from_string(Ref<Image> p_image, String p_strin
return;
}
float fw, fh;
- picture->viewbox(nullptr, nullptr, &fw, &fh);
+ picture->size(&fw, &fh);
uint32_t width = MIN(fw * p_scale, 16 * 1024);
uint32_t height = MIN(fh * p_scale, 16 * 1024);
@@ -94,7 +94,7 @@ void ImageLoaderSVG::create_image_from_string(Ref<Image> p_image, String p_strin
ERR_FAIL_MSG("ImageLoaderSVG can't create image.");
}
- res = sw_canvas->push(move(picture));
+ res = sw_canvas->push(std::move(picture));
if (res != tvg::Result::Success) {
memfree(buffer);
ERR_FAIL_MSG("ImageLoaderSVG can't create image.");
@@ -136,7 +136,7 @@ void ImageLoaderSVG::get_recognized_extensions(List<String> *p_extensions) const
p_extensions->push_back("svg");
}
-Error ImageLoaderSVG::load_image(Ref<Image> p_image, FileAccess *p_fileaccess, bool p_force_linear, float p_scale) {
+Error ImageLoaderSVG::load_image(Ref<Image> p_image, Ref<FileAccess> p_fileaccess, bool p_force_linear, float p_scale) {
String svg = p_fileaccess->get_as_utf8_string();
create_image_from_string(p_image, svg, p_scale, false, false);
ERR_FAIL_COND_V(p_image->is_empty(), FAILED);
diff --git a/modules/svg/image_loader_svg.h b/modules/svg/image_loader_svg.h
index d0bd71d92d..94c17fda43 100644
--- a/modules/svg/image_loader_svg.h
+++ b/modules/svg/image_loader_svg.h
@@ -42,7 +42,7 @@ public:
void set_replace_colors(Dictionary p_replace_colors) { replace_colors = p_replace_colors; }
void create_image_from_string(Ref<Image> p_image, String p_string, float p_scale, bool p_upsample, bool p_convert_color);
- virtual Error load_image(Ref<Image> p_image, FileAccess *p_fileaccess, bool p_force_linear, float p_scale) override;
+ virtual Error load_image(Ref<Image> p_image, Ref<FileAccess> p_fileaccess, bool p_force_linear, float p_scale) override;
virtual void get_recognized_extensions(List<String> *p_extensions) const override;
};
diff --git a/modules/svg/register_types.cpp b/modules/svg/register_types.cpp
index a4341c6f1e..5b4d1d31ca 100644
--- a/modules/svg/register_types.cpp
+++ b/modules/svg/register_types.cpp
@@ -36,16 +36,24 @@
static ImageLoaderSVG *image_loader_svg = nullptr;
-void register_svg_types() {
+void initialize_svg_module(ModuleInitializationLevel p_level) {
+ if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
+ return;
+ }
+
tvg::CanvasEngine tvgEngine = tvg::CanvasEngine::Sw;
- if (tvg::Initializer::init(tvgEngine, 0) != tvg::Result::Success) {
+ if (tvg::Initializer::init(tvgEngine, 1) != tvg::Result::Success) {
return;
}
image_loader_svg = memnew(ImageLoaderSVG);
ImageLoader::add_image_format_loader(image_loader_svg);
}
-void unregister_svg_types() {
+void uninitialize_svg_module(ModuleInitializationLevel p_level) {
+ if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
+ return;
+ }
+
if (!image_loader_svg) {
return;
}
diff --git a/modules/svg/register_types.h b/modules/svg/register_types.h
index 11fd9e7007..66f3e94600 100644
--- a/modules/svg/register_types.h
+++ b/modules/svg/register_types.h
@@ -31,7 +31,9 @@
#ifndef SVG_REGISTER_TYPES_H
#define SVG_REGISTER_TYPES_H
-void register_svg_types();
-void unregister_svg_types();
+#include "modules/register_module_types.h"
+
+void initialize_svg_module(ModuleInitializationLevel p_level);
+void uninitialize_svg_module(ModuleInitializationLevel p_level);
#endif // SVG_REGISTER_TYPES_H