Fix Fill, Polyform/Polyline, and Contour fill when using effects (Transparency) with layers: it was reading from all visible layers instead of only current, so the result kind of 'fused' the pixels. Related to issue 245.

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1286 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2010-01-28 02:48:56 +00:00
parent 259a3d3338
commit 62cc506737
6 changed files with 32 additions and 33 deletions

View File

@ -4289,12 +4289,8 @@ void Button_Effects(void)
Display_cursor(); Display_cursor();
break; break;
case 13 : // Feedback (pour Colorize et Shade) case 13 : // Feedback (pour Colorize et Shade)
if ((Config.FX_Feedback=!Config.FX_Feedback)) //!!! Config.FX_Feedback = !Config.FX_Feedback;
FX_feedback_screen=Main_backups->Pages->Image[Main_current_layer]; Update_FX_feedback(Config.FX_Feedback);
// Main_screen
else
FX_feedback_screen=Main_backups->Pages->Next->Image[Main_current_layer];
// Screen_backup
Hide_cursor(); Hide_cursor();
Display_feedback_state(); Display_feedback_state();
Display_cursor(); Display_cursor();

View File

@ -609,12 +609,6 @@ GFX2_GLOBAL struct
/// Current effecting function. When no effect is selected this is ::No_effect() /// Current effecting function. When no effect is selected this is ::No_effect()
GFX2_GLOBAL Func_effect Effect_function; GFX2_GLOBAL Func_effect Effect_function;
///
/// Pointer to the image to read, while drawing. It's either ::Main_screen
/// (the image you draw) when FX feedback is ON, or ::Screen_backup (a backup
/// copy) when FX feedback is off.
GFX2_GLOBAL byte * FX_feedback_screen;
/// ///
/// Array of booleans, indicates which colors should never be picked by /// Array of booleans, indicates which colors should never be picked by
/// ::Best_color() /// ::Best_color()

15
graph.c
View File

