[clutter/wip/actor-content: 31/33] image: Remove size out arguments from load methods
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/wip/actor-content: 31/33] image: Remove size out arguments from load methods
- Date: Wed, 18 May 2011 11:13:01 +0000 (UTC)
commit c3ac13e9ce9dda087413e2f46e3eb64db3031f88
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Tue Apr 19 12:18:37 2011 +0100
image: Remove size out arguments from load methods
We already have clutter_image_get_size() for that, and it makes adding
size constraint arguments or methods weird and complicated.
clutter/clutter-image.c | 26 -----------------
clutter/clutter-image.h | 4 ---
tests/conform/test-image.c | 16 +++++-----
tests/interactive/test-border-image.c | 47 +++++++++++++++++++-------------
tests/interactive/test-image-content.c | 6 +---
5 files changed, 37 insertions(+), 62 deletions(-)
---
diff --git a/clutter/clutter-image.c b/clutter/clutter-image.c
index 568d6f1..fd97797 100644
--- a/clutter/clutter-image.c
+++ b/clutter/clutter-image.c
@@ -434,8 +434,6 @@ clutter_image_load_from_data (ClutterImage *image,
* @image: a #ClutterImage
* @gfile: a #GFile
* @cancellable: (allow-none): a #GCancellable, or %NULL
- * @width: (out): return location for the width of the image, or %NULL
- * @height: (out): return location for the height of the image, or %NULL
* @error: return location for a #GError, or %NULL
*
* Synchronously loads image data available to the location pointed
@@ -457,8 +455,6 @@ gboolean
clutter_image_load (ClutterImage *image,
GFile *gfile,
GCancellable *cancellable,
- gint *width,
- gint *height,
GError **error)
{
ClutterImageLoader *loader;
@@ -546,12 +542,6 @@ clutter_image_load (ClutterImage *image,
g_object_thaw_notify (G_OBJECT (image));
- if (width)
- *width = priv->image_width;
-
- if (height)
- *height = priv->image_height;
-
g_object_unref (loader);
g_object_unref (stream);
@@ -727,8 +717,6 @@ clutter_image_load_async (ClutterImage *image,
* clutter_image_load_finish:
* @image: a #ClutterImage
* @res: a #GAsyncResult
- * @width: (out): return location for the width of the image data, or %NULL
- * @height: (out): return location for the height of the image data, or %NULL
* @error: return location for a #GError, or %NULL
*
* Terminates the asynchronous loading started by clutter_image_load_async()
@@ -741,8 +729,6 @@ clutter_image_load_async (ClutterImage *image,
gboolean
clutter_image_load_finish (ClutterImage *image,
GAsyncResult *res,
- gint *width,
- gint *height,
GError **error)
{
AsyncReadClosure *closure;
@@ -765,12 +751,6 @@ clutter_image_load_finish (ClutterImage *image,
closure = g_simple_async_result_get_op_res_gpointer (simple);
if (closure->error != NULL)
{
- if (width)
- *width = 0;
-
- if (height)
- *height = 0;
-
g_propagate_error (error, closure->error);
closure->error = NULL;
@@ -826,12 +806,6 @@ clutter_image_load_finish (ClutterImage *image,
g_object_thaw_notify (G_OBJECT (image));
- if (width)
- *width = priv->image_width;
-
- if (height)
- *height = priv->image_height;
-
return TRUE;
}
diff --git a/clutter/clutter-image.h b/clutter/clutter-image.h
index 6dfbd5a..48dd16a 100644
--- a/clutter/clutter-image.h
+++ b/clutter/clutter-image.h
@@ -137,8 +137,6 @@ gboolean clutter_image_load_from_data (ClutterImage *image,
gboolean clutter_image_load (ClutterImage *image,
GFile *gfile,
GCancellable *cancellable,
- gint *width,
- gint *height,
GError **error);
void clutter_image_load_async (ClutterImage *image,
GFile *gfile,
@@ -147,8 +145,6 @@ void clutter_image_load_async (ClutterImage *image,
gpointer user_data);
gboolean clutter_image_load_finish (ClutterImage *image,
GAsyncResult *res,
- gint *width,
- gint *height,
GError **error);
void clutter_image_get_size (ClutterImage *image,
diff --git a/tests/conform/test-image.c b/tests/conform/test-image.c
index a607a7c..2a24ec8 100644
--- a/tests/conform/test-image.c
+++ b/tests/conform/test-image.c
@@ -17,18 +17,18 @@ image_sync_loading (void)
width = height = 0;
error = NULL;
- res = clutter_image_load (image, gfile, NULL,
- &width,
- &height,
- &error);
+ res = clutter_image_load (image, gfile, NULL, &error);
if (g_test_verbose() && error != NULL)
g_print ("Unexpected error: %s\n", error->message);
g_assert (error == NULL);
g_assert (res);
+
+ clutter_image_get_size (image, &width, &height);
g_assert_cmpint (width, >, 0);
g_assert_cmpint (height, >, 0);
+
g_assert (clutter_image_get_cogl_texture (image) != COGL_INVALID_HANDLE);
g_object_unref (gfile);
@@ -47,18 +47,18 @@ async_load_done_cb (GObject *gobject,
gboolean res;
width = height = 0;
- res = clutter_image_load_finish (image, result,
- &width,
- &height,
- &error);
+ res = clutter_image_load_finish (image, result, &error);
if (g_test_verbose () && error != NULL)
g_print ("Unexpected error: %s\n", error->message);
g_assert (res);
g_assert (error == NULL);
+
+ clutter_image_get_size (image, &width, &height);
g_assert_cmpint (width, >, 0);
g_assert_cmpint (height, >, 0);
+
g_assert (clutter_image_get_cogl_texture (image) != COGL_INVALID_HANDLE);
g_main_loop_quit (main_loop);
diff --git a/tests/interactive/test-border-image.c b/tests/interactive/test-border-image.c
index 4b0cac7..3eec8ab 100644
--- a/tests/interactive/test-border-image.c
+++ b/tests/interactive/test-border-image.c
@@ -16,17 +16,15 @@ load_async_done (GObject *gobject,
{
GError *error = NULL;
gboolean res;
- int width, height;
- res = clutter_image_load_finish (CLUTTER_IMAGE (gobject), result,
- &width,
- &height,
- &error);
+ res = clutter_image_load_finish (CLUTTER_IMAGE (gobject), result, &error);
if (!res)
{
- g_print ("Unable to load 'border-image.png': %s", error->message);
- g_error_free (error);
- return;
+ if (error != NULL)
+ {
+ g_print ("Unable to load image: %s", error->message);
+ g_error_free (error);
+ }
}
}
@@ -35,7 +33,7 @@ test_border_image_main (int argc,
char *argv[])
{
ClutterActor *stage, *group;
- ClutterContent *content;
+ ClutterContent *bg, *color, *image;
int i, j, n_cols, n_rows;
float last_x, last_y;
GFile *gfile;
@@ -51,11 +49,11 @@ test_border_image_main (int argc,
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
- content = clutter_border_image_new ();
- clutter_border_image_set_slices (CLUTTER_BORDER_IMAGE (content),
+ bg = clutter_border_image_new ();
+ clutter_border_image_set_slices (CLUTTER_BORDER_IMAGE (bg),
0.26, 0.413, 0.26, 0.413);
gfile = g_file_new_for_path (TESTS_DATADIR "/border-image.png");
- clutter_image_load_async (CLUTTER_IMAGE (content), gfile, NULL,
+ clutter_image_load_async (CLUTTER_IMAGE (bg), gfile, NULL,
load_async_done,
NULL);
g_object_unref (gfile);
@@ -64,13 +62,20 @@ test_border_image_main (int argc,
clutter_container_add_actor (CLUTTER_CONTAINER (stage), group);
clutter_actor_add_constraint (group, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.5));
clutter_actor_add_constraint (group, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.5));
- clutter_actor_set_content (group, content);
- g_object_unref (content);
+ clutter_actor_set_content (group, bg);
+ g_object_unref (bg);
+
+ color = clutter_rgba_new (g_random_double_range (0.0, 1.0),
+ g_random_double_range (0.0, 1.0),
+ g_random_double_range (0.0, 1.0),
+ 0.25);
- content = clutter_rgba_new (g_random_double_range (0.0, 1.0),
- g_random_double_range (0.0, 1.0),
- g_random_double_range (0.0, 1.0),
- 0.25);
+ image = CLUTTER_CONTENT (clutter_image_new ());
+ gfile = g_file_new_for_path (TESTS_DATADIR "/redhand.png");
+ clutter_image_load_async (CLUTTER_IMAGE (image), gfile, NULL,
+ load_async_done,
+ NULL);
+ g_object_unref (gfile);
n_cols = (STAGE_WIDTH - (2 * PADDING)) / (RECT_SIZE + (2 * SPACING));
n_rows = (STAGE_HEIGHT - (2 * PADDING)) / (RECT_SIZE + (2 * SPACING));
@@ -82,6 +87,9 @@ test_border_image_main (int argc,
for (j = 0; j < n_cols; j++)
{
ClutterActor *rect = clutter_actor_new ();
+ ClutterContent *content = (i + j) % 2 == 0
+ ? image
+ : color;
clutter_actor_set_position (rect, last_x, last_y);
clutter_actor_set_size (rect, RECT_SIZE, RECT_SIZE);
@@ -97,7 +105,8 @@ test_border_image_main (int argc,
clutter_actor_set_size (group, last_x + PADDING, last_y + PADDING);
- g_object_unref (content);
+ g_object_unref (image);
+ g_object_unref (color);
clutter_main ();
diff --git a/tests/interactive/test-image-content.c b/tests/interactive/test-image-content.c
index 52a580d..359c760 100644
--- a/tests/interactive/test-image-content.c
+++ b/tests/interactive/test-image-content.c
@@ -16,12 +16,8 @@ load_async_done (GObject *gobject,
{
GError *error = NULL;
gboolean res;
- int width, height;
- res = clutter_image_load_finish (CLUTTER_IMAGE (gobject), result,
- &width,
- &height,
- &error);
+ res = clutter_image_load_finish (CLUTTER_IMAGE (gobject), result, &error);
if (!res)
{
g_print ("Unable to load 'redhand.png': %s", error->message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]