[mutter/gbsneto/content: 12/14] shaped-texture: Draw pipeline relative to alloc



commit 33db454c62b1223747e9e6158b05a03eb7846ac6
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Dec 27 14:16:50 2018 -0200

    shaped-texture: Draw pipeline relative to alloc
    
    When an actor passes the allocation box, it is important to
    draw the contents of MetaShapedTexture relative to it.

 src/compositor/meta-shaped-texture.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index 144482623..18222bcff 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -413,10 +413,20 @@ paint_clipped_rectangle_node (MetaShapedTexture     *stex,
                               ClutterActorBox       *alloc)
 {
   g_autoptr (ClutterPaintNode) node = NULL;
+  float ratio_h, ratio_v;
+  float x1, y1, x2, y2;
   float coords[8];
   float alloc_width;
   float alloc_height;
 
+  ratio_h = clutter_actor_box_get_width (alloc) / (float) stex->dst_width;
+  ratio_v = clutter_actor_box_get_height (alloc) / (float) stex->dst_height;
+
+  x1 = alloc->x1 + rect->x * ratio_h;
+  y1 = alloc->y1 + rect->y * ratio_v;
+  x2 = alloc->x1 + (rect->x + rect->width) * ratio_h;
+  y2 = alloc->y1 + (rect->y + rect->height) * ratio_v;
+
   alloc_width = alloc->x2 - alloc->x1;
   alloc_height = alloc->y2 - alloc->y1;
 
@@ -471,10 +481,10 @@ paint_clipped_rectangle_node (MetaShapedTexture     *stex,
 
   clutter_paint_node_add_multitexture_rectangle (node,
                                                  &(ClutterActorBox) {
-                                                   .x1 = rect->x,
-                                                   .x2 = rect->x + rect->width,
-                                                   .y1 = rect->y,
-                                                   .y2 = rect->y + rect->height,
+                                                   .x1 = x1,
+                                                   .y1 = y1,
+                                                   .x2 = x2,
+                                                   .y2 = y2,
                                                  },
                                                  coords, 8);
 }


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