[layers] Sped up the switching from one active layer to another, when the new layer was already displayed (thanks to the depth buffer, again)
git-svn-id: svn://pulkomandy.tk/GrafX2/branches/layers@1049 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
20b1aef7f5
commit
9be9ed9c17
12
buttons.c
12
buttons.c
@ -2879,6 +2879,7 @@ void Load_picture(byte image)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Compute_optimal_menu_colors(Main_palette);
|
Compute_optimal_menu_colors(Main_palette);
|
||||||
|
Redraw_layered_image();
|
||||||
Display_all_screen();
|
Display_all_screen();
|
||||||
|
|
||||||
if (image)
|
if (image)
|
||||||
@ -2980,7 +2981,7 @@ void Button_Reload(void)
|
|||||||
Compute_limits();
|
Compute_limits();
|
||||||
Compute_paintbrush_coordinates();
|
Compute_paintbrush_coordinates();
|
||||||
}
|
}
|
||||||
|
Redraw_layered_image();
|
||||||
Display_all_screen();
|
Display_all_screen();
|
||||||
|
|
||||||
Main_image_is_modified=0;
|
Main_image_is_modified=0;
|
||||||
@ -4260,6 +4261,10 @@ void Transparency_set(byte amount)
|
|||||||
|
|
||||||
void Layer_activate(short layer, short side)
|
void Layer_activate(short layer, short side)
|
||||||
{
|
{
|
||||||
|
byte old_layers;
|
||||||
|
|
||||||
|
// Keep a copy of which layers were visible
|
||||||
|
old_layers = Main_layers_visible;
|
||||||
if (side == RIGHT_SIDE)
|
if (side == RIGHT_SIDE)
|
||||||
{
|
{
|
||||||
// Right-click on current layer
|
// Right-click on current layer
|
||||||
@ -4290,7 +4295,10 @@ void Layer_activate(short layer, short side)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Hide_cursor();
|
Hide_cursor();
|
||||||
Redraw_layered_image();
|
if (Main_layers_visible != old_layers)
|
||||||
|
Redraw_layered_image();
|
||||||
|
else
|
||||||
|
Update_depth_buffer(); // Only need the depth buffer
|
||||||
//Download_infos_page_main(Main_backups->Pages);
|
//Download_infos_page_main(Main_backups->Pages);
|
||||||
//Download_infos_backup(Main_backups);
|
//Download_infos_backup(Main_backups);
|
||||||
Display_all_screen();
|
Display_all_screen();
|
||||||
|
|||||||
45
pages.c
45
pages.c
@ -191,6 +191,51 @@ void Redraw_layered_image(void)
|
|||||||
Download_infos_backup(Main_backups);
|
Download_infos_backup(Main_backups);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Update_depth_buffer(void)
|
||||||
|
{
|
||||||
|
// Re-construct the depth buffer with the visible layers.
|
||||||
|
// This function doesn't touch the visible buffer, it assumes
|
||||||
|
// that it was already up-to-date. (Ex. user only changed active layer)
|
||||||
|
|
||||||
|
int layer;
|
||||||
|
// First layer
|
||||||
|
for (layer=0; layer<Main_backups->Pages->Nb_layers; layer++)
|
||||||
|
{
|
||||||
|
if ((1<<layer) & Main_layers_visible)
|
||||||
|
{
|
||||||
|
// Initialize the depth buffer
|
||||||
|
memset(Visible_image_depth_buffer.Image,
|
||||||
|
layer,
|
||||||
|
Main_image_width*Main_image_height);
|
||||||
|
|
||||||
|
// skip all other layers
|
||||||
|
layer++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// subsequent layer(s)
|
||||||
|
for (; layer<Main_backups->Pages->Nb_layers; layer++)
|
||||||
|
{
|
||||||
|
// skip the current layer, whenever we reach it
|
||||||
|
if (layer == Main_current_layer)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ((1<<layer) & Main_layers_visible)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i=0; i<Main_image_width*Main_image_height; i++)
|
||||||
|
{
|
||||||
|
byte color = *(Main_backups->Pages->Image[layer]+i);
|
||||||
|
if (color != 0) /* transp color */
|
||||||
|
{
|
||||||
|
*(Visible_image_depth_buffer.Image+i) = layer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Download_infos_backup(Main_backups);
|
||||||
|
}
|
||||||
|
|
||||||
void Redraw_current_layer(void)
|
void Redraw_current_layer(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
4
pages.h
4
pages.h
@ -82,4 +82,8 @@ void Free_current_page(void); // 'Kill' button
|
|||||||
void Exchange_main_and_spare(void);
|
void Exchange_main_and_spare(void);
|
||||||
void End_of_modification(void);
|
void End_of_modification(void);
|
||||||
|
|
||||||
|
void Update_depth_buffer(void);
|
||||||
|
void Redraw_layered_image(void);
|
||||||
|
void Redraw_current_layer(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user