2008-07-08 Matthew Allum <mallum@openedhand.com>

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.
This commit is contained in:
Matthew Allum 2008-07-08 11:58:08 +00:00
parent 0a1ad0342e
commit 34f6defca9
3 changed files with 92 additions and 33 deletions

View File

@ -1,3 +1,13 @@
2008-07-08 Matthew Allum <mallum@openedhand.com>
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 <mallum@openedhand.com> 2008-07-07 Matthew Allum <mallum@openedhand.com>
Bug 1016 - Changing window-redirect-automatic property after Bug 1016 - Changing window-redirect-automatic property after

View File

@ -222,16 +222,10 @@ clutter_glx_texture_pixmap_realize (ClutterActor *actor)
priv = CLUTTER_GLX_TEXTURE_PIXMAP (actor)->priv; priv = CLUTTER_GLX_TEXTURE_PIXMAP (actor)->priv;
if (priv->use_fallback if (priv->use_fallback)
|| !_have_tex_from_pixmap_ext
|| !clutter_feature_available (COGL_FEATURE_TEXTURE_NPOT))
{ {
/* Fall back */
CLUTTER_NOTE (TEXTURE, "texture from pixmap appears unsupported"); CLUTTER_NOTE (TEXTURE, "texture from pixmap appears unsupported");
CLUTTER_NOTE (TEXTURE, "Falling back to X11 manual mechansim"); 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)-> CLUTTER_ACTOR_CLASS (clutter_glx_texture_pixmap_parent_class)->
realize (actor); realize (actor);
@ -461,6 +455,10 @@ clutter_glx_texture_pixmap_create_glx_pixmap (ClutterGLXTexturePixmap *texture)
dpy = clutter_x11_get_default_display (); dpy = clutter_x11_get_default_display ();
if (priv->use_fallback == TRUE
|| !clutter_glx_texture_pixmap_using_extension (texture))
goto cleanup;
priv->use_fallback = FALSE; priv->use_fallback = FALSE;
g_object_get (texture, g_object_get (texture,
@ -556,6 +554,11 @@ clutter_glx_texture_pixmap_create_glx_pixmap (ClutterGLXTexturePixmap *texture)
{ {
priv->use_fallback = TRUE; 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; 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));
} }
/** /**

View File

@ -1,4 +1,3 @@
#include <config.h> #include <config.h>
#include <stdlib.h> #include <stdlib.h>
@ -19,9 +18,44 @@
#define IMAGE "redhand.png" #define IMAGE "redhand.png"
# ifdef USE_GDKPIXBUF # 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 static gboolean
stage_press_cb (ClutterActor *actor, 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, ClutterEvent *event,
gpointer data) gpointer data)
{ {
@ -41,7 +75,6 @@ stage_press_cb (ClutterActor *actor,
return FALSE; return FALSE;
} }
Pixmap Pixmap
create_pixmap (guint *width, guint *height, guint *depth) create_pixmap (guint *width, guint *height, guint *depth)
{ {
@ -146,14 +179,20 @@ int
main (int argc, char **argv) main (int argc, char **argv)
{ {
#ifdef USE_GDKPIXBUF #ifdef USE_GDKPIXBUF
GOptionContext *context;
ClutterActor *stage, *tex; ClutterActor *stage, *tex;
Pixmap pixmap; Pixmap pixmap;
const ClutterColor gry = { 0x99, 0x99, 0x99, 0xFF }; const ClutterColor gry = { 0x99, 0x99, 0x99, 0xFF };
Window win_remote; Window win_remote;
gboolean glx_only = FALSE;
guint w, h, d; guint w, h, d;
clutter_init (&argc, &argv); 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) if (argc < 2)
g_error ("usage: %s <window id>", argv[0]); g_error ("usage: %s <window id>", argv[0]);
@ -162,7 +201,6 @@ main (int argc, char **argv)
stage = clutter_stage_get_default (); stage = clutter_stage_get_default ();
clutter_stage_set_color (CLUTTER_STAGE (stage), &gry); clutter_stage_set_color (CLUTTER_STAGE (stage), &gry);
/* a pixmap */ /* a pixmap */
pixmap = create_pixmap (&w, &h, &d); pixmap = create_pixmap (&w, &h, &d);
@ -175,6 +213,8 @@ main (int argc, char **argv)
- clutter_actor_get_height (tex)); - clutter_actor_get_height (tex));
/* a window */ /* a window */
if (!disable_x11)
{
tex = clutter_x11_texture_pixmap_new_with_window (win_remote); tex = clutter_x11_texture_pixmap_new_with_window (win_remote);
clutter_actor_set_position (tex, 0, 0); clutter_actor_set_position (tex, 0, 0);
@ -183,9 +223,12 @@ main (int argc, char **argv)
clutter_x11_texture_pixmap_set_automatic (CLUTTER_X11_TEXTURE_PIXMAP (tex), clutter_x11_texture_pixmap_set_automatic (CLUTTER_X11_TEXTURE_PIXMAP (tex),
TRUE); TRUE);
}
# ifdef HAVE_CLUTTER_GLX # ifdef HAVE_CLUTTER_GLX
/* a window with glx */ /* a window with glx */
if (!disable_glx)
{
tex = clutter_glx_texture_pixmap_new_with_window (win_remote); tex = clutter_glx_texture_pixmap_new_with_window (win_remote);
clutter_actor_set_position (tex, clutter_actor_set_position (tex,
@ -193,15 +236,17 @@ main (int argc, char **argv)
- clutter_actor_get_width (tex), - clutter_actor_get_width (tex),
0); 0);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), tex);
clutter_x11_texture_pixmap_set_automatic (CLUTTER_X11_TEXTURE_PIXMAP (tex), clutter_x11_texture_pixmap_set_automatic (CLUTTER_X11_TEXTURE_PIXMAP (tex),
TRUE); TRUE);
}
clutter_container_add_actor (CLUTTER_CONTAINER (stage),
tex);
#endif /* HAVE_CLUTTER_GLX */ #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_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); clutter_actor_show_all (stage);