2019-12-14 21:06:12 +00:00
|
|
|
uniform mat4 u_projection;
|
|
|
|
uniform mat4 u_modelview;
|
2019-12-17 14:55:24 +00:00
|
|
|
uniform float u_alpha;
|
2019-12-14 21:06:12 +00:00
|
|
|
|
2020-01-20 10:21:52 +00:00
|
|
|
#if defined(GSK_GLES) || defined(GSK_LEGACY)
|
2019-12-14 21:06:12 +00:00
|
|
|
attribute vec2 aPosition;
|
|
|
|
attribute vec2 aUv;
|
2019-12-17 11:19:37 +00:00
|
|
|
_OUT_ vec2 vUv;
|
2019-12-14 21:06:12 +00:00
|
|
|
#else
|
2019-12-17 11:19:37 +00:00
|
|
|
_IN_ vec2 aPosition;
|
|
|
|
_IN_ vec2 aUv;
|
|
|
|
_OUT_ vec2 vUv;
|
2019-12-14 21:06:12 +00:00
|
|
|
#endif
|
2020-01-19 19:08:23 +00:00
|
|
|
|
|
|
|
// amount is: top, right, bottom, left
|
2020-09-18 09:35:29 +00:00
|
|
|
GskRoundedRect
|
|
|
|
gsk_rounded_rect_shrink (GskRoundedRect r, vec4 amount)
|
2020-01-19 19:08:23 +00:00
|
|
|
{
|
|
|
|
vec4 new_bounds = r.bounds + vec4(1.0,1.0,-1.0,-1.0) * amount.wxyz;
|
|
|
|
vec4 new_corner_points1 = r.corner_points1;
|
|
|
|
vec4 new_corner_points2 = r.corner_points2;
|
|
|
|
|
|
|
|
if (r.corner_points1.xy == r.bounds.xy) new_corner_points1.xy = new_bounds.xy;
|
|
|
|
if (r.corner_points1.zw == r.bounds.zy) new_corner_points1.zw = new_bounds.zy;
|
|
|
|
if (r.corner_points2.xy == r.bounds.zw) new_corner_points2.xy = new_bounds.zw;
|
|
|
|
if (r.corner_points2.zw == r.bounds.xw) new_corner_points2.zw = new_bounds.xw;
|
|
|
|
|
2020-09-18 09:35:29 +00:00
|
|
|
return GskRoundedRect (new_bounds, new_corner_points1, new_corner_points2);
|
2020-01-19 19:08:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-09-18 09:35:29 +00:00
|
|
|
gsk_rounded_rect_offset(inout GskRoundedRect r, vec2 offset)
|
2020-01-19 19:08:23 +00:00
|
|
|
{
|
|
|
|
r.bounds.xy += offset;
|
|
|
|
r.bounds.zw += offset;
|
|
|
|
r.corner_points1.xy += offset;
|
|
|
|
r.corner_points1.zw += offset;
|
|
|
|
r.corner_points2.xy += offset;
|
|
|
|
r.corner_points2.zw += offset;
|
|
|
|
}
|
|
|
|
|
2020-09-18 09:35:29 +00:00
|
|
|
void gsk_rounded_rect_transform(inout GskRoundedRect r, mat4 mat)
|
2020-01-19 19:08:23 +00:00
|
|
|
{
|
|
|
|
r.bounds.xy = (mat * vec4(r.bounds.xy, 0.0, 1.0)).xy;
|
|
|
|
r.bounds.zw = (mat * vec4(r.bounds.zw, 0.0, 1.0)).xy;
|
|
|
|
|
|
|
|
r.corner_points1.xy = (mat * vec4(r.corner_points1.xy, 0.0, 1.0)).xy;
|
|
|
|
r.corner_points1.zw = (mat * vec4(r.corner_points1.zw, 0.0, 1.0)).xy;
|
|
|
|
|
|
|
|
r.corner_points2.xy = (mat * vec4(r.corner_points2.xy, 0.0, 1.0)).xy;
|
|
|
|
r.corner_points2.zw = (mat * vec4(r.corner_points2.zw, 0.0, 1.0)).xy;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(GSK_LEGACY)
|
|
|
|
// Can't have out or inout array parameters...
|
2020-09-18 09:35:29 +00:00
|
|
|
#define gsk_rounded_rect_encode(r, uni) uni[0] = r.bounds; uni[1] = r.corner_points1; uni[2] = r.corner_points2;
|
2020-01-19 19:08:23 +00:00
|
|
|
#else
|
2020-09-18 09:35:29 +00:00
|
|
|
void gsk_rounded_rect_encode(GskRoundedRect r, out _GSK_ROUNDED_RECT_UNIFORM_ out_r)
|
2020-01-19 19:08:23 +00:00
|
|
|
{
|
|
|
|
#if defined(GSK_GLES)
|
|
|
|
out_r[0] = r.bounds;
|
|
|
|
out_r[1] = r.corner_points1;
|
|
|
|
out_r[2] = r.corner_points2;
|
|
|
|
#else
|
|
|
|
out_r = r;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|