mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-18 07:34:54 +00:00
Merge branch 'gbsneto/snapshot' into 'main'
Draft: Snapshot See merge request GNOME/gnome-shell!3372
This commit is contained in:
commit
ad853a7fe9
16 changed files with 3183 additions and 0 deletions
|
|
@ -571,6 +571,34 @@ class RedBorderEffect extends Clutter.Effect {
|
|||
box.set_size(width, alloc.get_height() - width * 2);
|
||||
pipelineNode.add_rectangle(box);
|
||||
}
|
||||
|
||||
vfunc_snapshot(snapshot, flags) {
|
||||
super.vfunc_snapshot(snapshot, flags);
|
||||
|
||||
const color = new Cogl.Color();
|
||||
color.init_from_4f(1.0, 0.0, 0.0, 196.0 / 255.0);
|
||||
|
||||
snapshot.push_color(color);
|
||||
|
||||
// clockwise order
|
||||
box.set_origin(0, 0);
|
||||
box.set_size(alloc.get_width(), width);
|
||||
snapshot.add_rectangle(box);
|
||||
|
||||
box.set_origin(alloc.get_width() - width, width);
|
||||
box.set_size(width, alloc.get_height() - width);
|
||||
snapshot.add_rectangle(box);
|
||||
|
||||
box.set_origin(0, alloc.get_height() - width);
|
||||
box.set_size(alloc.get_width() - width, width);
|
||||
snapshot.add_rectangle(box);
|
||||
|
||||
box.set_origin(0, width);
|
||||
box.set_size(width, alloc.get_height() - width * 2);
|
||||
snapshot.add_rectangle(box);
|
||||
|
||||
snapshot.pop();
|
||||
}
|
||||
});
|
||||
|
||||
export const Inspector = GObject.registerClass({
|
||||
|
|
|
|||
|
|
@ -75,6 +75,17 @@ const MouseSpriteContent = GObject.registerClass({
|
|||
textureNode.add_rectangle(actor.get_content_box());
|
||||
}
|
||||
|
||||
vfunc_snapshot(actor, snapshot) {
|
||||
if (!this._texture)
|
||||
return;
|
||||
|
||||
let [minFilter, magFilter] = actor.get_content_scaling_filters();
|
||||
|
||||
snapshot.push_texture_full(this._texture, null, minFilter, magFilter);
|
||||
snapshot.add_rectangle(actor.get_content_box());
|
||||
snapshot.pop();
|
||||
}
|
||||
|
||||
get texture() {
|
||||
return this._texture;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,6 +157,10 @@ class UserWidgetLabel extends St.Widget {
|
|||
this._currentLabel.paint(paintContext);
|
||||
}
|
||||
|
||||
vfunc_snapshot(snapshot) {
|
||||
this.snapshot_child(this._currentLabel, snapshot);
|
||||
}
|
||||
|
||||
_updateUser() {
|
||||
if (this._user.is_loaded) {
|
||||
this._realNameLabel.text = this._user.get_real_name();
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ st_sources = [
|
|||
'st-theme-context.c',
|
||||
'st-theme-node.c',
|
||||
'st-theme-node-drawing.c',
|
||||
'st-theme-node-snapshot.c',
|
||||
'st-theme-node-transition.c',
|
||||
'st-viewport.c',
|
||||
'st-widget.c'
|
||||
|
|
|
|||
|
|
@ -870,6 +870,57 @@ st_entry_paint (ClutterActor *actor,
|
|||
parent_class->paint (actor, paint_context);
|
||||
}
|
||||
|
||||
static void
|
||||
st_entry_snapshot (ClutterActor *actor,
|
||||
ClutterSnapshot *snapshot)
|
||||
{
|
||||
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
|
||||
ClutterActorClass *parent_class;
|
||||
|
||||
st_widget_snapshot_background (ST_WIDGET (actor), snapshot);
|
||||
|
||||
if (priv->shadow_spec)
|
||||
{
|
||||
ClutterActorBox allocation;
|
||||
float width, height;
|
||||
|
||||
clutter_actor_get_allocation_box (priv->entry, &allocation);
|
||||
clutter_actor_box_get_size (&allocation, &width, &height);
|
||||
|
||||
if (priv->text_shadow_material == NULL ||
|
||||
width != priv->shadow_width ||
|
||||
height != priv->shadow_height)
|
||||
{
|
||||
CoglPipeline *material;
|
||||
|
||||
g_clear_object (&priv->text_shadow_material);
|
||||
|
||||
material = _st_create_shadow_pipeline_from_actor (priv->shadow_spec,
|
||||
priv->entry);
|
||||
|
||||
priv->shadow_width = width;
|
||||
priv->shadow_height = height;
|
||||
priv->text_shadow_material = material;
|
||||
}
|
||||
|
||||
if (priv->text_shadow_material != NULL)
|
||||
{
|
||||
_st_snapshot_shadow_with_opacity (priv->shadow_spec,
|
||||
snapshot,
|
||||
priv->text_shadow_material,
|
||||
&allocation,
|
||||
clutter_actor_get_paint_opacity (priv->entry));
|
||||
}
|
||||
}
|
||||
|
||||
/* Since we paint the background ourselves, chain to the parent class
|
||||
* of StWidget, to avoid painting it twice.
|
||||
* This is needed as we still want to paint children.
|
||||
*/
|
||||
parent_class = g_type_class_peek_parent (st_entry_parent_class);
|
||||
parent_class->snapshot (actor, snapshot);
|
||||
}
|
||||
|
||||
static void
|
||||
st_entry_unmap (ClutterActor *actor)
|
||||
{
|
||||
|
|
@ -902,6 +953,7 @@ st_entry_class_init (StEntryClass *klass)
|
|||
actor_class->get_preferred_height = st_entry_get_preferred_height;
|
||||
actor_class->allocate = st_entry_allocate;
|
||||
actor_class->paint = st_entry_paint;
|
||||
actor_class->snapshot = st_entry_snapshot;
|
||||
actor_class->unmap = st_entry_unmap;
|
||||
actor_class->get_paint_volume = st_entry_get_paint_volume;
|
||||
|
||||
|
|
|
|||
|
|
@ -230,6 +230,36 @@ st_icon_paint (ClutterActor *actor,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
st_icon_snapshot (ClutterActor *actor,
|
||||
ClutterSnapshot *snapshot)
|
||||
{
|
||||
StIcon *icon = ST_ICON (actor);
|
||||
StIconPrivate *priv = icon->priv;
|
||||
|
||||
st_widget_snapshot_background (ST_WIDGET (actor), snapshot);
|
||||
|
||||
if (priv->icon_texture)
|
||||
{
|
||||
st_icon_update_shadow_pipeline (icon);
|
||||
|
||||
if (priv->shadow_pipeline)
|
||||
{
|
||||
ClutterActorBox allocation;
|
||||
|
||||
clutter_actor_get_allocation_box (priv->icon_texture, &allocation);
|
||||
|
||||
_st_snapshot_shadow_with_opacity (priv->shadow_spec,
|
||||
snapshot,
|
||||
priv->shadow_pipeline,
|
||||
&allocation,
|
||||
clutter_actor_get_paint_opacity (priv->icon_texture));
|
||||
}
|
||||
|
||||
clutter_actor_snapshot_child (actor, priv->icon_texture, snapshot);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
st_icon_style_changed (StWidget *widget)
|
||||
{
|
||||
|
|
@ -301,6 +331,7 @@ st_icon_class_init (StIconClass *klass)
|
|||
object_class->dispose = st_icon_dispose;
|
||||
|
||||
actor_class->paint = st_icon_paint;
|
||||
actor_class->snapshot = st_icon_snapshot;
|
||||
|
||||
widget_class->style_changed = st_icon_style_changed;
|
||||
actor_class->resource_scale_changed = st_icon_resource_scale_changed;
|
||||
|
|
|
|||
|
|
@ -256,6 +256,54 @@ st_label_paint (ClutterActor *actor,
|
|||
clutter_actor_paint (priv->label, paint_context);
|
||||
}
|
||||
|
||||
static void
|
||||
st_label_snapshot (ClutterActor *actor,
|
||||
ClutterSnapshot *snapshot)
|
||||
{
|
||||
StLabelPrivate *priv = ST_LABEL (actor)->priv;
|
||||
|
||||
st_widget_snapshot_background (ST_WIDGET (actor), snapshot);
|
||||
|
||||
if (priv->shadow_spec)
|
||||
{
|
||||
ClutterActorBox allocation;
|
||||
float width, height;
|
||||
float resource_scale;
|
||||
|
||||
clutter_actor_get_allocation_box (priv->label, &allocation);
|
||||
clutter_actor_box_get_size (&allocation, &width, &height);
|
||||
|
||||
resource_scale = clutter_actor_get_resource_scale (priv->label);
|
||||
|
||||
width *= resource_scale;
|
||||
height *= resource_scale;
|
||||
|
||||
if (priv->text_shadow_pipeline == NULL ||
|
||||
width != priv->shadow_width ||
|
||||
height != priv->shadow_height)
|
||||
{
|
||||
g_clear_object (&priv->text_shadow_pipeline);
|
||||
|
||||
priv->shadow_width = width;
|
||||
priv->shadow_height = height;
|
||||
priv->text_shadow_pipeline =
|
||||
_st_create_shadow_pipeline_from_actor (priv->shadow_spec,
|
||||
priv->label);
|
||||
}
|
||||
|
||||
if (priv->text_shadow_pipeline != NULL)
|
||||
{
|
||||
_st_snapshot_shadow_with_opacity (priv->shadow_spec,
|
||||
snapshot,
|
||||
priv->text_shadow_pipeline,
|
||||
&allocation,
|
||||
clutter_actor_get_paint_opacity (priv->label));
|
||||
}
|
||||
}
|
||||
|
||||
clutter_actor_snapshot_child (actor, priv->label, snapshot);
|
||||
}
|
||||
|
||||
static void
|
||||
st_label_resource_scale_changed (ClutterActor *actor)
|
||||
{
|
||||
|
|
@ -279,6 +327,7 @@ st_label_class_init (StLabelClass *klass)
|
|||
gobject_class->dispose = st_label_dispose;
|
||||
|
||||
actor_class->paint = st_label_paint;
|
||||
actor_class->snapshot = st_label_snapshot;
|
||||
actor_class->allocate = st_label_allocate;
|
||||
actor_class->get_preferred_width = st_label_get_preferred_width;
|
||||
actor_class->get_preferred_height = st_label_get_preferred_height;
|
||||
|
|
|
|||
|
|
@ -799,3 +799,31 @@ _st_paint_shadow_with_opacity (StShadow *shadow_spec,
|
|||
shadow_box.x1, shadow_box.y1,
|
||||
shadow_box.x2, shadow_box.y2);
|
||||
}
|
||||
|
||||
void
|
||||
_st_snapshot_shadow_with_opacity (StShadow *shadow_spec,
|
||||
ClutterSnapshot *snapshot,
|
||||
CoglPipeline *shadow_pipeline,
|
||||
ClutterActorBox *box,
|
||||
guint8 paint_opacity)
|
||||
{
|
||||
ClutterActorBox shadow_box;
|
||||
CoglColor color;
|
||||
|
||||
g_return_if_fail (shadow_spec != NULL);
|
||||
g_return_if_fail (shadow_pipeline != NULL);
|
||||
|
||||
st_shadow_get_box (shadow_spec, box, &shadow_box);
|
||||
|
||||
cogl_color_init_from_4f (&color,
|
||||
shadow_spec->color.red / 255.0 * paint_opacity / 255.0,
|
||||
shadow_spec->color.green / 255.0 * paint_opacity / 255.0,
|
||||
shadow_spec->color.blue / 255.0 * paint_opacity / 255.0,
|
||||
shadow_spec->color.alpha / 255.0 * paint_opacity / 255.0);
|
||||
cogl_color_premultiply (&color);
|
||||
cogl_pipeline_set_layer_combine_constant (shadow_pipeline, 0, &color);
|
||||
|
||||
clutter_snapshot_push_pipeline (snapshot, shadow_pipeline);
|
||||
clutter_snapshot_add_rectangle (snapshot, &shadow_box);
|
||||
clutter_snapshot_pop (snapshot);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,4 +72,10 @@ void _st_paint_shadow_with_opacity (StShadow *shadow_spec,
|
|||
ClutterActorBox *box,
|
||||
guint8 paint_opacity);
|
||||
|
||||
void _st_snapshot_shadow_with_opacity (StShadow *shadow_spec,
|
||||
ClutterSnapshot *snapshot,
|
||||
CoglPipeline *shadow_pipeline,
|
||||
ClutterActorBox *box,
|
||||
guint8 paint_opacity);
|
||||
|
||||
#endif /* __ST_PRIVATE_H__ */
|
||||
|
|
|
|||
2800
src/st/st-theme-node-snapshot.c
Normal file
2800
src/st/st-theme-node-snapshot.c
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -395,6 +395,57 @@ st_theme_node_transition_paint (StThemeNodeTransition *transition,
|
|||
tex_coords, 8);
|
||||
}
|
||||
|
||||
void
|
||||
st_theme_node_transition_snapshot (StThemeNodeTransition *transition,
|
||||
ClutterSnapshot *snapshot,
|
||||
ClutterActorBox *allocation,
|
||||
guint8 paint_opacity,
|
||||
float resource_scale)
|
||||
{
|
||||
StThemeNodeTransitionPrivate *priv = transition->priv;
|
||||
|
||||
CoglColor constant, pipeline_color;
|
||||
float tex_coords[] = {
|
||||
0.0, 0.0, 1.0, 1.0,
|
||||
0.0, 0.0, 1.0, 1.0,
|
||||
};
|
||||
|
||||
g_return_if_fail (ST_IS_THEME_NODE (priv->old_theme_node));
|
||||
g_return_if_fail (ST_IS_THEME_NODE (priv->new_theme_node));
|
||||
|
||||
if (!clutter_actor_box_equal (allocation, &priv->last_allocation))
|
||||
priv->needs_setup = TRUE;
|
||||
|
||||
if (priv->needs_setup)
|
||||
{
|
||||
priv->last_allocation = *allocation;
|
||||
|
||||
calculate_offscreen_box (transition, allocation);
|
||||
priv->needs_setup = clutter_actor_box_get_area (&priv->offscreen_box) == 0 ||
|
||||
!setup_framebuffers (transition, allocation,
|
||||
resource_scale);
|
||||
|
||||
if (priv->needs_setup) /* setting up framebuffers failed */
|
||||
return;
|
||||
}
|
||||
|
||||
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_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);
|
||||
|
||||
clutter_snapshot_push_pipeline (snapshot, priv->material);
|
||||
clutter_snapshot_add_multitexture_rectangle (snapshot,
|
||||
&priv->offscreen_box,
|
||||
tex_coords, 8);
|
||||
clutter_snapshot_pop (snapshot);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
st_theme_node_transition_dispose (GObject *object)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -47,6 +47,12 @@ void st_theme_node_transition_paint (StThemeNodeTransition *transition,
|
|||
guint8 paint_opacity,
|
||||
float resource_scale);
|
||||
|
||||
void st_theme_node_transition_snapshot (StThemeNodeTransition *transition,
|
||||
ClutterSnapshot *snapshot,
|
||||
ClutterActorBox *allocation,
|
||||
guint8 paint_opacity,
|
||||
float resource_scale);
|
||||
|
||||
void st_theme_node_transition_get_paint_box (StThemeNodeTransition *transition,
|
||||
const ClutterActorBox *allocation,
|
||||
ClutterActorBox *paint_box);
|
||||
|
|
|
|||
|
|
@ -347,6 +347,16 @@ void st_theme_node_paint (StThemeNode *node,
|
|||
guint8 paint_opacity,
|
||||
float resource_scale);
|
||||
|
||||
/**
|
||||
* st_theme_node_snapshot: (skip)
|
||||
*/
|
||||
void st_theme_node_snapshot (StThemeNode *node,
|
||||
StThemeNodePaintState *state,
|
||||
ClutterSnapshot *snapshot,
|
||||
const ClutterActorBox *box,
|
||||
guint8 paint_opacity,
|
||||
float resource_scale);
|
||||
|
||||
void st_theme_node_invalidate_background_image (StThemeNode *node);
|
||||
void st_theme_node_invalidate_border_image (StThemeNode *node);
|
||||
|
||||
|
|
|
|||
|
|
@ -455,6 +455,56 @@ st_viewport_paint (ClutterActor *actor,
|
|||
cogl_framebuffer_pop_clip (fb);
|
||||
}
|
||||
|
||||
static void
|
||||
st_viewport_snapshot (ClutterActor *actor,
|
||||
ClutterSnapshot *snapshot)
|
||||
{
|
||||
StViewport *viewport = ST_VIEWPORT (actor);
|
||||
StViewportPrivate *priv = st_viewport_get_instance_private (viewport);
|
||||
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
|
||||
int x, y;
|
||||
ClutterActorBox allocation_box;
|
||||
ClutterActorBox content_box;
|
||||
ClutterActor *child;
|
||||
|
||||
get_border_paint_offsets (viewport, &x, &y);
|
||||
if (x != 0 || y != 0)
|
||||
clutter_snapshot_push_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
|
||||
|
||||
st_widget_snapshot_background (ST_WIDGET (actor), snapshot);
|
||||
|
||||
if (x != 0 || y != 0)
|
||||
clutter_snapshot_pop (snapshot);
|
||||
|
||||
if (clutter_actor_get_n_children (actor) == 0)
|
||||
return;
|
||||
|
||||
clutter_actor_get_allocation_box (actor, &allocation_box);
|
||||
st_theme_node_get_content_box (theme_node, &allocation_box, &content_box);
|
||||
|
||||
content_box.x1 += x;
|
||||
content_box.y1 += y;
|
||||
content_box.x2 += x;
|
||||
content_box.y2 += y;
|
||||
|
||||
/* The content area forms the viewport into the scrolled contents, while
|
||||
* the borders and background stay in place; after drawing the borders and
|
||||
* background, we clip to the content area */
|
||||
if (priv->clip_to_view && (priv->hadjustment || priv->vadjustment))
|
||||
{
|
||||
clutter_snapshot_push_clip (snapshot);
|
||||
clutter_snapshot_add_rectangle (snapshot, &content_box);
|
||||
}
|
||||
|
||||
for (child = clutter_actor_get_first_child (actor);
|
||||
child != NULL;
|
||||
child = clutter_actor_get_next_sibling (child))
|
||||
clutter_actor_snapshot_child (actor, child, snapshot);
|
||||
|
||||
if (priv->clip_to_view && (priv->hadjustment || priv->vadjustment))
|
||||
clutter_snapshot_pop (snapshot);
|
||||
}
|
||||
|
||||
static void
|
||||
st_viewport_pick (ClutterActor *actor,
|
||||
ClutterPickContext *pick_context)
|
||||
|
|
@ -565,6 +615,7 @@ st_viewport_class_init (StViewportClass *klass)
|
|||
actor_class->apply_transform = st_viewport_apply_transform;
|
||||
|
||||
actor_class->paint = st_viewport_paint;
|
||||
actor_class->snapshot = st_viewport_snapshot;
|
||||
actor_class->get_paint_volume = st_viewport_get_paint_volume;
|
||||
actor_class->pick = st_viewport_pick;
|
||||
|
||||
|
|
|
|||
|
|
@ -452,6 +452,48 @@ st_widget_paint_background (StWidget *widget,
|
|||
resource_scale);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_widget_snapshot_background:
|
||||
* @widget: The #StWidget
|
||||
* @snapshot: a #ClutterSnapshot
|
||||
*
|
||||
* Snapshots the background of the widget. This is meant to be called
|
||||
* by subclasses of StWidget that need to paint the background without
|
||||
* painting children.
|
||||
*/
|
||||
void
|
||||
st_widget_snapshot_background (StWidget *widget,
|
||||
ClutterSnapshot *snapshot)
|
||||
{
|
||||
StWidgetPrivate *priv = st_widget_get_instance_private (widget);
|
||||
StThemeNode *theme_node;
|
||||
ClutterActorBox allocation;
|
||||
float resource_scale;
|
||||
guint8 opacity;
|
||||
|
||||
resource_scale = clutter_actor_get_resource_scale (CLUTTER_ACTOR (widget));
|
||||
|
||||
theme_node = st_widget_get_theme_node (widget);
|
||||
|
||||
clutter_actor_get_allocation_box (CLUTTER_ACTOR (widget), &allocation);
|
||||
|
||||
opacity = clutter_actor_get_paint_opacity (CLUTTER_ACTOR (widget));
|
||||
|
||||
if (priv->transition_animation)
|
||||
st_theme_node_transition_snapshot (priv->transition_animation,
|
||||
snapshot,
|
||||
&allocation,
|
||||
opacity,
|
||||
resource_scale);
|
||||
else
|
||||
st_theme_node_snapshot (theme_node,
|
||||
current_paint_state (widget),
|
||||
snapshot,
|
||||
&allocation,
|
||||
opacity,
|
||||
resource_scale);
|
||||
}
|
||||
|
||||
static void
|
||||
st_widget_paint (ClutterActor *actor,
|
||||
ClutterPaintContext *paint_context)
|
||||
|
|
@ -462,6 +504,16 @@ st_widget_paint (ClutterActor *actor,
|
|||
CLUTTER_ACTOR_CLASS (st_widget_parent_class)->paint (actor, paint_context);
|
||||
}
|
||||
|
||||
static void
|
||||
st_widget_snapshot (ClutterActor *actor,
|
||||
ClutterSnapshot *snapshot)
|
||||
{
|
||||
st_widget_snapshot_background (ST_WIDGET (actor), snapshot);
|
||||
|
||||
/* Chain up so we paint children. */
|
||||
CLUTTER_ACTOR_CLASS (st_widget_parent_class)->snapshot (actor, snapshot);
|
||||
}
|
||||
|
||||
static void
|
||||
st_widget_parent_set (ClutterActor *widget,
|
||||
ClutterActor *old_parent)
|
||||
|
|
@ -893,6 +945,7 @@ st_widget_class_init (StWidgetClass *klass)
|
|||
actor_class->get_preferred_height = st_widget_get_preferred_height;
|
||||
actor_class->allocate = st_widget_allocate;
|
||||
actor_class->paint = st_widget_paint;
|
||||
actor_class->snapshot = st_widget_snapshot;
|
||||
actor_class->get_paint_volume = st_widget_get_paint_volume;
|
||||
actor_class->parent_set = st_widget_parent_set;
|
||||
actor_class->map = st_widget_map;
|
||||
|
|
|
|||
|
|
@ -145,6 +145,8 @@ StThemeNode * st_widget_peek_theme_node (StWidget *widg
|
|||
GList * st_widget_get_focus_chain (StWidget *widget);
|
||||
void st_widget_paint_background (StWidget *widget,
|
||||
ClutterPaintContext *paint_context);
|
||||
void st_widget_snapshot_background (StWidget *widget,
|
||||
ClutterSnapshot *snapshot);
|
||||
|
||||
/* debug methods */
|
||||
char *st_describe_actor (ClutterActor *actor);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue