Skip to content

Commit

Permalink
Do not run update_mask() method if there is no pressure sensitivity o…
Browse files Browse the repository at this point in the history
…ption

Major speedup for large images. update_mask() is meant for pen pressure only, so there is no reason to calculate it if we don't have pressure sensitivity enabled
  • Loading branch information
OverloadedOrama committed Apr 1, 2021
1 parent 943a69c commit 6cce27a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Tools/Draw.gd
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ func update_mirror_brush() -> void:


func update_mask() -> void:
if Global.pressure_sensitivity_mode == Global.PressureSensitivity.NONE:
return
var size := _get_draw_image().get_size()
# Faster than zeroing PoolByteArray directly. See: https://github.com/Orama-Interactive/Pixelorama/pull/439
var nulled_array := []
Expand Down Expand Up @@ -345,8 +347,11 @@ func _set_pixel(position : Vector2) -> void:

var image := _get_draw_image()
var i := int(position.x + position.y * image.get_size().x)
if _mask[i] < Tools.pen_pressure:
_mask[i] = Tools.pen_pressure
if Global.pressure_sensitivity_mode != Global.PressureSensitivity.NONE:
if _mask[i] < Tools.pen_pressure:
_mask[i] = Tools.pen_pressure
_drawer.set_pixel(image, position, tool_slot.color)
else:
_drawer.set_pixel(image, position, tool_slot.color)


Expand Down

0 comments on commit 6cce27a

Please sign in to comment.