[clutter] cairo-texture: Deprecate create()/create_region()
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] cairo-texture: Deprecate create()/create_region()
- Date: Tue, 26 Jul 2011 13:12:35 +0000 (UTC)
commit 278daca61cbeaffbf5515f7d105ff168b33a3be1
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Tue Jul 26 12:53:22 2011 +0100
cairo-texture: Deprecate create()/create_region()
The recommended way of drawing on a ClutterCairoTexture is the ::draw
signal.
clutter/clutter-cairo-texture.c | 8 ++++
clutter/clutter-cairo-texture.h | 2 +
tests/conform/test-clutter-cairo-texture.c | 1 +
tests/interactive/test-bin-layout.c | 21 +++++-----
tests/interactive/test-cairo-flowers.c | 1 +
tests/interactive/test-easing.c | 60 +++++++++++++++++-----------
6 files changed, 59 insertions(+), 34 deletions(-)
---
diff --git a/clutter/clutter-cairo-texture.c b/clutter/clutter-cairo-texture.c
index 74002cb..d1bac41 100644
--- a/clutter/clutter-cairo-texture.c
+++ b/clutter/clutter-cairo-texture.c
@@ -718,6 +718,10 @@ intersect_rectangles (cairo_rectangle_int_t *a,
* to upload the contents of the context when done drawing
*
* Since: 1.0
+ *
+ * Deprecated: 1.8: Use the #ClutterCairoTexture::draw signal and
+ * clutter_cairo_texture_invalidate_rectangle() to obtain a
+ * clipped Cairo context for 2D drawing.
*/
cairo_t *
clutter_cairo_texture_create_region (ClutterCairoTexture *self,
@@ -879,6 +883,10 @@ clutter_cairo_texture_invalidate (ClutterCairoTexture *self)
* to upload the contents of the context when done drawing
*
* Since: 1.0
+ *
+ * Deprecated: 1.8: Use the #ClutterCairoTexture::draw signal and
+ * the clutter_cairo_texture_invalidate() function to obtain a
+ * Cairo context for 2D drawing.
*/
cairo_t *
clutter_cairo_texture_create (ClutterCairoTexture *self)
diff --git a/clutter/clutter-cairo-texture.h b/clutter/clutter-cairo-texture.h
index d529185..cf163ce 100644
--- a/clutter/clutter-cairo-texture.h
+++ b/clutter/clutter-cairo-texture.h
@@ -115,12 +115,14 @@ GType clutter_cairo_texture_get_type (void) G_GNUC_CONST;
ClutterActor * clutter_cairo_texture_new (guint width,
guint height);
+#ifndef CLUTTER_DISABLE_DEPRECATED
cairo_t * clutter_cairo_texture_create_region (ClutterCairoTexture *self,
gint x_offset,
gint y_offset,
gint width,
gint height);
cairo_t * clutter_cairo_texture_create (ClutterCairoTexture *self);
+#endif /* CLUTTER_DISABLE_DEPRECATED */
void clutter_cairo_texture_set_surface_size (ClutterCairoTexture *self,
guint width,
diff --git a/tests/conform/test-clutter-cairo-texture.c b/tests/conform/test-clutter-cairo-texture.c
index a6b73c8..d0700bf 100644
--- a/tests/conform/test-clutter-cairo-texture.c
+++ b/tests/conform/test-clutter-cairo-texture.c
@@ -1,3 +1,4 @@
+#undef CLUTTER_DISABLE_DEPRECATED
#include <clutter/clutter.h>
#include <cogl/cogl.h>
diff --git a/tests/interactive/test-bin-layout.c b/tests/interactive/test-bin-layout.c
index d5aa4d3..c516266 100644
--- a/tests/interactive/test-bin-layout.c
+++ b/tests/interactive/test-bin-layout.c
@@ -7,15 +7,15 @@ static const ClutterColor bg_color = { 0xcc, 0xcc, 0xcc, 0x99 };
static gboolean is_expanded = FALSE;
-static void
-update_background (ClutterActor *tex,
- const ClutterColor *color,
- gfloat width,
- gfloat height)
+static gboolean
+draw_background (ClutterCairoTexture *texture,
+ cairo_t *cr)
{
- cairo_t *cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (tex));
cairo_pattern_t *pat;
gfloat x, y;
+ guint width, height;
+
+ clutter_cairo_texture_get_surface_size (texture, &width, &height);
#define BG_ROUND_RADIUS 12
@@ -33,7 +33,7 @@ update_background (ClutterActor *tex,
cairo_close_path (cr);
- clutter_cairo_set_source_color (cr, color);
+ clutter_cairo_set_source_color (cr, &bg_color);
cairo_stroke (cr);
x += 4;
@@ -63,9 +63,10 @@ update_background (ClutterActor *tex,
cairo_fill (cr);
cairo_pattern_destroy (pat);
- cairo_destroy (cr);
#undef BG_ROUND_RADIUS
+
+ return TRUE;
}
static gboolean
@@ -147,8 +148,7 @@ on_box_allocation_changed (ClutterActor *box,
clutter_cairo_texture_set_surface_size (CLUTTER_CAIRO_TEXTURE (background),
new_width,
new_height);
-
- update_background (background, &bg_color, new_width, new_height);
+ clutter_cairo_texture_invalidate (CLUTTER_CAIRO_TEXTURE (background));
}
G_MODULE_EXPORT int
@@ -183,6 +183,7 @@ test_bin_layout_main (int argc, char *argv[])
* box's size
*/
rect = clutter_cairo_texture_new (100, 100);
+ g_signal_connect (rect, "draw", G_CALLBACK (draw_background), NULL);
/* first method: use clutter_box_pack() */
clutter_box_pack (CLUTTER_BOX (box), rect,
diff --git a/tests/interactive/test-cairo-flowers.c b/tests/interactive/test-cairo-flowers.c
index 32eb650..b2c0352 100644
--- a/tests/interactive/test-cairo-flowers.c
+++ b/tests/interactive/test-cairo-flowers.c
@@ -2,6 +2,7 @@
* Pretty cairo flower hack.
*/
+#undef CLUTTER_DISABLE_DEPRECATED
#include <clutter/clutter.h>
#ifndef _MSC_VER
diff --git a/tests/interactive/test-easing.c b/tests/interactive/test-easing.c
index 09b934f..f4b5b39 100644
--- a/tests/interactive/test-easing.c
+++ b/tests/interactive/test-easing.c
@@ -50,6 +50,9 @@ static ClutterActor *easing_mode_label = NULL;
static ClutterAnimation *last_animation = NULL;
+static ClutterColor stage_color = { 0x88, 0x88, 0xdd, 0xff };
+static ClutterColor bouncer_color = { 0xee, 0x33, 0, 0xff };
+
static void
on_animation_completed (ClutterAnimation *animation,
ClutterActor *rectangle)
@@ -126,23 +129,19 @@ on_button_press (ClutterActor *actor,
return TRUE;
}
-static ClutterActor *
-make_bouncer (const ClutterColor *base_color,
- gfloat width,
- gfloat height)
+static gboolean
+draw_bouncer (ClutterCairoTexture *texture,
+ cairo_t *cr)
{
- ClutterActor *retval;
- cairo_t *cr;
+ guint width, height;
+ float radius;
cairo_pattern_t *pattern;
- gfloat radius = MAX (width, height);
- retval = clutter_cairo_texture_new (width, height);
+ clutter_cairo_texture_get_surface_size (texture, &width, &height);
- cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (retval));
+ radius = MAX (width, height);
- cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
- cairo_paint (cr);
- cairo_set_operator (cr, CAIRO_OPERATOR_ADD);
+ clutter_cairo_texture_clear (texture);
cairo_arc (cr, radius / 2, radius / 2, radius / 2, 0.0, 2.0 * G_PI);
@@ -150,28 +149,41 @@ make_bouncer (const ClutterColor *base_color,
radius, radius, radius);
cairo_pattern_add_color_stop_rgba (pattern,
0,
- base_color->red / 255.0,
- base_color->green / 255.0,
- base_color->blue / 255.0,
- base_color->alpha / 255.0);
+ bouncer_color.red / 255.0,
+ bouncer_color.green / 255.0,
+ bouncer_color.blue / 255.0,
+ bouncer_color.alpha / 255.0);
cairo_pattern_add_color_stop_rgba (pattern,
0.9,
- base_color->red / 255.0,
- base_color->green / 255.0,
- base_color->blue / 255.0,
+ bouncer_color.red / 255.0,
+ bouncer_color.green / 255.0,
+ bouncer_color.blue / 255.0,
0.1);
cairo_set_source (cr, pattern);
cairo_fill_preserve (cr);
cairo_pattern_destroy (pattern);
- cairo_destroy (cr);
+
+ return TRUE;
+}
+
+static ClutterActor *
+make_bouncer (gfloat width,
+ gfloat height)
+{
+ ClutterActor *retval;
+
+ retval = clutter_cairo_texture_new (width, height);
+ g_signal_connect (retval, "draw", G_CALLBACK (draw_bouncer), NULL);
clutter_actor_set_name (retval, "bouncer");
clutter_actor_set_size (retval, width, height);
clutter_actor_set_anchor_point (retval, width / 2, height / 2);
clutter_actor_set_reactive (retval, TRUE);
+ clutter_cairo_texture_invalidate (CLUTTER_CAIRO_TEXTURE (retval));
+
return retval;
}
@@ -198,8 +210,6 @@ G_MODULE_EXPORT int
test_easing_main (int argc, char *argv[])
{
ClutterActor *stage, *rect, *label;
- ClutterColor stage_color = { 0x88, 0x88, 0xdd, 0xff };
- ClutterColor rect_color = { 0xee, 0x33, 0, 0xff };
gchar *text;
gfloat stage_width, stage_height;
gfloat label_width, label_height;
@@ -212,13 +222,15 @@ test_easing_main (int argc, char *argv[])
&error) != CLUTTER_INIT_SUCCESS)
return 1;
- stage = clutter_stage_get_default ();
+ stage = clutter_stage_new ();
+ clutter_stage_set_title (CLUTTER_STAGE (stage), "Easing Modes");
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
+ g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
main_stage = stage;
clutter_actor_get_size (stage, &stage_width, &stage_height);
- rect = make_bouncer (&rect_color, 50, 50);
+ rect = make_bouncer (50, 50);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect);
clutter_actor_set_position (rect, stage_width / 2, stage_height / 2);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]