Lua: Running a script no longer systematically take an history step ('Undo/Redo'). This backup is now only performed on the first time that an image-modifying function is called, and only on layers/frames that need it. Also fix up selectlayer() a little.

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@2052 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud
2013-02-07 00:13:11 +00:00
parent ee83b59464
commit 37007e7a7b
3 changed files with 172 additions and 23 deletions

View File

@@ -1140,6 +1140,26 @@ void Backup_layers(int layer)
*/
}
/// Backs up a layer, unless it's already different from previous history step.
// This function checks if a layer/frame shares the same
// bitmap as its Undo history parent.
// If this is the case, it instanciates a new copy, and returns true.
// Otherwise, it returns false.
int Dup_layer_if_shared(T_Page * page, int layer)
{
if (page->Image[layer].Pixels == page->Next->Image[layer].Pixels)
{
Free_layer(page, layer);
page->Image[layer].Pixels=New_layer(page->Height*page->Width);
memcpy(
page->Image[layer].Pixels,
page->Next->Image[layer].Pixels,
page->Width*page->Height);
return 1;
}
return 0;
}
void Backup_the_spare(int layer)
{
int i;