diff options
Diffstat (limited to 'modules/svg')
-rw-r--r-- | modules/svg/SCsub | 4 | ||||
-rw-r--r-- | modules/svg/image_loader_svg.cpp | 22 | ||||
-rw-r--r-- | modules/svg/image_loader_svg.h | 11 | ||||
-rw-r--r-- | modules/svg/register_types.cpp | 4 | ||||
-rw-r--r-- | modules/svg/register_types.h | 4 |
5 files changed, 22 insertions, 23 deletions
diff --git a/modules/svg/SCsub b/modules/svg/SCsub index 9324c1634b..7961d1f33e 100644 --- a/modules/svg/SCsub +++ b/modules/svg/SCsub @@ -13,10 +13,6 @@ thirdparty_sources = [ thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] env_svg.Prepend(CPPPATH=[thirdparty_dir]) -# FIXME: Needed in editor/editor_themes.cpp for now, but ideally there -# shouldn't be a dependency on modules/ and its own 3rd party deps. -env.Prepend(CPPPATH=[thirdparty_dir]) -env.Append(CPPDEFINES=["SVG_ENABLED"]) env_thirdparty = env_svg.Clone() env_thirdparty.disable_warnings() diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp index a2ef88d130..7f91908a33 100644 --- a/modules/svg/image_loader_svg.cpp +++ b/modules/svg/image_loader_svg.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 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 */ @@ -30,9 +30,8 @@ #include "image_loader_svg.h" -#include "core/os/os.h" -#include "core/print_string.h" -#include "core/ustring.h" +#include <nanosvg.h> +#include <nanosvgrast.h> void SVGRasterizer::rasterize(NSVGimage *p_image, float p_tx, float p_ty, float p_scale, unsigned char *p_dst, int p_w, int p_h, int p_stride) { nsvgRasterize(rasterizer, p_image, p_tx, p_ty, p_scale, p_dst, p_w, p_h, p_stride); @@ -103,15 +102,17 @@ Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const PoolVector<uint8_t ERR_PRINT("SVG Corrupted"); return ERR_FILE_CORRUPT; } - if (convert_colors) + + if (convert_colors) { _convert_colors(svg_image); + } - float upscale = upsample ? 2.0 : 1.0; + const float upscale = upsample ? 2.0 : 1.0; - int w = (int)(svg_image->width * p_scale * upscale); + const int w = (int)(svg_image->width * p_scale * upscale); ERR_FAIL_COND_V_MSG(w > Image::MAX_WIDTH, ERR_PARAMETER_RANGE_ERROR, vformat("Can't create image from SVG with scale %s, the resulting image size exceeds max width.", rtos(p_scale))); - int h = (int)(svg_image->height * p_scale * upscale); + const int h = (int)(svg_image->height * p_scale * upscale); ERR_FAIL_COND_V_MSG(h > Image::MAX_HEIGHT, ERR_PARAMETER_RANGE_ERROR, vformat("Can't create image from SVG with scale %s, the resulting image size exceeds max height.", rtos(p_scale))); PoolVector<uint8_t> dst_image; @@ -123,8 +124,9 @@ Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const PoolVector<uint8_t dw.release(); p_image->create(w, h, false, Image::FORMAT_RGBA8, dst_image); - if (upsample) + if (upsample) { p_image->shrink_x2(); + } nsvgDelete(svg_image); diff --git a/modules/svg/image_loader_svg.h b/modules/svg/image_loader_svg.h index 2116079aef..24cee82480 100644 --- a/modules/svg/image_loader_svg.h +++ b/modules/svg/image_loader_svg.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 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 */ @@ -34,13 +34,14 @@ #include "core/io/image_loader.h" #include "core/ustring.h" -#include <nanosvg.h> -#include <nanosvgrast.h> - /** @author Daniel Ramirez <djrmuv@gmail.com> */ +// Forward declare and include thirdparty headers in .cpp. +struct NSVGrasterizer; +struct NSVGimage; + class SVGRasterizer { NSVGrasterizer *rasterizer; diff --git a/modules/svg/register_types.cpp b/modules/svg/register_types.cpp index 5707c29f60..b0782dae88 100644 --- a/modules/svg/register_types.cpp +++ b/modules/svg/register_types.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 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 */ diff --git a/modules/svg/register_types.h b/modules/svg/register_types.h index 13eb12d2d1..aa50540552 100644 --- a/modules/svg/register_types.h +++ b/modules/svg/register_types.h @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 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 */ |