Skip to content

Towards interpolating gradients in non-premultiplied space#1140

Closed
LaurenzV wants to merge 2 commits into
mainfrom
premul
Closed

Towards interpolating gradients in non-premultiplied space#1140
LaurenzV wants to merge 2 commits into
mainfrom
premul

Conversation

@LaurenzV
Copy link
Copy Markdown
Collaborator

This doesn't solve the issue for gradients with non-SRGB color space because the color crate will always provide a linear approximation in premultiplied space, but at least we can resolve the issue for SRGB color spaces, which seems like a good first step.

Fixes #1129.

ctx.fill_rect(&Rect::new(0.0, 0.0, 4.0, 4.0));
}

// See <https://github.com/linebender/vello/issues/1129>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better if this and the link in the comment above pointed to #1056 instead of #1129, since the latter was closed as “not planned”?

// TODO: The `color` crate will always interpolate in premultiplied space, while for Srgb
// we do it in unpremultiplied space since this is more desirable for most 2D rendering
// situations (see https://github.com/linebender/vello/issues/1129), so the results might
// look off until this is implemented in the `color` crate.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the issue in color crate related to what you mentioned? Can we link it here, even though it will hopefully be closed soon?


// See <https://github.com/linebender/vello/issues/1129>
#[vello_test]
fn gradient_with_last_stop_0_opacity(ctx: &mut impl Renderer) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you pull from main, you’ll see another test called gradient_color_alpha added in #1142

@LaurenzV
Copy link
Copy Markdown
Collaborator Author

@grebmeg ah sorry, I forgot about this, I am probably not going to merge this since it would be better to merge @sagudev proper implementation, so I think it doesn’t make sense to have this intermediate hack. But thanks for taking a look!

@LaurenzV LaurenzV closed this Aug 11, 2025
@DJMcNab DJMcNab deleted the premul branch August 11, 2025 12:40
github-merge-queue Bot pushed a commit that referenced this pull request Oct 4, 2025
…ha space (#1145)

Some SIMD stuff is from #1140

Depends on linebender/peniko#115

This currently includes only Vello CPU/Hybrid implementation, but I plan
to do classic Vello too.

Fixes #1056

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[vello_cpu]: Gradient in Blitz counter example renders as solid red/orange

2 participants