Recent gtk+ on DirectFB

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

 



Hi,

As you may know, DirectFB backend of gtk+ in recent versions is heavily 
broken, and I want to know if anyone working on fixing DirectFB backend :)

I was able to fix crash by applying 2 patches (attached) from André Draszik, 
and now simple gtk apps works, but that's not enough for complete gtk-demo - 
it just draws white window.

Does anyone knows what can cause such behavior? Any thoughts/ideas/clues? I've 
debugged app that doesn't work correctly, and noticed that with DirectFB 
backend gtk calls _gdk_windowing_create_cairo_surface more often than with X11 
backend. Also I've noticed that backend calls surface->Flip() for GdkWindow 
surface, so windows flushes its content to screen, but for some reason there's 
no content :)

Regards
Vasily
From 99284a2257559d3f2a74ca0e9d25662268d17cb7 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Andr=C3=A9=20Draszik?= <andre.draszik@xxxxxx>
Date: Mon, 14 Sep 2009 16:04:17 +0100
Subject: [PATCH] gdk/directfb: fix usage of cairo_directfb_surface_create()
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

It expects an already created IDirectFBSurface, not NULL.
This change fixes another GTK+ segfault on startup and gtk's 'simple'
test app works again

Signed-off-by: André Draszik <andre.draszik@xxxxxx>
---
 gdk/directfb/gdkdrawable-directfb.c |   85 ++++++++++++++++++++---------------
 gdk/directfb/gdkprivate-directfb.h  |    2 +-
 2 files changed, 49 insertions(+), 38 deletions(-)

diff --git a/gdk/directfb/gdkdrawable-directfb.c b/gdk/directfb/gdkdrawable-directfb.c
index 3406f08..d91a0a3 100644
--- a/gdk/directfb/gdkdrawable-directfb.c
+++ b/gdk/directfb/gdkdrawable-directfb.c
@@ -1593,18 +1593,24 @@ static GdkScreen * gdk_directfb_get_screen (GdkDrawable    *drawable){
         return gdk_screen_get_default();
 }
 
-static void
-gdk_directfb_cairo_surface_destroy (void *data)
-{
-  GdkDrawableImplDirectFB *impl = data;
-  impl->cairo_surface = NULL;
-}
-
 void
 _gdk_windowing_set_cairo_surface_size (cairo_surface_t *surface,
                                        int width,
                                        int height)
 {
+  /* no need to call cairo here, cairo figures this out on its own */
+}
+
+
+static void
+gdk_directfb_cairo_surface_destroy (void *data)
+{
+  GdkDrawableImplDirectFB *impl = GDK_DRAWABLE_IMPL_DIRECTFB (data);
+
+  D_ASSUME (impl->cairo_surface != NULL);
+
+  cairo_surface_destroy (impl->cairo_surface);
+  impl->cairo_surface = NULL;
 }
 
 cairo_surface_t *
@@ -1613,17 +1619,36 @@ _gdk_windowing_create_cairo_surface (GdkDrawable *drawable,
                                      int height)
 {
   GdkDrawableImplDirectFB *impl;
-  IDirectFB *dfb;
-  cairo_surface_t *ret;
+  GdkDisplayDFB           *display_dfb;
+  IDirectFBSurface        *surface;
+  cairo_surface_t         *ret;
 
   impl = GDK_DRAWABLE_IMPL_DIRECTFB (drawable);
-  dfb = GDK_DISPLAY_DFB (gdk_drawable_get_display (drawable))->directfb;
 
-  ret = cairo_directfb_surface_create (dfb, impl->surface);
+  if (impl->cairo_surface)
+    return cairo_surface_reference (impl->cairo_surface);
+
+  display_dfb = GDK_DISPLAY_DFB (gdk_drawable_get_display (drawable));
+
+  /* if we don't have a surface yet, we have to create one */
+  surface = impl->surface;
+  if (!surface)
+    {
+      D_ASSUME (impl->format != DSPF_UNKNOWN);
+
+      surface = gdk_display_dfb_create_surface (display_dfb,
+                                                impl->format, width, height);
+      if (!surface)
+        return NULL;
+    }
+
+  ret = cairo_directfb_surface_create (display_dfb->directfb, surface);
   cairo_surface_set_user_data (ret,
                                &gdk_directfb_cairo_key, drawable,
                                gdk_directfb_cairo_surface_destroy);
 
+  impl->surface = surface;
+
   return ret;
 }
 
@@ -1631,38 +1656,24 @@ static cairo_surface_t *
 gdk_directfb_ref_cairo_surface (GdkDrawable *drawable)
 {
   GdkDrawableImplDirectFB *impl;
-  IDirectFB               *dfb;
-  
+
   g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
   g_return_val_if_fail (GDK_IS_DRAWABLE_IMPL_DIRECTFB (drawable), NULL);
 
   impl = GDK_DRAWABLE_IMPL_DIRECTFB (drawable);
-  dfb = GDK_DISPLAY_DFB(gdk_drawable_get_display(drawable))->directfb;
-  
-  if (!impl->cairo_surface) {
-    IDirectFBSurface *surface;
-    g_assert (impl->surface != NULL);
-#if defined(CAIRO_VERSION) && CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,5,5)
-    impl->surface->GetSubSurface (impl->surface, NULL, &surface);
-#else
-    surface = impl->surface;
-#endif
-    if (surface) {
-      impl->cairo_surface = cairo_directfb_surface_create (dfb, surface);
-      if (impl->cairo_surface) {
-        cairo_surface_set_user_data (impl->cairo_surface, 
-                                     &gdk_directfb_cairo_key, drawable, 
-                                     gdk_directfb_cairo_surface_destroy);
-      }
-#if defined(CAIRO_VERSION) && CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,5,5)
-      surface->Release (surface);
-#endif
+
+  if (!impl->cairo_surface)
+    {
+      int width, height;
+
+      gdk_drawable_get_size (drawable, &width, &height);
+      impl->cairo_surface = _gdk_windowing_create_cairo_surface (drawable,
+                                                                 width,
+                                                                 height);
     }
-  } else {
+  else
     cairo_surface_reference (impl->cairo_surface);
-  }
-  
-  g_assert (impl->cairo_surface != NULL);
+
   return impl->cairo_surface;
 }
 
diff --git a/gdk/directfb/gdkprivate-directfb.h b/gdk/directfb/gdkprivate-directfb.h
index 201a1e6..df53cc9 100644
--- a/gdk/directfb/gdkprivate-directfb.h
+++ b/gdk/directfb/gdkprivate-directfb.h
@@ -85,7 +85,7 @@ struct _GdkDrawableImplDirectFB
 
   IDirectFBSurface       *surface;
   DFBSurfacePixelFormat   format;
-  cairo_surface_t *  cairo_surface;
+  cairo_surface_t        *cairo_surface;
 
 };
 
-- 
1.6.3.3

From ce88c3f1baf1d780842bf5b93fb3a8beaa775b11 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Andr=C3=A9=20Draszik?= <gtk@xxxxxxxxxx>
Date: Sun, 14 Feb 2010 11:33:04 +0000
Subject: [PATCH] for pop

---
 gdk/directfb/gdkdrawable-directfb.c |   31 +++++++++++++++++++++++--
 gdk/directfb/gdkevents-directfb.c   |    3 +-
 gdk/directfb/gdkwindow-directfb.c   |   42 ++++++++++++++++++++++++++++++----
 3 files changed, 67 insertions(+), 9 deletions(-)

diff --git a/gdk/directfb/gdkdrawable-directfb.c b/gdk/directfb/gdkdrawable-directfb.c
index b211968..1b922f3 100644
--- a/gdk/directfb/gdkdrawable-directfb.c
+++ b/gdk/directfb/gdkdrawable-directfb.c
@@ -1656,9 +1671,12 @@ gdk_directfb_cairo_surface_destroy (void *data)
 {
   GdkDrawableImplDirectFB *impl = GDK_DRAWABLE_IMPL_DIRECTFB (data);
 
+  D_DEBUG_AT (GDKDFB_Drawable, "%s for %p (cairo: %p surface: %p)\n",
+              G_STRLOC, impl, impl->cairo_surface, impl->surface);
+
   D_ASSUME (impl->cairo_surface != NULL);
 
-  cairo_surface_destroy (impl->cairo_surface);
+//  cairo_surface_destroy (impl->cairo_surface);
   impl->cairo_surface = NULL;
 }
 
@@ -1674,6 +1692,9 @@ _gdk_windowing_create_cairo_surface (GdkDrawable *drawable,
 
   impl = GDK_DRAWABLE_IMPL_DIRECTFB (drawable);
 
+  D_DEBUG_AT (GDKDFB_Drawable, "%s for %p (cairo: %p surface: %p)\n",
+              G_STRLOC, impl, impl->cairo_surface, impl->surface);
+
   if (impl->cairo_surface)
     return cairo_surface_reference (impl->cairo_surface);
 
@@ -1697,6 +1718,7 @@ _gdk_windowing_create_cairo_surface (GdkDrawable *drawable,
                                gdk_directfb_cairo_surface_destroy);
 
   impl->surface = surface;
+  impl->cairo_surface = ret;
 
   return ret;
 }
@@ -1711,6 +1733,9 @@ gdk_directfb_ref_cairo_surface (GdkDrawable *drawable)
 
   impl = GDK_DRAWABLE_IMPL_DIRECTFB (drawable);
 
+  D_DEBUG_AT (GDKDFB_Drawable, "%s for %p (cairo: %p surface: %p)\n",
+              G_STRLOC, impl, impl->cairo_surface, impl->surface);
+
   if (!impl->cairo_surface)
     {
       int width, height;

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux