mirror of
https://github.com/brl/mutter.git
synced 2024-12-24 12:02:04 +00:00
[tests] Some improvements for test-pixmap
The test no longer requires an XID argument to run; instead it creates its own X Window. The test now also aims to demonstrate whether mipmapping is working, and clearly informs you if fallbacks are being used for GLX tfp.
This commit is contained in:
parent
b4f9c8204d
commit
41ef2ef587
@ -24,7 +24,7 @@
|
|||||||
static gboolean disable_x11 = FALSE;
|
static gboolean disable_x11 = FALSE;
|
||||||
static gboolean disable_glx = FALSE;
|
static gboolean disable_glx = FALSE;
|
||||||
|
|
||||||
static GOptionEntry g_options[] =
|
static GOptionEntry g_options[] =
|
||||||
{
|
{
|
||||||
{ "disable-x11",
|
{ "disable-x11",
|
||||||
0, 0,
|
0, 0,
|
||||||
@ -73,7 +73,7 @@ stage_button_press_cb (ClutterActor *actor,
|
|||||||
0,
|
0,
|
||||||
&gc_values);
|
&gc_values);
|
||||||
|
|
||||||
XDrawLine (dpy, pxm, gc, 0, 0, 100, 100);
|
XDrawLine (dpy, pxm, gc, 0, 0, 100, 100);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -178,79 +178,146 @@ create_pixmap (guint *width, guint *height, guint *depth)
|
|||||||
}
|
}
|
||||||
# endif /* USE_GDKPIXBUF */
|
# endif /* USE_GDKPIXBUF */
|
||||||
|
|
||||||
|
/* each time the timeline animating the label completes, swap the direction */
|
||||||
|
static void
|
||||||
|
timeline_completed (ClutterTimeline *timeline,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
clutter_timeline_set_direction (timeline,
|
||||||
|
!clutter_timeline_get_direction (timeline));
|
||||||
|
clutter_timeline_start (timeline);
|
||||||
|
}
|
||||||
|
|
||||||
G_MODULE_EXPORT int
|
G_MODULE_EXPORT int
|
||||||
test_pixmap_main (int argc, char **argv)
|
test_pixmap_main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
#ifdef USE_GDKPIXBUF
|
#ifdef USE_GDKPIXBUF
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
ClutterActor *stage, *tex;
|
Display *xdpy;
|
||||||
Pixmap pixmap;
|
int screen;
|
||||||
const ClutterColor gry = { 0x99, 0x99, 0x99, 0xFF };
|
Window rootwin;
|
||||||
Window win_remote;
|
ClutterActor *group, *label, *stage, *tex;
|
||||||
guint w, h, d;
|
Pixmap pixmap;
|
||||||
|
const ClutterColor gry = { 0x99, 0x99, 0x99, 0xFF };
|
||||||
|
Window win_remote;
|
||||||
|
guint w, h, d;
|
||||||
|
GC gc;
|
||||||
|
ClutterTimeline *timeline;
|
||||||
|
ClutterAlpha *alpha;
|
||||||
|
ClutterBehaviour *depth_behavior;
|
||||||
|
int i;
|
||||||
|
int row_height;
|
||||||
|
|
||||||
clutter_init (&argc, &argv);
|
clutter_init (&argc, &argv);
|
||||||
|
|
||||||
context = g_option_context_new (" - text-pixmap options");
|
xdpy = clutter_x11_get_default_display ();
|
||||||
|
XSynchronize (xdpy, True);
|
||||||
|
|
||||||
|
context = g_option_context_new (" - test-pixmap options");
|
||||||
g_option_context_add_main_entries (context, g_options, NULL);
|
g_option_context_add_main_entries (context, g_options, NULL);
|
||||||
g_option_context_parse (context, &argc, &argv, NULL);
|
g_option_context_parse (context, &argc, &argv, NULL);
|
||||||
|
|
||||||
if (argc < 2)
|
|
||||||
g_error ("usage: %s <window id>", argv[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);
|
pixmap = create_pixmap (&w, &h, &d);
|
||||||
|
|
||||||
tex = clutter_x11_texture_pixmap_new_with_pixmap (pixmap);
|
screen = DefaultScreen(xdpy);
|
||||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), tex);
|
rootwin = RootWindow(xdpy, screen);
|
||||||
/* oddly, the actor's size is 0 until it is realized, even though
|
win_remote = XCreateSimpleWindow (xdpy, DefaultRootWindow(xdpy),
|
||||||
pixmap-height is set */
|
0, 0, 200, 200,
|
||||||
clutter_actor_set_position (tex, 0,
|
0,
|
||||||
clutter_actor_get_height (stage)
|
WhitePixel(xdpy, screen),
|
||||||
- clutter_actor_get_height (tex));
|
WhitePixel(xdpy, screen));
|
||||||
|
|
||||||
/* a window */
|
XMapWindow (xdpy, win_remote);
|
||||||
if (!disable_x11)
|
|
||||||
{
|
|
||||||
tex = clutter_x11_texture_pixmap_new_with_window (win_remote);
|
|
||||||
|
|
||||||
clutter_actor_set_position (tex, 0, 0);
|
stage = clutter_stage_get_default ();
|
||||||
|
clutter_actor_set_position (stage, 0, 150);
|
||||||
|
clutter_stage_set_color (CLUTTER_STAGE (stage), &gry);
|
||||||
|
|
||||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), tex);
|
timeline = clutter_timeline_new (60*5, 60);
|
||||||
|
g_signal_connect (timeline,
|
||||||
|
"completed", G_CALLBACK (timeline_completed),
|
||||||
|
NULL);
|
||||||
|
|
||||||
clutter_x11_texture_pixmap_set_automatic (CLUTTER_X11_TEXTURE_PIXMAP (tex),
|
alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR);
|
||||||
TRUE);
|
depth_behavior = clutter_behaviour_depth_new (alpha, -2500, 400);
|
||||||
}
|
|
||||||
|
|
||||||
# ifdef HAVE_CLUTTER_GLX
|
group = clutter_group_new ();
|
||||||
|
clutter_container_add_actor (CLUTTER_CONTAINER (stage), group);
|
||||||
|
label = clutter_text_new_with_text ("fixed", "ClutterX11Texture (Window)");
|
||||||
|
clutter_container_add_actor (CLUTTER_CONTAINER (group), label);
|
||||||
|
tex = clutter_x11_texture_pixmap_new_with_window (win_remote);
|
||||||
|
clutter_container_add_actor (CLUTTER_CONTAINER (group), tex);
|
||||||
|
clutter_actor_set_position (tex, 0, 20);
|
||||||
|
clutter_x11_texture_pixmap_set_automatic (CLUTTER_X11_TEXTURE_PIXMAP (tex),
|
||||||
|
TRUE);
|
||||||
|
clutter_texture_set_filter_quality (CLUTTER_TEXTURE (tex),
|
||||||
|
CLUTTER_TEXTURE_QUALITY_HIGH);
|
||||||
|
clutter_actor_set_position (group, 0, 0);
|
||||||
|
clutter_behaviour_apply (depth_behavior, group);
|
||||||
|
|
||||||
|
#ifdef HAVE_CLUTTER_GLX
|
||||||
/* a window with glx */
|
/* a window with glx */
|
||||||
if (!disable_glx)
|
if (!disable_glx)
|
||||||
{
|
{
|
||||||
|
group = clutter_group_new ();
|
||||||
|
clutter_container_add_actor (CLUTTER_CONTAINER (stage), group);
|
||||||
|
label = clutter_text_new_with_text ("fixed",
|
||||||
|
"ClutterGLXTexture (Window)");
|
||||||
|
clutter_container_add_actor (CLUTTER_CONTAINER (group), label);
|
||||||
tex = clutter_glx_texture_pixmap_new_with_window (win_remote);
|
tex = clutter_glx_texture_pixmap_new_with_window (win_remote);
|
||||||
|
clutter_container_add_actor (CLUTTER_CONTAINER (group), tex);
|
||||||
clutter_actor_set_position (tex,
|
clutter_actor_set_position (tex, 0, 20);
|
||||||
clutter_actor_get_width (stage)
|
clutter_x11_texture_pixmap_set_automatic (CLUTTER_X11_TEXTURE_PIXMAP (tex),
|
||||||
|
TRUE);
|
||||||
|
clutter_texture_set_filter_quality (CLUTTER_TEXTURE (tex),
|
||||||
|
CLUTTER_TEXTURE_QUALITY_HIGH);
|
||||||
|
clutter_actor_set_position (group,
|
||||||
|
clutter_actor_get_width (stage)
|
||||||
- clutter_actor_get_width (tex),
|
- clutter_actor_get_width (tex),
|
||||||
0);
|
0);
|
||||||
|
clutter_behaviour_apply (depth_behavior, group);
|
||||||
|
|
||||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), tex);
|
if (!clutter_glx_texture_pixmap_using_extension (
|
||||||
|
CLUTTER_GLX_TEXTURE_PIXMAP (tex)))
|
||||||
clutter_x11_texture_pixmap_set_automatic (CLUTTER_X11_TEXTURE_PIXMAP (tex),
|
g_print ("NOTE: Using fallback path, not GLX TFP!\n");
|
||||||
TRUE);
|
|
||||||
}
|
}
|
||||||
#endif /* HAVE_CLUTTER_GLX */
|
#endif /* HAVE_CLUTTER_GLX */
|
||||||
|
|
||||||
g_signal_connect (stage, "key-release-event",
|
row_height = clutter_actor_get_height (group);
|
||||||
|
|
||||||
|
/* NB: We only draw on the window after being redirected, so we dont
|
||||||
|
* have to worry about handling expose events... */
|
||||||
|
gc = XCreateGC (xdpy, win_remote, 0, NULL);
|
||||||
|
XSetForeground (xdpy, gc, BlackPixel (xdpy, screen));
|
||||||
|
XSetLineAttributes(xdpy, gc, 5, LineSolid, CapButt, JoinMiter);
|
||||||
|
|
||||||
|
for (i = 0; i < 10; i++)
|
||||||
|
XDrawLine (xdpy, win_remote, gc, 0+i*20, 0, 10+i*20+i, 200);
|
||||||
|
|
||||||
|
|
||||||
|
group = clutter_group_new ();
|
||||||
|
clutter_container_add_actor (CLUTTER_CONTAINER (stage), group);
|
||||||
|
label = clutter_text_new_with_text ("fixed", "ClutterX11Texture (Pixmap)");
|
||||||
|
clutter_container_add_actor (CLUTTER_CONTAINER (group), label);
|
||||||
|
tex = clutter_x11_texture_pixmap_new_with_pixmap (pixmap);
|
||||||
|
clutter_container_add_actor (CLUTTER_CONTAINER (group), tex);
|
||||||
|
clutter_actor_set_position (tex, 0, 20);
|
||||||
|
clutter_texture_set_filter_quality (CLUTTER_TEXTURE (tex),
|
||||||
|
CLUTTER_TEXTURE_QUALITY_HIGH);
|
||||||
|
/* oddly, the actor's size is 0 until it is realized, even though
|
||||||
|
pixmap-height is set */
|
||||||
|
clutter_actor_set_position (group, 0, row_height);
|
||||||
|
clutter_behaviour_apply (depth_behavior, group);
|
||||||
|
|
||||||
|
|
||||||
|
g_signal_connect (stage, "key-release-event",
|
||||||
G_CALLBACK (stage_key_release_cb), (gpointer)pixmap);
|
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_button_press_cb), (gpointer)pixmap);
|
G_CALLBACK (stage_button_press_cb), (gpointer)pixmap);
|
||||||
|
|
||||||
clutter_actor_show_all (stage);
|
clutter_actor_show (stage);
|
||||||
|
|
||||||
|
clutter_timeline_start (timeline);
|
||||||
|
|
||||||
clutter_main ();
|
clutter_main ();
|
||||||
# endif /* USE_GDKPIXBUF */
|
# endif /* USE_GDKPIXBUF */
|
||||||
|
Loading…
Reference in New Issue
Block a user