From 6561f0e09bab16521ac0a32d397c21ec4b48a973 Mon Sep 17 00:00:00 2001 From: Matteo Piovanelli Date: Tue, 18 Jul 2023 00:36:57 +0200 Subject: [PATCH 1/2] Compress image data that is memorized for undo/redo operations --- src/Tools/Draw.gd | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Tools/Draw.gd b/src/Tools/Draw.gd index 0222842985bb..8a278e47ab73 100644 --- a/src/Tools/Draw.gd +++ b/src/Tools/Draw.gd @@ -209,10 +209,16 @@ func commit_undo() -> void: project.undos += 1 for image in redo_data: - project.undo_redo.add_do_property(image, "data", redo_data[image]) + var compressed_data = redo_data[image] + var buffer_size = compressed_data["data"].size() + compressed_data["data"] = compressed_data["data"].compress() + project.undo_redo.add_do_method(self, "undo_redo_draw_op", image, compressed_data, buffer_size) image.unlock() for image in _undo_data: - project.undo_redo.add_undo_property(image, "data", _undo_data[image]) + var compressed_data = _undo_data[image] + var buffer_size = compressed_data["data"].size() + compressed_data["data"] = compressed_data["data"].compress() + project.undo_redo.add_undo_method(self, "undo_redo_draw_op", image, compressed_data, buffer_size) project.undo_redo.add_do_method(Global, "undo_or_redo", false, frame, layer) project.undo_redo.add_undo_method(Global, "undo_or_redo", true, frame, layer) project.undo_redo.commit_action() @@ -220,6 +226,10 @@ func commit_undo() -> void: _undo_data.clear() +func undo_redo_draw_op(image: Object, compressed_image_data: Dictionary, buffer_size: int) -> void: + image["data"]["data"] = compressed_image_data["data"].decompress(buffer_size) + + func draw_tool(position: Vector2) -> void: if Global.mirror_view: # Even brushes are not perfectly centred and are offsetted by 1 px so we add it From f7f22728e534200ce9b99825485b4f5556a5c799 Mon Sep 17 00:00:00 2001 From: Matteo Piovanelli Date: Tue, 18 Jul 2023 00:41:41 +0200 Subject: [PATCH 2/2] Fixed formatting issues --- src/Tools/Draw.gd | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Tools/Draw.gd b/src/Tools/Draw.gd index 8a278e47ab73..6a9b0b124344 100644 --- a/src/Tools/Draw.gd +++ b/src/Tools/Draw.gd @@ -212,13 +212,17 @@ func commit_undo() -> void: var compressed_data = redo_data[image] var buffer_size = compressed_data["data"].size() compressed_data["data"] = compressed_data["data"].compress() - project.undo_redo.add_do_method(self, "undo_redo_draw_op", image, compressed_data, buffer_size) + project.undo_redo.add_do_method( + self, "undo_redo_draw_op", image, compressed_data, buffer_size + ) image.unlock() for image in _undo_data: var compressed_data = _undo_data[image] var buffer_size = compressed_data["data"].size() compressed_data["data"] = compressed_data["data"].compress() - project.undo_redo.add_undo_method(self, "undo_redo_draw_op", image, compressed_data, buffer_size) + project.undo_redo.add_undo_method( + self, "undo_redo_draw_op", image, compressed_data, buffer_size + ) project.undo_redo.add_do_method(Global, "undo_or_redo", false, frame, layer) project.undo_redo.add_undo_method(Global, "undo_or_redo", true, frame, layer) project.undo_redo.commit_action()