1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-20 12:33:14 +00:00

Compress image data that is memorized for undo/redo operations (#890)

* Compress image data that is memorized for undo/redo operations

* Fixed formatting issues
This commit is contained in:
Matteo Piovanelli 2023-07-18 19:39:36 +02:00 committed by GitHub
parent e195e32e00
commit 8fd306b734
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -209,10 +209,20 @@ 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 +230,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