glyphy: remove glyphy debug code

We don't have a knob to turn this on, and it is
not really useful outside of glyphy itself, so
remove it.
This commit is contained in:
Matthias Clasen
2022-04-04 01:14:45 -04:00
parent 1854f4d21a
commit 1bedfe3dcd
2 changed files with 11 additions and 37 deletions

View File

@@ -99,5 +99,4 @@ GSK_GL_DEFINE_PROGRAM (glyphy,
GSK_GL_ADD_UNIFORM (2, GLYPHY_OUTLINE_THICKNESS, u_outline_thickness)
GSK_GL_ADD_UNIFORM (3, GLYPHY_OUTLINE, u_outline)
GSK_GL_ADD_UNIFORM (4, GLYPHY_BOLDNESS, u_boldness)
GSK_GL_ADD_UNIFORM (5, GLYPHY_DEBUG, u_debug)
GSK_GL_ADD_UNIFORM (6, GLYPHY_ATLAS_INFO, u_atlas_info))

View File

@@ -6,13 +6,12 @@ uniform float u_gamma_adjust;
uniform float u_outline_thickness;
uniform bool u_outline;
uniform float u_boldness;
uniform bool u_debug;
_IN_ vec4 v_glyph;
_IN_ vec4 final_color;
#define SQRT2_2 0.70710678118654757 /* 1 / sqrt(2.) */
#define SQRT2 1.4142135623730951
#define SQRT2 1.4142135623730951
#define SQRT2_INV 0.70710678118654757 /* 1 / sqrt(2.) */
struct glyph_info_t {
ivec2 nominal_size;
@@ -44,44 +43,20 @@ main()
/* isotropic antialiasing */
vec2 dpdx = dFdx (p);
vec2 dpdy = dFdy (p);
float m = length (vec2 (length (dpdx), length (dpdy))) * SQRT2_2;
float m = length (vec2 (length (dpdx), length (dpdy))) * SQRT2_INV;
float gsdist = glyphy_sdf (p, gi.nominal_size GLYPHY_DEMO_EXTRA_ARGS);
float sdist = gsdist / m * u_contrast;
if (!u_debug) {
sdist -= u_boldness * 10.;
if (u_outline)
sdist = abs (sdist) - u_outline_thickness * .5;
if (sdist > 1.)
discard;
float alpha = antialias (-sdist);
if (u_gamma_adjust != 1.)
alpha = pow (alpha, 1./u_gamma_adjust);
if (u_outline)
sdist = abs (sdist) - u_outline_thickness * .5;
gskSetOutputColor(final_color * alpha);
} else {
vec4 color = vec4 (0,0,0,0);
if (sdist > 1.)
discard;
// Color the inside of the glyph a light red
color += vec4 (.5,0,0,.5) * smoothstep (1., -1., sdist);
float alpha = antialias (-sdist);
if (u_gamma_adjust != 1.)
alpha = pow (alpha, 1./u_gamma_adjust);
float udist = abs (sdist);
float gudist = abs (gsdist);
// Color the outline red
color += vec4 (1,0,0,1) * smoothstep (2., 1., udist);
// Color the distance field in green
if (!glyphy_isinf (udist))
color += vec4(0,.4,0,.4 - (abs(gsdist) / max(float(gi.nominal_size.x), float(gi.nominal_size.y))) * 4.);
float pdist = glyphy_point_dist (p, gi.nominal_size GLYPHY_DEMO_EXTRA_ARGS);
// Color points green
color = mix (vec4 (0,1,0,.5), color, smoothstep (.05, .06, pdist));
glyphy_arc_list_t arc_list = glyphy_arc_list (p, gi.nominal_size GLYPHY_DEMO_EXTRA_ARGS);
// Color the number of endpoints per cell blue
color += vec4 (0,0,1,.1) * float(arc_list.num_endpoints) * 32./255.;
gskSetOutputColor(color);
}
gskSetOutputColor(final_color * alpha);
}