7 Commits
Author SHA1 Message Date
Calixte Denizet b29564d94c Fix function-based shading scaled by the CTM
A function-based shading was sampled at one step per user-space unit of
its own matrix, so a unit domain scaled up by the CTM, a form matrix or
a pattern matrix was drawn with a single cell.
The sampling grid is now computed from the transform the shading is
painted with, and the generated meshes are cached per grid size.

The setFillColorN/setStrokeColorN cases are merged so the base transform
is only passed in one place.

The software mesh rasterizer now clamps triangles to the canvas, so
pixels on the right edge no longer wrap into the next row.

It fixes #22616.
2026-11-28 16:36:15 +01:00
Calixte Denizet 74999b6415 Make PDF function and color space parsing asynchronous
Prepare callers for loading calculator functions on demand. Keep
function streams reusable and reject circular stitching functions.
2026-11-20 17:28:27 +01:00
calixteman c67fe1529d Check shading function dimensions and bound sampled interpolation
Expose function input/output counts and reject incompatible shading and
stitching functions.

Reuse interpolation buffers instead of allocating cube vertices per call.
Skip axes at integer sample coordinates, fixing invalid sample accesses
for Size=1 axes.

For functions with more than eight inputs, use simplex interpolation.
It reads at most m + 1 sample-table entries per output for m inputs,
instead of up to 2^m. It can produce different values from multilinear
interpolation.
2026-10-03 16:22:43 +02:00
Tim van der Meij 7ba4589a47 Enable the unicorn/prefer-short-arrow-method linting rule
This makes the code a bit more compact, and consistent with newer code
where we already use this. For more information about the rule, see
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-short-arrow-method.md.
2026-09-22 20:16:39 +02:00
calixteman 526b69651f Convert shading colors in bulk, rather than one at a time
The axial/radial ramps and the function-based lattice converted one color per
call, i.e. one Wasm round-trip each for `IccColorSpace` (hence for
`/DeviceCMYK`). Add `ColorSpace.getRgbItems`, overridden by `IccColorSpace` and
`AlternateCS`, to convert a whole batch at once.
2026-07-26 17:02:22 +02:00
Calixte Denizet a2c57ee69e Use the gpu for drawing meshes only when it has more than 16 triangles (bug 2030745)
And in order to slightly improve performances, move the figure creation in the worker.
2026-04-13 22:23:03 +02:00
Calixte Denizet 3727b7095a Add support for function-based shadings (bug 1254066)
It fixes #5046.
We just generate a mesh for the pattern rectangle where the color of each vertex is computed from the function.
Since the mesh is generated in the worker we don't really take into account the current transform when it's drawn.
That being said, there are maybe some possible improvements in using directly the gpu for the shading creation
which could then take into account the current transform, but it could only work with ps function we can convert
ino wgsl language and simple enough color spaces (gray and rgb).
2026-03-31 20:46:01 +02:00