mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 01:50:42 -05:00
[fixed] Remove ClutterFixed API
Since the switch from fixed point to floating point, and the introduction of CoglFixed, ClutterFixed has been typedef'd into a float. This makes ClutterFixed the worst fixed point API ever. Now that Clutter has been migrated to CoglFixed and gfloat whenever needed, ClutterFixed can be safely removed. The only thing that Clutter should still provide is ClutterParamSpecFixed, for installing fixed point properties into GObject classes. The ClutterFixed symbols have been entirely removed from the API.
This commit is contained in:
parent
d1f3190f5b
commit
9b83a6f291
@ -29,8 +29,9 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <cogl/cogl.h>
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gobject/gvaluecollector.h>
|
||||
|
||||
#include "clutter-fixed.h"
|
||||
#include "clutter-private.h"
|
||||
@ -70,149 +71,9 @@
|
||||
* </itemizedlist>
|
||||
*/
|
||||
|
||||
static GTypeInfo _info = {
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
0,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static GTypeFundamentalInfo _finfo = { 0, };
|
||||
|
||||
static void
|
||||
clutter_value_init_fixed (GValue *value)
|
||||
{
|
||||
value->data[0].v_int = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_value_copy_fixed (const GValue *src,
|
||||
GValue *dest)
|
||||
{
|
||||
dest->data[0].v_int = src->data[0].v_int;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
clutter_value_collect_fixed (GValue *value,
|
||||
guint n_collect_values,
|
||||
GTypeCValue *collect_values,
|
||||
guint collect_flags)
|
||||
{
|
||||
value->data[0].v_int = collect_values[0].v_int;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
clutter_value_lcopy_fixed (const GValue *value,
|
||||
guint n_collect_values,
|
||||
GTypeCValue *collect_values,
|
||||
guint collect_flags)
|
||||
{
|
||||
gint32 *fixed_p = collect_values[0].v_pointer;
|
||||
|
||||
if (!fixed_p)
|
||||
return g_strdup_printf ("value location for `%s' passed as NULL",
|
||||
G_VALUE_TYPE_NAME (value));
|
||||
|
||||
*fixed_p = value->data[0].v_int;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_value_transform_fixed_int (const GValue *src,
|
||||
GValue *dest)
|
||||
{
|
||||
dest->data[0].v_int = (src->data[0].v_int);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_value_transform_fixed_double (const GValue *src,
|
||||
GValue *dest)
|
||||
{
|
||||
dest->data[0].v_double = CLUTTER_FIXED_TO_DOUBLE (src->data[0].v_int);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_value_transform_fixed_float (const GValue *src,
|
||||
GValue *dest)
|
||||
{
|
||||
dest->data[0].v_float = CLUTTER_FIXED_TO_FLOAT (src->data[0].v_int);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_value_transform_int_fixed (const GValue *src,
|
||||
GValue *dest)
|
||||
{
|
||||
dest->data[0].v_int = (float)(src->data[0].v_int);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_value_transform_double_fixed (const GValue *src,
|
||||
GValue *dest)
|
||||
{
|
||||
dest->data[0].v_int = CLUTTER_FLOAT_TO_FIXED (src->data[0].v_double);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_value_transform_float_fixed (const GValue *src,
|
||||
GValue *dest)
|
||||
{
|
||||
dest->data[0].v_int = CLUTTER_FLOAT_TO_FIXED (src->data[0].v_float);
|
||||
}
|
||||
|
||||
|
||||
static const GTypeValueTable _clutter_fixed_value_table = {
|
||||
clutter_value_init_fixed,
|
||||
NULL,
|
||||
clutter_value_copy_fixed,
|
||||
NULL,
|
||||
"i",
|
||||
clutter_value_collect_fixed,
|
||||
"p",
|
||||
clutter_value_lcopy_fixed
|
||||
};
|
||||
|
||||
GType
|
||||
clutter_fixed_get_type (void)
|
||||
{
|
||||
static GType _clutter_fixed_type = 0;
|
||||
|
||||
if (G_UNLIKELY (_clutter_fixed_type == 0))
|
||||
{
|
||||
_info.value_table = & _clutter_fixed_value_table;
|
||||
_clutter_fixed_type =
|
||||
g_type_register_fundamental (g_type_fundamental_next (),
|
||||
I_("ClutterFixed"),
|
||||
&_info, &_finfo, 0);
|
||||
|
||||
g_value_register_transform_func (_clutter_fixed_type, G_TYPE_INT,
|
||||
clutter_value_transform_fixed_int);
|
||||
g_value_register_transform_func (G_TYPE_INT, _clutter_fixed_type,
|
||||
clutter_value_transform_int_fixed);
|
||||
g_value_register_transform_func (_clutter_fixed_type, G_TYPE_FLOAT,
|
||||
clutter_value_transform_fixed_float);
|
||||
g_value_register_transform_func (G_TYPE_FLOAT, _clutter_fixed_type,
|
||||
clutter_value_transform_float_fixed);
|
||||
g_value_register_transform_func (_clutter_fixed_type, G_TYPE_DOUBLE,
|
||||
clutter_value_transform_fixed_double);
|
||||
g_value_register_transform_func (G_TYPE_DOUBLE, _clutter_fixed_type,
|
||||
clutter_value_transform_double_fixed);
|
||||
}
|
||||
|
||||
return _clutter_fixed_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_value_set_fixed:
|
||||
* @value: a #GValue initialized to #CLUTTER_TYPE_FIXED
|
||||
* @value: a #GValue initialized to %COGL_TYPE_FIXED
|
||||
* @fixed_: the fixed point value to set
|
||||
*
|
||||
* Sets @value to @fixed_.
|
||||
@ -221,7 +82,7 @@ clutter_fixed_get_type (void)
|
||||
*/
|
||||
void
|
||||
clutter_value_set_fixed (GValue *value,
|
||||
ClutterFixed fixed_)
|
||||
CoglFixed fixed_)
|
||||
{
|
||||
g_return_if_fail (CLUTTER_VALUE_HOLDS_FIXED (value));
|
||||
|
||||
@ -230,7 +91,7 @@ clutter_value_set_fixed (GValue *value,
|
||||
|
||||
/**
|
||||
* clutter_value_get_fixed:
|
||||
* @value: a #GValue initialized to #CLUTTER_TYPE_FIXED
|
||||
* @value: a #GValue initialized to %COGL_TYPE_FIXED
|
||||
*
|
||||
* Gets the fixed point value stored inside @value.
|
||||
*
|
||||
@ -238,7 +99,7 @@ clutter_value_set_fixed (GValue *value,
|
||||
*
|
||||
* Since: 0.8
|
||||
*/
|
||||
ClutterFixed
|
||||
CoglFixed
|
||||
clutter_value_get_fixed (const GValue *value)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_VALUE_HOLDS_FIXED (value), 0);
|
||||
@ -251,8 +112,8 @@ param_fixed_init (GParamSpec *pspec)
|
||||
{
|
||||
ClutterParamSpecFixed *fspec = CLUTTER_PARAM_SPEC_FIXED (pspec);
|
||||
|
||||
fspec->minimum = CLUTTER_MAXFIXED;
|
||||
fspec->maximum = CLUTTER_MINFIXED;
|
||||
fspec->minimum = COGL_FIXED_MIN;
|
||||
fspec->maximum = COGL_FIXED_MAX;
|
||||
fspec->default_value = 0;
|
||||
}
|
||||
|
||||
@ -268,7 +129,7 @@ param_fixed_validate (GParamSpec *pspec,
|
||||
GValue *value)
|
||||
{
|
||||
ClutterParamSpecFixed *fspec = CLUTTER_PARAM_SPEC_FIXED (pspec);
|
||||
gint oval = (value->data[0].v_int);
|
||||
gint oval = value->data[0].v_int;
|
||||
gint min, max, val;
|
||||
|
||||
g_assert (CLUTTER_IS_PARAM_SPEC_FIXED (pspec));
|
||||
@ -276,7 +137,6 @@ param_fixed_validate (GParamSpec *pspec,
|
||||
/* we compare the integer part of the value because the minimum
|
||||
* and maximum values cover just that part of the representation
|
||||
*/
|
||||
|
||||
min = fspec->minimum;
|
||||
max = fspec->maximum;
|
||||
val = (value->data[0].v_int);
|
||||
@ -313,7 +173,7 @@ clutter_param_fixed_get_type (void)
|
||||
sizeof (ClutterParamSpecFixed),
|
||||
16,
|
||||
param_fixed_init,
|
||||
CLUTTER_TYPE_FIXED,
|
||||
COGL_TYPE_FIXED,
|
||||
NULL,
|
||||
param_fixed_set_default,
|
||||
param_fixed_validate,
|
||||
@ -347,9 +207,9 @@ GParamSpec *
|
||||
clutter_param_spec_fixed (const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
ClutterFixed minimum,
|
||||
ClutterFixed maximum,
|
||||
ClutterFixed default_value,
|
||||
CoglFixed minimum,
|
||||
CoglFixed maximum,
|
||||
CoglFixed default_value,
|
||||
GParamFlags flags)
|
||||
{
|
||||
ClutterParamSpecFixed *fspec;
|
||||
|
@ -34,234 +34,6 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* ClutterFixed:
|
||||
*
|
||||
* Fixed point number (16.16)
|
||||
*/
|
||||
typedef float ClutterFixed;
|
||||
|
||||
/**
|
||||
* ClutterAngle:
|
||||
*
|
||||
* An abstract representation of an angle.
|
||||
*/
|
||||
typedef float ClutterAngle;
|
||||
|
||||
#define CLUTTER_ANGLE_FROM_DEG(x) ((float)(x))
|
||||
#define CLUTTER_ANGLE_FROM_DEGX(x) (CLUTTER_FIXED_TO_FLOAT (x))
|
||||
#define CLUTTER_ANGLE_TO_DEG(x) ((float)(x))
|
||||
#define CLUTTER_ANGLE_TO_DEGX(x) (CLUTTER_FLOAT_TO_FIXED (x))
|
||||
|
||||
/*
|
||||
* some commonly used constants
|
||||
*/
|
||||
|
||||
/**
|
||||
* CFX_ONE:
|
||||
*
|
||||
* 1.0 represented as a fixed point value.
|
||||
*/
|
||||
#define CFX_ONE 1.0
|
||||
|
||||
/**
|
||||
* CFX_HALF:
|
||||
*
|
||||
* 0.5 represented as a fixed point value.
|
||||
*/
|
||||
#define CFX_HALF 0.5
|
||||
|
||||
/**
|
||||
* CFX_MAX:
|
||||
*
|
||||
* Maximum fixed point value.
|
||||
*/
|
||||
#define CFX_MAX G_MAXFLOAT
|
||||
|
||||
/**
|
||||
* CFX_MIN:
|
||||
*
|
||||
* Minimum fixed point value.
|
||||
*/
|
||||
#define CFX_MIN (-G_MAXFLOAT)
|
||||
|
||||
/**
|
||||
* CFX_PI:
|
||||
*
|
||||
* Fixed point representation of Pi
|
||||
*/
|
||||
#define CFX_PI G_PI
|
||||
/**
|
||||
* CFX_2PI:
|
||||
*
|
||||
* Fixed point representation of Pi*2
|
||||
*/
|
||||
#define CFX_2PI (G_PI * 2)
|
||||
/**
|
||||
* CFX_PI_2:
|
||||
*
|
||||
* Fixed point representation of Pi/2
|
||||
*/
|
||||
#define CFX_PI_2 (G_PI / 2)
|
||||
/**
|
||||
* CFX_PI_4:
|
||||
*
|
||||
* Fixed point representation of Pi/4
|
||||
*/
|
||||
#define CFX_PI_4 (G_PI / 4)
|
||||
/**
|
||||
* CFX_360:
|
||||
*
|
||||
* Fixed point representation of the number 360
|
||||
*/
|
||||
#define CFX_360 360.0
|
||||
/**
|
||||
* CFX_240:
|
||||
*
|
||||
* Fixed point representation of the number 240
|
||||
*/
|
||||
#define CFX_240 240.0
|
||||
/**
|
||||
* CFX_180:
|
||||
*
|
||||
* Fixed point representation of the number 180
|
||||
*/
|
||||
#define CFX_180 180.0
|
||||
/**
|
||||
* CFX_120:
|
||||
*
|
||||
* Fixed point representation of the number 120
|
||||
*/
|
||||
#define CFX_120 120.0
|
||||
/**
|
||||
* CFX_60:
|
||||
*
|
||||
* Fixed point representation of the number 60
|
||||
*/
|
||||
#define CFX_60 60.0
|
||||
/**
|
||||
* CFX_RADIANS_TO_DEGREES:
|
||||
*
|
||||
* Fixed point representation of the number 180 / pi
|
||||
*/
|
||||
#define CFX_RADIANS_TO_DEGREES (180.0 / G_PI)
|
||||
/**
|
||||
* CFX_255:
|
||||
*
|
||||
* Fixed point representation of the number 255
|
||||
*/
|
||||
#define CFX_255 255.0
|
||||
|
||||
/**
|
||||
* CLUTTER_FIXED_TO_FLOAT:
|
||||
* @x: a fixed point value
|
||||
*
|
||||
* Convert a fixed point value to float.
|
||||
*/
|
||||
#define CLUTTER_FIXED_TO_FLOAT(x) (x)
|
||||
|
||||
/**
|
||||
* CLUTTER_FIXED_TO_DOUBLE:
|
||||
* @x: a fixed point value
|
||||
*
|
||||
* Convert a fixed point value to double.
|
||||
*/
|
||||
#define CLUTTER_FIXED_TO_DOUBLE(x) ((double)(x))
|
||||
|
||||
/**
|
||||
* CLUTTER_FLOAT_TO_FIXED:
|
||||
* @x: a floating point value
|
||||
*
|
||||
* Convert a float value to fixed.
|
||||
*/
|
||||
#define CLUTTER_FLOAT_TO_FIXED(x) ((x))
|
||||
|
||||
/**
|
||||
* CLUTTER_FLOAT_TO_INT:
|
||||
* @x: a floating point value
|
||||
*
|
||||
* Convert a float value to int.
|
||||
*/
|
||||
#define CLUTTER_FLOAT_TO_INT(x) ((int)(x))
|
||||
|
||||
/**
|
||||
* CLUTTER_FLOAT_TO_UINT:
|
||||
* @x: a floating point value
|
||||
*
|
||||
* Convert a float value to unsigned int.
|
||||
*/
|
||||
#define CLUTTER_FLOAT_TO_UINT(x) ((unsigned int)(x))
|
||||
|
||||
/**
|
||||
* CLUTTER_INT_TO_FIXED:
|
||||
* @x: an integer value
|
||||
*
|
||||
* Convert an integer value to fixed point.
|
||||
*/
|
||||
#define CLUTTER_INT_TO_FIXED(x) ((float)(x))
|
||||
|
||||
/**
|
||||
* CLUTTER_FIXED_TO_INT:
|
||||
* @x: a fixed point value
|
||||
*
|
||||
* Converts a fixed point value to integer (removing the decimal part).
|
||||
*
|
||||
* Since: 0.6
|
||||
*/
|
||||
#define CLUTTER_FIXED_TO_INT(x) ((int)(x))
|
||||
|
||||
/**
|
||||
* CLUTTER_FIXED_FRACTION:
|
||||
* @x: a fixed point value
|
||||
*
|
||||
* Retrieves the fractionary part of a fixed point value
|
||||
*/
|
||||
#define CLUTTER_FIXED_FRACTION(x) ((x)-floorf (x))
|
||||
|
||||
/**
|
||||
* CLUTTER_FIXED_FLOOR:
|
||||
* @x: a fixed point value
|
||||
*
|
||||
* Round down a fixed point value to an integer.
|
||||
*/
|
||||
#define CLUTTER_FIXED_FLOOR(x) (floorf (x))
|
||||
|
||||
/**
|
||||
* CLUTTER_FIXED_CEIL:
|
||||
* @x: a fixed point value
|
||||
*
|
||||
* Round up a fixed point value to an integer.
|
||||
*/
|
||||
#define CLUTTER_FIXED_CEIL(x) (ceilf (x))
|
||||
|
||||
/**
|
||||
* CLUTTER_FIXED_MUL:
|
||||
* @x: a fixed point value
|
||||
* @y: a fixed point value
|
||||
*
|
||||
* Multiply two fixed point values
|
||||
*/
|
||||
#define CLUTTER_FIXED_MUL(x,y) ((x) * (y))
|
||||
|
||||
/**
|
||||
* CLUTTER_FIXED_DIV:
|
||||
* @x: a fixed point value
|
||||
* @y: a fixed point value
|
||||
*
|
||||
* Divide two fixed point values
|
||||
*/
|
||||
#define CLUTTER_FIXED_DIV(x,y) ((x) / (y))
|
||||
|
||||
#define clutter_qmulx(x,y) ((x) * (y))
|
||||
#define clutter_qdivx(x,y) ((x) / (y))
|
||||
|
||||
#define clutter_sinx(a) sinf (a * (G_PI/180.0))
|
||||
#define clutter_tanx(a) tanf (a * (G_PI/180.0))
|
||||
#define clutter_atanx(a) atanf (a * (G_PI/180.0))
|
||||
#define clutter_atan2x(x,y) atan2f (x, y)
|
||||
#define clutter_cosx(a) cosf (a * (G_PI/180.0))
|
||||
|
||||
#define CLUTTER_TYPE_FIXED (clutter_fixed_get_type ())
|
||||
#define CLUTTER_TYPE_PARAM_FIXED (clutter_param_fixed_get_type ())
|
||||
#define CLUTTER_PARAM_SPEC_FIXED(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), CLUTTER_TYPE_PARAM_FIXED, ClutterParamSpecFixed))
|
||||
#define CLUTTER_IS_PARAM_SPEC_FIXED(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), CLUTTER_TYPE_PARAM_FIXED))
|
||||
@ -270,32 +42,14 @@ typedef float ClutterAngle;
|
||||
* CLUTTER_VALUE_HOLDS_FIXED:
|
||||
* @x: a #GValue
|
||||
*
|
||||
* Evaluates to %TRUE if @x holds a #ClutterFixed.
|
||||
* Evaluates to %TRUE if @x holds a #CoglFixed .
|
||||
*
|
||||
* Since: 0.8
|
||||
*/
|
||||
#define CLUTTER_VALUE_HOLDS_FIXED(x) (G_VALUE_HOLDS ((x), CLUTTER_TYPE_FIXED))
|
||||
#define CLUTTER_VALUE_HOLDS_FIXED(x) (G_VALUE_HOLDS ((x), COGL_TYPE_FIXED))
|
||||
|
||||
typedef struct _ClutterParamSpecFixed ClutterParamSpecFixed;
|
||||
|
||||
/**
|
||||
* CLUTTER_MAXFIXED:
|
||||
*
|
||||
* Higher boundary for #ClutterFixed
|
||||
*
|
||||
* Since: 0.8
|
||||
*/
|
||||
#define CLUTTER_MAXFIXED G_MAXFLOAT
|
||||
|
||||
/**
|
||||
* CLUTTER_MINFIXED:
|
||||
*
|
||||
* Lower boundary for #ClutterFixed
|
||||
*
|
||||
* Since: 0.8
|
||||
*/
|
||||
#define CLUTTER_MINFIXED (-G_MAXFLOAT)
|
||||
|
||||
/**
|
||||
* ClutterParamSpecFixed
|
||||
* @minimum: lower boundary
|
||||
@ -312,24 +66,23 @@ struct _ClutterParamSpecFixed
|
||||
GParamSpec parent_instance;
|
||||
|
||||
/*< public >*/
|
||||
ClutterFixed minimum;
|
||||
ClutterFixed maximum;
|
||||
ClutterFixed default_value;
|
||||
CoglFixed minimum;
|
||||
CoglFixed maximum;
|
||||
CoglFixed default_value;
|
||||
};
|
||||
|
||||
GType clutter_fixed_get_type (void) G_GNUC_CONST;
|
||||
GType clutter_param_fixed_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void clutter_value_set_fixed (GValue *value,
|
||||
ClutterFixed fixed_);
|
||||
ClutterFixed clutter_value_get_fixed (const GValue *value);
|
||||
CoglFixed fixed_);
|
||||
CoglFixed clutter_value_get_fixed (const GValue *value);
|
||||
|
||||
GParamSpec * clutter_param_spec_fixed (const gchar *name,
|
||||
const gchar *nick,
|
||||
const gchar *blurb,
|
||||
ClutterFixed minimum,
|
||||
ClutterFixed maximum,
|
||||
ClutterFixed default_value,
|
||||
CoglFixed minimum,
|
||||
CoglFixed maximum,
|
||||
CoglFixed default_value,
|
||||
GParamFlags flags);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user