/* * Cogl * * A Low Level GPU Graphics and Utilities API * * Copyright (C) 2009,2010 Intel Corporation. * * 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. * * */ #pragma once #include "cogl/cogl-types.h" #include G_BEGIN_DECLS typedef struct _CoglObject CoglObject; #define COGL_OBJECT(X) ((CoglObject *)X) /** * 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) */ /** * cogl_object_get_gtype: * * Returns: a #GType that can be used with the GLib type system. */ COGL_EXPORT GType cogl_object_get_gtype (void); /** * cogl_object_ref: (skip) * @object: a #CoglObject * * Increases the reference count of @object by 1 * * Returns: the @object, with its reference count increased */ COGL_EXPORT 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 */ COGL_EXPORT void cogl_object_unref (void *object); /** * cogl_clear_object: (skip) * @object_ptr: a pointer to a #CoglObject reference * * Clears a reference to a #CoglObject. * * @object_ptr must not be %NULL. * * If the reference is %NULL then this function does nothing. * Otherwise, the reference count of the object is decreased using * cogl_object_unref() and the pointer is set to %NULL. */ #define cogl_clear_object(object_ptr) g_clear_pointer ((object_ptr), cogl_object_unref) /** * 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. */ typedef struct { 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(). */ typedef void (* CoglDebugObjectForeachTypeCallback) (const CoglDebugObjectTypeInfo *info, void *user_data); /** * cogl_debug_object_foreach_type: * @func: (scope call): A callback function for each type * @user_data: (closure): A pointer to pass to @func * * 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. */ COGL_EXPORT 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. */ COGL_EXPORT void cogl_debug_object_print_instances (void); G_END_DECLS