[mutter/gbsneto/content: 2/3] shaped-texture: Draw pipeline relative to alloc
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/content: 2/3] shaped-texture: Draw pipeline relative to alloc
- Date: Tue, 29 Jan 2019 23:48:16 +0000 (UTC)
commit a161102c73c6e2ab6e419c38eaf5aa63b9088d63
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 | 33 ++++++++++++++++++++++-----------
1 file changed, 22 insertions(+), 11 deletions(-)
---
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index 32d7eeee2..567d739e2 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -386,18 +386,29 @@ get_unblended_pipeline (MetaShapedTexture *stex,
}
static void
-paint_clipped_rectangle_node (ClutterPaintNode *root_node,
+paint_clipped_rectangle_node (MetaShapedTexture *stex,
+ ClutterPaintNode *root_node,
CoglPipeline *pipeline,
cairo_rectangle_int_t *rect,
ClutterActorBox *alloc)
{
g_autoptr(ClutterPaintNode) node = NULL;
+ float ratio_h, ratio_v;
+ float x1, y1, x2, y2;
float coords[8];
- coords[0] = rect->x / (alloc->x2 - alloc->x1);
- coords[1] = rect->y / (alloc->y2 - alloc->y1);
- coords[2] = (rect->x + rect->width) / (alloc->x2 - alloc->x1);
- coords[3] = (rect->y + rect->height) / (alloc->y2 - alloc->y1);
+ 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;
+
+ coords[0] = rect->x / (float) stex->dst_width;
+ coords[1] = rect->y / (float) stex->dst_height;
+ coords[2] = (rect->x + rect->width) / (float) stex->dst_width;
+ coords[3] = (rect->y + rect->height) / (float) stex->dst_height;
coords[4] = coords[0];
coords[5] = coords[1];
@@ -411,10 +422,10 @@ paint_clipped_rectangle_node (ClutterPaintNode *root_node,
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);
}
@@ -614,7 +625,7 @@ do_paint_content (MetaShapedTexture *stex,
{
cairo_rectangle_int_t rect;
cairo_region_get_rectangle (region, i, &rect);
- paint_clipped_rectangle_node (root_node, opaque_pipeline, &rect, alloc);
+ paint_clipped_rectangle_node (stex, root_node, opaque_pipeline, &rect, alloc);
}
}
@@ -667,7 +678,7 @@ do_paint_content (MetaShapedTexture *stex,
if (!gdk_rectangle_intersect (&tex_rect, &rect, &rect))
continue;
- paint_clipped_rectangle_node (root_node, blended_pipeline, &rect, alloc);
+ paint_clipped_rectangle_node (stex, root_node, blended_pipeline, &rect, alloc);
}
}
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]