Merge branch 'wip/color-state-plumbing' into 'main'

Color state plumbing

See merge request GNOME/gnome-shell!3363
This commit is contained in:
Jonas Ådahl 2024-06-29 21:00:09 +00:00
commit 02e1646c5c
15 changed files with 186 additions and 120 deletions

View file

@ -83,8 +83,9 @@ st_drawing_area_allocate (ClutterActor *self,
}
static void
st_drawing_area_paint_node (ClutterActor *actor,
ClutterPaintNode *root)
st_drawing_area_paint_node (ClutterActor *actor,
ClutterPaintNode *root,
ClutterPaintContext *paint_context)
{
StDrawingArea *area = ST_DRAWING_AREA (actor);
StDrawingAreaPrivate *priv = st_drawing_area_get_instance_private (area);

View file

@ -107,7 +107,7 @@ struct _StEntryPrivate
StShadow *shadow_spec;
CoglPipeline *text_shadow_material;
CoglPipeline *text_shadow_pipeline;
gfloat shadow_width;
gfloat shadow_height;
};
@ -216,7 +216,7 @@ st_entry_dispose (GObject *object)
StEntry *entry = ST_ENTRY (object);
StEntryPrivate *priv = ST_ENTRY_PRIV (entry);
g_clear_object (&priv->text_shadow_material);
g_clear_object (&priv->text_shadow_pipeline);
G_OBJECT_CLASS (st_entry_parent_class)->dispose (object);
}
@ -254,7 +254,7 @@ st_entry_style_changed (StWidget *self)
if (!priv->shadow_spec || !shadow_spec ||
!st_shadow_equal (shadow_spec, priv->shadow_spec))
{
g_clear_object (&priv->text_shadow_material);
g_clear_object (&priv->text_shadow_pipeline);
g_clear_pointer (&priv->shadow_spec, st_shadow_unref);
if (shadow_spec)
@ -555,7 +555,7 @@ clutter_text_cursor_changed (ClutterText *text,
st_entry_update_hint_visibility (entry);
g_clear_object (&priv->text_shadow_material);
g_clear_object (&priv->text_shadow_pipeline);
}
static void
@ -569,7 +569,7 @@ clutter_text_changed_cb (GObject *object,
st_entry_update_hint_visibility (entry);
/* Since the text changed, force a regen of the shadow texture */
g_clear_object (&priv->text_shadow_material);
g_clear_object (&priv->text_shadow_pipeline);
g_object_notify_by_pspec (G_OBJECT (entry), props[PROP_TEXT]);
}
@ -581,7 +581,7 @@ invalidate_shadow_pipeline (GObject *object,
{
StEntryPrivate *priv = ST_ENTRY_PRIV (entry);
g_clear_object (&priv->text_shadow_material);
g_clear_object (&priv->text_shadow_pipeline);
}
static void
@ -817,12 +817,13 @@ st_entry_leave_event (ClutterActor *actor,
}
static void
st_entry_paint_node (ClutterActor *actor,
ClutterPaintNode *node)
st_entry_paint_node (ClutterActor *actor,
ClutterPaintNode *node,
ClutterPaintContext *paint_context)
{
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
st_widget_paint_background (ST_WIDGET (actor), node);
st_widget_paint_background (ST_WIDGET (actor), node, paint_context);
if (priv->shadow_spec)
{
@ -832,27 +833,28 @@ st_entry_paint_node (ClutterActor *actor,
clutter_actor_get_allocation_box (priv->entry, &allocation);
clutter_actor_box_get_size (&allocation, &width, &height);
if (priv->text_shadow_material == NULL ||
if (priv->text_shadow_pipeline == NULL ||
width != priv->shadow_width ||
height != priv->shadow_height)
{
CoglPipeline *material;
CoglPipeline *pipeline;
g_clear_object (&priv->text_shadow_material);
g_clear_object (&priv->text_shadow_pipeline);
material = _st_create_shadow_pipeline_from_actor (priv->shadow_spec,
priv->entry);
pipeline = _st_create_shadow_pipeline_from_actor (priv->shadow_spec,
priv->entry,
paint_context);
priv->shadow_width = width;
priv->shadow_height = height;
priv->text_shadow_material = material;
priv->text_shadow_pipeline = pipeline;
}
if (priv->text_shadow_material != NULL)
if (priv->text_shadow_pipeline != NULL)
{
_st_paint_shadow_with_opacity (priv->shadow_spec,
node,
priv->text_shadow_material,
priv->text_shadow_pipeline,
&allocation,
clutter_actor_get_paint_opacity (priv->entry));
}
@ -1093,7 +1095,7 @@ st_entry_init (StEntry *entry)
priv->spacing = 6.0f;
priv->text_shadow_material = NULL;
priv->text_shadow_pipeline = NULL;
priv->shadow_width = -1.;
priv->shadow_height = -1.;

View file

@ -78,7 +78,8 @@ G_DEFINE_TYPE_WITH_PRIVATE (StIcon, st_icon, ST_TYPE_WIDGET)
static void st_icon_update (StIcon *icon);
static gboolean st_icon_update_icon_size (StIcon *icon);
static void st_icon_update_shadow_pipeline (StIcon *icon);
static void st_icon_update_shadow_pipeline (StIcon *icon,
ClutterPaintContext *paint_context);
static void st_icon_clear_shadow_pipeline (StIcon *icon);
static GIcon *default_gicon = NULL;
@ -200,17 +201,18 @@ st_icon_dispose (GObject *gobject)
}
static void
st_icon_paint_node (ClutterActor *actor,
ClutterPaintNode *node)
st_icon_paint_node (ClutterActor *actor,
ClutterPaintNode *node,
ClutterPaintContext *paint_context)
{
StIcon *icon = ST_ICON (actor);
StIconPrivate *priv = icon->priv;
st_widget_paint_background (ST_WIDGET (actor), node);
st_widget_paint_background (ST_WIDGET (actor), node, paint_context);
if (priv->icon_texture)
{
st_icon_update_shadow_pipeline (icon);
st_icon_update_shadow_pipeline (icon, paint_context);
if (priv->shadow_pipeline)
{
@ -415,7 +417,8 @@ st_icon_clear_shadow_pipeline (StIcon *icon)
}
static void
st_icon_update_shadow_pipeline (StIcon *icon)
st_icon_update_shadow_pipeline (StIcon *icon,
ClutterPaintContext *paint_context)
{
StIconPrivate *priv = icon->priv;
@ -436,7 +439,8 @@ st_icon_update_shadow_pipeline (StIcon *icon)
priv->shadow_pipeline =
_st_create_shadow_pipeline_from_actor (priv->shadow_spec,
priv->icon_texture);
priv->icon_texture,
paint_context);
if (priv->shadow_pipeline)
graphene_size_init (&priv->shadow_size, width, height);

View file

@ -205,12 +205,13 @@ st_label_dispose (GObject *object)
}
static void
st_label_paint_node (ClutterActor *actor,
ClutterPaintNode *node)
st_label_paint_node (ClutterActor *actor,
ClutterPaintNode *node,
ClutterPaintContext *paint_context)
{
StLabelPrivate *priv = ST_LABEL (actor)->priv;
st_widget_paint_background (ST_WIDGET (actor), node);
st_widget_paint_background (ST_WIDGET (actor), node, paint_context);
if (priv->shadow_spec)
{
@ -236,7 +237,8 @@ st_label_paint_node (ClutterActor *actor,
priv->shadow_height = height;
priv->text_shadow_pipeline =
_st_create_shadow_pipeline_from_actor (priv->shadow_spec,
priv->label);
priv->label,
paint_context);
}
if (priv->text_shadow_pipeline != NULL)

View file

@ -376,9 +376,10 @@ blur_pixels (guchar *pixels_in,
}
CoglPipeline *
_st_create_shadow_pipeline (StShadow *shadow_spec,
CoglTexture *src_texture,
float resource_scale)
_st_create_shadow_pipeline (StShadow *shadow_spec,
ClutterPaintContext *paint_context,
CoglTexture *src_texture,
float resource_scale)
{
ClutterBackend *backend = clutter_get_default_backend ();
CoglContext *ctx = clutter_backend_get_cogl_context (backend);
@ -386,7 +387,8 @@ _st_create_shadow_pipeline (StShadow *shadow_spec,
g_autoptr (ClutterPaintNode) blur_node = NULL;
g_autoptr (CoglOffscreen) offscreen = NULL;
g_autoptr (GError) error = NULL;
ClutterPaintContext *paint_context;
ClutterPaintContext *nested_paint_context;
ClutterColorState *color_state;
CoglFramebuffer *fb;
CoglPipeline *pipeline;
CoglTexture *texture;
@ -472,10 +474,14 @@ _st_create_shadow_pipeline (StShadow *shadow_spec,
.y2 = src_height + sampling_radius,
});
paint_context =
clutter_paint_context_new_for_framebuffer (fb, NULL, CLUTTER_PAINT_FLAG_NONE);
clutter_paint_node_paint (blur_node, paint_context);
clutter_paint_context_destroy (paint_context);
color_state = clutter_paint_context_get_color_state (paint_context);
nested_paint_context =
clutter_paint_context_new_for_framebuffer (fb, NULL, CLUTTER_PAINT_FLAG_NONE,
color_state);
clutter_paint_context_push_color_state (nested_paint_context, color_state);
clutter_paint_node_paint (blur_node, nested_paint_context);
clutter_paint_context_pop_color_state (nested_paint_context, color_state);
clutter_paint_context_destroy (nested_paint_context);
if (G_UNLIKELY (shadow_pipeline_template == NULL))
{
@ -498,14 +504,16 @@ _st_create_shadow_pipeline (StShadow *shadow_spec,
}
CoglPipeline *
_st_create_shadow_pipeline_from_actor (StShadow *shadow_spec,
ClutterActor *actor)
_st_create_shadow_pipeline_from_actor (StShadow *shadow_spec,
ClutterActor *actor,
ClutterPaintContext *paint_context)
{
ClutterContent *image = NULL;
CoglPipeline *shadow_pipeline = NULL;
float resource_scale;
float width, height;
ClutterPaintContext *paint_context;
ClutterColorState *color_state;
ClutterPaintContext *nested_paint_context;
g_return_val_if_fail (clutter_actor_has_allocation (actor), NULL);
@ -528,8 +536,12 @@ _st_create_shadow_pipeline_from_actor (StShadow *shadow_spec,
if (texture &&
cogl_texture_get_width (texture) == width &&
cogl_texture_get_height (texture) == height)
shadow_pipeline = _st_create_shadow_pipeline (shadow_spec, texture,
resource_scale);
{
shadow_pipeline = _st_create_shadow_pipeline (shadow_spec,
paint_context,
texture,
resource_scale);
}
}
if (shadow_pipeline == NULL)
@ -570,17 +582,22 @@ _st_create_shadow_pipeline_from_actor (StShadow *shadow_spec,
clutter_actor_set_opacity_override (actor, 255);
paint_context =
color_state = clutter_actor_get_color_state (actor);
nested_paint_context =
clutter_paint_context_new_for_framebuffer (fb, NULL,
CLUTTER_PAINT_FLAG_NONE);
clutter_actor_paint (actor, paint_context);
clutter_paint_context_destroy (paint_context);
CLUTTER_PAINT_FLAG_NONE,
color_state);
clutter_paint_context_push_color_state (nested_paint_context, color_state);
clutter_actor_paint (actor, nested_paint_context);
clutter_paint_context_pop_color_state (nested_paint_context, color_state);
clutter_paint_context_destroy (nested_paint_context);
clutter_actor_set_opacity_override (actor, -1);
g_object_unref (fb);
shadow_pipeline = _st_create_shadow_pipeline (shadow_spec,
paint_context,
g_steal_pointer (&buffer),
resource_scale);
}

View file

@ -58,11 +58,13 @@ void _st_set_text_from_style (ClutterText *text,
CoglPipeline * _st_create_texture_pipeline (CoglTexture *src_texture);
/* Helper for widgets which need to draw additional shadows */
CoglPipeline * _st_create_shadow_pipeline (StShadow *shadow_spec,
CoglTexture *src_texture,
float resource_scale);
CoglPipeline * _st_create_shadow_pipeline_from_actor (StShadow *shadow_spec,
ClutterActor *actor);
CoglPipeline * _st_create_shadow_pipeline (StShadow *shadow_spec,
ClutterPaintContext *paint_context,
CoglTexture *src_texture,
float resource_scale);
CoglPipeline * _st_create_shadow_pipeline_from_actor (StShadow *shadow_spec,
ClutterActor *actor,
ClutterPaintContext *paint_context);
cairo_pattern_t *_st_create_shadow_cairo_pattern (StShadow *shadow_spec,
cairo_pattern_t *src_pattern);

View file

@ -218,12 +218,14 @@ st_shadow_helper_new (StShadow *shadow)
* st_shadow_helper_update:
* @helper: a #StShadowHelper
* @source: a #ClutterActor
* @paint_context: a #ClutterPaintContext
*
* Update @helper from @source.
*/
void
st_shadow_helper_update (StShadowHelper *helper,
ClutterActor *source)
st_shadow_helper_update (StShadowHelper *helper,
ClutterActor *source,
ClutterPaintContext *paint_context)
{
gfloat width, height;
@ -236,7 +238,9 @@ st_shadow_helper_update (StShadowHelper *helper,
if (helper->pipeline)
g_object_unref (helper->pipeline);
helper->pipeline = _st_create_shadow_pipeline_from_actor (helper->shadow, source);
helper->pipeline = _st_create_shadow_pipeline_from_actor (helper->shadow,
source,
paint_context);
helper->width = width;
helper->height = height;
}

View file

@ -81,8 +81,9 @@ StShadowHelper *st_shadow_helper_new (StShadow *shadow);
StShadowHelper *st_shadow_helper_copy (StShadowHelper *helper);
void st_shadow_helper_free (StShadowHelper *helper);
void st_shadow_helper_update (StShadowHelper *helper,
ClutterActor *source);
void st_shadow_helper_update (StShadowHelper *helper,
ClutterActor *source,
ClutterPaintContext *paint_context);
void st_shadow_helper_paint (StShadowHelper *helper,
ClutterPaintNode *node,

View file

@ -73,7 +73,7 @@ elliptical_arc (cairo_t *cr,
}
static CoglTexture *
create_corner_material (StCornerSpec *corner)
create_corner_pipeline (StCornerSpec *corner)
{
ClutterBackend *backend = clutter_get_default_backend ();
CoglContext *ctx = clutter_backend_get_cogl_context (backend);
@ -216,7 +216,7 @@ load_corner (StTextureCache *cache,
void *datap,
GError **error)
{
return create_corner_material ((StCornerSpec *) datap);
return create_corner_pipeline ((StCornerSpec *) datap);
}
/* To match the CSS specification, we want the border to look like it was
@ -368,7 +368,7 @@ st_theme_node_lookup_corner (StThemeNode *node,
StCorner corner_id)
{
CoglTexture *texture = NULL;
CoglPipeline *material = NULL;
CoglPipeline *pipeline = NULL;
char *key;
StTextureCache *cache;
StCornerSpec corner;
@ -426,13 +426,13 @@ st_theme_node_lookup_corner (StThemeNode *node,
if (texture)
{
material = _st_create_texture_pipeline (texture);
pipeline = _st_create_texture_pipeline (texture);
g_object_unref (texture);
}
g_free (key);
return material;
return pipeline;
}
static void
@ -1416,13 +1416,13 @@ st_theme_node_maybe_prerender_background (StThemeNodePaintState *state,
}
}
state->corner_material[ST_CORNER_TOPLEFT] =
state->corner_pipeline[ST_CORNER_TOPLEFT] =
st_theme_node_lookup_corner (node, width, height, resource_scale, ST_CORNER_TOPLEFT);
state->corner_material[ST_CORNER_TOPRIGHT] =
state->corner_pipeline[ST_CORNER_TOPRIGHT] =
st_theme_node_lookup_corner (node, width, height, resource_scale, ST_CORNER_TOPRIGHT);
state->corner_material[ST_CORNER_BOTTOMRIGHT] =
state->corner_pipeline[ST_CORNER_BOTTOMRIGHT] =
st_theme_node_lookup_corner (node, width, height, resource_scale, ST_CORNER_BOTTOMRIGHT);
state->corner_material[ST_CORNER_BOTTOMLEFT] =
state->corner_pipeline[ST_CORNER_BOTTOMLEFT] =
st_theme_node_lookup_corner (node, width, height, resource_scale, ST_CORNER_BOTTOMLEFT);
/* Use cairo to prerender the node if there is a gradient, or
@ -1499,8 +1499,9 @@ st_theme_node_invalidate_background_image (StThemeNode *node)
}
static gboolean
st_theme_node_load_background_image (StThemeNode *node,
gfloat resource_scale)
st_theme_node_load_background_image (StThemeNode *node,
ClutterPaintContext *paint_context,
float resource_scale)
{
if (node->background_texture == NULL)
{
@ -1528,6 +1529,7 @@ st_theme_node_load_background_image (StThemeNode *node,
if (background_image_shadow_spec)
{
node->background_shadow_pipeline = _st_create_shadow_pipeline (background_image_shadow_spec,
paint_context,
node->background_texture,
resource_scale);
}
@ -1564,11 +1566,13 @@ st_theme_node_invalidate_resources_for_file (StThemeNode *node,
}
static void st_theme_node_compute_maximum_borders (StThemeNodePaintState *state);
static void st_theme_node_prerender_shadow (StThemeNodePaintState *state);
static void st_theme_node_prerender_shadow (StThemeNodePaintState *state,
ClutterPaintContext *paint_context);
static void
st_theme_node_render_resources (StThemeNodePaintState *state,
StThemeNode *node,
ClutterPaintContext *paint_context,
float width,
float height,
float resource_scale)
@ -1603,14 +1607,16 @@ st_theme_node_render_resources (StThemeNodePaintState *state,
if (st_theme_node_load_border_image (node, resource_scale))
state->box_shadow_pipeline = _st_create_shadow_pipeline (box_shadow_spec,
paint_context,
node->border_slices_texture,
state->resource_scale);
else if (state->prerendered_texture != NULL)
state->box_shadow_pipeline = _st_create_shadow_pipeline (box_shadow_spec,
paint_context,
state->prerendered_texture,
state->resource_scale);
else
st_theme_node_prerender_shadow (state);
st_theme_node_prerender_shadow (state, paint_context);
}
/* If we don't have cached textures yet, check whether we can cache
@ -1630,6 +1636,7 @@ st_theme_node_render_resources (StThemeNodePaintState *state,
static void
st_theme_node_update_resources (StThemeNodePaintState *state,
StThemeNode *node,
ClutterPaintContext *paint_context,
float width,
float height,
float resource_scale)
@ -1665,13 +1672,14 @@ st_theme_node_update_resources (StThemeNodePaintState *state,
if (had_box_shadow)
state->box_shadow_pipeline = _st_create_shadow_pipeline (box_shadow_spec,
paint_context,
state->prerendered_texture,
state->resource_scale);
}
static void
paint_material_with_opacity (ClutterPaintNode *node,
CoglPipeline *material,
paint_pipeline_with_opacity (ClutterPaintNode *node,
CoglPipeline *pipeline,
ClutterActorBox *box,
ClutterActorBox *coords,
guint8 paint_opacity)
@ -1682,9 +1690,9 @@ paint_material_with_opacity (ClutterPaintNode *node,
cogl_color_init_from_4f (&color,
paint_opacity / 255.0, paint_opacity / 255.0,
paint_opacity / 255.0, paint_opacity / 255.0);
cogl_pipeline_set_color (material, &color);
cogl_pipeline_set_color (pipeline, &color);
pipeline_node = clutter_pipeline_node_new (material);
pipeline_node = clutter_pipeline_node_new (pipeline);
clutter_paint_node_add_child (node, pipeline_node);
if (coords)
@ -1825,13 +1833,13 @@ st_theme_node_paint_borders (StThemeNodePaintState *state,
{
g_autoptr (ClutterPaintNode) corners_node = NULL;
if (state->corner_material[corner_id] == NULL)
if (state->corner_pipeline[corner_id] == NULL)
continue;
cogl_pipeline_set_color (state->corner_material[corner_id], &pipeline_color);
cogl_pipeline_set_color (state->corner_pipeline[corner_id], &pipeline_color);
corners_node =
clutter_pipeline_node_new (state->corner_material[corner_id]);
clutter_pipeline_node_new (state->corner_pipeline[corner_id]);
clutter_paint_node_set_static_name (corners_node,
"StThemeNode (CSS border corners)");
clutter_paint_node_add_child (root, corners_node);
@ -2411,7 +2419,8 @@ st_theme_node_paint_sliced_shadow (StThemeNodePaintState *state,
}
static void
st_theme_node_prerender_shadow (StThemeNodePaintState *state)
st_theme_node_prerender_shadow (StThemeNodePaintState *state,
ClutterPaintContext *paint_context)
{
StThemeNode *node = state->node;
CoglContext *ctx;
@ -2436,7 +2445,8 @@ st_theme_node_prerender_shadow (StThemeNodePaintState *state)
if (cogl_framebuffer_allocate (framebuffer, &error))
{
g_autoptr (ClutterPaintNode) root_node = NULL;
ClutterPaintContext *paint_context;
ClutterColorState *color_state;
ClutterPaintContext *nested_paint_context;
CoglColor clear_color;
ClutterActorBox box = { 0, 0, state->box_shadow_width, state->box_shadow_height};
@ -2454,14 +2464,19 @@ st_theme_node_prerender_shadow (StThemeNodePaintState *state)
st_theme_node_paint_borders (state, root_node, &box,
ST_PAINT_BORDERS_MODE_SILHOUETTE, 0xff);
paint_context =
color_state = clutter_paint_context_get_color_state (paint_context);
nested_paint_context =
clutter_paint_context_new_for_framebuffer (framebuffer,
NULL,
CLUTTER_PAINT_FLAG_NONE);
clutter_paint_node_paint (root_node, paint_context);
clutter_paint_context_destroy (paint_context);
CLUTTER_PAINT_FLAG_NONE,
color_state);
clutter_paint_context_push_color_state (nested_paint_context, color_state);
clutter_paint_node_paint (root_node, nested_paint_context);
clutter_paint_context_pop_color_state (nested_paint_context, color_state);
clutter_paint_context_destroy (nested_paint_context);
state->box_shadow_pipeline = _st_create_shadow_pipeline (st_theme_node_get_box_shadow (node),
paint_context,
buffer, state->resource_scale);
}
@ -2719,6 +2734,7 @@ st_theme_node_needs_new_box_shadow_for_size (StThemeNodePaintState *state,
void
st_theme_node_paint (StThemeNode *node,
StThemeNodePaintState *state,
ClutterPaintContext *paint_context,
ClutterPaintNode *root,
const ClutterActorBox *box,
guint8 paint_opacity,
@ -2755,13 +2771,17 @@ st_theme_node_paint (StThemeNode *node,
fabsf (resource_scale - state->resource_scale) < FLT_EPSILON)
st_theme_node_paint_state_copy (state, &node->cached_state);
else
st_theme_node_render_resources (state, node, width, height, resource_scale);
st_theme_node_render_resources (state, node, paint_context,
width, height, resource_scale);
node->rendered_once = TRUE;
}
else if (state->alloc_width != width || state->alloc_height != height ||
fabsf (state->resource_scale - resource_scale) > FLT_EPSILON)
st_theme_node_update_resources (state, node, width, height, resource_scale);
{
st_theme_node_update_resources (state, node, paint_context,
width, height, resource_scale);
}
/* Rough notes about the relationship of borders and backgrounds in CSS3;
* see http://www.w3.org/TR/css3-background/ for more accurate details.
@ -2816,7 +2836,7 @@ st_theme_node_paint (StThemeNode *node,
&allocation,
&paint_box);
paint_material_with_opacity (root,
paint_pipeline_with_opacity (root,
state->prerendered_pipeline,
&paint_box,
NULL,
@ -2834,7 +2854,7 @@ st_theme_node_paint (StThemeNode *node,
st_theme_node_paint_outline (node, root, box, paint_opacity);
if (state->prerendered_pipeline == NULL &&
st_theme_node_load_background_image (node, resource_scale))
st_theme_node_load_background_image (node, paint_context, resource_scale))
{
ClutterActorBox background_box;
ClutterActorBox texture_coords;
@ -2880,7 +2900,7 @@ st_theme_node_paint (StThemeNode *node,
&background_box,
paint_opacity);
paint_material_with_opacity (root,
paint_pipeline_with_opacity (root,
node->background_pipeline,
&background_box,
&texture_coords,
@ -2899,7 +2919,7 @@ st_theme_node_paint_state_node_free_internal (StThemeNodePaintState *state,
g_clear_object (&state->box_shadow_pipeline);
for (corner_id = 0; corner_id < 4; corner_id++)
g_clear_object (&state->corner_material[corner_id]);
g_clear_object (&state->corner_pipeline[corner_id]);
if (unref_node)
st_theme_node_paint_state_set_node (state, NULL);
@ -2948,7 +2968,7 @@ st_theme_node_paint_state_init (StThemeNodePaintState *state)
state->prerendered_pipeline = NULL;
for (corner_id = 0; corner_id < 4; corner_id++)
state->corner_material[corner_id] = NULL;
state->corner_pipeline[corner_id] = NULL;
}
void
@ -2977,8 +2997,8 @@ st_theme_node_paint_state_copy (StThemeNodePaintState *state,
if (other->prerendered_pipeline)
state->prerendered_pipeline = g_object_ref (other->prerendered_pipeline);
for (corner_id = 0; corner_id < 4; corner_id++)
if (other->corner_material[corner_id])
state->corner_material[corner_id] = g_object_ref (other->corner_material[corner_id]);
if (other->corner_pipeline[corner_id])
state->corner_pipeline[corner_id] = g_object_ref (other->corner_pipeline[corner_id]);
}
void

View file

@ -50,7 +50,7 @@ struct _StThemeNodeTransitionPrivate {
CoglFramebuffer *old_offscreen;
CoglFramebuffer *new_offscreen;
CoglPipeline *material;
CoglPipeline *pipeline;
ClutterTimeline *timeline;
@ -244,6 +244,7 @@ st_theme_node_transition_get_paint_box (StThemeNodeTransition *transition,
static gboolean
setup_framebuffers (StThemeNodeTransition *transition,
ClutterPaintContext *paint_context,
ClutterPaintNode *node,
const ClutterActorBox *allocation,
float resource_scale)
@ -256,8 +257,8 @@ setup_framebuffers (StThemeNodeTransition *transition,
guint width, height;
GError *catch_error = NULL;
/* template material to avoid unnecessary shader compilation */
static CoglPipeline *material_template = NULL;
/* template pipeline to avoid unnecessary shader compilation */
static CoglPipeline *pipeline_template = NULL;
ctx = clutter_backend_get_cogl_context (clutter_get_default_backend ());
width = ceilf ((priv->offscreen_box.x2 - priv->offscreen_box.x1) * resource_scale);
@ -296,32 +297,32 @@ setup_framebuffers (StThemeNodeTransition *transition,
return FALSE;
}
if (priv->material == NULL)
if (priv->pipeline == NULL)
{
if (G_UNLIKELY (material_template == NULL))
if (G_UNLIKELY (pipeline_template == NULL))
{
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
material_template = cogl_pipeline_new (ctx);
pipeline_template = cogl_pipeline_new (ctx);
cogl_pipeline_set_layer_combine (material_template, 0,
cogl_pipeline_set_layer_combine (pipeline_template, 0,
"RGBA = REPLACE (TEXTURE)",
NULL);
cogl_pipeline_set_layer_combine (material_template, 1,
cogl_pipeline_set_layer_combine (pipeline_template, 1,
"RGBA = INTERPOLATE (PREVIOUS, "
"TEXTURE, "
"CONSTANT[A])",
NULL);
cogl_pipeline_set_layer_combine (material_template, 2,
cogl_pipeline_set_layer_combine (pipeline_template, 2,
"RGBA = MODULATE (PREVIOUS, "
"PRIMARY)",
NULL);
}
priv->material = cogl_pipeline_copy (material_template);
priv->pipeline = cogl_pipeline_copy (pipeline_template);
}
cogl_pipeline_set_layer_texture (priv->material, 0, priv->new_texture);
cogl_pipeline_set_layer_texture (priv->material, 1, priv->old_texture);
cogl_pipeline_set_layer_texture (priv->pipeline, 0, priv->new_texture);
cogl_pipeline_set_layer_texture (priv->pipeline, 1, priv->old_texture);
noop_pipeline = cogl_pipeline_new (ctx);
cogl_framebuffer_orthographic (priv->old_offscreen,
@ -335,6 +336,7 @@ setup_framebuffers (StThemeNodeTransition *transition,
clutter_paint_node_add_child (node, old_layer_node);
st_theme_node_paint (priv->old_theme_node, &priv->old_paint_state,
paint_context,
old_layer_node, allocation, 255, resource_scale);
new_layer_node = clutter_layer_node_new_to_framebuffer (priv->new_offscreen,
@ -346,6 +348,7 @@ setup_framebuffers (StThemeNodeTransition *transition,
priv->offscreen_box.x2,
priv->offscreen_box.y2, 0.0, 1.0);
st_theme_node_paint (priv->new_theme_node, &priv->new_paint_state,
paint_context,
new_layer_node, allocation, 255, resource_scale);
g_clear_object (&noop_pipeline);
@ -355,6 +358,7 @@ setup_framebuffers (StThemeNodeTransition *transition,
void
st_theme_node_transition_paint (StThemeNodeTransition *transition,
ClutterPaintContext *paint_context,
ClutterPaintNode *node,
ClutterActorBox *allocation,
guint8 paint_opacity,
@ -382,6 +386,7 @@ st_theme_node_transition_paint (StThemeNodeTransition *transition,
calculate_offscreen_box (transition, allocation);
priv->needs_setup = clutter_actor_box_get_area (&priv->offscreen_box) == 0 ||
!setup_framebuffers (transition,
paint_context,
node,
allocation,
resource_scale);
@ -392,14 +397,14 @@ st_theme_node_transition_paint (StThemeNodeTransition *transition,
cogl_color_init_from_4f (&constant, 0., 0., 0.,
clutter_timeline_get_progress (priv->timeline));
cogl_pipeline_set_layer_combine_constant (priv->material, 1, &constant);
cogl_pipeline_set_layer_combine_constant (priv->pipeline, 1, &constant);
cogl_color_init_from_4f (&pipeline_color,
paint_opacity / 255.0, paint_opacity / 255.0,
paint_opacity / 255.0, paint_opacity / 255.0);
cogl_pipeline_set_color (priv->material, &pipeline_color);
cogl_pipeline_set_color (priv->pipeline, &pipeline_color);
pipeline_node = clutter_pipeline_node_new (priv->material);
pipeline_node = clutter_pipeline_node_new (priv->pipeline);
clutter_paint_node_add_child (node, pipeline_node);
clutter_paint_node_add_multitexture_rectangle (pipeline_node,
&priv->offscreen_box,
@ -421,7 +426,7 @@ st_theme_node_transition_dispose (GObject *object)
g_clear_object (&priv->old_offscreen);
g_clear_object (&priv->new_offscreen);
g_clear_object (&priv->material);
g_clear_object (&priv->pipeline);
if (priv->timeline)
{

View file

@ -42,6 +42,7 @@ void st_theme_node_transition_update (StThemeNodeTransition *transition,
StThemeNode *new_node);
void st_theme_node_transition_paint (StThemeNodeTransition *transition,
ClutterPaintContext *paint_context,
ClutterPaintNode *node,
ClutterActorBox *allocation,
guint8 paint_opacity,

View file

@ -172,7 +172,7 @@ struct _StThemeNodePaintState {
CoglPipeline *box_shadow_pipeline;
CoglTexture *prerendered_texture;
CoglPipeline *prerendered_pipeline;
CoglPipeline *corner_material[4];
CoglPipeline *corner_pipeline[4];
};
StThemeNode *st_theme_node_new (StThemeContext *context,
@ -342,6 +342,7 @@ gboolean st_theme_node_paint_equal (StThemeNode *node,
*/
void st_theme_node_paint (StThemeNode *node,
StThemeNodePaintState *state,
ClutterPaintContext *paint_context,
ClutterPaintNode *root,
const ClutterActorBox *box,
guint8 paint_opacity,

View file

@ -399,8 +399,9 @@ get_border_paint_offsets (StViewport *viewport,
static void
st_viewport_paint_node (ClutterActor *actor,
ClutterPaintNode *node)
st_viewport_paint_node (ClutterActor *actor,
ClutterPaintNode *node,
ClutterPaintContext *paint_context)
{
StViewport *viewport = ST_VIEWPORT (actor);
int x, y;
@ -420,7 +421,7 @@ st_viewport_paint_node (ClutterActor *actor,
node = transform_node;
}
st_widget_paint_background (ST_WIDGET (actor), node);
st_widget_paint_background (ST_WIDGET (actor), node, paint_context);
}
static void

View file

@ -418,8 +418,9 @@ st_widget_allocate (ClutterActor *actor,
* painting children.
*/
void
st_widget_paint_background (StWidget *widget,
ClutterPaintNode *node)
st_widget_paint_background (StWidget *widget,
ClutterPaintNode *node,
ClutterPaintContext *paint_context)
{
StWidgetPrivate *priv = st_widget_get_instance_private (widget);
StThemeNode *theme_node;
@ -437,6 +438,7 @@ st_widget_paint_background (StWidget *widget,
if (priv->transition_animation)
st_theme_node_transition_paint (priv->transition_animation,
paint_context,
node,
&allocation,
opacity,
@ -444,6 +446,7 @@ st_widget_paint_background (StWidget *widget,
else
st_theme_node_paint (theme_node,
current_paint_state (widget),
paint_context,
node,
&allocation,
opacity,
@ -451,10 +454,11 @@ st_widget_paint_background (StWidget *widget,
}
static void
st_widget_paint_node (ClutterActor *actor,
ClutterPaintNode *node)
st_widget_paint_node (ClutterActor *actor,
ClutterPaintNode *node,
ClutterPaintContext *paint_context)
{
st_widget_paint_background (ST_WIDGET (actor), node);
st_widget_paint_background (ST_WIDGET (actor), node, paint_context);
}
static void

View file

@ -143,8 +143,9 @@ StThemeNode * st_widget_get_theme_node (StWidget *widg
StThemeNode * st_widget_peek_theme_node (StWidget *widget);
GList * st_widget_get_focus_chain (StWidget *widget);
void st_widget_paint_background (StWidget *widget,
ClutterPaintNode *node);
void st_widget_paint_background (StWidget *widget,
ClutterPaintNode *node,
ClutterPaintContext *paint_context);
/* debug methods */
char *st_describe_actor (ClutterActor *actor);