Replace ClutterSize by graphene_size_t

https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
This commit is contained in:
Georges Basile Stavracas Neto 2019-02-20 11:27:00 -03:00
parent cb36a7363f
commit a06ad3a923
No known key found for this signature in database
GPG Key ID: 886C17EE170D1385
8 changed files with 51 additions and 219 deletions

View File

@ -173,8 +173,8 @@ struct _ClutterLayoutInfo
guint x_expand : 1; guint x_expand : 1;
guint y_expand : 1; guint y_expand : 1;
ClutterSize minimum; graphene_size_t minimum;
ClutterSize natural; graphene_size_t natural;
}; };
const ClutterLayoutInfo * _clutter_actor_get_layout_info_or_defaults (ClutterActor *self); const ClutterLayoutInfo * _clutter_actor_get_layout_info_or_defaults (ClutterActor *self);

View File

@ -5077,7 +5077,7 @@ clutter_actor_set_property (GObject *object,
case PROP_SIZE: case PROP_SIZE:
{ {
const ClutterSize *size = g_value_get_boxed (value); const graphene_size_t *size = g_value_get_boxed (value);
if (size != NULL) if (size != NULL)
clutter_actor_set_size (actor, size->width, size->height); clutter_actor_set_size (actor, size->width, size->height);
@ -5431,11 +5431,11 @@ clutter_actor_get_property (GObject *object,
case PROP_SIZE: case PROP_SIZE:
{ {
ClutterSize size; graphene_size_t size;
clutter_size_init (&size, graphene_size_init (&size,
clutter_actor_get_width (actor), clutter_actor_get_width (actor),
clutter_actor_get_height (actor)); clutter_actor_get_height (actor));
g_value_set_boxed (value, &size); g_value_set_boxed (value, &size);
} }
break; break;
@ -6476,7 +6476,7 @@ clutter_actor_class_init (ClutterActorClass *klass)
g_param_spec_boxed ("size", g_param_spec_boxed ("size",
P_("Size"), P_("Size"),
P_("The size of the actor"), P_("The size of the actor"),
CLUTTER_TYPE_SIZE, GRAPHENE_TYPE_SIZE,
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS | G_PARAM_STATIC_STRINGS |
CLUTTER_PARAM_ANIMATABLE); CLUTTER_PARAM_ANIMATABLE);
@ -10730,8 +10730,8 @@ clutter_actor_set_height_internal (ClutterActor *self,
} }
static void static void
clutter_actor_set_size_internal (ClutterActor *self, clutter_actor_set_size_internal (ClutterActor *self,
const ClutterSize *size) const graphene_size_t *size)
{ {
if (size != NULL) if (size != NULL)
{ {
@ -10767,11 +10767,11 @@ clutter_actor_set_size (ClutterActor *self,
gfloat width, gfloat width,
gfloat height) gfloat height)
{ {
ClutterSize new_size; graphene_size_t new_size;
g_return_if_fail (CLUTTER_IS_ACTOR (self)); g_return_if_fail (CLUTTER_IS_ACTOR (self));
clutter_size_init (&new_size, width, height); graphene_size_init (&new_size, width, height);
/* minor optimization: if we don't have a duration then we can /* minor optimization: if we don't have a duration then we can
* skip the get_size() below, to avoid the chance of going through * skip the get_size() below, to avoid the chance of going through
@ -10790,11 +10790,11 @@ clutter_actor_set_size (ClutterActor *self,
} }
else else
{ {
ClutterSize cur_size; graphene_size_t cur_size;
clutter_size_init (&cur_size, graphene_size_init (&cur_size,
clutter_actor_get_width (self), clutter_actor_get_width (self),
clutter_actor_get_height (self)); clutter_actor_get_height (self));
_clutter_actor_create_transition (self, _clutter_actor_create_transition (self,
obj_props[PROP_SIZE], obj_props[PROP_SIZE],
@ -18314,8 +18314,8 @@ static const ClutterLayoutInfo default_layout_info = {
CLUTTER_ACTOR_ALIGN_FILL, /* x-align */ CLUTTER_ACTOR_ALIGN_FILL, /* x-align */
CLUTTER_ACTOR_ALIGN_FILL, /* y-align */ CLUTTER_ACTOR_ALIGN_FILL, /* y-align */
FALSE, FALSE, /* expand */ FALSE, FALSE, /* expand */
CLUTTER_SIZE_INIT_ZERO, /* minimum */ GRAPHENE_SIZE_INIT_ZERO, /* minimum */
CLUTTER_SIZE_INIT_ZERO, /* natural */ GRAPHENE_SIZE_INIT_ZERO, /* natural */
}; };
static void static void

View File

@ -96,7 +96,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPaintVolume, clutter_paint_volume_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPathNode, clutter_path_node_free) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPathNode, clutter_path_node_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPoint, clutter_point_free) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterPoint, clutter_point_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterRect, clutter_rect_free) G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterRect, clutter_rect_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClutterSize, clutter_size_free)
#endif /* __GI_SCANNER__ */ #endif /* __GI_SCANNER__ */

View File

@ -400,133 +400,6 @@ G_DEFINE_BOXED_TYPE_WITH_CODE (ClutterPoint, clutter_point,
/*
* ClutterSize
*/
/**
* clutter_size_alloc: (constructor)
*
* Allocates a new #ClutterSize.
*
* Return value: (transfer full): the newly allocated #ClutterSize.
* Use clutter_size_free() to free its resources.
*
* Since: 1.12
*/
ClutterSize *
clutter_size_alloc (void)
{
return g_slice_new0 (ClutterSize);
}
/**
* clutter_size_init:
* @size: a #ClutterSize
* @width: the width
* @height: the height
*
* Initializes a #ClutterSize with the given dimensions.
*
* Return value: (transfer none): the initialized #ClutterSize
*
* Since: 1.12
*/
ClutterSize *
clutter_size_init (ClutterSize *size,
float width,
float height)
{
g_return_val_if_fail (size != NULL, NULL);
size->width = width;
size->height = height;
return size;
}
/**
* clutter_size_copy:
* @size: a #ClutterSize
*
* Creates a new #ClutterSize and duplicates @size.
*
* Return value: (transfer full): the newly allocated #ClutterSize.
* Use clutter_size_free() to free its resources.
*
* Since: 1.12
*/
ClutterSize *
clutter_size_copy (const ClutterSize *size)
{
return g_slice_dup (ClutterSize, size);
}
/**
* clutter_size_free:
* @size: a #ClutterSize
*
* Frees the resources allocated for @size.
*
* Since: 1.12
*/
void
clutter_size_free (ClutterSize *size)
{
if (size != NULL)
g_slice_free (ClutterSize, size);
}
/**
* clutter_size_equals:
* @a: a #ClutterSize to compare
* @b: a #ClutterSize to compare
*
* Compares two #ClutterSize for equality.
*
* Return value: %TRUE if the two #ClutterSize are equal
*
* Since: 1.12
*/
gboolean
clutter_size_equals (const ClutterSize *a,
const ClutterSize *b)
{
if (a == b)
return TRUE;
if (a == NULL || b == NULL)
return FALSE;
return fabsf (a->width - b->width) < FLOAT_EPSILON &&
fabsf (a->height - b->height) < FLOAT_EPSILON;
}
static gboolean
clutter_size_progress (const GValue *a,
const GValue *b,
gdouble progress,
GValue *retval)
{
const ClutterSize *as = g_value_get_boxed (a);
const ClutterSize *bs = g_value_get_boxed (b);
ClutterSize res = CLUTTER_SIZE_INIT (0, 0);
res.width = as->width + (bs->width - as->width) * progress;
res.height = as->height + (bs->height - as->height) * progress;
g_value_set_boxed (retval, &res);
return TRUE;
}
G_DEFINE_BOXED_TYPE_WITH_CODE (ClutterSize, clutter_size,
clutter_size_copy,
clutter_size_free,
CLUTTER_REGISTER_INTERVAL_PROGRESS (clutter_size_progress))
/* /*
* ClutterRect * ClutterRect
*/ */
@ -711,7 +584,7 @@ clutter_rect_equals (ClutterRect *a,
clutter_rect_normalize_internal (b); clutter_rect_normalize_internal (b);
return clutter_point_equals (&a->origin, &b->origin) && return clutter_point_equals (&a->origin, &b->origin) &&
clutter_size_equals (&a->size, &b->size); graphene_size_equal (&a->size, &b->size);
} }
/** /**

View File

@ -43,9 +43,28 @@ graphene_point3d_progress (const GValue *a,
return TRUE; return TRUE;
} }
static gboolean
graphene_size_progress (const GValue *a,
const GValue *b,
gdouble progress,
GValue *retval)
{
const graphene_size_t *as = g_value_get_boxed (a);
const graphene_size_t *bs = g_value_get_boxed (b);
graphene_size_t res;
graphene_size_interpolate (as, bs, progress, &res);
g_value_set_boxed (retval, &res);
return TRUE;
}
void void
clutter_graphene_init (void) clutter_graphene_init (void)
{ {
clutter_interval_register_progress_func (GRAPHENE_TYPE_POINT3D, clutter_interval_register_progress_func (GRAPHENE_TYPE_POINT3D,
graphene_point3d_progress); graphene_point3d_progress);
clutter_interval_register_progress_func (GRAPHENE_TYPE_SIZE,
graphene_size_progress);
} }

View File

@ -546,8 +546,8 @@ _clutter_script_parse_point (ClutterScript *script,
} }
static gboolean static gboolean
parse_size_from_array (JsonArray *array, parse_size_from_array (JsonArray *array,
ClutterSize *size) graphene_size_t *size)
{ {
if (json_array_get_length (array) != 2) if (json_array_get_length (array) != 2)
return FALSE; return FALSE;
@ -559,8 +559,8 @@ parse_size_from_array (JsonArray *array,
} }
static gboolean static gboolean
parse_size_from_object (JsonObject *object, parse_size_from_object (JsonObject *object,
ClutterSize *size) graphene_size_t *size)
{ {
if (json_object_has_member (object, "width")) if (json_object_has_member (object, "width"))
size->width = json_object_get_double_member (object, "width"); size->width = json_object_get_double_member (object, "width");
@ -576,9 +576,9 @@ parse_size_from_object (JsonObject *object,
} }
gboolean gboolean
_clutter_script_parse_size (ClutterScript *script, _clutter_script_parse_size (ClutterScript *script,
JsonNode *node, JsonNode *node,
ClutterSize *size) graphene_size_t *size)
{ {
g_return_val_if_fail (CLUTTER_IS_SCRIPT (script), FALSE); g_return_val_if_fail (CLUTTER_IS_SCRIPT (script), FALSE);
g_return_val_if_fail (node != NULL, FALSE); g_return_val_if_fail (node != NULL, FALSE);
@ -1374,9 +1374,9 @@ _clutter_script_parse_node (ClutterScript *script,
return TRUE; return TRUE;
} }
} }
else if (p_type == CLUTTER_TYPE_SIZE) else if (p_type == GRAPHENE_TYPE_SIZE)
{ {
ClutterSize size = CLUTTER_SIZE_INIT_ZERO; graphene_size_t size = GRAPHENE_SIZE_INIT_ZERO;
if (_clutter_script_parse_size (script, node, &size)) if (_clutter_script_parse_size (script, node, &size))
{ {
@ -1451,9 +1451,9 @@ _clutter_script_parse_node (ClutterScript *script,
return TRUE; return TRUE;
} }
} }
else if (G_VALUE_HOLDS (value, CLUTTER_TYPE_SIZE)) else if (G_VALUE_HOLDS (value, GRAPHENE_TYPE_SIZE))
{ {
ClutterSize size = CLUTTER_SIZE_INIT_ZERO; graphene_size_t size = GRAPHENE_SIZE_INIT_ZERO;
if (_clutter_script_parse_size (script, node, &size)) if (_clutter_script_parse_size (script, node, &size))
{ {

View File

@ -135,7 +135,7 @@ gboolean _clutter_script_parse_point (ClutterScript *script,
ClutterPoint *point); ClutterPoint *point);
gboolean _clutter_script_parse_size (ClutterScript *script, gboolean _clutter_script_parse_size (ClutterScript *script,
JsonNode *node, JsonNode *node,
ClutterSize *size); graphene_size_t *size);
gboolean _clutter_script_parse_translatable_string (ClutterScript *script, gboolean _clutter_script_parse_translatable_string (ClutterScript *script,
JsonNode *node, JsonNode *node,

View File

@ -45,7 +45,6 @@ G_BEGIN_DECLS
#define CLUTTER_TYPE_PAINT_VOLUME (clutter_paint_volume_get_type ()) #define CLUTTER_TYPE_PAINT_VOLUME (clutter_paint_volume_get_type ())
#define CLUTTER_TYPE_PERSPECTIVE (clutter_perspective_get_type ()) #define CLUTTER_TYPE_PERSPECTIVE (clutter_perspective_get_type ())
#define CLUTTER_TYPE_POINT (clutter_point_get_type ()) #define CLUTTER_TYPE_POINT (clutter_point_get_type ())
#define CLUTTER_TYPE_SIZE (clutter_size_get_type ())
#define CLUTTER_TYPE_RECT (clutter_rect_get_type ()) #define CLUTTER_TYPE_RECT (clutter_rect_get_type ())
typedef struct _ClutterActor ClutterActor; typedef struct _ClutterActor ClutterActor;
@ -85,7 +84,6 @@ typedef struct _ClutterMargin ClutterMargin;
typedef struct _ClutterPerspective ClutterPerspective; typedef struct _ClutterPerspective ClutterPerspective;
typedef struct _ClutterPoint ClutterPoint; typedef struct _ClutterPoint ClutterPoint;
typedef struct _ClutterRect ClutterRect; typedef struct _ClutterRect ClutterRect;
typedef struct _ClutterSize ClutterSize;
typedef struct _ClutterAlpha ClutterAlpha; typedef struct _ClutterAlpha ClutterAlpha;
typedef struct _ClutterAnimation ClutterAnimation; typedef struct _ClutterAnimation ClutterAnimation;
@ -199,63 +197,6 @@ float clutter_point_distance (const ClutterPoint *a,
float *x_distance, float *x_distance,
float *y_distance); float *y_distance);
/**
* ClutterSize:
* @width: the width, in pixels
* @height: the height, in pixels
*
* A size, in 2D space.
*
* Since: 1.12
*/
struct _ClutterSize
{
float width;
float height;
};
/**
* CLUTTER_SIZE_INIT:
* @width: the width
* @height: the height
*
* A simple macro for initializing a #ClutterSize when declaring it, e.g.:
*
* |[
* ClutterSize s = CLUTTER_SIZE_INIT (200, 200);
* ]|
*
* Since: 1.12
*/
#define CLUTTER_SIZE_INIT(width,height) { (width), (height) }
/**
* CLUTTER_SIZE_INIT_ZERO:
*
* A simple macro for initializing a #ClutterSize to (0, 0) when
* declaring it.
*
* Since: 1.12
*/
#define CLUTTER_SIZE_INIT_ZERO CLUTTER_SIZE_INIT (0.f, 0.f)
CLUTTER_EXPORT
GType clutter_size_get_type (void) G_GNUC_CONST;
CLUTTER_EXPORT
ClutterSize * clutter_size_alloc (void);
CLUTTER_EXPORT
ClutterSize * clutter_size_init (ClutterSize *size,
float width,
float height);
CLUTTER_EXPORT
ClutterSize * clutter_size_copy (const ClutterSize *size);
CLUTTER_EXPORT
void clutter_size_free (ClutterSize *size);
CLUTTER_EXPORT
gboolean clutter_size_equals (const ClutterSize *a,
const ClutterSize *b);
/** /**
* ClutterRect: * ClutterRect:
* @origin: the origin of the rectangle * @origin: the origin of the rectangle
@ -280,7 +221,7 @@ gboolean clutter_size_equals (const ClutterSize *a,
struct _ClutterRect struct _ClutterRect
{ {
ClutterPoint origin; ClutterPoint origin;
ClutterSize size; graphene_size_t size;
}; };
/** /**