summaryrefslogtreecommitdiff
path: root/gsk/gskroundedrect.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2016-12-24 04:58:51 +0100
committerBenjamin Otte <otte@redhat.com>2016-12-24 06:19:16 +0100
commit81c487b8415fed4990b069b03245b2aa11f12ab7 (patch)
tree2ab48d9138ac457a6e1cc6e04c4cf55d568d9c6d /gsk/gskroundedrect.c
parent18b65a23789008a68c53e0430aa2dffadcc259f4 (diff)
downloadgtk+-81c487b8415fed4990b069b03245b2aa11f12ab7.tar.gz
vulkan: Fold clip into push constants
As a side effect, the clipping data is now available inside shaders. Not that any shader would use them yet, but they could!
Diffstat (limited to 'gsk/gskroundedrect.c')
-rw-r--r--gsk/gskroundedrect.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/gsk/gskroundedrect.c b/gsk/gskroundedrect.c
index 16ad85ef45..03f987e964 100644
--- a/gsk/gskroundedrect.c
+++ b/gsk/gskroundedrect.c
@@ -501,3 +501,33 @@ gsk_rounded_rect_path (const GskRoundedRect *self,
cairo_close_path (cr);
}
+/*
+ * Converts to the format we use in our shaders:
+ * vec4 rect;
+ * vec4 corner_widths;
+ * vec4 corner_heights;
+ * rect is (x, y, width, height), the corners are the same
+ * order as in the rounded rect.
+ *
+ * This is so that shaders can use just the first vec4 for
+ * rectilinear rects, the 2nd vec4 for circular rects and
+ * only look at the last vec4 if they have to.
+ */
+void
+gsk_rounded_rect_to_float (const GskRoundedRect *self,
+ float rect[12])
+{
+ guint i;
+
+ rect[0] = self->bounds.origin.x;
+ rect[1] = self->bounds.origin.y;
+ rect[2] = self->bounds.size.width;
+ rect[3] = self->bounds.size.height;
+
+ for (i = 0; i < 4; i++)
+ {
+ rect[4 + i] = self->corner[i].width;
+ rect[8 + i] = self->corner[i].height;
+ }
+}
+