summaryrefslogtreecommitdiff
path: root/modules/svg
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-01-31 10:15:01 +0100
committerGitHub <noreply@github.com>2020-01-31 10:15:01 +0100
commit43f84445ba187ff5a913f99aa1c4fb8640ffb36b (patch)
treef4cb93a872bcd3675b6f0315f731cbe4c0c54536 /modules/svg
parent8f9e1858dd53fe88b2019a9d1252cac223620e6d (diff)
parent9e3393a624d3c9d7e0a7f5c8bedbd3eb0d1e1b42 (diff)
Merge pull request #35340 from Calinou/optimize-editor-icon-generation
Optimize the editor icon generation
Diffstat (limited to 'modules/svg')
-rw-r--r--modules/svg/image_loader_svg.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp
index 57097aaa06..11ae2f81bf 100644
--- a/modules/svg/image_loader_svg.cpp
+++ b/modules/svg/image_loader_svg.cpp
@@ -103,15 +103,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 +125,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);