diff --git a/src/tests/clutter/interactive/test-cogl-offscreen.c b/src/tests/clutter/interactive/test-cogl-offscreen.c index 5fe90a9ee..1c4645c75 100644 --- a/src/tests/clutter/interactive/test-cogl-offscreen.c +++ b/src/tests/clutter/interactive/test-cogl-offscreen.c @@ -13,50 +13,19 @@ G_BEGIN_DECLS #define TEST_TYPE_COGLBOX test_coglbox_get_type() -#define TEST_COGLBOX(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - TEST_TYPE_COGLBOX, TestCoglbox)) - -#define TEST_COGLBOX_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - TEST_TYPE_COGLBOX, TestCoglboxClass)) - -#define TEST_IS_COGLBOX(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - TEST_TYPE_COGLBOX)) - -#define TEST_IS_COGLBOX_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - TEST_TYPE_COGLBOX)) - -#define TEST_COGLBOX_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - TEST_TYPE_COGLBOX, TestCoglboxClass)) - -typedef struct _TestCoglbox TestCoglbox; -typedef struct _TestCoglboxClass TestCoglboxClass; -typedef struct _TestCoglboxPrivate TestCoglboxPrivate; +static +G_DECLARE_FINAL_TYPE (TestCoglbox, test_coglbox, TEST, COGLBOX, ClutterActor) struct _TestCoglbox { ClutterActor parent; - /*< private >*/ - TestCoglboxPrivate *priv; + CoglHandle texhand_id; + CoglHandle texture_id; + CoglFramebuffer *framebuffer; }; -struct _TestCoglboxClass -{ - ClutterActorClass parent_class; - - /* padding for future expansion */ - void (*_test_coglbox1) (void); - void (*_test_coglbox2) (void); - void (*_test_coglbox3) (void); - void (*_test_coglbox4) (void); -}; - -static GType test_coglbox_get_type (void) G_GNUC_CONST; +G_DEFINE_TYPE (TestCoglbox, test_coglbox, CLUTTER_TYPE_ACTOR); int test_cogl_offscreen_main (int argc, char *argv[]); @@ -66,21 +35,6 @@ test_cogl_offscreen_describe (void); G_END_DECLS -/* Coglbox private declaration - *--------------------------------------------------*/ - -struct _TestCoglboxPrivate -{ - CoglHandle texhand_id; - CoglHandle texture_id; - CoglFramebuffer *framebuffer; -}; - -G_DEFINE_TYPE_WITH_PRIVATE (TestCoglbox, test_coglbox, CLUTTER_TYPE_ACTOR); - -#define TEST_COGLBOX_GET_PRIVATE(obj) \ -(test_coglbox_get_instance_private (TEST_COGLBOX ((obj)))) - /* Coglbox implementation *--------------------------------------------------*/ @@ -88,7 +42,7 @@ static void test_coglbox_paint (ClutterActor *self, ClutterPaintContext *paint_context) { - TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (self); + TestCoglbox *coglbox = TEST_COGLBOX (self); CoglFramebuffer *framebuffer = clutter_paint_context_get_framebuffer (paint_context); CoglContext *ctx = cogl_framebuffer_get_context (framebuffer); @@ -101,7 +55,7 @@ test_coglbox_paint (ClutterActor *self, cogl_object_unref (pipeline); pipeline = cogl_pipeline_new (ctx); - cogl_pipeline_set_layer_texture (pipeline, 0, priv->texhand_id); + cogl_pipeline_set_layer_texture (pipeline, 0, coglbox->texhand_id); cogl_framebuffer_draw_textured_rectangle (framebuffer, pipeline, 0, 0, 400, 400, @@ -111,17 +65,17 @@ test_coglbox_paint (ClutterActor *self, pipeline = cogl_pipeline_new (ctx); cogl_pipeline_set_color4ub (pipeline, 0xff, 0, 0, 0xff); - cogl_framebuffer_draw_rectangle (priv->framebuffer, pipeline, + cogl_framebuffer_draw_rectangle (coglbox->framebuffer, pipeline, 20, 20, 20 + 100, 20 + 100); cogl_pipeline_set_color4ub (pipeline, 0, 0xff, 0, 0xff); - cogl_framebuffer_draw_rectangle (priv->framebuffer, pipeline, + cogl_framebuffer_draw_rectangle (coglbox->framebuffer, pipeline, 80, 80, 80 + 100, 80 + 100); cogl_object_unref (pipeline); pipeline = cogl_pipeline_new (ctx); cogl_pipeline_set_color4ub (pipeline, 0x88, 0x88, 0x88, 0x88); - cogl_pipeline_set_layer_texture (pipeline, 0, priv->texture_id); + cogl_pipeline_set_layer_texture (pipeline, 0, coglbox->texture_id); cogl_framebuffer_draw_textured_rectangle (framebuffer, pipeline, 100, 100, 300, 300, @@ -141,12 +95,10 @@ test_coglbox_finalize (GObject *object) static void test_coglbox_dispose (GObject *object) { - TestCoglboxPrivate *priv; + TestCoglbox *coglbox = TEST_COGLBOX (object); - priv = TEST_COGLBOX_GET_PRIVATE (object); - - cogl_object_unref (priv->texture_id); - g_object_unref (priv->framebuffer); + cogl_object_unref (coglbox->texture_id); + g_object_unref (coglbox->framebuffer); G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object); } @@ -247,7 +199,7 @@ setup_viewport (CoglFramebuffer *framebuffer, static void test_coglbox_map (ClutterActor *actor) { - TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (actor); + TestCoglbox *coglbox = TEST_COGLBOX (actor); ClutterActor *stage; ClutterPerspective perspective; float stage_width; @@ -257,48 +209,45 @@ test_coglbox_map (ClutterActor *actor) CLUTTER_ACTOR_CLASS (test_coglbox_parent_class)->map (actor); printf ("Creating offscreen\n"); - priv->framebuffer = - COGL_FRAMEBUFFER (cogl_offscreen_new_with_texture (priv->texture_id)); - if (!cogl_framebuffer_allocate (priv->framebuffer, &error)) + coglbox->framebuffer = + COGL_FRAMEBUFFER (cogl_offscreen_new_with_texture (coglbox->texture_id)); + if (!cogl_framebuffer_allocate (coglbox->framebuffer, &error)) g_error ("Failed to allocate framebuffer: %s", error->message); stage = clutter_actor_get_stage (actor); clutter_stage_get_perspective (CLUTTER_STAGE (stage), &perspective); clutter_actor_get_size (stage, &stage_width, &stage_height); - setup_viewport (priv->framebuffer, + setup_viewport (coglbox->framebuffer, stage_width, stage_height, perspective.fovy, perspective.aspect, perspective.z_near, perspective.z_far); - if (!priv->framebuffer) + if (!coglbox->framebuffer) printf ("Failed creating offscreen to texture!\n"); } static void test_coglbox_init (TestCoglbox *self) { - TestCoglboxPrivate *priv; CoglContext *ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ()); gchar *file; - self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self); - printf ("Loading redhand.png\n"); file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); - priv->texhand_id = cogl_texture_new_from_file (file, + self->texhand_id = cogl_texture_new_from_file (file, COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_ANY, NULL); g_free (file); printf ("Creating texture with size\n"); - priv->texture_id = cogl_texture_2d_new_with_size (ctx, 200, 200); + self->texture_id = cogl_texture_2d_new_with_size (ctx, 200, 200); - if (priv->texture_id == NULL) + if (self->texture_id == NULL) printf ("Failed creating texture with size!\n"); } diff --git a/src/tests/clutter/interactive/test-cogl-tex-convert.c b/src/tests/clutter/interactive/test-cogl-tex-convert.c index 069f00f75..77da67ab5 100644 --- a/src/tests/clutter/interactive/test-cogl-tex-convert.c +++ b/src/tests/clutter/interactive/test-cogl-tex-convert.c @@ -13,50 +13,18 @@ G_BEGIN_DECLS #define TEST_TYPE_COGLBOX test_coglbox_get_type() -#define TEST_COGLBOX(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - TEST_TYPE_COGLBOX, TestCoglbox)) - -#define TEST_COGLBOX_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - TEST_TYPE_COGLBOX, TestCoglboxClass)) - -#define TEST_IS_COGLBOX(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - TEST_TYPE_COGLBOX)) - -#define TEST_IS_COGLBOX_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - TEST_TYPE_COGLBOX)) - -#define TEST_COGLBOX_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - TEST_TYPE_COGLBOX, TestCoglboxClass)) - -typedef struct _TestCoglbox TestCoglbox; -typedef struct _TestCoglboxClass TestCoglboxClass; -typedef struct _TestCoglboxPrivate TestCoglboxPrivate; +static +G_DECLARE_FINAL_TYPE (TestCoglbox, test_coglbox, TEST, COGLBOX, ClutterActor) struct _TestCoglbox { ClutterActor parent; - /*< private >*/ - TestCoglboxPrivate *priv; + CoglHandle cogl_tex_id[4]; + gint frame; }; -struct _TestCoglboxClass -{ - ClutterActorClass parent_class; - - /* padding for future expansion */ - void (*_test_coglbox1) (void); - void (*_test_coglbox2) (void); - void (*_test_coglbox3) (void); - void (*_test_coglbox4) (void); -}; - -static GType test_coglbox_get_type (void) G_GNUC_CONST; +G_DEFINE_TYPE (TestCoglbox, test_coglbox, CLUTTER_TYPE_ACTOR); int test_cogl_tex_convert_main (int argc, char *argv[]); @@ -66,20 +34,6 @@ test_cogl_tex_convert_describe (void); G_END_DECLS -/* Coglbox private declaration - *--------------------------------------------------*/ - -struct _TestCoglboxPrivate -{ - CoglHandle cogl_tex_id[4]; - gint frame; -}; - -G_DEFINE_TYPE_WITH_PRIVATE (TestCoglbox, test_coglbox, CLUTTER_TYPE_ACTOR); - -#define TEST_COGLBOX_GET_PRIVATE(obj) \ -(test_coglbox_get_instance_private (TEST_COGLBOX ((obj)))) - /* Coglbox implementation *--------------------------------------------------*/ @@ -87,15 +41,13 @@ static void test_coglbox_paint (ClutterActor *self, ClutterPaintContext *paint_context) { - TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (self); + TestCoglbox *coglbox = TEST_COGLBOX (self); CoglPipeline *pipeline; CoglFramebuffer *framebuffer = clutter_paint_context_get_framebuffer (paint_context); CoglContext *ctx = cogl_framebuffer_get_context (framebuffer); gfloat texcoords[4] = { 0.0, 0.0, 1.0, 1.0 }; - priv = TEST_COGLBOX_GET_PRIVATE (self); - pipeline = cogl_pipeline_new (ctx); cogl_pipeline_set_color4ub (pipeline, 0x66, 0x66, 0xdd, 0xff); cogl_framebuffer_draw_rectangle (framebuffer, pipeline, 0, 0, 400, 400); @@ -104,7 +56,7 @@ test_coglbox_paint (ClutterActor *self, pipeline = cogl_pipeline_new (ctx); cogl_framebuffer_push_matrix (framebuffer); - cogl_pipeline_set_layer_texture (pipeline, 0, priv->cogl_tex_id[0]); + cogl_pipeline_set_layer_texture (pipeline, 0, coglbox->cogl_tex_id[0]); cogl_framebuffer_draw_textured_rectangle (framebuffer, pipeline, 0, 0, 200, 213, texcoords[0], texcoords[1], @@ -113,7 +65,7 @@ test_coglbox_paint (ClutterActor *self, cogl_framebuffer_pop_matrix (framebuffer); cogl_framebuffer_push_matrix (framebuffer); cogl_framebuffer_translate (framebuffer, 200, 0, 0); - cogl_pipeline_set_layer_texture (pipeline, 0, priv->cogl_tex_id[1]); + cogl_pipeline_set_layer_texture (pipeline, 0, coglbox->cogl_tex_id[1]); cogl_framebuffer_draw_textured_rectangle (framebuffer, pipeline, 0, 0, 200, 213, texcoords[0], texcoords[1], @@ -122,7 +74,7 @@ test_coglbox_paint (ClutterActor *self, cogl_framebuffer_pop_matrix (framebuffer); cogl_framebuffer_push_matrix (framebuffer); cogl_framebuffer_translate (framebuffer, 0, 200, 0); - cogl_pipeline_set_layer_texture (pipeline, 0, priv->cogl_tex_id[2]); + cogl_pipeline_set_layer_texture (pipeline, 0, coglbox->cogl_tex_id[2]); cogl_framebuffer_draw_textured_rectangle (framebuffer, pipeline, 0, 0, 200, 213, texcoords[0], texcoords[1], @@ -131,7 +83,7 @@ test_coglbox_paint (ClutterActor *self, cogl_framebuffer_pop_matrix (framebuffer); cogl_framebuffer_push_matrix (framebuffer); cogl_framebuffer_translate (framebuffer, 200, 200, 0); - cogl_pipeline_set_layer_texture (pipeline, 0, priv->cogl_tex_id[3]); + cogl_pipeline_set_layer_texture (pipeline, 0, coglbox->cogl_tex_id[3]); cogl_framebuffer_draw_textured_rectangle (framebuffer, pipeline, 0, 0, 200, 213, texcoords[0], texcoords[1], @@ -151,10 +103,9 @@ test_coglbox_finalize (GObject *object) static void test_coglbox_dispose (GObject *object) { - TestCoglboxPrivate *priv; + TestCoglbox *coglbox = TEST_COGLBOX (object); - priv = TEST_COGLBOX_GET_PRIVATE (object); - cogl_object_unref (priv->cogl_tex_id); + cogl_object_unref (coglbox->cogl_tex_id); G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object); } @@ -162,32 +113,29 @@ test_coglbox_dispose (GObject *object) static void test_coglbox_init (TestCoglbox *self) { - TestCoglboxPrivate *priv; gchar *file; - self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self); - file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); - priv->cogl_tex_id[0] = + self->cogl_tex_id[0] = cogl_texture_new_from_file (file, COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_ANY, NULL); - priv->cogl_tex_id[1] = + self->cogl_tex_id[1] = cogl_texture_new_from_file (file, COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_BGRA_8888, NULL); - priv->cogl_tex_id[2] = + self->cogl_tex_id[2] = cogl_texture_new_from_file (file, COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_ARGB_8888, NULL); - priv->cogl_tex_id[3] = + self->cogl_tex_id[3] = cogl_texture_new_from_file (file, COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_G_8, diff --git a/src/tests/clutter/interactive/test-cogl-tex-polygon.c b/src/tests/clutter/interactive/test-cogl-tex-polygon.c index 3fd60112e..7226484b2 100644 --- a/src/tests/clutter/interactive/test-cogl-tex-polygon.c +++ b/src/tests/clutter/interactive/test-cogl-tex-polygon.c @@ -13,50 +13,21 @@ G_BEGIN_DECLS #define TEST_TYPE_COGLBOX test_coglbox_get_type() -#define TEST_COGLBOX(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - TEST_TYPE_COGLBOX, TestCoglbox)) - -#define TEST_COGLBOX_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - TEST_TYPE_COGLBOX, TestCoglboxClass)) - -#define TEST_IS_COGLBOX(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - TEST_TYPE_COGLBOX)) - -#define TEST_IS_COGLBOX_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - TEST_TYPE_COGLBOX)) - -#define TEST_COGLBOX_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - TEST_TYPE_COGLBOX, TestCoglboxClass)) - -typedef struct _TestCoglbox TestCoglbox; -typedef struct _TestCoglboxClass TestCoglboxClass; -typedef struct _TestCoglboxPrivate TestCoglboxPrivate; +static +G_DECLARE_FINAL_TYPE (TestCoglbox, test_coglbox, TEST, COGLBOX, ClutterActor) struct _TestCoglbox { ClutterActor parent; - /*< private >*/ - TestCoglboxPrivate *priv; + CoglHandle sliced_tex, not_sliced_tex; + gint frame; + gboolean use_sliced; + gboolean use_linear_filtering; }; -struct _TestCoglboxClass -{ - ClutterActorClass parent_class; +G_DEFINE_TYPE (TestCoglbox, test_coglbox, CLUTTER_TYPE_ACTOR); - /* padding for future expansion */ - void (*_test_coglbox1) (void); - void (*_test_coglbox2) (void); - void (*_test_coglbox3) (void); - void (*_test_coglbox4) (void); -}; - -static GType test_coglbox_get_type (void) G_GNUC_CONST; int test_cogl_tex_polygon_main (int argc, char *argv[]); @@ -66,22 +37,6 @@ test_cogl_tex_polygon_describe (void); G_END_DECLS -/* Coglbox private declaration - *--------------------------------------------------*/ - -struct _TestCoglboxPrivate -{ - CoglHandle sliced_tex, not_sliced_tex; - gint frame; - gboolean use_sliced; - gboolean use_linear_filtering; -}; - -G_DEFINE_TYPE_WITH_PRIVATE (TestCoglbox, test_coglbox, CLUTTER_TYPE_ACTOR); - -#define TEST_COGLBOX_GET_PRIVATE(obj) \ -((TestCoglboxPrivate *)test_coglbox_get_instance_private (TEST_COGLBOX ((obj)))) - /* Coglbox implementation *--------------------------------------------------*/ @@ -194,9 +149,9 @@ static void test_coglbox_paint (ClutterActor *self, ClutterPaintContext *paint_context) { - TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (self); - CoglHandle tex_handle = priv->use_sliced ? priv->sliced_tex - : priv->not_sliced_tex; + TestCoglbox *coglbox = TEST_COGLBOX (self); + CoglHandle tex_handle = coglbox->use_sliced ? coglbox->sliced_tex + : coglbox->not_sliced_tex; int tex_width = cogl_texture_get_width (tex_handle); int tex_height = cogl_texture_get_height (tex_handle); CoglPipeline *pipeline; @@ -209,16 +164,16 @@ test_coglbox_paint (ClutterActor *self, cogl_pipeline_set_layer_texture (pipeline, 0, tex_handle); cogl_pipeline_set_layer_filters (pipeline, 0, - priv->use_linear_filtering + coglbox->use_linear_filtering ? COGL_PIPELINE_FILTER_LINEAR : COGL_PIPELINE_FILTER_NEAREST, - priv->use_linear_filtering + coglbox->use_linear_filtering ? COGL_PIPELINE_FILTER_LINEAR : COGL_PIPELINE_FILTER_NEAREST); cogl_framebuffer_push_matrix (framebuffer); cogl_framebuffer_translate (framebuffer, tex_width / 2, 0, 0); - cogl_framebuffer_rotate (framebuffer, priv->frame, 0, 1, 0); + cogl_framebuffer_rotate (framebuffer, coglbox->frame, 0, 1, 0); cogl_framebuffer_translate (framebuffer, -tex_width / 2, 0, 0); /* Draw a hand and reflect it */ @@ -235,7 +190,7 @@ test_coglbox_paint (ClutterActor *self, cogl_framebuffer_push_matrix (framebuffer); cogl_framebuffer_translate (framebuffer, tex_width * 3 / 2 + 60, 0, 0); - cogl_framebuffer_rotate (framebuffer, priv->frame, 0, 1, 0); + cogl_framebuffer_rotate (framebuffer, coglbox->frame, 0, 1, 0); cogl_framebuffer_translate (framebuffer, -tex_width / 2 - 10, 0, 0); /* Draw the texture split into two triangles */ @@ -266,11 +221,10 @@ test_coglbox_finalize (GObject *object) static void test_coglbox_dispose (GObject *object) { - TestCoglboxPrivate *priv; + TestCoglbox *coglbox = TEST_COGLBOX (object); - priv = TEST_COGLBOX_GET_PRIVATE (object); - cogl_object_unref (priv->not_sliced_tex); - cogl_object_unref (priv->sliced_tex); + cogl_object_unref (coglbox->not_sliced_tex); + cogl_object_unref (coglbox->sliced_tex); G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object); } @@ -278,22 +232,19 @@ test_coglbox_dispose (GObject *object) static void test_coglbox_init (TestCoglbox *self) { - TestCoglboxPrivate *priv; GError *error = NULL; gchar *file; - self->priv = priv = TEST_COGLBOX_GET_PRIVATE (self); - - priv->use_linear_filtering = FALSE; - priv->use_sliced = FALSE; + self->use_linear_filtering = FALSE; + self->use_sliced = FALSE; file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); - priv->sliced_tex = + self->sliced_tex = cogl_texture_new_from_file (file, COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_ANY, &error); - if (priv->sliced_tex == NULL) + if (self->sliced_tex == NULL) { if (error) { @@ -305,12 +256,12 @@ test_coglbox_init (TestCoglbox *self) g_warning ("Texture loading failed: "); } - priv->not_sliced_tex = + self->not_sliced_tex = cogl_texture_new_from_file (file, COGL_TEXTURE_NO_SLICING, COGL_PIXEL_FORMAT_ANY, &error); - if (priv->not_sliced_tex == NULL) + if (self->not_sliced_tex == NULL) { if (error) { @@ -346,10 +297,10 @@ frame_cb (ClutterTimeline *timeline, int elapsed_msecs, gpointer data) { - TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (data); + TestCoglbox *coglbox = TEST_COGLBOX (data); gdouble progress = clutter_timeline_get_progress (timeline); - priv->frame = 360.0 * progress; + coglbox->frame = 360.0 * progress; clutter_actor_queue_redraw (CLUTTER_ACTOR (data)); } @@ -392,7 +343,7 @@ G_MODULE_EXPORT int test_cogl_tex_polygon_main (int argc, char *argv[]) { ClutterActor *stage; - ClutterActor *coglbox; + TestCoglbox *coglbox; ClutterActor *filtering_toggle; ClutterActor *slicing_toggle; ClutterActor *note; @@ -409,8 +360,9 @@ test_cogl_tex_polygon_main (int argc, char *argv[]) g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); /* Cogl Box */ - coglbox = test_coglbox_new (); - clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox); + coglbox = TEST_COGLBOX (test_coglbox_new ()); + clutter_container_add_actor (CLUTTER_CONTAINER (stage), + CLUTTER_ACTOR (coglbox)); /* Timeline for animation */ timeline = clutter_timeline_new_for_actor (stage, 6000); @@ -419,15 +371,12 @@ test_cogl_tex_polygon_main (int argc, char *argv[]) clutter_timeline_start (timeline); /* Labels for toggling settings */ - slicing_toggle = make_toggle ("Texture slicing: ", - &(TEST_COGLBOX_GET_PRIVATE (coglbox) - ->use_sliced)); + slicing_toggle = make_toggle ("Texture slicing: ", &coglbox->use_sliced); clutter_actor_set_position (slicing_toggle, 0, clutter_actor_get_height (stage) - clutter_actor_get_height (slicing_toggle)); filtering_toggle = make_toggle ("Linear filtering: ", - &(TEST_COGLBOX_GET_PRIVATE (coglbox) - ->use_linear_filtering)); + &coglbox->use_linear_filtering); clutter_actor_set_position (filtering_toggle, 0, clutter_actor_get_y (slicing_toggle) - clutter_actor_get_height (filtering_toggle)); diff --git a/src/tests/clutter/interactive/test-cogl-tex-tile.c b/src/tests/clutter/interactive/test-cogl-tex-tile.c index b316f2a2b..4c6b91d65 100644 --- a/src/tests/clutter/interactive/test-cogl-tex-tile.c +++ b/src/tests/clutter/interactive/test-cogl-tex-tile.c @@ -14,50 +14,18 @@ G_BEGIN_DECLS #define TEST_TYPE_COGLBOX test_coglbox_get_type() -#define TEST_COGLBOX(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - TEST_TYPE_COGLBOX, TestCoglbox)) - -#define TEST_COGLBOX_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - TEST_TYPE_COGLBOX, TestCoglboxClass)) - -#define TEST_IS_COGLBOX(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - TEST_TYPE_COGLBOX)) - -#define TEST_IS_COGLBOX_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - TEST_TYPE_COGLBOX)) - -#define TEST_COGLBOX_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - TEST_TYPE_COGLBOX, TestCoglboxClass)) - -typedef struct _TestCoglbox TestCoglbox; -typedef struct _TestCoglboxClass TestCoglboxClass; -typedef struct _TestCoglboxPrivate TestCoglboxPrivate; +static +G_DECLARE_FINAL_TYPE (TestCoglbox, test_coglbox, TEST, COGLBOX, ClutterActor) struct _TestCoglbox { ClutterActor parent; - /*< private >*/ - TestCoglboxPrivate *priv; + CoglHandle cogl_tex_id; + gdouble animation_progress; }; -struct _TestCoglboxClass -{ - ClutterActorClass parent_class; - - /* padding for future expansion */ - void (*_test_coglbox1) (void); - void (*_test_coglbox2) (void); - void (*_test_coglbox3) (void); - void (*_test_coglbox4) (void); -}; - -static GType test_coglbox_get_type (void) G_GNUC_CONST; +G_DEFINE_TYPE (TestCoglbox, test_coglbox, CLUTTER_TYPE_ACTOR); int test_cogl_tex_tile_main (int argc, char *argv[]); @@ -67,20 +35,6 @@ test_cogl_tex_tile_describe (void); G_END_DECLS -/* Coglbox private declaration - *--------------------------------------------------*/ - -struct _TestCoglboxPrivate -{ - CoglHandle cogl_tex_id; - gdouble animation_progress; -}; - -G_DEFINE_TYPE_WITH_PRIVATE (TestCoglbox, test_coglbox, CLUTTER_TYPE_ACTOR); - -#define TEST_COGLBOX_GET_PRIVATE(obj) \ -(test_coglbox_get_instance_private (TEST_COGLBOX ((obj)))) - /* Coglbox implementation *--------------------------------------------------*/ @@ -88,7 +42,7 @@ static void test_coglbox_paint (ClutterActor *self, ClutterPaintContext *paint_context) { - TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (self); + TestCoglbox *coglbox = TEST_COGLBOX (self); CoglFramebuffer *framebuffer = clutter_paint_context_get_framebuffer (paint_context); CoglContext *ctx = cogl_framebuffer_get_context (framebuffer); @@ -98,11 +52,11 @@ test_coglbox_paint (ClutterActor *self, gfloat frac; gint t; - angle = priv->animation_progress * 2 * G_PI; + angle = coglbox->animation_progress * 2 * G_PI; - frac = ((priv->animation_progress <= 0.5f - ? priv->animation_progress - : 1.0f - priv->animation_progress) + 0.5f) * 2.0f; + frac = ((coglbox->animation_progress <= 0.5f + ? coglbox->animation_progress + : 1.0f - coglbox->animation_progress) + 0.5f) * 2.0f; for (t=0; t<4; t+=2) { @@ -113,8 +67,6 @@ test_coglbox_paint (ClutterActor *self, texcoords[t+1] *= frac; } - priv = TEST_COGLBOX_GET_PRIVATE (self); - cogl_framebuffer_push_matrix (framebuffer); pipeline = cogl_pipeline_new (ctx); @@ -125,7 +77,7 @@ test_coglbox_paint (ClutterActor *self, cogl_framebuffer_translate (framebuffer, 100, 100, 0); pipeline = cogl_pipeline_new (ctx); - cogl_pipeline_set_layer_texture (pipeline, 0, priv->cogl_tex_id); + cogl_pipeline_set_layer_texture (pipeline, 0, coglbox->cogl_tex_id); cogl_framebuffer_draw_textured_rectangle (framebuffer, pipeline, 0, 0, 200, 213, texcoords[0], texcoords[1], @@ -144,10 +96,9 @@ test_coglbox_finalize (GObject *object) static void test_coglbox_dispose (GObject *object) { - TestCoglboxPrivate *priv; + TestCoglbox *coglbox = TEST_COGLBOX (object); - priv = TEST_COGLBOX_GET_PRIVATE (object); - cogl_object_unref (priv->cogl_tex_id); + cogl_object_unref (coglbox->cogl_tex_id); G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object); } @@ -155,13 +106,10 @@ test_coglbox_dispose (GObject *object) static void test_coglbox_init (TestCoglbox *self) { - TestCoglboxPrivate *priv; gchar *file; - self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self); - file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); - priv->cogl_tex_id = cogl_texture_new_from_file (file, + self->cogl_tex_id = cogl_texture_new_from_file (file, COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_ANY, NULL); @@ -190,9 +138,9 @@ frame_cb (ClutterTimeline *timeline, int msecs, gpointer data) { - TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (data); + TestCoglbox *coglbox = TEST_COGLBOX (data); - priv->animation_progress = clutter_timeline_get_progress (timeline); + coglbox->animation_progress = clutter_timeline_get_progress (timeline); clutter_actor_queue_redraw (CLUTTER_ACTOR (data)); }