From a05f8ac4abc5c05cd4d28b166e35ef596d7fbbfa Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Sat, 13 Jun 2020 15:30:58 +0300 Subject: [PATCH] Use Image class' blend_rect method if Godot's version is 3.2.2 https://github.com/godotengine/godot/issues/31124 has now been fixed in Godot 3.2.2-rc1, so we can use Image.blend_rect() instead of a custom method. This makes exporting large images and drawing with large brush sizes a lot faster. Once Godot 3.2.2 stable is released, the custom blend_rect method will be completely removed. --- src/Autoload/DrawingAlgos.gd | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Autoload/DrawingAlgos.gd b/src/Autoload/DrawingAlgos.gd index e2a8ac5cb..9303c4318 100644 --- a/src/Autoload/DrawingAlgos.gd +++ b/src/Autoload/DrawingAlgos.gd @@ -332,7 +332,14 @@ func blend_colors(color_1 : Color, color_2 : Color) -> Color: # Custom blend rect function, needed because Godot's issue #31124 +# The issue has been solved in Godot 3.2.2 and the method will be removed +# once 3.2.2 stable is released func blend_rect(bg : Image, brush : Image, src_rect : Rect2, dst : Vector2) -> void: + var godot_version = Engine.get_version_info() + if godot_version.major >= 3 and godot_version.minor >= 2 and godot_version.patch >= 2: + bg.blend_rect(brush, src_rect, dst) + return + var brush_size := brush.get_size() var clipped_src_rect := Rect2(Vector2.ZERO, brush_size).clip(src_rect) if clipped_src_rect.size.x <= 0 || clipped_src_rect.size.y <= 0: