12
12
*/
13
13
14
14
#include "qemu/osdep.h"
15
+ #include "qemu/main-loop.h"
15
16
16
17
#include "trace.h"
17
18
@@ -94,6 +95,18 @@ void gd_egl_draw(VirtualConsole *vc)
94
95
}
95
96
96
97
glFlush ();
98
+ #ifdef CONFIG_GBM
99
+ if (vc -> gfx .guest_fb .dmabuf ) {
100
+ QemuDmaBuf * dmabuf = vc -> gfx .guest_fb .dmabuf ;
101
+
102
+ egl_dmabuf_create_fence (dmabuf );
103
+ if (dmabuf -> fence_fd > 0 ) {
104
+ qemu_set_fd_handler (dmabuf -> fence_fd , gd_hw_gl_flushed , NULL , vc );
105
+ return ;
106
+ }
107
+ graphic_hw_gl_block (vc -> gfx .dcl .con , false);
108
+ }
109
+ #endif
97
110
graphic_hw_gl_flushed (vc -> gfx .dcl .con );
98
111
}
99
112
@@ -209,6 +222,8 @@ void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
209
222
QemuDmaBuf * dmabuf )
210
223
{
211
224
#ifdef CONFIG_GBM
225
+ VirtualConsole * vc = container_of (dcl , VirtualConsole , gfx .dcl );
226
+
212
227
egl_dmabuf_import_texture (dmabuf );
213
228
if (!dmabuf -> texture ) {
214
229
return ;
@@ -217,6 +232,10 @@ void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
217
232
gd_egl_scanout_texture (dcl , dmabuf -> texture ,
218
233
false, dmabuf -> width , dmabuf -> height ,
219
234
0 , 0 , dmabuf -> width , dmabuf -> height );
235
+
236
+ if (dmabuf -> allow_fences ) {
237
+ vc -> gfx .guest_fb .dmabuf = dmabuf ;
238
+ }
220
239
#endif
221
240
}
222
241
@@ -249,14 +268,6 @@ void gd_egl_cursor_position(DisplayChangeListener *dcl,
249
268
vc -> gfx .cursor_y = pos_y * vc -> gfx .scale_y ;
250
269
}
251
270
252
- void gd_egl_release_dmabuf (DisplayChangeListener * dcl ,
253
- QemuDmaBuf * dmabuf )
254
- {
255
- #ifdef CONFIG_GBM
256
- egl_dmabuf_release_texture (dmabuf );
257
- #endif
258
- }
259
-
260
271
void gd_egl_scanout_flush (DisplayChangeListener * dcl ,
261
272
uint32_t x , uint32_t y , uint32_t w , uint32_t h )
262
273
{
@@ -289,9 +300,30 @@ void gd_egl_scanout_flush(DisplayChangeListener *dcl,
289
300
egl_fb_blit (& vc -> gfx .win_fb , & vc -> gfx .guest_fb , !vc -> gfx .y0_top );
290
301
}
291
302
303
+ #ifdef CONFIG_GBM
304
+ if (vc -> gfx .guest_fb .dmabuf ) {
305
+ egl_dmabuf_create_sync (vc -> gfx .guest_fb .dmabuf );
306
+ }
307
+ #endif
308
+
292
309
eglSwapBuffers (qemu_egl_display , vc -> gfx .esurface );
293
310
}
294
311
312
+ void gd_egl_flush (DisplayChangeListener * dcl ,
313
+ uint32_t x , uint32_t y , uint32_t w , uint32_t h )
314
+ {
315
+ VirtualConsole * vc = container_of (dcl , VirtualConsole , gfx .dcl );
316
+ GtkWidget * area = vc -> gfx .drawing_area ;
317
+
318
+ if (vc -> gfx .guest_fb .dmabuf ) {
319
+ graphic_hw_gl_block (vc -> gfx .dcl .con , true);
320
+ gtk_widget_queue_draw_area (area , x , y , w , h );
321
+ return ;
322
+ }
323
+
324
+ gd_egl_scanout_flush (& vc -> gfx .dcl , x , y , w , h );
325
+ }
326
+
295
327
void gtk_egl_init (DisplayGLMode mode )
296
328
{
297
329
GdkDisplay * gdk_display = gdk_display_get_default ();
0 commit comments