mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
canvas: Remove invalidate_with_size()
We can replace it by adding a return value to set_size() that can tell us if the set_size() invalidated the contents of the canvas or not.
This commit is contained in:
parent
323ec19dcc
commit
755f41f559
@ -151,19 +151,29 @@ clutter_canvas_set_property (GObject *gobject,
|
|||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_WIDTH:
|
case PROP_WIDTH:
|
||||||
if (priv->width != g_value_get_int (value))
|
{
|
||||||
{
|
gint new_size = g_value_get_int (value);
|
||||||
priv->width = g_value_get_int (value);
|
|
||||||
clutter_content_invalidate (CLUTTER_CONTENT (gobject));
|
if (priv->width != new_size)
|
||||||
}
|
{
|
||||||
|
priv->width = new_size;
|
||||||
|
|
||||||
|
clutter_content_invalidate (CLUTTER_CONTENT (gobject));
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_HEIGHT:
|
case PROP_HEIGHT:
|
||||||
if (priv->height != g_value_get_int (value))
|
{
|
||||||
{
|
gint new_size = g_value_get_int (value);
|
||||||
priv->height = g_value_get_int (value);
|
|
||||||
clutter_content_invalidate (CLUTTER_CONTENT (gobject));
|
if (priv->height != new_size)
|
||||||
}
|
{
|
||||||
|
priv->height = new_size;
|
||||||
|
|
||||||
|
clutter_content_invalidate (CLUTTER_CONTENT (gobject));
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -494,13 +504,13 @@ clutter_canvas_new (void)
|
|||||||
return g_object_new (CLUTTER_TYPE_CANVAS, NULL);
|
return g_object_new (CLUTTER_TYPE_CANVAS, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static gboolean
|
||||||
clutter_canvas_invalidate_internal (ClutterCanvas *canvas,
|
clutter_canvas_invalidate_internal (ClutterCanvas *canvas,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height)
|
||||||
gboolean force_invalidate)
|
|
||||||
{
|
{
|
||||||
gboolean width_changed = FALSE, height_changed = FALSE;
|
gboolean width_changed = FALSE, height_changed = FALSE;
|
||||||
|
gboolean res = FALSE;
|
||||||
GObject *obj;
|
GObject *obj;
|
||||||
|
|
||||||
obj = G_OBJECT (canvas);
|
obj = G_OBJECT (canvas);
|
||||||
@ -523,10 +533,15 @@ clutter_canvas_invalidate_internal (ClutterCanvas *canvas,
|
|||||||
g_object_notify_by_pspec (obj, obj_props[PROP_HEIGHT]);
|
g_object_notify_by_pspec (obj, obj_props[PROP_HEIGHT]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (force_invalidate || (width_changed || height_changed))
|
if (width_changed || height_changed)
|
||||||
clutter_content_invalidate (CLUTTER_CONTENT (canvas));
|
{
|
||||||
|
clutter_content_invalidate (CLUTTER_CONTENT (canvas));
|
||||||
|
res = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
g_object_thaw_notify (obj);
|
g_object_thaw_notify (obj);
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -540,39 +555,27 @@ clutter_canvas_invalidate_internal (ClutterCanvas *canvas,
|
|||||||
* This function will cause the @canvas to be invalidated only
|
* This function will cause the @canvas to be invalidated only
|
||||||
* if the size of the canvas surface has changed.
|
* if the size of the canvas surface has changed.
|
||||||
*
|
*
|
||||||
|
* If you want to invalidate the contents of the @canvas when setting
|
||||||
|
* the size, you can use the return value of the function to conditionally
|
||||||
|
* call clutter_content_invalidate():
|
||||||
|
*
|
||||||
|
* |[
|
||||||
|
* if (!clutter_canvas_set_size (canvas, width, height))
|
||||||
|
* clutter_content_invalidate (CLUTTER_CONTENT (canvas));
|
||||||
|
* ]|
|
||||||
|
*
|
||||||
|
* Return value: this function returns %TRUE if the size change
|
||||||
|
* caused a content invalidation, and %FALSE otherwise
|
||||||
|
*
|
||||||
* Since: 1.10
|
* Since: 1.10
|
||||||
*/
|
*/
|
||||||
void
|
gboolean
|
||||||
clutter_canvas_set_size (ClutterCanvas *canvas,
|
clutter_canvas_set_size (ClutterCanvas *canvas,
|
||||||
int width,
|
int width,
|
||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
g_return_if_fail (CLUTTER_IS_CANVAS (canvas));
|
g_return_val_if_fail (CLUTTER_IS_CANVAS (canvas), FALSE);
|
||||||
g_return_if_fail (width >= -1 && height >= -1);
|
g_return_val_if_fail (width >= -1 && height >= -1, FALSE);
|
||||||
|
|
||||||
clutter_canvas_invalidate_internal (canvas, width, height, FALSE);
|
return clutter_canvas_invalidate_internal (canvas, width, height);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* clutter_canvas_invalidate_with_size:
|
|
||||||
* @canvas: a #ClutterCanvas
|
|
||||||
* @width: the width of the canvas, in pixels
|
|
||||||
* @height: the height of the canvas, in pixels
|
|
||||||
*
|
|
||||||
* Sets the size of the @canvas, and invalidates the content.
|
|
||||||
*
|
|
||||||
* This function will cause the @canvas to be invalidated regardless
|
|
||||||
* of the size change.
|
|
||||||
*
|
|
||||||
* Since: 1.16
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
clutter_canvas_invalidate_with_size (ClutterCanvas *canvas,
|
|
||||||
int width,
|
|
||||||
int height)
|
|
||||||
{
|
|
||||||
g_return_if_fail (CLUTTER_IS_CANVAS (canvas));
|
|
||||||
g_return_if_fail (width >= -1 && height >= -1);
|
|
||||||
|
|
||||||
clutter_canvas_invalidate_internal (canvas, width, height, TRUE);
|
|
||||||
}
|
}
|
||||||
|
@ -91,14 +91,10 @@ GType clutter_canvas_get_type (void) G_GNUC_CONST;
|
|||||||
CLUTTER_AVAILABLE_IN_1_10
|
CLUTTER_AVAILABLE_IN_1_10
|
||||||
ClutterContent * clutter_canvas_new (void);
|
ClutterContent * clutter_canvas_new (void);
|
||||||
CLUTTER_AVAILABLE_IN_1_10
|
CLUTTER_AVAILABLE_IN_1_10
|
||||||
void clutter_canvas_set_size (ClutterCanvas *canvas,
|
gboolean clutter_canvas_set_size (ClutterCanvas *canvas,
|
||||||
int width,
|
int width,
|
||||||
int height);
|
int height);
|
||||||
|
|
||||||
CLUTTER_AVAILABLE_IN_1_16
|
|
||||||
void clutter_canvas_invalidate_with_size (ClutterCanvas *canvas,
|
|
||||||
int width,
|
|
||||||
int height);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user