tests/clutter: Use a dummy actor for some interactive tests
While completely untested, at least this makes it work "in theory" again. Before it'd listen to signals on the stage, but have an incorrect type signature to handle the test paint procedures, meaning it'd probably crash or cause memory corruptions. What was needed was a signal which in the callback the test could call some cogl functions to paint on the framebuffer. While there is no such signal on the stage, and the ClutterActor::paint signal (which they probably used in the past) is long gone, lets add a "test actor" that is just a wrapper that adds that paint signal with a paint context. The tests that need it are changed to add this actor to the stage, and to listen to the paint signal on the actor instead of incorrectly listening on stage signals. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2807>
This commit is contained in:
parent
48dc8073de
commit
64c3b824fa
@ -15,6 +15,13 @@ typedef struct
|
|||||||
MetaContext *context;
|
MetaContext *context;
|
||||||
} ClutterTestEnvironment;
|
} ClutterTestEnvironment;
|
||||||
|
|
||||||
|
struct _ClutterTestActor
|
||||||
|
{
|
||||||
|
ClutterActor parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (ClutterTestActor, clutter_test_actor, CLUTTER_TYPE_ACTOR)
|
||||||
|
|
||||||
static ClutterTestEnvironment *test_environ = NULL;
|
static ClutterTestEnvironment *test_environ = NULL;
|
||||||
|
|
||||||
static GMainLoop *clutter_test_main_loop = NULL;
|
static GMainLoop *clutter_test_main_loop = NULL;
|
||||||
@ -485,3 +492,31 @@ clutter_test_check_color_at_point (ClutterActor *stage,
|
|||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_actor_paint (ClutterActor *actor,
|
||||||
|
ClutterPaintContext *paint_context)
|
||||||
|
{
|
||||||
|
g_signal_emit_by_name (actor, "paint", paint_context);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_test_actor_class_init (ClutterTestActorClass *klass)
|
||||||
|
{
|
||||||
|
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
||||||
|
|
||||||
|
actor_class->paint = test_actor_paint;
|
||||||
|
|
||||||
|
g_signal_new ("paint",
|
||||||
|
G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
0,
|
||||||
|
NULL, NULL, NULL,
|
||||||
|
G_TYPE_NONE, 1,
|
||||||
|
CLUTTER_TYPE_PAINT_CONTEXT);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_test_actor_init (ClutterTestActor *test_actor)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@ -87,6 +87,11 @@ main (int argc, char *argv[]) \
|
|||||||
return clutter_test_run (); \
|
return clutter_test_run (); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CLUTTER_TYPE_TEST_ACTOR (clutter_test_actor_get_type ())
|
||||||
|
CLUTTER_EXPORT
|
||||||
|
G_DECLARE_FINAL_TYPE (ClutterTestActor, clutter_test_actor,
|
||||||
|
CLUTTER, TEST_ACTOR, ClutterActor)
|
||||||
|
|
||||||
CLUTTER_EXPORT
|
CLUTTER_EXPORT
|
||||||
void clutter_test_init (int *argc,
|
void clutter_test_init (int *argc,
|
||||||
char ***argv);
|
char ***argv);
|
||||||
|
@ -166,8 +166,8 @@ static unsigned int timeout_id = 0;
|
|||||||
static int shader_no = 0;
|
static int shader_no = 0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_after_paint (ClutterActor *actor,
|
on_paint (ClutterActor *actor,
|
||||||
ClutterPaintContext *paint_context)
|
ClutterPaintContext *paint_context)
|
||||||
{
|
{
|
||||||
CoglFramebuffer *framebuffer =
|
CoglFramebuffer *framebuffer =
|
||||||
clutter_paint_context_get_framebuffer (paint_context);
|
clutter_paint_context_get_framebuffer (paint_context);
|
||||||
@ -307,6 +307,7 @@ G_MODULE_EXPORT int
|
|||||||
test_cogl_shader_glsl_main (int argc, char *argv[])
|
test_cogl_shader_glsl_main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
ClutterActor *stage;
|
ClutterActor *stage;
|
||||||
|
ClutterActor *actor;
|
||||||
char *file;
|
char *file;
|
||||||
GError *error;
|
GError *error;
|
||||||
ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff };
|
ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff };
|
||||||
@ -317,6 +318,8 @@ test_cogl_shader_glsl_main (int argc, char *argv[])
|
|||||||
clutter_test_init (&argc, &argv);
|
clutter_test_init (&argc, &argv);
|
||||||
|
|
||||||
stage = clutter_test_get_stage ();
|
stage = clutter_test_get_stage ();
|
||||||
|
actor = g_object_new (CLUTTER_TYPE_TEST_ACTOR, NULL);
|
||||||
|
clutter_actor_add_child (stage, actor);
|
||||||
|
|
||||||
clutter_stage_set_title (CLUTTER_STAGE (stage), "Assembly Shader Test");
|
clutter_stage_set_title (CLUTTER_STAGE (stage), "Assembly Shader Test");
|
||||||
clutter_actor_set_background_color (CLUTTER_ACTOR (stage), &stage_color);
|
clutter_actor_set_background_color (CLUTTER_ACTOR (stage), &stage_color);
|
||||||
@ -331,7 +334,7 @@ test_cogl_shader_glsl_main (int argc, char *argv[])
|
|||||||
cogl_pipeline_set_layer_texture (pipeline, 0, redhand);
|
cogl_pipeline_set_layer_texture (pipeline, 0, redhand);
|
||||||
|
|
||||||
set_shader_num (0);
|
set_shader_num (0);
|
||||||
g_signal_connect (CLUTTER_STAGE (stage), "after-paint", G_CALLBACK (on_after_paint), NULL);
|
g_signal_connect (actor, "paint", G_CALLBACK (on_paint), NULL);
|
||||||
|
|
||||||
clutter_actor_set_reactive (stage, TRUE);
|
clutter_actor_set_reactive (stage, TRUE);
|
||||||
g_signal_connect (stage, "button-release-event",
|
g_signal_connect (stage, "button-release-event",
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <gmodule.h>
|
#include <gmodule.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <clutter/clutter.h>
|
#include <clutter/clutter.h>
|
||||||
|
#include <clutter/clutter-mutter.h>
|
||||||
#include <cogl/cogl.h>
|
#include <cogl/cogl.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
@ -100,9 +101,9 @@ TestCallback tests[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_after_paint (ClutterActor *actor,
|
on_paint (ClutterActor *actor,
|
||||||
ClutterPaintContext *paint_context,
|
ClutterPaintContext *paint_context,
|
||||||
TestState *state)
|
TestState *state)
|
||||||
{
|
{
|
||||||
tests[state->current_test] (state, paint_context);
|
tests[state->current_test] (state, paint_context);
|
||||||
}
|
}
|
||||||
@ -120,6 +121,7 @@ main (int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
TestState state;
|
TestState state;
|
||||||
ClutterActor *stage;
|
ClutterActor *stage;
|
||||||
|
ClutterActor *actor;
|
||||||
|
|
||||||
g_setenv ("CLUTTER_VBLANK", "none", FALSE);
|
g_setenv ("CLUTTER_VBLANK", "none", FALSE);
|
||||||
g_setenv ("CLUTTER_SHOW_FPS", "1", FALSE);
|
g_setenv ("CLUTTER_SHOW_FPS", "1", FALSE);
|
||||||
@ -129,6 +131,8 @@ main (int argc, char *argv[])
|
|||||||
state.current_test = 0;
|
state.current_test = 0;
|
||||||
|
|
||||||
state.stage = stage = clutter_test_get_stage ();
|
state.stage = stage = clutter_test_get_stage ();
|
||||||
|
actor = g_object_new (CLUTTER_TYPE_TEST_ACTOR, NULL);
|
||||||
|
clutter_actor_add_child (stage, actor);
|
||||||
|
|
||||||
clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT);
|
clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT);
|
||||||
clutter_actor_set_background_color (CLUTTER_ACTOR (stage), CLUTTER_COLOR_White);
|
clutter_actor_set_background_color (CLUTTER_ACTOR (stage), CLUTTER_COLOR_White);
|
||||||
@ -137,7 +141,7 @@ main (int argc, char *argv[])
|
|||||||
/* We want continuous redrawing of the stage... */
|
/* We want continuous redrawing of the stage... */
|
||||||
clutter_threads_add_idle (queue_redraw, stage);
|
clutter_threads_add_idle (queue_redraw, stage);
|
||||||
|
|
||||||
g_signal_connect (CLUTTER_STAGE (stage), "after-paint", G_CALLBACK (on_after_paint), &state);
|
g_signal_connect (actor, "paint", G_CALLBACK (on_paint), &state);
|
||||||
|
|
||||||
clutter_actor_show (stage);
|
clutter_actor_show (stage);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user