[gnome-boxes/wip/dont-crash-gl: 2/2] WIP



commit 8fc546fa85e0485334a5c18bdeaded933c370f8d
Author: Felipe Borges <felipeborges gnome org>
Date:   Mon May 27 08:59:44 2019 +0200

    WIP

 src/spice-display.vala | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/src/spice-display.vala b/src/spice-display.vala
index 5223549a..5eff2043 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -196,12 +196,25 @@ public override void set_enable_audio (bool enable) {
         /* FIXME: This is a temporary workaround for a mesa issue that causes
          * Boxes to crash when calling spice_display_get_pixbuf ();
          * See https://bugs.freedesktop.org/106811 */
-        if ((machine as LibvirtMachine).acceleration_3d)
-            return null;
+        if ((machine as LibvirtMachine).acceleration_3d) {
+            return draw_pixbuf_client_side (display);
+        }
 
         return display.get_pixbuf ();
     }
 
+    private Gdk.Pixbuf draw_pixbuf_client_side (Spice.Display display) {
+        Gtk.Allocation alloc;
+        var widget = display as Gtk.Widget;
+        widget.get_allocation (out alloc);
+
+        var surface = new Cairo.ImageSurface (ARGB32, alloc.width, alloc.height);
+        var context = new Cairo.Context (surface);
+        widget.draw (context);
+
+        return Gdk.pixbuf_get_from_surface (surface, 0, 0, alloc.width, alloc.height);
+    }
+
     public override void collect_logs (StringBuilder builder) {
         builder.append_printf ("URL: %s\n", uri);
         if (gtk_session != null) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]