Commit 57e354c2 authored by Matthias Clasen's avatar Matthias Clasen
Browse files

glsl: Make rounded rect clipping cheaper

Add early acceptance checks for non-corner cases.
parent 5d305695
Pipeline #263876 passed with stages
in 37 minutes and 39 seconds
......@@ -50,16 +50,24 @@ gsk_rounded_rect_coverage (GskRoundedRect r, vec2 p)
p.x >= r.bounds.z || p.y >= r.bounds.w)
return 0.0;
vec2 rad_tl = r.corner_points1.xy - r.bounds.xy;
vec2 rad_tr = r.corner_points1.zw - r.bounds.zy;
vec2 rad_br = r.corner_points2.xy - r.bounds.zw;
vec2 rad_bl = r.corner_points2.zw - r.bounds.xw;
vec2 ref_tl = r.corner_points1.xy;
vec2 ref_tr = r.corner_points1.zw;
vec2 ref_br = r.corner_points2.xy;
vec2 ref_bl = r.corner_points2.zw;
if (p.x >= ref_tl.x && p.x >= ref_bl.x &&
p.x <= ref_tr.x && p.x <= ref_br.x)
return 1.0;
if (p.y >= ref_tl.y && p.y >= ref_tr.y &&
p.y <= ref_bl.y && p.y <= ref_br.y)
return 1.0;
vec2 rad_tl = r.corner_points1.xy - r.bounds.xy;
vec2 rad_tr = r.corner_points1.zw - r.bounds.zy;
vec2 rad_br = r.corner_points2.xy - r.bounds.zw;
vec2 rad_bl = r.corner_points2.zw - r.bounds.xw;
float d_tl = gsk_ellipsis_coverage(p, ref_tl, rad_tl);
float d_tr = gsk_ellipsis_coverage(p, ref_tr, rad_tr);
float d_br = gsk_ellipsis_coverage(p, ref_br, rad_br);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment