mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 18:11:05 -05:00
Bug 1034 - Picking doesn't work on Eee PC
* clutter/clutter-main.c (_clutter_id_to_color): When choosing a pick color, set all but the most significant of the unused bits. This should make make it more likely that the GL implementation will round down to the right value. * tests/test-pick.c: Test case for picking. It creates 192 actors at known positions and stores their gids. It then calls clutter_stage_get_actor_at_pos with each position to check that the right gid is returned. * tests/Makefile.am (noinst_PROGRAMS): Add test-pick
This commit is contained in:
parent
b16e75db2c
commit
8d429e8abc
16
ChangeLog
16
ChangeLog
@ -1,3 +1,19 @@
|
||||
2008-09-12 Neil Roberts <neil@linux.intel.com>
|
||||
|
||||
Bug 1034 - Picking doesn't work on Eee PC
|
||||
|
||||
* clutter/clutter-main.c (_clutter_id_to_color): When choosing a
|
||||
pick color, set all but the most significant of the unused
|
||||
bits. This should make make it more likely that the GL
|
||||
implementation will round down to the right value.
|
||||
|
||||
* tests/test-pick.c: Test case for picking. It creates 192 actors
|
||||
at known positions and stores their gids. It then calls
|
||||
clutter_stage_get_actor_at_pos with each position to check that
|
||||
the right gid is returned.
|
||||
|
||||
* tests/Makefile.am (noinst_PROGRAMS): Add test-pick
|
||||
|
||||
2008-09-12 Neil Roberts <neil@linux.intel.com>
|
||||
|
||||
Bug 1010 - ClutterLabel does not update the layout (again)
|
||||
|
@ -304,9 +304,9 @@ _clutter_id_to_color (guint id, ClutterColor *col)
|
||||
blue = blue * 2 + 1;
|
||||
|
||||
/* shift up to be full 8bit values */
|
||||
red = red << (8 - ctx->fb_r_mask);
|
||||
green = green << (8 - ctx->fb_g_mask);
|
||||
blue = blue << (8 - ctx->fb_b_mask);
|
||||
red = (red << (8 - ctx->fb_r_mask)) | (0xff >> (ctx->fb_r_mask + 1));
|
||||
green = (green << (8 - ctx->fb_g_mask)) | (0xff >> (ctx->fb_g_mask + 1));
|
||||
blue = (blue << (8 - ctx->fb_b_mask)) | (0xff >> (ctx->fb_b_mask + 1));
|
||||
|
||||
col->red = red;
|
||||
col->green = green;
|
||||
|
@ -14,7 +14,7 @@ noinst_PROGRAMS = test-textures test-events test-offscreen test-scale \
|
||||
test-cogl-tex-polygon test-stage-read-pixels \
|
||||
test-random-text test-clip test-paint-wrapper \
|
||||
test-texture-quality test-entry-auto test-layout \
|
||||
test-invariants test-label-cache
|
||||
test-invariants test-label-cache test-pick
|
||||
|
||||
if X11_TESTS
|
||||
noinst_PROGRAMS += test-pixmap
|
||||
@ -73,5 +73,6 @@ test_layout_SOURCES = test-layout.c
|
||||
test_invariants_SOURCES = test-invariants.c
|
||||
test_devices_SOURCES = test-devices.c
|
||||
test_label_cache_SOURCES = test-label-cache.c
|
||||
test_pick_SOURCES = test-pick.c
|
||||
|
||||
EXTRA_DIST = redhand.png test-script.json
|
||||
|
99
tests/test-pick.c
Normal file
99
tests/test-pick.c
Normal file
@ -0,0 +1,99 @@
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#define STAGE_WIDTH 320
|
||||
#define STAGE_HEIGHT 200
|
||||
#define ACTORS_X 12
|
||||
#define ACTORS_Y 16
|
||||
|
||||
typedef struct _Data Data;
|
||||
|
||||
struct _Data
|
||||
{
|
||||
ClutterActor *stage;
|
||||
int y, x;
|
||||
guint32 gids[ACTORS_X * ACTORS_Y];
|
||||
guint actor_width, actor_height;
|
||||
int ret;
|
||||
};
|
||||
|
||||
static gboolean
|
||||
on_timeout (Data *data)
|
||||
{
|
||||
int y, x;
|
||||
|
||||
for (y = 0; y < ACTORS_Y; y++)
|
||||
for (x = 0; x < ACTORS_X; x++)
|
||||
{
|
||||
gboolean pass = FALSE;
|
||||
guint32 gid;
|
||||
ClutterActor *actor
|
||||
= clutter_stage_get_actor_at_pos (CLUTTER_STAGE (data->stage),
|
||||
x * data->actor_width
|
||||
+ data->actor_width / 2,
|
||||
y * data->actor_height
|
||||
+ data->actor_height / 2);
|
||||
|
||||
printf ("actor %u -> ", data->gids[y * ACTORS_X + x]);
|
||||
|
||||
if (actor == NULL)
|
||||
printf ("NULL: FAIL\n");
|
||||
else
|
||||
{
|
||||
gid = clutter_actor_get_gid (actor);
|
||||
if (gid == data->gids[y * ACTORS_X + x])
|
||||
pass = TRUE;
|
||||
printf ("% 8i: %s\n", gid, pass ? "pass" : "FAIL");
|
||||
}
|
||||
|
||||
if (!pass)
|
||||
data->ret = 1;
|
||||
}
|
||||
|
||||
clutter_main_quit ();
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int y, x;
|
||||
Data data;
|
||||
|
||||
data.ret = 0;
|
||||
|
||||
clutter_init (&argc, &argv);
|
||||
|
||||
data.stage = clutter_stage_get_default ();
|
||||
|
||||
clutter_actor_set_size (data.stage, STAGE_WIDTH, STAGE_HEIGHT);
|
||||
data.actor_width = STAGE_WIDTH / ACTORS_X;
|
||||
data.actor_height = STAGE_HEIGHT / ACTORS_Y;
|
||||
|
||||
for (y = 0; y < ACTORS_Y; y++)
|
||||
for (x = 0; x < ACTORS_X; x++)
|
||||
{
|
||||
ClutterColor color = { x * 255 / (ACTORS_X - 1),
|
||||
y * 255 / (ACTORS_Y - 1),
|
||||
128, 255 };
|
||||
ClutterGeometry geom = { x * data.actor_width, y * data.actor_height,
|
||||
data.actor_width, data.actor_height };
|
||||
ClutterActor *rect = clutter_rectangle_new_with_color (&color);
|
||||
|
||||
clutter_actor_set_geometry (rect, &geom);
|
||||
|
||||
clutter_container_add (CLUTTER_CONTAINER (data.stage), rect, NULL);
|
||||
|
||||
data.gids[y * ACTORS_X + x] = clutter_actor_get_gid (rect);
|
||||
}
|
||||
|
||||
clutter_actor_show (data.stage);
|
||||
|
||||
g_timeout_add (250, (GSourceFunc) on_timeout, &data);
|
||||
|
||||
clutter_main ();
|
||||
|
||||
printf ("end result: %s\n", data.ret ? "FAIL" : "pass");
|
||||
|
||||
return data.ret;
|
||||
}
|
Loading…
Reference in New Issue
Block a user