4
* An object oriented GL/GLES Abstraction/Utility Layer
6
* Copyright (C) 2007,2008,2009,2010 Intel Corporation.
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
* License as published by the Free Software Foundation; either
11
* version 2 of the License, or (at your option) any later version.
13
* This library is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Lesser General Public License for more details.
18
* You should have received a copy of the GNU Lesser General Public
19
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
28
#include <glib-object.h>
29
#include <gobject/gvaluecollector.h>
33
#include "cogl-fixed.h"
34
#include "cogl-internal.h"
35
#include "cogl-material.h"
36
#include "cogl-offscreen.h"
37
#include "cogl-shader.h"
38
#include "cogl-texture.h"
39
#include "cogl-types.h"
40
#include "cogl-handle.h"
41
#include "cogl-util.h"
45
* @a: Value to get the next power
47
* Calculates the next power greater than @a.
49
* Return value: The next power after @a.
52
cogl_util_next_p2 (int a)
65
cogl_handle_ref (CoglHandle handle)
67
CoglHandleObject *obj = (CoglHandleObject *)handle;
69
g_return_val_if_fail (handle != COGL_INVALID_HANDLE, COGL_INVALID_HANDLE);
76
cogl_handle_unref (CoglHandle handle)
78
CoglHandleObject *obj = (CoglHandleObject *)handle;
80
g_return_if_fail (handle != COGL_INVALID_HANDLE);
81
g_return_if_fail (obj->ref_count > 0);
83
if (--obj->ref_count < 1)
85
void (*free_func)(void *obj);
87
COGL_HANDLE_DEBUG_FREE (obj);
88
free_func = obj->klass->virt_free;
94
cogl_handle_get_type (void)
96
static GType our_type = 0;
98
if (G_UNLIKELY (our_type == 0))
99
our_type = g_boxed_type_register_static (g_intern_static_string ("CoglHandle"),
100
(GBoxedCopyFunc) cogl_handle_ref,
101
(GBoxedFreeFunc) cogl_handle_unref);
110
static GTypeInfo _info = {
123
static GTypeFundamentalInfo _finfo = { 0, };
126
cogl_value_init_fixed (GValue *value)
128
value->data[0].v_int = 0;
132
cogl_value_copy_fixed (const GValue *src,
135
dest->data[0].v_int = src->data[0].v_int;
139
cogl_value_collect_fixed (GValue *value,
140
unsigned int n_collect_values,
141
GTypeCValue *collect_values,
142
unsigned int collect_flags)
144
value->data[0].v_int = collect_values[0].v_int;
150
cogl_value_lcopy_fixed (const GValue *value,
151
unsigned int n_collect_values,
152
GTypeCValue *collect_values,
153
unsigned int collect_flags)
155
gint32 *fixed_p = collect_values[0].v_pointer;
158
return g_strdup_printf ("value location for '%s' passed as NULL",
159
G_VALUE_TYPE_NAME (value));
161
*fixed_p = value->data[0].v_int;
167
cogl_value_transform_fixed_int (const GValue *src,
170
dest->data[0].v_int = COGL_FIXED_TO_INT (src->data[0].v_int);
174
cogl_value_transform_fixed_double (const GValue *src,
177
dest->data[0].v_double = COGL_FIXED_TO_DOUBLE (src->data[0].v_int);
181
cogl_value_transform_fixed_float (const GValue *src,
184
dest->data[0].v_float = COGL_FIXED_TO_FLOAT (src->data[0].v_int);
188
cogl_value_transform_int_fixed (const GValue *src,
191
dest->data[0].v_int = COGL_FIXED_FROM_INT (src->data[0].v_int);
195
cogl_value_transform_double_fixed (const GValue *src,
198
dest->data[0].v_int = COGL_FIXED_FROM_DOUBLE (src->data[0].v_double);
202
cogl_value_transform_float_fixed (const GValue *src,
205
dest->data[0].v_int = COGL_FIXED_FROM_FLOAT (src->data[0].v_float);
209
static const GTypeValueTable _cogl_fixed_value_table = {
210
cogl_value_init_fixed,
212
cogl_value_copy_fixed,
215
cogl_value_collect_fixed,
217
cogl_value_lcopy_fixed
221
cogl_fixed_get_type (void)
223
static GType _cogl_fixed_type = 0;
225
if (G_UNLIKELY (_cogl_fixed_type == 0))
227
_info.value_table = & _cogl_fixed_value_table;
229
g_type_register_fundamental (g_type_fundamental_next (),
230
g_intern_static_string ("CoglFixed"),
233
g_value_register_transform_func (_cogl_fixed_type, G_TYPE_INT,
234
cogl_value_transform_fixed_int);
235
g_value_register_transform_func (G_TYPE_INT, _cogl_fixed_type,
236
cogl_value_transform_int_fixed);
238
g_value_register_transform_func (_cogl_fixed_type, G_TYPE_FLOAT,
239
cogl_value_transform_fixed_float);
240
g_value_register_transform_func (G_TYPE_FLOAT, _cogl_fixed_type,
241
cogl_value_transform_float_fixed);
243
g_value_register_transform_func (_cogl_fixed_type, G_TYPE_DOUBLE,
244
cogl_value_transform_fixed_double);
245
g_value_register_transform_func (G_TYPE_DOUBLE, _cogl_fixed_type,
246
cogl_value_transform_double_fixed);
249
return _cogl_fixed_type;