@ -934,7 +934,6 @@ void Fill_general(byte fill_color)
// //
{ {
byte cursor_shape_before_fill; byte cursor_shape_before_fill;
byte * old_fx_feedback_screen;
short x_pos,y_pos; short x_pos,y_pos;
short top_reached ,bottom_reached; short top_reached ,bottom_reached;
short left_reached,right_reached; short left_reached,right_reached;
@ -962,8 +961,7 @@ void Fill_general(byte fill_color)
Backup(); Backup();
// On fait attention au Feedback qui DOIT se faire avec le backup. // On fait attention au Feedback qui DOIT se faire avec le backup.
old_fx_feedback_screen=FX_feedback_screen; Update_FX_feedback(0);
FX_feedback_screen=Screen_backup;
// On va maintenant "épurer" la zone visible de l'image: // On va maintenant "épurer" la zone visible de l'image:
memset(replace_table,0,256); memset(replace_table,0,256);
@ -1032,7 +1030,8 @@ void Fill_general(byte fill_color)
else else
Pixel_in_current_screen(x_pos,y_pos,Read_pixel_from_backup_layer(x_pos,y_pos),0); Pixel_in_current_screen(x_pos,y_pos,Read_pixel_from_backup_layer(x_pos,y_pos),0);
FX_feedback_screen=old_fx_feedback_screen; // Restore original feedback value
Update_FX_feedback(Config.FX_Feedback);
// A la fin, on n'a pas besoin de réafficher le curseur puisque c'est // A la fin, on n'a pas besoin de réafficher le curseur puisque c'est
// l'appelant qui s'en charge, et on n'a pas besoin de rafficher l'image // l'appelant qui s'en charge, et on n'a pas besoin de rafficher l'image
@ -2541,7 +2540,6 @@ void Polyfill_general(int vertices, short * points, int color)
void Polyfill(int vertices, short * points, int color) void Polyfill(int vertices, short * points, int color)
{ {
int index; int index;
byte *old_fx_feedback_screen;
Pixel_clipped(points[0],points[1],color); Pixel_clipped(points[0],points[1],color);
if (vertices==1) if (vertices==1)
@ -2552,8 +2550,7 @@ void Polyfill(int vertices, short * points, int color)
// Comme pour le Fill, cette operation fait un peu d'"overdraw" // Comme pour le Fill, cette operation fait un peu d'"overdraw"
// (pixels dessinés plus d'une fois) alors on force le FX Feedback à OFF // (pixels dessinés plus d'une fois) alors on force le FX Feedback à OFF
old_fx_feedback_screen=FX_feedback_screen; Update_FX_feedback(0);
FX_feedback_screen=Screen_backup;
Pixel_figure=Pixel_clipped; Pixel_figure=Pixel_clipped;
Polyfill_general(vertices,points,color); Polyfill_general(vertices,points,color);
@ -2567,8 +2564,8 @@ void Polyfill(int vertices, short * points, int color)
Draw_line_general(points[index*2],points[index*2+1],points[index*2+2],points[index*2+3],color); Draw_line_general(points[index*2],points[index*2+1],points[index*2+2],points[index*2+3],color);
Draw_line_general(points[0],points[1],points[index*2],points[index*2+1],color); Draw_line_general(points[0],points[1],points[index*2],points[index*2+1],color);
// restore de l'etat du FX Feedback // Restore original feedback value
FX_feedback_screen=old_fx_feedback_screen; Update_FX_feedback(Config.FX_Feedback);
} }

View File

@ -83,7 +83,7 @@ void Layer_activate(byte layer, short side)
else else
Update_depth_buffer(); // Only need the depth buffer 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); //Update_FX_feedback(Config.FX_Feedback);
Display_all_screen(); Display_all_screen();
Display_layerbar(); Display_layerbar();
Display_cursor(); Display_cursor();

22
pages.c
View File

@ -218,7 +218,7 @@ void Redraw_layered_image(void)
#else #else
Update_screen_targets(); Update_screen_targets();
#endif #endif
Download_infos_backup(Main_backups); Update_FX_feedback(Config.FX_Feedback);
} }
void Update_depth_buffer(void) void Update_depth_buffer(void)
@ -265,7 +265,7 @@ void Update_depth_buffer(void)
} }
} }
#endif #endif
Download_infos_backup(Main_backups); Update_FX_feedback(Config.FX_Feedback);
} }
void Redraw_spare_image(void) void Redraw_spare_image(void)
@ -374,13 +374,15 @@ void Upload_infos_page_spare(T_Page * page)
} }
} }
void Download_infos_backup(T_List_of_pages * list) byte * FX_feedback_screen;
void Update_FX_feedback(byte with_feedback)
{ {
if (Config.FX_Feedback) if (with_feedback)
FX_feedback_screen=list->Pages->Image[Main_current_layer]; FX_feedback_screen=Main_backups->Pages->Image[Main_current_layer];
else else
FX_feedback_screen=list->Pages->Next->Image[Main_current_layer]; FX_feedback_screen=Main_backups->Pages->Next->Image[Main_current_layer];
} }
void Clear_page(T_Page * page) void Clear_page(T_Page * page)
@ -732,7 +734,7 @@ int Init_all_backup_lists(int width,int height)
#endif #endif
Download_infos_page_main(Main_backups->Pages); Download_infos_page_main(Main_backups->Pages);
Download_infos_backup(Main_backups); Update_FX_feedback(Config.FX_Feedback);
// Default values for spare page // Default values for spare page
Spare_backups->Pages->Width = width; Spare_backups->Pages->Width = width;
@ -818,7 +820,7 @@ int Backup_with_new_dimensions(int upload,byte layers,int width,int height)
#else #else
Update_screen_targets(); Update_screen_targets();
#endif #endif
Download_infos_backup(Main_backups); Update_FX_feedback(Config.FX_Feedback);
// -- // --
return_code=1; return_code=1;
@ -904,7 +906,7 @@ void Backup_layers(dword layer_mask)
Create_new_page(new_page,Main_backups,layer_mask); Create_new_page(new_page,Main_backups,layer_mask);
Download_infos_page_main(new_page); Download_infos_page_main(new_page);
Download_infos_backup(Main_backups); Update_FX_feedback(Config.FX_Feedback);
// Copy the actual pixels from the backup to the latest page // Copy the actual pixels from the backup to the latest page
for (i=0; i<Main_backups->Pages->Nb_layers;i++) for (i=0; i<Main_backups->Pages->Nb_layers;i++)
@ -1080,7 +1082,7 @@ void End_of_modification(void)
Update_screen_targets(); Update_screen_targets();
#endif #endif
Download_infos_backup(Main_backups); Update_FX_feedback(Config.FX_Feedback);
/* /*
Last_backed_up_layers = 0; Last_backed_up_layers = 0;
Backup(); Backup();

12
pages.h
View File

@ -27,6 +27,13 @@
#ifndef _PAGES_H_ #ifndef _PAGES_H_
#define _PAGES_H_ #define _PAGES_H_
///
/// Pointer to the image to read, while drawing. It's either the last history
/// layer page when FX feedback is on, or the history page before it
/// when FX feedback is off.
extern byte * FX_feedback_screen;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/////////////////////////// BACKUP /////////////////////////////////////// /////////////////////////// BACKUP ///////////////////////////////////////
@ -59,7 +66,6 @@ byte Merge_layer();
T_Page * New_page(byte nb_layers); T_Page * New_page(byte nb_layers);
void Download_infos_page_spare(T_Page * page); void Download_infos_page_spare(T_Page * page);
void Upload_infos_page_spare(T_Page * page); void Upload_infos_page_spare(T_Page * page);
void Download_infos_backup(T_List_of_pages * list);
void Clear_page(T_Page * page); void Clear_page(T_Page * page);
void Copy_S_page(T_Page * dest,T_Page * source); void Copy_S_page(T_Page * dest,T_Page * source);
@ -110,6 +116,10 @@ void Update_screen_targets(void);
int Update_buffers(int width, int height); int Update_buffers(int width, int height);
int Update_spare_buffers(int width, int height); int Update_spare_buffers(int width, int height);
void Redraw_spare_image(void); void Redraw_spare_image(void);
///
/// Must be called after changing the head of Main_backups list, or
/// Main_current_layer
void Update_FX_feedback(byte with_feedback);
/// ///
/// STATISTICS /// STATISTICS