Revision control

++ static const char *hb_gpu_vertex_msl =
++ "/*\n"
++ " * Copyright (C) 2026 Behdad Esfahbod\n"
++ " *\n"
++ " * This is part of HarfBuzz, a text shaping library.\n"
++ " *\n"
++ " * Permission is hereby granted, without written agreement and without\n"
++ " * license or royalty fees, to use, copy, modify, and distribute this\n"
++ " * software and its documentation for any purpose, provided that the\n"
++ " * above copyright notice and the following two paragraphs appear in\n"
++ " * all copies of this software.\n"
++ " *\n"
++ " * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\n"
++ " * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\n"
++ " * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\n"
++ " * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\n"
++ " * DAMAGE.\n"
++ " *\n"
++ " * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\n"
++ " * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\n"
++ " * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS\n"
++ " * ON AN \"AS IS\" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\n"
++ " * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\n"
++ " */\n"
++ "\n"
++ "\n"
++ "/* Requires Metal Shading Language 2.0. */\n"
++ "\n"
++ "\n"
++ "/* Dilate a glyph vertex by half a pixel on screen.\n"
++ " *\n"
++ " * position: object-space vertex position (modified in place)\n"
++ " * texcoord: em-space sample coordinates (modified in place)\n"
++ " * normal: object-space outward normal at this vertex\n"
++ " * jac: inverse of the 2x2 linear part of the em-to-object transform,\n"
++ " * stored row-major as (j00, j01, j10, j11). Maps object-space\n"
++ " * displacements back to em-space for texcoord adjustment.\n"
++ " * For simple scaling with y-flip (the common case):\n"
++ " * em-to-object = [[s, 0], [0, -s]]\n"
++ " * jac = (1/s, 0, 0, -1/s)\n"
++ " * m: model-view-projection matrix\n"
++ " * viewport: viewport size in pixels\n"
++ " */\n"
++ "void hb_gpu_dilate (thread float2& position, thread float2& texcoord,\n"
++ " float2 normal, float4 jac,\n"
++ " float4x4 m, float2 viewport)\n"
++ "{\n"
++ " float2 n = normalize (normal);\n"
++ "\n"
++ " float4 clipPos = m * float4 (position, 0.0, 1.0);\n"
++ " float4 clipN = m * float4 (n, 0.0, 0.0);\n"
++ "\n"
++ " float s = clipPos.w;\n"
++ " float t = clipN.w;\n"
++ "\n"
++ " float u = (s * clipN.x - t * clipPos.x) * viewport.x;\n"
++ " float v = (s * clipN.y - t * clipPos.y) * viewport.y;\n"
++ "\n"
++ " float s2 = s * s;\n"
++ " float st = s * t;\n"
++ " float uv = u * u + v * v;\n"
++ "\n"
++ " float denom = uv - st * st;\n"
++ " float d = abs (denom) > 1.0 / 16777216.0\n"
++ " ? s2 * (st + sqrt (uv)) / denom\n"
++ " : 0.0;\n"
++ "\n"
++ " float2 dPos = d * normal;\n"
++ " position += dPos;\n"
++ " texcoord += float2 (dot (dPos, jac.xy), dot (dPos, jac.zw));\n"
++ "}\n"
++ ;