[cogl] Add cogl_primitive_foreach_attribute()



commit 354e923cbfa7df31521f8289e96f7ef57cef798d
Author: Neil Roberts <neil linux intel com>
Date:   Mon Feb 6 13:29:35 2012 +0000

    Add cogl_primitive_foreach_attribute()
    
    This adds a public function to iterate the attributes of a
    CoglPrimitive. Previously there was no way to query back the
    attributes but there was methods to query back all of the other
    properties.
    
    Reviewed-by: Robert Bragg <robert linux intel com>

 cogl/cogl-primitive.c                              |   12 +++++++
 cogl/cogl-primitive.h                              |   35 ++++++++++++++++++++
 .../cogl-2.0-experimental-sections.txt             |    2 +
 3 files changed, 49 insertions(+), 0 deletions(-)
---
diff --git a/cogl/cogl-primitive.c b/cogl/cogl-primitive.c
index 10983cd..6fa9a9d 100644
--- a/cogl/cogl-primitive.c
+++ b/cogl/cogl-primitive.c
@@ -596,3 +596,15 @@ cogl_primitive_draw (CoglPrimitive *primitive)
 {
   _cogl_primitive_draw (primitive, 0 /* no flags */);
 }
+
+void
+cogl_primitive_foreach_attribute (CoglPrimitive *primitive,
+                                  CoglPrimitiveAttributeCallback callback,
+                                  void *user_data)
+{
+  int i;
+
+  for (i = 0; i < primitive->n_attributes; i++)
+    if (!callback (primitive, primitive->attributes[i], user_data))
+      break;
+}
diff --git a/cogl/cogl-primitive.h b/cogl/cogl-primitive.h
index 62293ab..debaba1 100644
--- a/cogl/cogl-primitive.h
+++ b/cogl/cogl-primitive.h
@@ -816,6 +816,41 @@ cogl_primitive_draw (CoglPrimitive *primitive);
 gboolean
 cogl_is_primitive (void *object);
 
+/**
+ * CoglPrimitiveAttributeCallback:
+ * @primitive: The #CoglPrimitive whose attributes are being iterated
+ * @attribute: The #CoglAttribute
+ * @user_data: The private data passed to cogl_primitive_foreach_attribute()
+ *
+ * The callback prototype used with cogl_primitive_foreach_attribute()
+ * for iterating all the attributes of a #CoglPrimitive.
+ *
+ * The function should return TRUE to continue iteration or FALSE to
+ * stop.
+ *
+ * Since: 1.10
+ * Stability: Unstable
+ */
+typedef gboolean (* CoglPrimitiveAttributeCallback) (CoglPrimitive *primitive,
+                                                     CoglAttribute *attribute,
+                                                     void *user_data);
+
+/**
+ * cogl_primitive_foreach_attribute:
+ * @primitive: A #CoglPrimitive object
+ * @callback: A #CoglPrimitiveAttributeCallback to be called for each attribute
+ * @user_data: Private data that will be passed to the callback
+ *
+ * Iterates all the attributes of the given #CoglPrimitive.
+ *
+ * Since: 1.10
+ * Stability: Unstable
+ */
+void
+cogl_primitive_foreach_attribute (CoglPrimitive *primitive,
+                                  CoglPrimitiveAttributeCallback callback,
+                                  void *user_data);
+
 G_END_DECLS
 
 #endif /* __COGL_PRIMITIVE_H__ */
diff --git a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
index c6f0c2b..d338d85 100644
--- a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
+++ b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt
@@ -238,6 +238,8 @@ cogl_primitive_set_attributes
 cogl_primitive_set_indices
 cogl_primitive_draw
 cogl_primitive_copy
+CoglPrimitiveAttributeCallback
+cogl_primitive_foreach_attribute
 </SECTION>
 
 <SECTION>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]