[mutter/gbsneto/background-content: 6/6] background-content: Render background slices relative to actor box



commit d4accdaa56ab13164d67de55016dc3a91926096a
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Jun 9 13:52:14 2020 -0300

    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

 src/compositor/meta-background-content.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/compositor/meta-background-content.c b/src/compositor/meta-background-content.c
index 1690140ce8..13c9e85c51 100644
--- a/src/compositor/meta-background-content.c
+++ b/src/compositor/meta-background-content.c
@@ -444,12 +444,17 @@ 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;
@@ -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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]