Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/Tools/Draw.gd
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,31 @@ 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()

_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
Expand Down