From 34f6defca9596e9b7c3ac8080d073998b6add3e7 Mon Sep 17 00:00:00 2001 From: Matthew Allum Date: Tue, 8 Jul 2008 11:58:08 +0000 Subject: [PATCH] 2008-07-08 Matthew Allum Bug 1011 - Fix TFP fallback mechanism (take 2) * clutter/glx/clutter-glx-texture-pixmap.c: * tests/test-pixmap.c: Slightly modified patch from Gwenole Beauchesne applied to better handle both falling back to non accelerated tfp and improvements to the test case. --- ChangeLog | 10 +++ clutter/glx/clutter-glx-texture-pixmap.c | 22 +++--- tests/test-pixmap.c | 93 ++++++++++++++++++------ 3 files changed, 92 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index a816640ce..5e8302be1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-07-08 Matthew Allum + + Bug 1011 - Fix TFP fallback mechanism (take 2) + + * clutter/glx/clutter-glx-texture-pixmap.c: + * tests/test-pixmap.c: + Slightly modified patch from Gwenole Beauchesne applied + to better handle both falling back to non accelerated tfp + and improvements to the test case. + 2008-07-07 Matthew Allum Bug 1016 - Changing window-redirect-automatic property after diff --git a/clutter/glx/clutter-glx-texture-pixmap.c b/clutter/glx/clutter-glx-texture-pixmap.c index 855e28b99..da55a7872 100644 --- a/clutter/glx/clutter-glx-texture-pixmap.c +++ b/clutter/glx/clutter-glx-texture-pixmap.c @@ -222,16 +222,10 @@ clutter_glx_texture_pixmap_realize (ClutterActor *actor) priv = CLUTTER_GLX_TEXTURE_PIXMAP (actor)->priv; - if (priv->use_fallback - || !_have_tex_from_pixmap_ext - || !clutter_feature_available (COGL_FEATURE_TEXTURE_NPOT)) + if (priv->use_fallback) { - /* Fall back */ CLUTTER_NOTE (TEXTURE, "texture from pixmap appears unsupported"); CLUTTER_NOTE (TEXTURE, "Falling back to X11 manual mechansim"); - /* FIXME: Also check for sliced npots ? */ - - priv->use_fallback = TRUE; CLUTTER_ACTOR_CLASS (clutter_glx_texture_pixmap_parent_class)-> realize (actor); @@ -461,6 +455,10 @@ clutter_glx_texture_pixmap_create_glx_pixmap (ClutterGLXTexturePixmap *texture) dpy = clutter_x11_get_default_display (); + if (priv->use_fallback == TRUE + || !clutter_glx_texture_pixmap_using_extension (texture)) + goto cleanup; + priv->use_fallback = FALSE; g_object_get (texture, @@ -555,7 +553,12 @@ clutter_glx_texture_pixmap_create_glx_pixmap (ClutterGLXTexturePixmap *texture) else { priv->use_fallback = TRUE; - priv->glx_pixmap = None; + priv->glx_pixmap = None; + + /* Some fucky logic here - we've fallen back and need to make sure + * we realize here.. + */ + clutter_actor_realize (CLUTTER_ACTOR (texture)); } } @@ -658,7 +661,8 @@ clutter_glx_texture_pixmap_using_extension (ClutterGLXTexturePixmap *texture) priv = CLUTTER_GLX_TEXTURE_PIXMAP (texture)->priv; - return (_have_tex_from_pixmap_ext); + return (_have_tex_from_pixmap_ext + && clutter_feature_available (COGL_FEATURE_TEXTURE_NPOT)); } /** diff --git a/tests/test-pixmap.c b/tests/test-pixmap.c index 8a8ec9802..e838cc97b 100644 --- a/tests/test-pixmap.c +++ b/tests/test-pixmap.c @@ -1,4 +1,3 @@ - #include #include @@ -19,11 +18,46 @@ #define IMAGE "redhand.png" # ifdef USE_GDKPIXBUF +static gboolean disable_x11 = FALSE; +static gboolean disable_glx = FALSE; + +static GOptionEntry g_options[] = +{ + { "disable-x11", + 0, 0, + G_OPTION_ARG_NONE, + &disable_x11, + "Disable redirection through X11 pixmap", + NULL }, + { "disable-glx", + 0, 0, + G_OPTION_ARG_NONE, + &disable_glx, + "Disable redirection through GLX pixmap", + NULL }, + + { NULL } +}; static gboolean -stage_press_cb (ClutterActor *actor, - ClutterEvent *event, - gpointer data) +stage_key_release_cb (ClutterActor *actor, + ClutterEvent *event, + gpointer data) +{ + switch (clutter_key_event_symbol (&event->key)) + { + case CLUTTER_q: + case CLUTTER_Q: + clutter_main_quit (); + break; + } + return FALSE; +} + +static gboolean +stage_button_press_cb (ClutterActor *actor, + ClutterEvent *event, + gpointer data) { Pixmap pxm = (Pixmap)data; Display *dpy = clutter_x11_get_default_display (); @@ -41,7 +75,6 @@ stage_press_cb (ClutterActor *actor, return FALSE; } - Pixmap create_pixmap (guint *width, guint *height, guint *depth) { @@ -145,24 +178,29 @@ create_pixmap (guint *width, guint *height, guint *depth) int main (int argc, char **argv) { -# ifdef USE_GDKPIXBUF +#ifdef USE_GDKPIXBUF + GOptionContext *context; ClutterActor *stage, *tex; Pixmap pixmap; const ClutterColor gry = { 0x99, 0x99, 0x99, 0xFF }; Window win_remote; + gboolean glx_only = FALSE; guint w, h, d; clutter_init (&argc, &argv); + context = g_option_context_new (" - text-pixmap options"); + g_option_context_add_main_entries (context, g_options, NULL); + g_option_context_parse (context, &argc, &argv, NULL); + if (argc < 2) g_error ("usage: %s ", argv[0]); - win_remote = strtol(argv[1], NULL, 0); + win_remote = strtol (argv[1], NULL, 0); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &gry); - /* a pixmap */ pixmap = create_pixmap (&w, &h, &d); @@ -175,33 +213,40 @@ main (int argc, char **argv) - clutter_actor_get_height (tex)); /* a window */ - tex = clutter_x11_texture_pixmap_new_with_window (win_remote); + if (!disable_x11) + { + tex = clutter_x11_texture_pixmap_new_with_window (win_remote); - clutter_actor_set_position (tex, 0, 0); + clutter_actor_set_position (tex, 0, 0); - clutter_container_add_actor (CLUTTER_CONTAINER (stage), tex); + clutter_container_add_actor (CLUTTER_CONTAINER (stage), tex); - clutter_x11_texture_pixmap_set_automatic (CLUTTER_X11_TEXTURE_PIXMAP (tex), - TRUE); + clutter_x11_texture_pixmap_set_automatic (CLUTTER_X11_TEXTURE_PIXMAP (tex), + TRUE); + } # ifdef HAVE_CLUTTER_GLX /* a window with glx */ - tex = clutter_glx_texture_pixmap_new_with_window (win_remote); + if (!disable_glx) + { + tex = clutter_glx_texture_pixmap_new_with_window (win_remote); - clutter_actor_set_position (tex, - clutter_actor_get_width (stage) - - clutter_actor_get_width (tex), - 0); + clutter_actor_set_position (tex, + clutter_actor_get_width (stage) + - clutter_actor_get_width (tex), + 0); - clutter_x11_texture_pixmap_set_automatic (CLUTTER_X11_TEXTURE_PIXMAP (tex), - TRUE); + clutter_container_add_actor (CLUTTER_CONTAINER (stage), tex); - clutter_container_add_actor (CLUTTER_CONTAINER (stage), - tex); -# endif /* HAVE_CLUTTER_GLX */ + clutter_x11_texture_pixmap_set_automatic (CLUTTER_X11_TEXTURE_PIXMAP (tex), + TRUE); + } +#endif /* HAVE_CLUTTER_GLX */ + g_signal_connect (stage, "key-release-event", + G_CALLBACK (stage_key_release_cb), (gpointer)pixmap); g_signal_connect (stage, "button-press-event", - G_CALLBACK (stage_press_cb), (gpointer)pixmap); + G_CALLBACK (stage_button_press_cb), (gpointer)pixmap); clutter_actor_show_all (stage);