st-icon: Create shadow pipeline only at paint
Don't try to allocate the shadow after allocation, just do it at paint as it's done by other shadowed widgets
This commit is contained in:
parent
2ba26407f1
commit
e522e2e804
@ -56,12 +56,15 @@ struct _StIconPrivate
|
|||||||
|
|
||||||
CoglPipeline *shadow_pipeline;
|
CoglPipeline *shadow_pipeline;
|
||||||
StShadow *shadow_spec;
|
StShadow *shadow_spec;
|
||||||
|
ClutterSize shadow_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (StIcon, st_icon, ST_TYPE_WIDGET)
|
G_DEFINE_TYPE_WITH_PRIVATE (StIcon, st_icon, ST_TYPE_WIDGET)
|
||||||
|
|
||||||
static void st_icon_update (StIcon *icon);
|
static void st_icon_update (StIcon *icon);
|
||||||
static gboolean st_icon_update_icon_size (StIcon *icon);
|
static gboolean st_icon_update_icon_size (StIcon *icon);
|
||||||
|
static void st_icon_update_shadow_pipeline (StIcon *icon);
|
||||||
|
static void st_icon_clear_shadow_pipeline (StIcon *icon);
|
||||||
|
|
||||||
#define DEFAULT_ICON_SIZE 48
|
#define DEFAULT_ICON_SIZE 48
|
||||||
|
|
||||||
@ -158,12 +161,15 @@ st_icon_dispose (GObject *gobject)
|
|||||||
static void
|
static void
|
||||||
st_icon_paint (ClutterActor *actor)
|
st_icon_paint (ClutterActor *actor)
|
||||||
{
|
{
|
||||||
StIconPrivate *priv = ST_ICON (actor)->priv;
|
StIcon *icon = ST_ICON (actor);
|
||||||
|
StIconPrivate *priv = icon->priv;
|
||||||
|
|
||||||
st_widget_paint_background (ST_WIDGET (actor));
|
st_widget_paint_background (ST_WIDGET (actor));
|
||||||
|
|
||||||
if (priv->icon_texture)
|
if (priv->icon_texture)
|
||||||
{
|
{
|
||||||
|
st_icon_update_shadow_pipeline (icon);
|
||||||
|
|
||||||
if (priv->shadow_pipeline)
|
if (priv->shadow_pipeline)
|
||||||
{
|
{
|
||||||
ClutterActorBox allocation;
|
ClutterActorBox allocation;
|
||||||
@ -186,7 +192,7 @@ st_icon_style_changed (StWidget *widget)
|
|||||||
StThemeNode *theme_node = st_widget_get_theme_node (widget);
|
StThemeNode *theme_node = st_widget_get_theme_node (widget);
|
||||||
StIconPrivate *priv = self->priv;
|
StIconPrivate *priv = self->priv;
|
||||||
|
|
||||||
g_clear_pointer (&priv->shadow_pipeline, cogl_object_unref);
|
st_icon_clear_shadow_pipeline (self);
|
||||||
g_clear_pointer (&priv->shadow_spec, st_shadow_unref);
|
g_clear_pointer (&priv->shadow_spec, st_shadow_unref);
|
||||||
|
|
||||||
priv->shadow_spec = st_theme_node_get_shadow (theme_node, "icon-shadow");
|
priv->shadow_spec = st_theme_node_get_shadow (theme_node, "icon-shadow");
|
||||||
@ -265,21 +271,49 @@ st_icon_init (StIcon *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
st_icon_update_shadow_pipeline (StIcon *icon)
|
st_icon_clear_shadow_pipeline (StIcon *icon)
|
||||||
{
|
{
|
||||||
StIconPrivate *priv = icon->priv;
|
StIconPrivate *priv = icon->priv;
|
||||||
|
|
||||||
g_clear_pointer (&priv->shadow_pipeline, cogl_object_unref);
|
g_clear_pointer (&priv->shadow_pipeline, cogl_object_unref);
|
||||||
|
clutter_size_init (&priv->shadow_size, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (priv->shadow_spec)
|
static void
|
||||||
priv->shadow_pipeline = _st_create_shadow_pipeline_from_actor (priv->shadow_spec, priv->icon_texture);
|
st_icon_update_shadow_pipeline (StIcon *icon)
|
||||||
|
{
|
||||||
|
StIconPrivate *priv = icon->priv;
|
||||||
|
|
||||||
|
if (priv->icon_texture && priv->shadow_spec)
|
||||||
|
{
|
||||||
|
ClutterActorBox box;
|
||||||
|
float width, height;
|
||||||
|
|
||||||
|
clutter_actor_get_allocation_box (CLUTTER_ACTOR (icon), &box);
|
||||||
|
clutter_actor_box_get_size (&box, &width, &height);
|
||||||
|
|
||||||
|
if (priv->shadow_pipeline == NULL ||
|
||||||
|
priv->shadow_size.width != width ||
|
||||||
|
priv->shadow_size.height != height)
|
||||||
|
{
|
||||||
|
st_icon_clear_shadow_pipeline (icon);
|
||||||
|
|
||||||
|
priv->shadow_pipeline =
|
||||||
|
_st_create_shadow_pipeline_from_actor (priv->shadow_spec,
|
||||||
|
priv->icon_texture);
|
||||||
|
|
||||||
|
if (priv->shadow_pipeline)
|
||||||
|
clutter_size_init (&priv->shadow_size, width, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_pixbuf_changed (ClutterTexture *texture,
|
on_pixbuf_changed (ClutterTexture *texture,
|
||||||
StIcon *icon)
|
StIcon *icon)
|
||||||
{
|
{
|
||||||
st_icon_update_shadow_pipeline (icon);
|
st_icon_clear_shadow_pipeline (icon);
|
||||||
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (icon));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -304,7 +338,7 @@ st_icon_finish_update (StIcon *icon)
|
|||||||
/* Remove the temporary ref we added */
|
/* Remove the temporary ref we added */
|
||||||
g_object_unref (priv->icon_texture);
|
g_object_unref (priv->icon_texture);
|
||||||
|
|
||||||
st_icon_update_shadow_pipeline (icon);
|
st_icon_clear_shadow_pipeline (icon);
|
||||||
|
|
||||||
/* "pixbuf-change" is actually a misnomer for "texture-changed" */
|
/* "pixbuf-change" is actually a misnomer for "texture-changed" */
|
||||||
g_signal_connect_object (priv->icon_texture, "pixbuf-change",
|
g_signal_connect_object (priv->icon_texture, "pixbuf-change",
|
||||||
|
Loading…
Reference in New Issue
Block a user