1
0
Fork 0
forked from Miroirs/x49gp

Compare commits

...

2 commits

Author SHA1 Message Date
Gwenhael Le Moine
c9191b6c00
draw pixel using cairo_rectangle 2024-10-29 18:13:12 +01:00
Gwenhael Le Moine
b179f88451
pretty code 2024-10-29 18:12:33 +01:00
3 changed files with 27 additions and 32 deletions

View file

@ -97,8 +97,8 @@ static inline void __list_del( struct list_head* prev, struct list_head* next )
static inline void list_del( struct list_head* entry )
{
__list_del( entry->prev, entry->next );
entry->next = (struct list_head*)LIST_POISON1;
entry->prev = (struct list_head*)LIST_POISON2;
entry->next = ( struct list_head* )LIST_POISON1;
entry->prev = ( struct list_head* )LIST_POISON2;
}
/**
@ -391,8 +391,8 @@ static inline void __hlist_del( struct hlist_node* n )
static inline void hlist_del( struct hlist_node* n )
{
__hlist_del( n );
n->next = (struct hlist_node*)LIST_POISON1;
n->pprev = (struct hlist_node**)LIST_POISON2;
n->next = ( struct hlist_node* )LIST_POISON1;
n->pprev = ( struct hlist_node** )LIST_POISON2;
}
/**
@ -417,7 +417,7 @@ static inline void hlist_del( struct hlist_node* n )
static inline void hlist_del_rcu( struct hlist_node* n )
{
__hlist_del( n );
n->pprev = (struct hlist_node**)LIST_POISON2;
n->pprev = ( struct hlist_node** )LIST_POISON2;
}
static inline void hlist_del_init( struct hlist_node* n )

View file

@ -283,20 +283,20 @@ static int x49gp_get_pixel_color( s3c2410_lcd_t* lcd, int x, int y )
void x49gp_draw_rectangle( GdkPixmap* target, int x, int y, int w, int h, GdkColor* color )
{
cairo_t* cr = gdk_cairo_create (target);
cairo_set_source_rgb( cr, color->red, color->green, color->blue );
cairo_t* cr = gdk_cairo_create( target );
cairo_rectangle (cr, x, y, w, h );
cairo_fill (cr);
cairo_set_source_rgb( cr, color->red / 65535.0, color->green / 65535.0, color->blue / 65535.0 );
cairo_rectangle( cr, x, y, w, h );
cairo_fill( cr );
cairo_destroy (cr);
cairo_destroy( cr );
}
void x49gp_lcd_update( x49gp_t* x49gp )
{
x49gp_ui_t* ui = x49gp->ui;
s3c2410_lcd_t* lcd = x49gp->s3c2410_lcd;
//cairo_t* cr;
// cairo_t* cr;
gdk_draw_drawable( ui->lcd_pixmap, gtk_widget_get_style( ui->window )->bg_gc[ 0 ], ui->bg_pixmap, ui->lcd_x_offset, ui->lcd_y_offset, 0,
0, ui->lcd_width, ui->lcd_height );
@ -308,6 +308,11 @@ void x49gp_lcd_update( x49gp_t* x49gp )
gdk_gc_set_rgb_fg_color( ui->ann_left_gc, &( ui->colors[ UI_COLOR_GRAYSCALE_0 + color ] ) );
gdk_draw_rectangle( ui->lcd_pixmap, ui->ann_left_gc, true, 11, 0, 15, 12 );
/* cr = gdk_cairo_create( ui->ann_left ); */
/* gdk_cairo_set_source_pixbuf( cr, ui->lcd_pixmap, 11, 0 ); */
/* cairo_paint( cr ); */
/* cairo_destroy( cr ); */
color = x49gp_get_pixel_color( lcd, 131, 2 );
gdk_gc_set_rgb_fg_color( ui->ann_right_gc, &( ui->colors[ UI_COLOR_GRAYSCALE_0 + color ] ) );
gdk_draw_rectangle( ui->lcd_pixmap, ui->ann_right_gc, true, 56, 0, 15, 12 );
@ -328,21 +333,11 @@ void x49gp_lcd_update( x49gp_t* x49gp )
gdk_gc_set_rgb_fg_color( ui->ann_io_gc, &( ui->colors[ UI_COLOR_GRAYSCALE_0 + color ] ) );
gdk_draw_rectangle( ui->lcd_pixmap, ui->ann_io_gc, true, 236, 0, 15, 12 );
GdkGC* gc = gdk_gc_new( gtk_widget_get_window( ui->lcd_canvas ) );
for ( int y = 0; y < ( ui->lcd_height - ui->lcd_annunciators_height ) / LCD_PIXEL_SCALE; y++ ) {
for ( int x = 0; x < ui->lcd_width / LCD_PIXEL_SCALE; x++ ) {
color = x49gp_get_pixel_color( lcd, x, y );
/* gdk_gc_set_rgb_fg_color( gc, &( ui->colors[ UI_COLOR_GRAYSCALE_0 + color ] ) ); */
/* gdk_draw_rectangle( ui->lcd_pixmap, gc, true, LCD_PIXEL_SCALE * x, LCD_PIXEL_SCALE * y + ui->lcd_annunciators_height, */
/* LCD_PIXEL_SCALE, LCD_PIXEL_SCALE ); */
x49gp_draw_rectangle( ui->lcd_pixmap, LCD_PIXEL_SCALE * x, LCD_PIXEL_SCALE * y + ui->lcd_annunciators_height, LCD_PIXEL_SCALE, LCD_PIXEL_SCALE, &(ui->colors[ UI_COLOR_GRAYSCALE_0 + color ]) );
}
}
g_object_unref( gc );
for ( int y = 0; y < ( ( ui->lcd_height - ui->lcd_annunciators_height ) / LCD_PIXEL_SCALE ); y++ )
for ( int x = 0; x < ( ui->lcd_width / LCD_PIXEL_SCALE ); x++ )
x49gp_draw_rectangle( ui->lcd_pixmap, LCD_PIXEL_SCALE * x, LCD_PIXEL_SCALE * y + ui->lcd_annunciators_height,
LCD_PIXEL_SCALE, LCD_PIXEL_SCALE,
&(ui->colors[ UI_COLOR_GRAYSCALE_0 + x49gp_get_pixel_color( lcd, x, y ) ]) );
}
GdkRectangle rect;

