mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
Optimize canvas drawing by only calling update when the image has changed
This commit is contained in:
parent
ac1a438890
commit
ac6a4db43d
|
@ -76,6 +76,7 @@ onready var object_properties := {
|
|||
func sprite_changed_this_frame():
|
||||
_checker_update_qued = true
|
||||
_old_cel_image = _cel.get_image()
|
||||
Global.canvas.sprite_changed_this_frame = true
|
||||
|
||||
|
||||
func _input(_event: InputEvent) -> void:
|
||||
|
|
|
@ -46,6 +46,7 @@ func draw_start(position: Vector2) -> void:
|
|||
if Global.current_project.has_selection:
|
||||
selection_node.transform_content_start()
|
||||
_content_transformation_check = selection_node.is_moving_content
|
||||
Global.canvas.sprite_changed_this_frame = true
|
||||
|
||||
|
||||
func draw_move(position: Vector2) -> void:
|
||||
|
@ -63,6 +64,7 @@ func draw_move(position: Vector2) -> void:
|
|||
else:
|
||||
Global.canvas.move_preview_location = position - _start_pos
|
||||
_offset = position
|
||||
Global.canvas.sprite_changed_this_frame = true
|
||||
|
||||
|
||||
func draw_end(position: Vector2) -> void:
|
||||
|
@ -92,6 +94,7 @@ func draw_end(position: Vector2) -> void:
|
|||
|
||||
_start_pos = Vector2.INF
|
||||
_snap_to_grid = false
|
||||
Global.canvas.sprite_changed_this_frame = true
|
||||
|
||||
|
||||
func _snap_position(position: Vector2) -> Vector2:
|
||||
|
|
|
@ -93,14 +93,12 @@ func _input(event: InputEvent) -> void:
|
|||
var tmp_transform := get_canvas_transform().affine_inverse()
|
||||
current_pixel = tmp_transform.basis_xform(tmp_position) + tmp_transform.origin
|
||||
|
||||
if Global.has_focus:
|
||||
update()
|
||||
|
||||
sprite_changed_this_frame = false
|
||||
|
||||
Tools.handle_draw(current_pixel.floor(), event)
|
||||
|
||||
if sprite_changed_this_frame:
|
||||
if Global.has_focus:
|
||||
update()
|
||||
update_selected_cels_textures()
|
||||
|
||||
|
||||
|
|
|
@ -396,6 +396,7 @@ func resize_selection() -> void:
|
|||
Global.current_project.selection_map = selection_map_copy
|
||||
Global.current_project.selection_map_changed()
|
||||
update()
|
||||
Global.canvas.update()
|
||||
|
||||
|
||||
func _gizmo_rotate() -> void: # Does not work properly yet
|
||||
|
@ -430,6 +431,7 @@ func _gizmo_rotate() -> void: # Does not work properly yet
|
|||
Global.current_project.selection_map_changed()
|
||||
self.big_bounding_rectangle = bitmap_image.get_used_rect()
|
||||
update()
|
||||
Global.canvas.update()
|
||||
|
||||
|
||||
func select_rect(rect: Rect2, operation: int = SelectionOperation.ADD) -> void:
|
||||
|
@ -482,6 +484,7 @@ func move_borders(move: Vector2) -> void:
|
|||
marching_ants_outline.offset += move
|
||||
self.big_bounding_rectangle.position += move
|
||||
update()
|
||||
Global.canvas.update()
|
||||
|
||||
|
||||
func move_borders_end() -> void:
|
||||
|
@ -494,6 +497,7 @@ func move_borders_end() -> void:
|
|||
else:
|
||||
Global.current_project.selection_map_changed()
|
||||
update()
|
||||
Global.canvas.update()
|
||||
|
||||
|
||||
func transform_content_start() -> void:
|
||||
|
@ -510,6 +514,7 @@ func transform_content_start() -> void:
|
|||
original_big_bounding_rectangle = big_bounding_rectangle
|
||||
original_offset = Global.current_project.selection_offset
|
||||
update()
|
||||
Global.canvas.update()
|
||||
|
||||
|
||||
func move_content(move: Vector2) -> void:
|
||||
|
@ -554,6 +559,7 @@ func transform_content_confirm() -> void:
|
|||
is_moving_content = false
|
||||
is_pasting = false
|
||||
update()
|
||||
Global.canvas.update()
|
||||
|
||||
|
||||
func transform_content_cancel() -> void:
|
||||
|
@ -584,6 +590,7 @@ func transform_content_cancel() -> void:
|
|||
original_bitmap = SelectionMap.new()
|
||||
is_pasting = false
|
||||
update()
|
||||
Global.canvas.update()
|
||||
|
||||
|
||||
func commit_undo(action: String, undo_data_tmp: Dictionary) -> void:
|
||||
|
|
Loading…
Reference in a new issue