mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Compress image data saved in undo/redo for image effects, buckets and selection transformations
This commit is contained in:
parent
1a1d82ab3a
commit
e62548517f
|
@ -856,6 +856,23 @@ func path_join_array(basepaths: PackedStringArray, subpath: String) -> PackedStr
|
|||
return res
|
||||
|
||||
|
||||
func undo_redo_compress_images(redo_data: Dictionary, undo_data: Dictionary, project := current_project) -> void:
|
||||
for image in redo_data:
|
||||
if not image is Image:
|
||||
continue
|
||||
var buffer_size: int = redo_data[image]["data"].size()
|
||||
var compressed_data: PackedByteArray = redo_data[image]["data"].compress()
|
||||
project.undo_redo.add_do_method(undo_redo_draw_op.bind(image, compressed_data, buffer_size))
|
||||
for image in undo_data:
|
||||
if not image is Image:
|
||||
continue
|
||||
var buffer_size: int = undo_data[image]["data"].size()
|
||||
var compressed_data: PackedByteArray = undo_data[image]["data"].compress()
|
||||
project.undo_redo.add_undo_method(
|
||||
undo_redo_draw_op.bind(image, compressed_data, buffer_size)
|
||||
)
|
||||
|
||||
|
||||
## Decompresses the [param compressed_image_data] with [params buffer_size] to the [param image]
|
||||
## This is an opmization method used by [param Draw.gd] while performing undo/redo.
|
||||
func undo_redo_draw_op(
|
||||
|
|
|
@ -148,10 +148,7 @@ func _commit_undo(action: String, undo_data: Dictionary, project: Project) -> vo
|
|||
var redo_data := _get_undo_data(project)
|
||||
project.undos += 1
|
||||
project.undo_redo.create_action(action)
|
||||
for image in redo_data:
|
||||
project.undo_redo.add_do_property(image, "data", redo_data[image])
|
||||
for image in undo_data:
|
||||
project.undo_redo.add_undo_property(image, "data", undo_data[image])
|
||||
Global.undo_redo_compress_images(redo_data, undo_data, project)
|
||||
project.undo_redo.add_do_method(Global.undo_or_redo.bind(false, -1, -1, project))
|
||||
project.undo_redo.add_undo_method(Global.undo_or_redo.bind(true, -1, -1, project))
|
||||
project.undo_redo.commit_action()
|
||||
|
|
|
@ -483,10 +483,7 @@ func commit_undo(action: String, undo_data: Dictionary) -> void:
|
|||
|
||||
project.undos += 1
|
||||
project.undo_redo.create_action(action)
|
||||
for image in redo_data:
|
||||
project.undo_redo.add_do_property(image, "data", redo_data[image])
|
||||
for image in undo_data:
|
||||
project.undo_redo.add_undo_property(image, "data", undo_data[image])
|
||||
Global.undo_redo_compress_images(redo_data, undo_data, project)
|
||||
project.undo_redo.add_do_method(Global.undo_or_redo.bind(false, frame, layer))
|
||||
project.undo_redo.add_undo_method(Global.undo_or_redo.bind(true, frame, layer))
|
||||
project.undo_redo.commit_action()
|
||||
|
|
|
@ -213,20 +213,7 @@ func commit_undo() -> void:
|
|||
layer = project.current_layer
|
||||
|
||||
project.undos += 1
|
||||
for image in redo_data:
|
||||
var compressed_data: Dictionary = redo_data[image]
|
||||
var buffer_size: int = compressed_data["data"].size()
|
||||
compressed_data["data"] = compressed_data["data"].compress()
|
||||
project.undo_redo.add_do_method(
|
||||
Global.undo_redo_draw_op.bind(image, compressed_data["data"], buffer_size)
|
||||
)
|
||||
for image in _undo_data:
|
||||
var compressed_data: Dictionary = _undo_data[image]
|
||||
var buffer_size: int = compressed_data["data"].size()
|
||||
compressed_data["data"] = compressed_data["data"].compress()
|
||||
project.undo_redo.add_undo_method(
|
||||
Global.undo_redo_draw_op.bind(image, compressed_data["data"], buffer_size)
|
||||
)
|
||||
Global.undo_redo_compress_images(redo_data, _undo_data, project)
|
||||
project.undo_redo.add_do_method(Global.undo_or_redo.bind(false, frame, layer))
|
||||
project.undo_redo.add_undo_method(Global.undo_or_redo.bind(true, frame, layer))
|
||||
project.undo_redo.commit_action()
|
||||
|
|
|
@ -610,14 +610,7 @@ func commit_undo(action: String, undo_data_tmp: Dictionary) -> void:
|
|||
)
|
||||
|
||||
if undo_data_tmp["undo_image"]:
|
||||
for image in redo_data:
|
||||
if not image is Image:
|
||||
continue
|
||||
project.undo_redo.add_do_property(image, "data", redo_data[image])
|
||||
for image in undo_data_tmp:
|
||||
if not image is Image:
|
||||
continue
|
||||
project.undo_redo.add_undo_property(image, "data", undo_data_tmp[image])
|
||||
Global.undo_redo_compress_images(redo_data, undo_data_tmp, project)
|
||||
project.undo_redo.add_do_method(Global.undo_or_redo.bind(false))
|
||||
project.undo_redo.add_do_method(project.selection_map_changed)
|
||||
project.undo_redo.add_undo_method(Global.undo_or_redo.bind(true))
|
||||
|
|
Loading…
Reference in a new issue