View file

@ -3413,15 +3413,15 @@ static int gui_load( x49gp_module_t* module, GKeyFile* keyfile )
// {
ui->menu = gtk_menu_new();
GtkWidget *menu_mount_folder = gtk_menu_item_new_with_label( "Mount SD folder ..." );
GtkWidget* menu_mount_folder = gtk_menu_item_new_with_label( "Mount SD folder ..." );
gtk_menu_shell_append( GTK_MENU_SHELL( ui->menu ), menu_mount_folder );
g_signal_connect( G_OBJECT( menu_mount_folder ), "activate", G_CALLBACK( x49gp_ui_mount_sd_folder ), x49gp );
GtkWidget *menu_mount_image = gtk_menu_item_new_with_label( "Mount SD image ..." );
GtkWidget* menu_mount_image = gtk_menu_item_new_with_label( "Mount SD image ..." );
gtk_menu_shell_append( GTK_MENU_SHELL( ui->menu ), menu_mount_image );
g_signal_connect( G_OBJECT( menu_mount_image ), "activate", G_CALLBACK( x49gp_ui_mount_sd_image ), x49gp );
GtkWidget *menu_unmount = gtk_menu_item_new_with_label( "Unmount SD" );
GtkWidget* menu_unmount = gtk_menu_item_new_with_label( "Unmount SD" );
gtk_menu_shell_append( GTK_MENU_SHELL( ui->menu ), menu_unmount );
g_signal_connect_swapped( G_OBJECT( menu_unmount ), "activate", G_CALLBACK( s3c2410_sdi_unmount ), x49gp );
ui->menu_unmount = menu_unmount;
@ -3429,7 +3429,7 @@ static int gui_load( x49gp_module_t* module, GKeyFile* keyfile )
if ( x49gp->debug_port != 0 ) {
gtk_menu_shell_append( GTK_MENU_SHELL( ui->menu ), gtk_separator_menu_item_new() );
GtkWidget *menu_debug = gtk_menu_item_new_with_label( "Start debugger" );
GtkWidget* menu_debug = gtk_menu_item_new_with_label( "Start debugger" );
gtk_menu_shell_append( GTK_MENU_SHELL( ui->menu ), menu_debug );
g_signal_connect( G_OBJECT( menu_debug ), "activate", G_CALLBACK( x49gp_ui_debug ), x49gp );
ui->menu_debug = menu_debug;
@ -3438,11 +3438,11 @@ static int gui_load( x49gp_module_t* module, GKeyFile* keyfile )
gtk_menu_shell_append( GTK_MENU_SHELL( ui->menu ), gtk_separator_menu_item_new() );
GtkWidget *menu_reset = gtk_menu_item_new_with_label( "Reset" );
GtkWidget* menu_reset = gtk_menu_item_new_with_label( "Reset" );
gtk_menu_shell_append( GTK_MENU_SHELL( ui->menu ), menu_reset );
g_signal_connect( G_OBJECT( menu_reset ), "activate", G_CALLBACK( x49gp_ui_calculator_reset ), x49gp );
GtkWidget *menu_quit = gtk_menu_item_new_with_label( "Quit" );
GtkWidget* menu_quit = gtk_menu_item_new_with_label( "Quit" );
gtk_menu_shell_append( GTK_MENU_SHELL( ui->menu ), menu_quit );
g_signal_connect_swapped( G_OBJECT( menu_quit ), "activate", G_CALLBACK( x49gp_ui_quit ), x49gp );