)]}'
{
  "commit": "030cc6285dad56fdfbab50afd3e62f1ef498dfda",
  "tree": "25e4f6be47d5d20102c824acc9c33a39f0d218ab",
  "parents": [
    "abca8cb1a4f14912bed26fe619014582214803de"
  ],
  "author": {
    "name": "Behdad Esfahbod",
    "email": "behdad@behdad.org",
    "time": "Fri Nov 20 16:49:05 2026 -0600"
  },
  "committer": {
    "name": "Behdad Esfahbod",
    "email": "behdad@behdad.org",
    "time": "Fri Nov 20 17:23:09 2026 -0600"
  },
  "message": "[vector] Paint linear and radial gradients that repeat in PDF\n\nPDF shadings do not repeat.  A linear or radial gradient whose color\nline repeats or reflects was written as a shading over the color line\nalone, with nothing painted on either side of it.\n\nPaint it a period of the color line at a time, for the periods that\nreach what is painted, with the color line backwards in every other\none if it reflects.  What is painted is known from the bounds of the\nopen clips, which are kept for sizing sweep gradients: the periods are\nthose whose lines, or circles, touch the bounds.  No more than 256 are\nwritten, those nearest the color line itself.\n\nOne shading over a function that repeats the color line would be less\nto write, and is what cairo writes.  Viewers do badly with it.\npdfium and MuPDF resolve the function of a shading in 256 steps\nwhatever it holds, so every period makes all of them coarser.  And\npoppler splits a shading for as long as the colors at the two ends of\na piece differ, which they do not when a whole number of periods lie\nbetween them, as when the periods fit the clip: it paints that piece\nin one color.  It does so with cairo\u0027s own output.\n\nHow the periods are written is what it took for the viewers tried to\nagree with hb-raster:\n\n- The periods of a linear gradient are one shading, painted at one\n  place after another.  Each written with rounded numbers of its own,\n  they are not quite parallel, and MuPDF left holes between them.\n- Each period goes a little into the next, which is painted over it:\n  viewers decide pixel by pixel which side of the line between two\n  shadings a pixel is on.\n- Under a transform that rotates, the periods of a linear gradient\n  are painted in the space of the root.  Ghostscript gets the length\n  of an axial shading wrong under such a transform, depending on how\n  much of it the clip lets through, and a period is seldom seen whole.\n- Circles inside one another make rings, painted from the outside in\n  and each with its hole filled: MuPDF leaves holes between rings\n  that merely meet.  They are written growing, the color line\n  backwards if need be: poppler drops a radial shading that shrinks\n  and is extended at one end only.\n- The periods of a radial gradient are painted on top of each other,\n  so they are painted in a group, and the group once: under a clip\n  each would add to its antialiased edge.  So are periods that are\n  not opaque, their alphas in a soft mask.\n\nThe documentation no longer says that these are not supported.\n\nTesting: of the mapped glyphs of the COLR test fonts, 106 have a\ndifferent PDF, in five fonts.  19 of them had the pixels of hb-raster\nbefore, in each of pdfium, MuPDF, poppler\u0027s cairo backend and\nGhostscript.  All 106 do now, but for six in pdfium: the two glyphs\nof a cone that repeats, in three fonts, where hb-raster paints the\ncone\u0027s mirror image as well until #6845.\n\nReplaying the same paint calls on hb-raster and hb-vector for 300\nrandom scenes of clipped and transformed linear gradients and rings\nthat repeat or reflect, the pixels are the same in 300 with MuPDF and\nwith poppler\u0027s cairo backend, 299 with its Splash backend, and 298\nwith pdfium and with Ghostscript.  With one shading over a repeating\nfunction they were in 291 with pdfium, and poppler painted flat what\na whole number of periods filled.  With cones as well, and #6845 for\nhb-raster, they are the same in 300 with Ghostscript, 299 with MuPDF\nand 292 with pdfium and with Splash.  poppler\u0027s cairo backend is at\n165: it paints cones that shrink in one color, repeating or not.\n\nThe search for the circles that touch the bounds agrees with brute\nforce on 30000 random cases.\n\nA new test checks which periods are written and how, and fails\nwithout the change; six glyphs are added as an expected output.  It\nand the vector fuzzer are clean under ASan and UBSan, the test under\nMSan, and the fuzzer ran three minutes with failing allocations.\nFull test suite passes.\n\nCo-Authored-By: Claude Fable 5.2 \u003cnoreply@anthropic.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "82085bccd872a190ece85666d336968703f5d67e",
      "old_mode": 33188,
      "old_path": "src/hb-vector-paint-pdf.cc",
      "new_id": "058214e05884930d6f966f56d9e6b5e32ac7b57d",
      "new_mode": 33188,
      "new_path": "src/hb-vector-paint-pdf.cc"
    },
    {
      "type": "modify",
      "old_id": "6245df75c7ca69cad724b905a73772ebaef7f66d",
      "old_mode": 33188,
      "old_path": "src/hb-vector-paint.hh",
      "new_id": "00e7230d8561922f7d76521ffe14bb42902ef7df",
      "new_mode": 33188,
      "new_path": "src/hb-vector-paint.hh"
    },
    {
      "type": "modify",
      "old_id": "fdb0b359105e35fbfb6eeb1f4ed0ca503b785745",
      "old_mode": 33188,
      "old_path": "src/hb-vector.cc",
      "new_id": "4e5a3ef81d6409b49c812b1b385ff7871c1d5596",
      "new_mode": 33188,
      "new_path": "src/hb-vector.cc"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "2a131676165274df29116e71cb1e9e356d2b84d2",
      "new_mode": 33188,
      "new_path": "test/vector/data/expected/basic/colrv1-extend-repeat-reflect.pdf"
    },
    {
      "type": "modify",
      "old_id": "d1413b146db2be91a3d47b34cdb4d550bed60f65",
      "old_mode": 33188,
      "old_path": "test/vector/data/tests/basic.tests",
      "new_id": "4d33f130b2494f47f85d5b855234eb2ab823758e",
      "new_mode": 33188,
      "new_path": "test/vector/data/tests/basic.tests"
    },
    {
      "type": "modify",
      "old_id": "0770eb6406c8aa5bc66478f8be5ae10654dfc5c7",
      "old_mode": 33188,
      "old_path": "test/vector/meson.build",
      "new_id": "bb9cd8032cad76e994cfc08c61c519348b9cd171",
      "new_mode": 33188,
      "new_path": "test/vector/meson.build"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "67fa4fb7d7d4dea815343e906223176ac9dfdb8c",
      "new_mode": 33188,
      "new_path": "test/vector/test-vector-pdf-repeat.c"
    }
  ]
}
