background-content: Render background slices relative to actor box
The current code assumes that the actor will always have the same size and position of the background texture, but part of the implicit contract of being a ClutterContent is being able to render itself at any given actor, at any given size. For example, if the current code is given an actor with 0x0+100+100 as geometry, and no clipped region, it'll render not the whole background, but the 0x0+100+100 rectangle of the background. In practice, the actor geometry acts like a "clip mask" over the background texture, due to the assumption that the actor will always have the same size of the monitor. Make the calculation of the texture slices relative to the actor box. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1302
This commit is contained in:
parent
6d75b4fc53
commit
ca0156e9a7
@ -444,21 +444,26 @@ set_glsl_parameters (MetaBackgroundContent *self,
|
||||
static void
|
||||
paint_clipped_rectangle (MetaBackgroundContent *self,
|
||||
ClutterPaintNode *node,
|
||||
ClutterActorBox *actor_box,
|
||||
cairo_rectangle_int_t *rect)
|
||||
{
|
||||
g_autoptr (ClutterPaintNode) pipeline_node = NULL;
|
||||
float h_scale, v_scale;
|
||||
float x1, y1, x2, y2;
|
||||
float tx1, ty1, tx2, ty2;
|
||||
|
||||
h_scale = self->texture_area.width / clutter_actor_box_get_width (actor_box);
|
||||
v_scale = self->texture_area.height / clutter_actor_box_get_height (actor_box);
|
||||
|
||||
x1 = rect->x;
|
||||
y1 = rect->y;
|
||||
x2 = rect->x + rect->width;
|
||||
y2 = rect->y + rect->height;
|
||||
|
||||
tx1 = (x1 - self->texture_area.x) / (float)self->texture_area.width;
|
||||
ty1 = (y1 - self->texture_area.y) / (float)self->texture_area.height;
|
||||
tx2 = (x2 - self->texture_area.x) / (float)self->texture_area.width;
|
||||
ty2 = (y2 - self->texture_area.y) / (float)self->texture_area.height;
|
||||
tx1 = (x1 * h_scale - self->texture_area.x) / (float)self->texture_area.width;
|
||||
ty1 = (y1 * v_scale - self->texture_area.y) / (float)self->texture_area.height;
|
||||
tx2 = (x2 * h_scale - self->texture_area.x) / (float)self->texture_area.width;
|
||||
ty2 = (y2 * v_scale - self->texture_area.y) / (float)self->texture_area.height;
|
||||
|
||||
pipeline_node = clutter_pipeline_node_new (self->pipeline);
|
||||
clutter_paint_node_set_name (pipeline_node, "MetaBackgroundContent (Slice)");
|
||||
@ -530,14 +535,14 @@ meta_background_content_paint_content (ClutterContent *content,
|
||||
{
|
||||
cairo_rectangle_int_t rect;
|
||||
cairo_region_get_rectangle (region, i, &rect);
|
||||
paint_clipped_rectangle (self, node, &rect);
|
||||
paint_clipped_rectangle (self, node, &actor_box, &rect);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cairo_rectangle_int_t rect;
|
||||
cairo_region_get_extents (region, &rect);
|
||||
paint_clipped_rectangle (self, node, &rect);
|
||||
paint_clipped_rectangle (self, node, &actor_box, &rect);
|
||||
}
|
||||
|
||||
cairo_region_destroy (region);
|
||||
|
Loading…
Reference in New Issue
Block a user