From b131ecc42a88c1e1765373fa7a216879c52ef4de Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Mon, 8 Jun 2009 17:05:45 -0400 Subject: [PATCH 1/2] Work around a Clutter crash when there is no root pixmap When there is no root pixmap, the result will be a CoglMaterial with a layer with no texture, and that causes a crash. Work around this by supressing painting the root pixmap actor when there is no root pixmap. http://bugzilla.gnome.org/show_bug.cgi?id=585196 --- src/shell-global.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/shell-global.c b/src/shell-global.c index f3a4185b4..b1913f935 100644 --- a/src/shell-global.c +++ b/src/shell-global.c @@ -933,6 +933,7 @@ update_root_window_pixmap (ShellGlobal *global) gulong nitems; gulong bytes_after; guchar *data; + Pixmap root_pixmap_id = None; if (!XGetWindowProperty (gdk_x11_get_default_xdisplay (), gdk_x11_get_default_root_xwindow (), @@ -947,8 +948,7 @@ update_root_window_pixmap (ShellGlobal *global) if (type == XA_PIXMAP && format == 32 && nitems == 1) { /* Was what we expected. */ - clutter_x11_texture_pixmap_set_pixmap (CLUTTER_X11_TEXTURE_PIXMAP (global->root_pixmap), - *(Pixmap *)data); + root_pixmap_id = *(Pixmap *)data; } else { @@ -957,6 +957,9 @@ update_root_window_pixmap (ShellGlobal *global) XFree(data); } + + clutter_x11_texture_pixmap_set_pixmap (CLUTTER_X11_TEXTURE_PIXMAP (global->root_pixmap), + root_pixmap_id); } /* @@ -976,6 +979,22 @@ root_window_filter (GdkXEvent *native, GdkEvent *event, gpointer data) return GDK_FILTER_CONTINUE; } +/* Workaround for a clutter bug where if ClutterGLXTexturePixmap + * is painted without the pixmap being set, a crash will occur inside + * Cogl. + * + * http://bugzilla.openedhand.com/show_bug.cgi?id=1644 + */ +static void +root_pixmap_paint (ClutterActor *actor, gpointer data) +{ + Pixmap pixmap; + + g_object_get (G_OBJECT (actor), "pixmap", &pixmap, NULL); + if (!pixmap) + g_signal_stop_emission_by_name (actor, "paint"); +} + /* * Called when the root window pixmap actor is destroyed. */ @@ -1021,6 +1040,9 @@ shell_global_create_root_pixmap_actor (ShellGlobal *global) clutter_container_add_actor (CLUTTER_CONTAINER (stage), global->root_pixmap); + g_signal_connect (global->root_pixmap, "paint", + G_CALLBACK (root_pixmap_paint), NULL); + /* This really should never happen; but just in case... */ g_signal_connect (global->root_pixmap, "destroy", G_CALLBACK (root_pixmap_destroy), global); From 66459eff965fe06a2b78dc454a6ebc4789a45243 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Thu, 14 May 2009 10:00:22 -0400 Subject: [PATCH 2/2] BigRectangle: Use pre-multiplied colors With recent Clutter changes to the default blend mode, premultiplied colors should be used for cogl_material_set_color() in the normal case. http://bugzilla.gnome.org/show_bug.cgi?id=585473 --- src/big/rectangle.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/big/rectangle.c b/src/big/rectangle.c index 2b1fb7d37..8ca104d50 100644 --- a/src/big/rectangle.c +++ b/src/big/rectangle.c @@ -362,7 +362,7 @@ big_rectangle_paint(ClutterActor *actor) if (radius != 0) { cogl_color_set_from_4ub(&tmp_color, - 0xff, 0xff, 0xff, actor_opacity); + actor_opacity, actor_opacity, actor_opacity, actor_opacity); cogl_material_set_color(rectangle->corner_material, &tmp_color); cogl_set_source(rectangle->corner_material); @@ -401,6 +401,7 @@ big_rectangle_paint(ClutterActor *actor) border_color->green, border_color->blue, actor_opacity * border_color->alpha / 255); + cogl_color_premultiply (&tmp_color); cogl_material_set_color(rectangle->border_material, &tmp_color); cogl_set_source(rectangle->border_material); @@ -429,6 +430,7 @@ big_rectangle_paint(ClutterActor *actor) color->green, color->blue, actor_opacity * color->alpha / 255); + cogl_color_premultiply (&tmp_color); cogl_material_set_color(rectangle->background_material, &tmp_color); cogl_set_source(rectangle->background_material);