[mutter/gbsneto/content: 3/5] 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: 3/5] shaped-texture: Draw pipeline relative to alloc
- Date: Fri, 15 Feb 2019 13:03:28 +0000 (UTC)
commit d767189ecb096dd987b907c9539ae2a5ed77c72d
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.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/409
src/compositor/meta-shaped-texture.c | 34 ++++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
---
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index 4cf6fc173..bc642b54a 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;
@@ -427,10 +437,10 @@ paint_clipped_rectangle_node (MetaShapedTexture *stex,
float src_width;
float src_height;
- src_x = stex->viewport_src_rect.origin.x / stex->scale;
- src_y = stex->viewport_src_rect.origin.y / stex->scale;
- src_width = stex->viewport_src_rect.size.width / stex->scale;
- src_height = stex->viewport_src_rect.size.height / stex->scale;
+ src_x = stex->viewport_src_rect.origin.x / ratio_h;
+ src_y = stex->viewport_src_rect.origin.y / ratio_v;
+ src_width = stex->viewport_src_rect.size.width;
+ src_height = stex->viewport_src_rect.size.height;
coords[0] = rect->x * src_width / alloc_width + src_x;
coords[1] = rect->y * src_height / alloc_height + src_y;
@@ -454,10 +464,10 @@ paint_clipped_rectangle_node (MetaShapedTexture *stex,
}
else
{
- coords[0] = rect->x / alloc_width;
- coords[1] = rect->y / alloc_height;
- coords[2] = (rect->x + rect->width) / alloc_width;
- coords[3] = (rect->y + rect->height) / alloc_height;
+ coords[0] = rect->x / alloc_width * ratio_h;
+ coords[1] = rect->y / alloc_height * ratio_v;
+ coords[2] = (rect->x + rect->width) / alloc_width * ratio_h;
+ coords[3] = (rect->y + rect->height) / alloc_height * ratio_v;
}
coords[4] = coords[0];
@@ -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]