Init per editor.
This commit is contained in:
parent
e07f8c62ba
commit
5635219a3b
|
@ -64,6 +64,9 @@ 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) {
|
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));
|
ERR_FAIL_COND(Math::is_zero_approx(p_scale));
|
||||||
uint32_t bgColor = 0xffffffff;
|
uint32_t bgColor = 0xffffffff;
|
||||||
|
if (tvg::Initializer::init(tvg::CanvasEngine::Sw, 1) != tvg::Result::Success) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
std::unique_ptr<tvg::Picture> picture = tvg::Picture::gen();
|
std::unique_ptr<tvg::Picture> picture = tvg::Picture::gen();
|
||||||
float fw, fh;
|
float fw, fh;
|
||||||
CharString char_string = p_string.utf8();
|
CharString char_string = p_string.utf8();
|
||||||
|
@ -124,6 +127,7 @@ void ImageLoaderSVG::create_image_from_string(Ref<Image> p_image, String p_strin
|
||||||
|
|
||||||
free(buffer);
|
free(buffer);
|
||||||
p_image->create(width, height, false, Image::FORMAT_RGBA8, image);
|
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 {
|
void ImageLoaderSVG::get_recognized_extensions(List<String> *p_extensions) const {
|
||||||
|
|
|
@ -33,13 +33,11 @@
|
||||||
#include "image_loader_svg.h"
|
#include "image_loader_svg.h"
|
||||||
|
|
||||||
#include <thorvg.h>
|
#include <thorvg.h>
|
||||||
|
#include "thirdparty/thorvg/inc/config.h"
|
||||||
|
|
||||||
static ImageLoaderSVG *image_loader_svg = nullptr;
|
static ImageLoaderSVG *image_loader_svg = nullptr;
|
||||||
|
|
||||||
void register_svg_types() {
|
void register_svg_types() {
|
||||||
if (tvg::Initializer::init(tvg::CanvasEngine::Sw, 1) != tvg::Result::Success) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
image_loader_svg = memnew(ImageLoaderSVG);
|
image_loader_svg = memnew(ImageLoaderSVG);
|
||||||
ImageLoader::add_image_format_loader(image_loader_svg);
|
ImageLoader::add_image_format_loader(image_loader_svg);
|
||||||
}
|
}
|
||||||
|
@ -48,6 +46,5 @@ void unregister_svg_types() {
|
||||||
if (!image_loader_svg) {
|
if (!image_loader_svg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tvg::Initializer::term(tvg::CanvasEngine::Sw);
|
|
||||||
memdelete(image_loader_svg);
|
memdelete(image_loader_svg);
|
||||||
}
|
}
|
||||||
|
|
34
thirdparty/thorvg/inc/config.h
vendored
34
thirdparty/thorvg/inc/config.h
vendored
|
@ -1,6 +1,35 @@
|
||||||
// Adapted from the config.h generated by ThorVG's meson buildsystem.
|
/*************************************************************************/
|
||||||
|
/* config.h */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
||||||
|
/* */
|
||||||
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
|
/* a copy of this software and associated documentation files (the */
|
||||||
|
/* "Software"), to deal in the Software without restriction, including */
|
||||||
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||||
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||||
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||||
|
/* the following conditions: */
|
||||||
|
/* */
|
||||||
|
/* The above copyright notice and this permission notice shall be */
|
||||||
|
/* included in all copies or substantial portions of the Software. */
|
||||||
|
/* */
|
||||||
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||||
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||||
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||||
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||||
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||||
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#ifndef SVG_CONFIG_H
|
||||||
|
#define SVG_CONFIG_H
|
||||||
|
|
||||||
#define THORVG_SW_RASTER_SUPPORT 1
|
#define THORVG_SW_RASTER_SUPPORT 1
|
||||||
|
|
||||||
|
@ -15,3 +44,4 @@
|
||||||
#define THORVG_LOG_ENABLED 1
|
#define THORVG_LOG_ENABLED 1
|
||||||
|
|
||||||
#define THORVG_VERSION_STRING "master"
|
#define THORVG_VERSION_STRING "master"
|
||||||
|
#endif
|
34
thirdparty/thorvg/update-thorvg.sh
vendored
34
thirdparty/thorvg/update-thorvg.sh
vendored
|
@ -8,9 +8,38 @@ rm -rf src/bin src/bindings src/examples src/wasm
|
||||||
rm -rf src/lib/gl_engine
|
rm -rf src/lib/gl_engine
|
||||||
|
|
||||||
cat << 'EOF' > inc/config.h
|
cat << 'EOF' > inc/config.h
|
||||||
// Adapted from the config.h generated by ThorVG's meson buildsystem.
|
/*************************************************************************/
|
||||||
|
/* config.h */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
||||||
|
/* */
|
||||||
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
|
/* a copy of this software and associated documentation files (the */
|
||||||
|
/* "Software"), to deal in the Software without restriction, including */
|
||||||
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||||
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||||
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||||
|
/* the following conditions: */
|
||||||
|
/* */
|
||||||
|
/* The above copyright notice and this permission notice shall be */
|
||||||
|
/* included in all copies or substantial portions of the Software. */
|
||||||
|
/* */
|
||||||
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||||
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||||
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||||
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||||
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||||
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||||
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#ifndef SVG_CONFIG_H
|
||||||
|
#define SVG_CONFIG_H
|
||||||
|
|
||||||
#define THORVG_SW_RASTER_SUPPORT 1
|
#define THORVG_SW_RASTER_SUPPORT 1
|
||||||
|
|
||||||
|
@ -25,4 +54,5 @@ cat << 'EOF' > inc/config.h
|
||||||
#define THORVG_LOG_ENABLED 1
|
#define THORVG_LOG_ENABLED 1
|
||||||
|
|
||||||
#define THORVG_VERSION_STRING "master"
|
#define THORVG_VERSION_STRING "master"
|
||||||
|
#endif
|
||||||
EOF
|
EOF
|
||||||
|
|
Loading…
Reference in a new issue