[clutter/wip/actor-content: 33/33] content: Allow retrieving the material
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/wip/actor-content: 33/33] content: Allow retrieving the material
- Date: Wed, 18 May 2011 11:13:11 +0000 (UTC)
commit 6884ab94a5c61f9c45af28bffa0cd3b2feeeae92
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Tue Apr 19 14:28:15 2011 +0100
content: Allow retrieving the material
Add a virtual function to the Content interface, to allow retrieving the
Cogl material from a Content implementation.
clutter/clutter-content.c | 26 ++++++++++++++++++++++++++
clutter/clutter-content.h | 31 +++++++++++++++++++------------
clutter/clutter-image.c | 13 +++++++++++++
tests/interactive/test-image-content.c | 10 ++++++++++
4 files changed, 68 insertions(+), 12 deletions(-)
---
diff --git a/clutter/clutter-content.c b/clutter/clutter-content.c
index a296a86..1221d8c 100644
--- a/clutter/clutter-content.c
+++ b/clutter/clutter-content.c
@@ -116,6 +116,12 @@ clutter_content_real_get_paint_volume (ClutterContent *content,
return TRUE;
}
+static CoglMaterial *
+clutter_content_real_get_material (ClutterContent *content)
+{
+ return NULL;
+}
+
static void
clutter_content_real_invalidate (ClutterContent *content)
{
@@ -147,6 +153,7 @@ clutter_content_default_init (ClutterContentInterface *iface)
iface->update_geometry = clutter_content_real_update_geometry;
iface->paint_content = clutter_content_real_paint_content;
iface->get_paint_volume = clutter_content_real_get_paint_volume;
+ iface->get_material = clutter_content_real_get_material;
iface->invalidate = clutter_content_real_invalidate;
}
@@ -400,6 +407,25 @@ _clutter_content_add_actor (ClutterContent *content,
}
/**
+ * clutter_content_get_material:
+ * @content: a #ClutterContent
+ *
+ * Requests the Cogl material of @content, if any.
+ *
+ * Return value: (transfer none): a pointer to the Cogl material used
+ * by the #ClutterContent implementation, or %NULL
+ *
+ * Since: 1.8
+ */
+CoglMaterial *
+clutter_content_get_material (ClutterContent *content)
+{
+ g_return_val_if_fail (CLUTTER_IS_CONTENT (content), NULL);
+
+ return CLUTTER_CONTENT_GET_IFACE (content)->get_material (content);
+}
+
+/**
* clutter_content_invalidate:
* @content: a #ClutterContent
*
diff --git a/clutter/clutter-content.h b/clutter/clutter-content.h
index 105d33a..1ce5b93 100644
--- a/clutter/clutter-content.h
+++ b/clutter/clutter-content.h
@@ -29,6 +29,7 @@
#ifndef __CLUTTER_CONTENT_H__
#define __CLUTTER_CONTENT_H__
+#include <cogl/cogl.h>
#include <clutter/clutter-types.h>
G_BEGIN_DECLS
@@ -50,6 +51,8 @@ typedef struct _ClutterContentIface ClutterContentIface;
* the given actor
* @get_paint_volume: virtual function, used to update the paint volume
* for the given actor
+ * @get_material: virtual function, used to retrieve the Cogl material
+ * used by the content
* @invalidate: virtual function, used to notify actors of a content
* update
*
@@ -63,18 +66,20 @@ struct _ClutterContentIface
GTypeInterface g_iface;
/*< public >*/
- gboolean (* setup_material) (ClutterContent *content,
- ClutterActor *actor);
- void (* update_geometry) (ClutterContent *content,
- ClutterActor *actor);
- void (* paint_content) (ClutterContent *content,
- ClutterActor *actor);
-
- gboolean (* get_paint_volume) (ClutterContent *content,
- ClutterActor *actor,
- ClutterPaintVolume *volume);
-
- void (* invalidate) (ClutterContent *content);
+ gboolean (* setup_material) (ClutterContent *content,
+ ClutterActor *actor);
+ void (* update_geometry) (ClutterContent *content,
+ ClutterActor *actor);
+ void (* paint_content) (ClutterContent *content,
+ ClutterActor *actor);
+
+ gboolean (* get_paint_volume) (ClutterContent *content,
+ ClutterActor *actor,
+ ClutterPaintVolume *volume);
+
+ CoglMaterial *(* get_material) (ClutterContent *content);
+
+ void (* invalidate) (ClutterContent *content);
};
GType clutter_content_get_type (void) G_GNUC_CONST;
@@ -90,6 +95,8 @@ gboolean clutter_content_get_paint_volume (ClutterContent *con
ClutterActor *actor,
ClutterPaintVolume *volume);
+CoglMaterial * clutter_content_get_material (ClutterContent *content);
+
void clutter_content_invalidate (ClutterContent *content);
G_END_DECLS
diff --git a/clutter/clutter-image.c b/clutter/clutter-image.c
index 124067b..bb34de6 100644
--- a/clutter/clutter-image.c
+++ b/clutter/clutter-image.c
@@ -116,6 +116,18 @@ _clutter_image_create_material (ClutterImage *image)
return CLUTTER_IMAGE_GET_CLASS (image)->create_material (image);
}
+static CoglMaterial *
+clutter_image_get_material (ClutterContent *content)
+{
+ ClutterImage *image = CLUTTER_IMAGE (content);
+ ClutterImagePrivate *priv = image->priv;
+
+ if (priv->material == NULL)
+ priv->material = _clutter_image_create_material (image);
+
+ return priv->material;
+}
+
static gboolean
clutter_image_setup_material (ClutterContent *content,
ClutterActor *actor)
@@ -134,6 +146,7 @@ static void
clutter_content_iface_init (ClutterContentIface *iface)
{
iface->setup_material = clutter_image_setup_material;
+ iface->get_material = clutter_image_get_material;
}
static void
diff --git a/tests/interactive/test-image-content.c b/tests/interactive/test-image-content.c
index 359c760..84bb46d 100644
--- a/tests/interactive/test-image-content.c
+++ b/tests/interactive/test-image-content.c
@@ -14,6 +14,7 @@ load_async_done (GObject *gobject,
GAsyncResult *result,
gpointer dummy G_GNUC_UNUSED)
{
+ CoglMaterial *material;
GError *error = NULL;
gboolean res;
@@ -24,6 +25,15 @@ load_async_done (GObject *gobject,
g_error_free (error);
return;
}
+
+ material = clutter_content_get_material (CLUTTER_CONTENT (gobject));
+ if (material == NULL)
+ return;
+
+ /* change the layer filters for the Image material */
+ cogl_material_set_layer_filters (material, 0,
+ COGL_MATERIAL_FILTER_LINEAR_MIPMAP_LINEAR,
+ COGL_MATERIAL_FILTER_LINEAR);
}
G_MODULE_EXPORT int
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]