From abb6204757fe0dcc94aefa41528ab54cc0160ea4 Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Wed, 14 Oct 2009 00:13:49 +0000 Subject: [PATCH] [layers] Limited to 32 layers. (previously there was no limit and the 16-bit depth buffer wrapped). Fixed a display bug after picture transforms or layers add/del. git-svn-id: svn://pulkomandy.tk/GrafX2/branches/layers@1075 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- engine.c | 2 ++ global.h | 4 ++-- main.c | 4 ++-- pages.c | 26 +++++++++++++++----------- pages.h | 4 ++-- special.c | 4 ++-- transform.c | 1 + 7 files changed, 26 insertions(+), 19 deletions(-) diff --git a/engine.c b/engine.c index 2c2f9df1..ae230458 100644 --- a/engine.c +++ b/engine.c @@ -1042,6 +1042,7 @@ void Main_handler(void) Hide_cursor(); Display_all_screen(); Display_cursor(); + End_of_modification(); } action++; break; @@ -1054,6 +1055,7 @@ void Main_handler(void) Hide_cursor(); Display_all_screen(); Display_cursor(); + End_of_modification(); } action++; break; diff --git a/global.h b/global.h index 9f98c0c3..e7104a12 100644 --- a/global.h +++ b/global.h @@ -348,7 +348,7 @@ GFX2_GLOBAL short Main_magnifier_offset_Y; /// Index of layer currently being edited GFX2_GLOBAL int Main_current_layer; /// Bitfield that records which layers are visible. 2^0 for 0, 2^1 for 1, 2^2 for 2, etc. -GFX2_GLOBAL word Main_layers_visible; +GFX2_GLOBAL dword Main_layers_visible; // -- Spare page data @@ -412,7 +412,7 @@ GFX2_GLOBAL short Spare_magnifier_offset_Y; /// Index of layer currently being edited GFX2_GLOBAL short Spare_current_layer; /// Bitfield that records which layers are visible. 2^0 for 0, 2^1 for 1, 2^2 for 2, etc. -GFX2_GLOBAL word Spare_layers_visible; +GFX2_GLOBAL dword Spare_layers_visible; // -- Image backups /// Backup of the current screen, used during drawing when FX feedback is OFF. diff --git a/main.c b/main.c index 650563a6..2daddfbb 100644 --- a/main.c +++ b/main.c @@ -370,9 +370,9 @@ int Init_program(int argc,char * argv[]) Main_fileselector_offset=0; // Au début, le fileselect est en haut de la liste des fichiers Main_format=0; Main_current_layer=0; - Main_layers_visible=0xFFFF; + Main_layers_visible=0xFFFFFFFF; Spare_current_layer=0; - Spare_layers_visible=0xFFFF; + Spare_layers_visible=0xFFFFFFFF; Spare_fileselector_position=0; Spare_fileselector_offset=0; diff --git a/pages.c b/pages.c index c449815f..e591b5c0 100644 --- a/pages.c +++ b/pages.c @@ -36,7 +36,7 @@ /// /// Bitfield which records which layers are backed up in Page 0. -static word Last_backed_up_layers=0; +static dword Last_backed_up_layers=0; /// Total number of unique bitmaps (layers, animation frames, backups) long Stats_pages_number=0; @@ -483,7 +483,7 @@ void Free_last_page_of_list(T_List_of_pages * list) } // layer_mask tells which layers have to be fresh copies instead of references -int Create_new_page(T_Page * new_page, T_List_of_pages * list, word layer_mask) +int Create_new_page(T_Page * new_page, T_List_of_pages * list, dword layer_mask) { // Cette fonction crée une nouvelle page dont les attributs correspondent à @@ -697,7 +697,7 @@ int Backup_with_new_dimensions(int upload,byte layers,int width,int height) Upload_infos_page_main(new_page); new_page->Width=width; new_page->Height=height; - if (Create_new_page(new_page,Main_backups,0xFFFF)) + if (Create_new_page(new_page,Main_backups,0xFFFFFFFF)) { for (i=0; iWidth=width; new_page->Height=height; - if (Create_new_page(new_page,Spare_backups,0xFFFF)) + if (Create_new_page(new_page,Spare_backups,0xFFFFFFFF)) { byte i; @@ -764,7 +764,7 @@ void Backup(void) Backup_layers(1<Pages; + + // Hard limit of 32 at the moment, because layer bitmasks are 32bit. + if (list->Pages->Nb_layers == 32) + return 1; // Keep the position reasonable if (layer > list->Pages->Nb_layers) @@ -987,9 +991,9 @@ byte Add_layer(T_List_of_pages *list, byte layer) // Update the flags of visible layers. { - word layers_before; - word layers_after; - word *visible_layers_flag; + dword layers_before; + dword layers_after; + dword *visible_layers_flag; // Determine if we're modifying the spare or the main page. if (list == Main_backups) @@ -1048,9 +1052,9 @@ byte Delete_layer(T_List_of_pages *list, byte layer) // Update the flags of visible layers. { - word layers_before; - word layers_after; - word *visible_layers_flag; + dword layers_before; + dword layers_after; + dword *visible_layers_flag; byte new_current_layer; // Determine if we're modifying the spare or the main page. diff --git a/pages.h b/pages.h index 51c3c7b2..691ff668 100644 --- a/pages.h +++ b/pages.h @@ -62,7 +62,7 @@ int Allocate_list_of_pages(T_List_of_pages * list); void Backward_in_list_of_pages(T_List_of_pages * list); void Advance_in_list_of_pages(T_List_of_pages * list); void Free_last_page_of_list(T_List_of_pages * list); -int Create_new_page(T_Page * new_page,T_List_of_pages * current_list, word layer_mask); +int Create_new_page(T_Page * new_page,T_List_of_pages * current_list, dword layer_mask); void Change_page_number_of_list(T_List_of_pages * list,int number); void Free_page_of_a_list(T_List_of_pages * list); @@ -79,7 +79,7 @@ int Backup_and_resize_the_spare(int width,int height); /// Backup with a new copy for the working layer, and references for all others. void Backup(void); /// Backup with a new copy of some layers (the others are references). -void Backup_layers(word layer_mask); +void Backup_layers(dword layer_mask); void Undo(void); void Redo(void); void Free_current_page(void); // 'Kill' button diff --git a/special.c b/special.c index 06f17e7e..5b29f155 100644 --- a/special.c +++ b/special.c @@ -481,10 +481,10 @@ void Layer_activate(short layer, short side) // Right-click on current layer if (Main_current_layer == layer) { - if (Main_layers_visible == (1<