2010-05-27 18:31:40 -04:00
|
|
|
/*
|
|
|
|
* Cogl
|
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* A Low Level GPU Graphics and Utilities API
|
2010-05-27 18:31:40 -04:00
|
|
|
*
|
2010-05-27 17:24:56 -04:00
|
|
|
* Copyright (C) 2009,2010 Intel Corporation.
|
2010-05-27 18:31:40 -04:00
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
* restriction, including without limitation the rights to use, copy,
|
|
|
|
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
* of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
2010-05-27 18:31:40 -04:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __COGL_OBJECT_H
|
|
|
|
#define __COGL_OBJECT_H
|
|
|
|
|
2013-02-22 10:27:58 -05:00
|
|
|
#include <cogl/cogl-types.h>
|
|
|
|
|
2013-09-02 11:02:42 -04:00
|
|
|
#ifdef COGL_HAS_GTYPE_SUPPORT
|
|
|
|
#include <glib-object.h>
|
|
|
|
#endif
|
|
|
|
|
2013-02-22 10:27:58 -05:00
|
|
|
COGL_BEGIN_DECLS
|
|
|
|
|
2010-05-27 17:24:56 -04:00
|
|
|
typedef struct _CoglObject CoglObject;
|
2010-05-27 18:31:40 -04:00
|
|
|
|
2010-06-01 13:06:47 -04:00
|
|
|
#define COGL_OBJECT(X) ((CoglObject *)X)
|
|
|
|
|
2013-09-02 11:02:42 -04:00
|
|
|
/**
|
|
|
|
* CoglObject:
|
|
|
|
*
|
|
|
|
* Ref Func: cogl_object_ref
|
|
|
|
* Unref Func: cogl_object_unref
|
|
|
|
* Set Value Func: cogl_object_value_set_object
|
|
|
|
* Get Value Func: cogl_object_value_get_object
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef COGL_HAS_GTYPE_SUPPORT
|
|
|
|
/**
|
|
|
|
* cogl_object_get_gtype:
|
|
|
|
*
|
|
|
|
* Returns: a #GType that can be used with the GLib type system.
|
|
|
|
*/
|
|
|
|
GType cogl_object_get_gtype (void);
|
|
|
|
#endif
|
|
|
|
|
2012-09-29 19:24:46 -04:00
|
|
|
/**
|
|
|
|
* cogl_object_ref: (skip)
|
|
|
|
* @object: a #CoglObject
|
|
|
|
*
|
|
|
|
* Increases the reference count of @object by 1
|
|
|
|
*
|
|
|
|
* Returns: the @object, with its reference count increased
|
|
|
|
*/
|
|
|
|
void *
|
|
|
|
cogl_object_ref (void *object);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_object_unref: (skip)
|
|
|
|
* @object: a #CoglObject
|
|
|
|
*
|
|
|
|
* Drecreases the reference count of @object by 1; if the reference
|
|
|
|
* count reaches 0, the resources allocated by @object will be freed
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_object_unref (void *object);
|
|
|
|
|
2010-05-27 17:24:56 -04:00
|
|
|
/**
|
|
|
|
* CoglUserDataKey:
|
|
|
|
* @unused: ignored.
|
|
|
|
*
|
|
|
|
* A #CoglUserDataKey is used to declare a key for attaching data to a
|
|
|
|
* #CoglObject using cogl_object_set_user_data. The typedef only exists as a
|
|
|
|
* formality to make code self documenting since only the unique address of a
|
|
|
|
* #CoglUserDataKey is used.
|
|
|
|
*
|
|
|
|
* Typically you would declare a static #CoglUserDataKey and set private data
|
|
|
|
* on an object something like this:
|
2010-05-27 18:31:40 -04:00
|
|
|
*
|
2010-05-27 17:24:56 -04:00
|
|
|
* |[
|
|
|
|
* static CoglUserDataKey path_private_key;
|
2010-05-27 18:31:40 -04:00
|
|
|
*
|
2010-05-27 17:24:56 -04:00
|
|
|
* static void
|
|
|
|
* destroy_path_private_cb (void *data)
|
|
|
|
* {
|
|
|
|
* g_free (data);
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* static void
|
|
|
|
* my_path_set_data (CoglPath *path, void *data)
|
|
|
|
* {
|
|
|
|
* cogl_object_set_user_data (COGL_OBJECT (path),
|
|
|
|
* &private_key,
|
|
|
|
* data,
|
|
|
|
* destroy_path_private_cb);
|
|
|
|
* }
|
|
|
|
* ]|
|
|
|
|
*
|
|
|
|
* Since: 1.4
|
2010-05-27 18:31:40 -04:00
|
|
|
*/
|
2012-12-31 12:31:50 -05:00
|
|
|
typedef struct {
|
2010-05-27 17:24:56 -04:00
|
|
|
int unused;
|
|
|
|
} CoglUserDataKey;
|
2010-05-27 18:31:40 -04:00
|
|
|
|
2010-05-27 17:24:56 -04:00
|
|
|
/**
|
|
|
|
* CoglUserDataDestroyCallback:
|
|
|
|
* @user_data: The data whos association with a #CoglObject has been
|
|
|
|
* destoyed.
|
|
|
|
*
|
|
|
|
* When associating private data with a #CoglObject a callback can be
|
|
|
|
* given which will be called either if the object is destroyed or if
|
|
|
|
* cogl_object_set_user_data() is called with NULL user_data for the
|
|
|
|
* same key.
|
|
|
|
*
|
|
|
|
* Since: 1.4
|
|
|
|
*/
|
2013-09-03 17:00:36 -04:00
|
|
|
#ifdef COGL_HAS_GTYPE_SUPPORT
|
|
|
|
typedef GDestroyNotify CoglUserDataDestroyCallback;
|
|
|
|
#else
|
2010-05-27 17:24:56 -04:00
|
|
|
typedef void (*CoglUserDataDestroyCallback) (void *user_data);
|
2013-09-03 17:00:36 -04:00
|
|
|
#endif
|
2010-05-27 17:24:56 -04:00
|
|
|
|
2011-06-10 13:44:09 -04:00
|
|
|
/**
|
|
|
|
* CoglDebugObjectTypeInfo:
|
|
|
|
* @name: A human readable name for the type.
|
|
|
|
* @instance_count: The number of objects of this type that are
|
|
|
|
* currently in use
|
|
|
|
*
|
|
|
|
* This struct is used to pass information to the callback when
|
|
|
|
* cogl_debug_object_foreach_type() is called.
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
* Stability: unstable
|
|
|
|
*/
|
2012-12-31 12:31:50 -05:00
|
|
|
typedef struct {
|
2011-06-10 13:44:09 -04:00
|
|
|
const char *name;
|
|
|
|
unsigned long instance_count;
|
|
|
|
} CoglDebugObjectTypeInfo;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CoglDebugObjectForeachTypeCallback:
|
|
|
|
* @info: A pointer to a struct containing information about the type.
|
|
|
|
*
|
|
|
|
* A callback function to use for cogl_debug_object_foreach_type().
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
* Stability: unstable
|
|
|
|
*/
|
|
|
|
typedef void
|
|
|
|
(* CoglDebugObjectForeachTypeCallback) (const CoglDebugObjectTypeInfo *info,
|
|
|
|
void *user_data);
|
|
|
|
|
2010-05-27 17:24:56 -04:00
|
|
|
/**
|
2010-12-22 04:42:41 -05:00
|
|
|
* cogl_object_set_user_data: (skip)
|
2010-05-27 17:24:56 -04:00
|
|
|
* @object: The object to associate private data with
|
|
|
|
* @key: The address of a #CoglUserDataKey which provides a unique value
|
2010-12-22 04:42:41 -05:00
|
|
|
* with which to index the private data.
|
|
|
|
* @user_data: The data to associate with the given object,
|
|
|
|
* or %NULL to remove a previous association.
|
2010-05-27 17:24:56 -04:00
|
|
|
* @destroy: A #CoglUserDataDestroyCallback to call if the object is
|
2010-12-22 04:42:41 -05:00
|
|
|
* destroyed or if the association is removed by later setting
|
|
|
|
* %NULL data for the same key.
|
2010-05-27 17:24:56 -04:00
|
|
|
*
|
|
|
|
* Associates some private @user_data with a given #CoglObject. To
|
|
|
|
* later remove the association call cogl_object_set_user_data() with
|
|
|
|
* the same @key but NULL for the @user_data.
|
|
|
|
*
|
|
|
|
* Since: 1.4
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_object_set_user_data (CoglObject *object,
|
|
|
|
CoglUserDataKey *key,
|
|
|
|
void *user_data,
|
|
|
|
CoglUserDataDestroyCallback destroy);
|
|
|
|
|
|
|
|
/**
|
2010-12-22 04:42:41 -05:00
|
|
|
* cogl_object_get_user_data: (skip)
|
2010-05-27 17:24:56 -04:00
|
|
|
* @object: The object with associated private data to query
|
|
|
|
* @key: The address of a #CoglUserDataKey which provides a unique value
|
|
|
|
* with which to index the private data.
|
|
|
|
*
|
|
|
|
* Finds the user data previously associated with @object using
|
|
|
|
* the given @key. If no user data has been associated with @object
|
|
|
|
* for the given @key this function returns NULL.
|
|
|
|
*
|
2010-12-22 04:42:41 -05:00
|
|
|
* Returns: (transfer none): The user data previously associated
|
|
|
|
* with @object using the given @key; or %NULL if no associated
|
|
|
|
* data is found.
|
2010-05-27 17:24:56 -04:00
|
|
|
*
|
|
|
|
* Since: 1.4
|
|
|
|
*/
|
|
|
|
void *
|
|
|
|
cogl_object_get_user_data (CoglObject *object,
|
|
|
|
CoglUserDataKey *key);
|
2011-06-10 13:44:09 -04:00
|
|
|
|
|
|
|
#ifdef COGL_ENABLE_EXPERIMENTAL_API
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_debug_object_foreach_type:
|
2013-09-05 06:55:03 -04:00
|
|
|
* @func: (scope call): A callback function for each type
|
|
|
|
* @user_data: (closure): A pointer to pass to @func
|
2011-06-10 13:44:09 -04:00
|
|
|
*
|
|
|
|
* Invokes @func once for each type of object that Cogl uses and
|
|
|
|
* passes a count of the number of objects for that type. This is
|
|
|
|
* intended to be used solely for debugging purposes to track down
|
|
|
|
* issues with objects leaking.
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
* Stability: unstable
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_debug_object_foreach_type (CoglDebugObjectForeachTypeCallback func,
|
|
|
|
void *user_data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_debug_object_print_instances:
|
|
|
|
*
|
|
|
|
* Prints a list of all the object types that Cogl uses along with the
|
|
|
|
* number of objects of that type that are currently in use. This is
|
|
|
|
* intended to be used solely for debugging purposes to track down
|
|
|
|
* issues with objects leaking.
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
* Stability: unstable
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_debug_object_print_instances (void);
|
|
|
|
|
|
|
|
#endif /* COGL_ENABLE_EXPERIMENTAL_API */
|
|
|
|
|
2013-02-22 10:27:58 -05:00
|
|
|
COGL_END_DECLS
|
|
|
|
|
2010-05-27 18:31:40 -04:00
|
|
|
#endif /* __COGL_OBJECT_H */
|
|
|
|
|