Commit 567faf5f authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

Fix synchro problem. Still some check to do

parent c3d99649
......@@ -149,12 +149,12 @@ static void init_color_maps(){
/** Gtk cannot display a black and white image, therefore we convert it before updating it*/
gboolean update_Y800_image(GtkImage *image, GdkFrameClock *, gpointer pointer_statusbar)
{
int i, x, y, j;
int i, x, y, j, ret=-1;
double sx, sy;
uint32_t *values;
char text[64];
if (blc_command_loop_start()==0) exit(0);
if (blc_command_loop_start()){;
values = (uint32_t*)image_buffer;
if (channel->type=='UIN8') FOR_INV(i, channel->size) values[i]=color_map[channel->uchars[i]];
......@@ -164,7 +164,6 @@ gboolean update_Y800_image(GtkImage *image, GdkFrameClock *, gpointer pointer_st
gdk_window_get_device_position(gtk_widget_get_window(GTK_WIDGET(image)), pointer_device, &x, &y, NULL);
cairo_surface_get_device_scale(image_surface, &sx, &sy);
i=x*sx;
j=y*sy;
if (i<width && j<height && i>=0 && j>=0)
......@@ -176,8 +175,9 @@ gboolean update_Y800_image(GtkImage *image, GdkFrameClock *, gpointer pointer_st
}
iterations++;
blc_command_loop_end();
return G_SOURCE_CONTINUE;
return blc_status;
} else exit(EXIT_SUCCESS);
}
gboolean update_RGB3_image(GtkImage *image, GdkFrameClock *, gpointer pointer_statusbar)
......@@ -187,6 +187,7 @@ gboolean update_RGB3_image(GtkImage *image, GdkFrameClock *, gpointer pointer_st
int x, y, i=0, j=0;
int R, G, B;
if (blc_command_loop_start()==0) exit(0);
gdk_window_get_device_position(gtk_widget_get_window(GTK_WIDGET(image)), pointer_device, &x, &y, NULL);
......@@ -222,6 +223,7 @@ gboolean update_RGB3_image(GtkImage *image, GdkFrameClock *, gpointer pointer_st
}
gtk_image_set_from_surface(image, image_surface);
iterations++;
blc_command_loop_end();
return G_SOURCE_CONTINUE;
}
......@@ -234,6 +236,7 @@ gboolean update_RGBA_image(GtkImage *image, GdkFrameClock *, gpointer pointer_st
char text[NAME_MAX];
int R, G, B, A;
if (blc_command_loop_start()==0) exit(0);
gdk_window_get_device_position(gtk_widget_get_window(GTK_WIDGET(image)), pointer_device, &x, &y, NULL);
cairo_surface_get_device_scale(image_surface, &sx, &sy);
......@@ -260,6 +263,7 @@ gboolean update_RGBA_image(GtkImage *image, GdkFrameClock *, gpointer pointer_st
gtk_statusbar_push(GTK_STATUSBAR(pointer_statusbar), 0, text);
}
gtk_image_set_from_surface(image, image_surface);
blc_command_loop_end();
iterations++;
return G_SOURCE_CONTINUE;
}
......@@ -282,6 +286,9 @@ gboolean update_JPEG_image(GtkImage *image, GdkFrameClock *frame_clock, blc_chan
struct jpeg_error_mgr jerr;
(void) frame_clock;
if (blc_command_loop_start()==0) exit(0);
pixbuf = gtk_image_get_pixbuf(image);
pixels = gdk_pixbuf_get_pixels(pixbuf);
......@@ -309,6 +316,9 @@ gboolean update_JPEG_image(GtkImage *image, GdkFrameClock *frame_clock, blc_chan
jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
blc_command_loop_end();
return G_SOURCE_CONTINUE;
}
......@@ -323,6 +333,8 @@ gboolean update_YUYV_image(GtkImage *image, GdkFrameClock *frame_clock, void*)
(void) frame_clock;
if (blc_command_loop_start()==0) exit(0);
pixels = (uint32_t*)image_buffer;
if (blc_command_loop_start()==0) exit(0);
......@@ -344,6 +356,7 @@ gboolean update_YUYV_image(GtkImage *image, GdkFrameClock *frame_clock, void*)
blc_command_loop_end();
gtk_image_set_from_surface(image, image_surface);
blc_command_loop_end();
return G_SOURCE_CONTINUE;
}
......@@ -361,6 +374,8 @@ gboolean update_yuv2_image(GtkImage *image, GdkFrameClock *, gpointer pointer_st
uint32_t *tmp_pixels;
int Y, U = 128, V = 128;
if (blc_command_loop_start()==0) exit(0);
tmp_pixels = (uint32_t*)image_buffer;
i = 0;
......@@ -405,6 +420,8 @@ gboolean update_yuv2_image(GtkImage *image, GdkFrameClock *, gpointer pointer_st
}
gtk_image_set_from_surface(image, image_surface);
iterations++;
blc_command_loop_end();
return G_SOURCE_CONTINUE;
}
......@@ -435,6 +452,8 @@ gboolean update_histogram_cb(GtkImage *image, GdkFrameClock *, gpointer pointer_
x*=sx;
y*=sy;
switch (channel->format){
case 'Y800':
FOR_INV(i, channel->size) histogram[channel->uchars[i]]++;
......@@ -529,8 +548,6 @@ gboolean update_histogram_cb(GtkImage *image, GdkFrameClock *, gpointer pointer_
gtk_statusbar_push(GTK_STATUSBAR(pointer_statusbar), 0, text);
}
break;
default:
......@@ -726,8 +743,13 @@ GtkWidget *create_image_display(blc_channel *tmp_channel)
framerate_statusbar=gtk_statusbar_new();
pointer_statusbar=gtk_statusbar_new();
blc_loop_try_add_posting_semaphore(channel->sem_ack_data);
blc_loop_try_add_waiting_semaphore(channel->sem_new_data);
blc_command_loop_init(0);
switch (channel->format)
{
case 'NDEF':
case 'Y800':
width=channel->dims[0].length;
height=channel->dims[1].length;
......@@ -789,7 +811,6 @@ GtkWidget *create_image_display(blc_channel *tmp_channel)
default:return NULL;
}
channel=tmp_channel;
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 3);
scrolled_window=gtk_scrolled_window_new(NULL, NULL);
......
......@@ -56,7 +56,6 @@ void on_key_press(GtkWidget *widget, GdkEventKey *event){
void activate_cb(GApplication *app)
{
blc_channel *input;
char tmp_title[NAME_MAX*2+1];
GtkWidget *display=NULL;
GtkWidget *grid;
......@@ -72,9 +71,9 @@ void activate_cb(GApplication *app)
grid=gtk_grid_new();
// for(i=0; input_names[i]; i++){ This is for displaying multiple images
input=new blc_channel(/*input_names[i]*/ input_name, BLC_CHANNEL_READ);
display=create_image_display(input);
if (display==NULL) EXIT_ON_CHANNEL_ERROR(input, "Format not managed.");
// input=new blc_channel(/*input_names[i]*/ input_name, BLC_CHANNEL_READ);
display=create_image_display(&input);
if (display==NULL) EXIT_ON_CHANNEL_ERROR(&input, "Format not managed.");
gtk_widget_set_hexpand(display, 1);
gtk_widget_set_vexpand(display, 1);
gtk_container_add(GTK_CONTAINER(grid), display);
......@@ -83,7 +82,6 @@ void activate_cb(GApplication *app)
gtk_widget_show_all(window);
if (keyboard_mode) g_signal_connect(G_OBJECT(window), "key_press_event", G_CALLBACK (on_key_press), NULL);
blc_command_loop_init(0);
}
/** Classical GTK application.
......@@ -106,9 +104,10 @@ int main(int argc, char *argv[])
blc_program_init(&argc, &argv, ask_quit);
input.open(input_name, mode);
blc_loop_try_add_waiting_semaphore(input.sem_new_data);
blc_loop_try_add_posting_semaphore(input.sem_ack_data);
/*
while (sem_trywait(input.sem_ack_data)==0);
while (sem_trywait(input.sem_new_data)==0);
*/
gtk_disable_setlocale();
gtk_init(&argc, &argv);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment