Skip to content

Excessive sampling of linear gradients in PDF #7365

@saecki

Description

@saecki

After rebasing my test-suite branch, I noticed some PDF tests getting noticable slower. I pinpointed it to this PR: #7326

This specific test now takes up twice the amount of time:

--- gradient-math-misc ---
// Test miscellaneous
#show math.equation: set text(fill: gradient.linear(..color.map.rainbow))
#show math.equation: box

$ hat(x) = bar x bar = vec(x, y, z) = tilde(x) = dot(x) $
$ x prime = vec(1, 2, delim: "[") $
$ sum_(i in NN) 1 + i $
$ attach(
  Pi, t: alpha, b: beta,
  tl: 1, tr: 2+3, bl: 4+5, br: 6,
) $

The gradient code in typst-pdf generates 31 samples between every stop of a gradient. Since the rainbow gradient already has a lot of stops, this seems to be the culprit. Maybe we can choose the number of samples based on the distance of the stops and or distance of the hue instead? In the rainbow case I think it would be fine to basically omit any extra sampled stops.

Metadata

Metadata

Assignees

No one assigned

    Labels

    pdfRelated to PDF export or PDF embedding.perfRelated to performance and optimization.regressionSomething that did work before stopped working.urgentShould be fixed before the next release.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions