2019-12-14 21:06:12 +00:00
|
|
|
// VERTEX_SHADER:
|
2019-12-17 15:06:28 +00:00
|
|
|
uniform vec4 u_color;
|
2020-01-19 19:08:23 +00:00
|
|
|
uniform vec4 u_widths;
|
|
|
|
uniform vec4[3] u_outline_rect;
|
2019-12-17 15:06:28 +00:00
|
|
|
|
|
|
|
_OUT_ vec4 final_color;
|
2020-09-18 09:35:29 +00:00
|
|
|
_OUT_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
|
|
|
|
_OUT_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
|
2019-12-14 21:06:12 +00:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
|
2019-12-17 15:06:28 +00:00
|
|
|
|
2020-09-18 09:35:29 +00:00
|
|
|
final_color = gsk_premultiply(u_color) * u_alpha;
|
2020-01-19 19:08:23 +00:00
|
|
|
|
2020-09-18 09:35:29 +00:00
|
|
|
GskRoundedRect outside = gsk_create_rect(u_outline_rect);
|
|
|
|
GskRoundedRect inside = gsk_rounded_rect_shrink (outside, u_widths);
|
2020-01-19 19:08:23 +00:00
|
|
|
|
2020-09-18 09:35:29 +00:00
|
|
|
gsk_rounded_rect_transform(outside, u_modelview);
|
|
|
|
gsk_rounded_rect_transform(inside, u_modelview);
|
2020-01-19 19:08:23 +00:00
|
|
|
|
2020-09-18 09:35:29 +00:00
|
|
|
gsk_rounded_rect_encode(outside, transformed_outside_outline);
|
|
|
|
gsk_rounded_rect_encode(inside, transformed_inside_outline);
|
2019-12-14 21:06:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// FRAGMENT_SHADER:
|
2019-12-16 05:16:26 +00:00
|
|
|
uniform vec4[3] u_outline_rect;
|
2018-03-15 16:27:19 +00:00
|
|
|
|
2019-12-17 15:06:28 +00:00
|
|
|
_IN_ vec4 final_color;
|
2020-09-18 09:35:29 +00:00
|
|
|
_IN_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
|
|
|
|
_IN_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
|
2019-12-17 15:06:28 +00:00
|
|
|
|
2017-12-01 10:55:10 +00:00
|
|
|
void main() {
|
2020-09-18 09:35:29 +00:00
|
|
|
vec2 frag = gsk_get_frag_coord();
|
2017-12-01 10:55:10 +00:00
|
|
|
|
2020-09-18 09:35:29 +00:00
|
|
|
float alpha = clamp(gsk_rounded_rect_coverage(gsk_decode_rect(transformed_outside_outline), frag) -
|
|
|
|
gsk_rounded_rect_coverage(gsk_decode_rect(transformed_inside_outline), frag),
|
2020-01-19 19:08:23 +00:00
|
|
|
0.0, 1.0);
|
2017-12-01 10:55:10 +00:00
|
|
|
|
2020-09-18 09:35:29 +00:00
|
|
|
gskSetOutputColor(final_color * alpha);
|
2017-12-01 10:55:10 +00:00
|
|
|
}
|