Révision | b5d2faa81605973dc6399f2f6305c72bac356c73 (tree) |
---|---|
l'heure | 2020-09-11 12:02:59 |
Auteur | Ruben Agin <phabrics@phab...> |
Commiter | Ruben Agin |
New shared display code working with GTK.
@@ -67,3 +67,6 @@ build* | ||
67 | 67 | tmememory.h |
68 | 68 | *.tex |
69 | 69 | *.info |
70 | +mdate-sh | |
71 | +stamp-vti | |
72 | +version.texi |
@@ -1030,7 +1030,8 @@ if test "x$have_gtk" = xyes; then | ||
1030 | 1030 | if test "x${enable_gtk}" = xyes; then |
1031 | 1031 | TME_HOSTS="gtk display ${TME_HOSTS}" |
1032 | 1032 | fi |
1033 | - TME_FB_XLAT_DST="d32b32s0p32olml_r0xffff0000_g0xff00ff00_b0xff0000ff d24b32s0p32olml_r0xff0000_g0xff00_b0xff d16b16s0p32olml_r0xf800_g0x07e0_b0x001f d8b8s0p32olml_r0xff_g0xff_b0xff d1b1s0p32olml_r0x1_g0x1_b0x1" | |
1033 | + TME_FB_XLAT_DST="d32b32s0p32olml_r0xffff0000_g0xff00ff00_b0xff0000ff d24b32s0p32olml_r0xff0000_g0xff00_b0xff" | |
1034 | +# TME_FB_XLAT_DST="d32b32s0p32olml_r0xffff0000_g0xff00ff00_b0xff0000ff d24b32s0p32olml_r0xff0000_g0xff00_b0xff d16b16s0p32olml_r0xf800_g0x07e0_b0x001f d8b8s0p32olml_r0xff_g0xff_b0xff d1b1s0p32olml_r0x1_g0x1_b0x1" | |
1034 | 1035 | fi |
1035 | 1036 | |
1036 | 1037 | # if --with-tme-host-displays is given, characterize those given displays: |
@@ -38,13 +38,14 @@ | ||
38 | 38 | |
39 | 39 | static _tme_thret |
40 | 40 | _tme_screen_th_update(void *disp) { |
41 | - struct tme_fb_connection *conn_fb; | |
42 | 41 | struct tme_screen *screen; |
43 | - struct tme_display *display = (rfbScreenInfoPtr)disp; | |
42 | + struct tme_display *display = (struct tme_display *)disp; | |
44 | 43 | int rc; |
45 | 44 | |
46 | 45 | tme_thread_enter(NULL); |
47 | - | |
46 | +#ifdef TME_THREADS_SJLJ | |
47 | + tme_thread_create(&display->tme_display_thread, tme_sjlj_threads_main, NULL); | |
48 | +#endif | |
48 | 49 | //_tme_thread_suspended(); |
49 | 50 | |
50 | 51 | for(;;) { |
@@ -60,18 +61,15 @@ _tme_screen_th_update(void *disp) { | ||
60 | 61 | /* loop over all screens: */ |
61 | 62 | for (screen = display->tme_display_screens; |
62 | 63 | screen != NULL; |
63 | - screen = screen->tme_screen_next) | |
64 | + screen = screen->tme_screen_next) { | |
64 | 65 | switch(screen->tme_screen_update) { |
65 | 66 | case TME_SCREEN_UPDATE_REDRAW: |
66 | 67 | if(display->tme_screen_redraw) |
67 | 68 | display->tme_screen_redraw(screen); |
68 | 69 | break; |
69 | 70 | case TME_SCREEN_UPDATE_RESIZE: |
70 | - if(display->tme_screen_resize && | |
71 | - (conn_fb = screen->tme_screen_fb)) | |
72 | - display->tme_screen_resize(screen, | |
73 | - conn_fb->tme_fb_connection_width, | |
74 | - conn_fb->tme_fb_connection_height); | |
71 | + if(display->tme_screen_resize) | |
72 | + display->tme_screen_resize(screen); | |
75 | 73 | break; |
76 | 74 | case TME_SCREEN_UPDATE_NONE: |
77 | 75 | break; |
@@ -80,6 +78,8 @@ _tme_screen_th_update(void *disp) { | ||
80 | 78 | if(display->tme_screen_update) |
81 | 79 | display->tme_screen_update(screen); |
82 | 80 | } |
81 | + screen->tme_screen_update = TME_SCREEN_UPDATE_NONE; | |
82 | + } | |
83 | 83 | tme_mutex_unlock(&display->tme_display_mutex); |
84 | 84 | } |
85 | 85 |
@@ -104,7 +104,7 @@ _tme_display_update(struct tme_display *display) | ||
104 | 104 | /* skip this screen if it's unconnected: */ |
105 | 105 | if (screen->tme_screen_update != TME_SCREEN_UPDATE_NONE || |
106 | 106 | !(conn_fb = screen->tme_screen_fb) || |
107 | - !conn_fb->tme_fb_connection_buffer || | |
107 | + !conn_fb->tme_fb_connection_buffsz || | |
108 | 108 | !(conn_fb_other = (struct tme_fb_connection *)conn_fb->tme_fb_connection.tme_connection_other)) return rc; |
109 | 109 | |
110 | 110 | /* unlock the mutex: */ |
@@ -500,10 +500,11 @@ _tme_screen_configure(struct tme_screen *screen) | ||
500 | 500 | /* set the size & translation function */ |
501 | 501 | screen->tme_screen_fb_xlat = NULL; |
502 | 502 | if(conn_fb->tme_fb_connection_width != width || |
503 | - conn_fb->tme_fb_connection_height != height) | |
503 | + conn_fb->tme_fb_connection_height != height) { | |
504 | 504 | screen->tme_screen_update = TME_SCREEN_UPDATE_RESIZE; |
505 | 505 | conn_fb->tme_fb_connection_width = width; |
506 | 506 | conn_fb->tme_fb_connection_height = height; |
507 | + conn_fb->tme_fb_connection_buffsz = 0; | |
507 | 508 | } |
508 | 509 | } |
509 | 510 |
@@ -720,7 +721,7 @@ int tme_display_init(struct tme_element *element, | ||
720 | 721 | |
721 | 722 | /* setup the thread loop function: */ |
722 | 723 | #ifdef TME_THREADS_SJLJ |
723 | - tme_thread_create(&display->tme_display_thread, tme_sjlj_threads_main, NULL); | |
724 | + // tme_thread_create(&display->tme_display_thread, tme_sjlj_threads_main, NULL); | |
724 | 725 | tme_sjlj_thread_create(&display->tme_display_sjlj_thread, _tme_display_th_update, display); |
725 | 726 | #else |
726 | 727 | tme_thread_create(&display->tme_display_sjlj_thread, _tme_display_th_update, display); |
@@ -53,6 +53,9 @@ | ||
53 | 53 | #define TME_DISPLAY_CALLOUT_KEYBOARD_CTRL TME_BIT(1) |
54 | 54 | #define TME_DISPLAY_CALLOUT_MOUSE_CTRL TME_BIT(2) |
55 | 55 | #define BLANK_SIDE (16 * 8) |
56 | +#define TME_SCREEN_UPDATE_NONE (0) | |
57 | +#define TME_SCREEN_UPDATE_REDRAW (1) | |
58 | +#define TME_SCREEN_UPDATE_RESIZE (2) | |
56 | 59 | |
57 | 60 | /* types: */ |
58 | 61 |
@@ -159,10 +162,9 @@ struct tme_display { | ||
159 | 162 | /* implementation-specific callback functions: */ |
160 | 163 | struct tme_screen *(*tme_screen_add) _TME_P((struct tme_display *, struct tme_connection *)); |
161 | 164 | int (*tme_display_update) _TME_P((struct tme_display *)); |
162 | - int (*tme_screen_set_size) _TME_P((struct tme_screen *, | |
163 | - int, | |
164 | - int)); | |
165 | - | |
165 | + int (*tme_screen_resize) _TME_P((struct tme_screen *)); | |
166 | + int (*tme_screen_redraw) _TME_P((struct tme_screen *)); | |
167 | + int (*tme_screen_update) _TME_P((struct tme_screen *)); | |
166 | 168 | }; |
167 | 169 | |
168 | 170 | /* prototypes: */ |
@@ -51,7 +51,8 @@ _tme_gtk_screen_redraw(struct tme_gtk_screen *screen) | ||
51 | 51 | |
52 | 52 | static int |
53 | 53 | _tme_gtk_display_update(struct tme_display *display) { |
54 | - gtk_main_iteration_do(FALSE); | |
54 | + while (gtk_events_pending ()) | |
55 | + gtk_main_iteration (); | |
55 | 56 | return TME_OK; |
56 | 57 | } |
57 | 58 |
@@ -194,11 +195,13 @@ static struct tme_display_menu_item format_items[] = | ||
194 | 195 | }; |
195 | 196 | |
196 | 197 | /* Screen-specific size request */ |
197 | -static void _tme_gtk_screen_resize(struct tme_gtk_screen *screen, | |
198 | - int width, | |
199 | - int height) { | |
198 | +static void _tme_gtk_screen_resize(struct tme_gtk_screen *screen) { | |
199 | + struct tme_fb_connection *conn_fb = screen->screen.tme_screen_fb; | |
200 | + | |
200 | 201 | /* set a minimum size */ |
201 | - gtk_widget_set_size_request(screen->tme_gtk_screen_gtkframe, width, height); | |
202 | + gtk_widget_set_size_request(screen->tme_gtk_screen_gtkframe, | |
203 | + conn_fb->tme_fb_connection_width, | |
204 | + conn_fb->tme_fb_connection_height); | |
202 | 205 | } |
203 | 206 | |
204 | 207 | /* Create a similar image surface to the screen's target surface (i.e., backing store) */ |
@@ -302,13 +305,13 @@ _tme_gtk_screen_configure(GtkWidget *widget, | ||
302 | 305 | conn_fb->tme_fb_connection_order = TME_ENDIAN_NATIVE; |
303 | 306 | conn_fb->tme_fb_connection_buffer = cairo_image_surface_get_data(screen->tme_gtk_screen_surface); |
304 | 307 | conn_fb->tme_fb_connection_buffsz = cairo_image_surface_get_stride(screen->tme_gtk_screen_surface) * conn_fb->tme_fb_connection_height; |
305 | - conn_fb->tme_fb_connection_bits_per_pixel = 16; | |
306 | - conn_fb->tme_fb_connection_depth = 16; | |
308 | + conn_fb->tme_fb_connection_bits_per_pixel = 32; | |
309 | + conn_fb->tme_fb_connection_depth = 24; | |
307 | 310 | conn_fb->tme_fb_connection_class = TME_FB_XLAT_CLASS_COLOR; |
308 | - conn_fb->tme_fb_connection_mask_g = 0x0007e0; | |
309 | - conn_fb->tme_fb_connection_mask_b = 0x00001f; | |
310 | - conn_fb->tme_fb_connection_mask_r = 0x00f800; | |
311 | - | |
311 | + conn_fb->tme_fb_connection_mask_g = 0x00ff00; | |
312 | + conn_fb->tme_fb_connection_mask_b = 0x0000ff; | |
313 | + conn_fb->tme_fb_connection_mask_r = 0xff0000; | |
314 | + | |
312 | 315 | /* unlock our mutex: */ |
313 | 316 | tme_mutex_unlock(&display->tme_display_mutex); |
314 | 317 |
@@ -338,7 +341,6 @@ _tme_gtk_screen_draw(GtkWidget *widget, | ||
338 | 341 | |
339 | 342 | cairo_set_source_surface(cr, screen->tme_gtk_screen_surface, 0, 0); |
340 | 343 | cairo_paint(cr); |
341 | - screen->screen.tme_screen_update = TME_SCREEN_UPDATE_NONE; | |
342 | 344 | |
343 | 345 | /* unlock our mutex: */ |
344 | 346 | tme_mutex_unlock(&display->tme_display_mutex); |
@@ -440,7 +442,7 @@ _tme_gtk_screen_new(struct tme_gdk_display *display, | ||
440 | 442 | // _tme_gtk_screen_init(screen->tme_gtk_screen_gtkframe, screen); |
441 | 443 | |
442 | 444 | |
443 | - _tme_screen_format_set(screen, CAIRO_FORMAT_RGB16_565); | |
445 | + _tme_screen_format_set(screen, CAIRO_FORMAT_RGB24); | |
444 | 446 | |
445 | 447 | /* pack the Gtkframe into the outer vertical packing box: */ |
446 | 448 | gtk_box_pack_start(GTK_BOX(screen->tme_gtk_screen_vbox0), |
@@ -461,6 +463,8 @@ _tme_gtk_screen_new(struct tme_gdk_display *display, | ||
461 | 463 | |
462 | 464 | snprintf(title, sizeof(title), "%s (%s)", PACKAGE_STRING, conn->tme_connection_other->tme_connection_element->tme_element_args[0]); |
463 | 465 | gtk_window_set_title(GTK_WINDOW(screen->tme_gtk_screen_window), title); |
466 | + | |
467 | + _tme_gtk_screen_resize(screen); | |
464 | 468 | |
465 | 469 | /* unlock our mutex: */ |
466 | 470 | tme_mutex_unlock(&display->display.tme_display_mutex); |