Skip to content

Refactor Brush to use generic types for image and gradient data#134

Merged
sagudev merged 2 commits intolinebender:mainfrom
sagudev:generic-brush
Sep 29, 2025
Merged

Refactor Brush to use generic types for image and gradient data#134
sagudev merged 2 commits intolinebender:mainfrom
sagudev:generic-brush

Conversation

@sagudev
Copy link
Copy Markdown
Contributor

@sagudev sagudev commented Sep 15, 2025

As discussed in #133 (review) we can also generalize Brush over image data and gradient. This makes BrushRef<'a> = Brush<ImageBrushRef<'a>, &'a Gradient> which allows to share more From impls, most notably various color implementations (even owned version can now support conversion from &color because color is copy anyway).

@sagudev sagudev force-pushed the generic-brush branch 2 times, most recently from 1eba552 to 203b17e Compare September 16, 2025 14:46
@sagudev sagudev marked this pull request as ready for review September 16, 2025 14:50
@sagudev
Copy link
Copy Markdown
Contributor Author

sagudev commented Sep 25, 2025

@LaurenzV
Copy link
Copy Markdown
Contributor

@DJMcNab Is this intended to land before 0.5.0?

@DJMcNab
Copy link
Copy Markdown
Member

DJMcNab commented Sep 26, 2025

We talked about this in office hours yesterday. My thinking is to not do so - this is something which it only makes sense to think about once we get Vello API working, probably.

If this would be useful for Vello CPU, it could land though. I don't think it has a huge cost.

@sagudev
Copy link
Copy Markdown
Contributor Author

sagudev commented Sep 26, 2025

This change is backwards compatible, so it can be done in patch release.

If this would be useful for Vello CPU, it could land though. I don't think it has a huge cost.

My idea is to start passing this type down to vello_cpu renderer (instead of own type) and deal with opacity, BGRA and alpha on sampling, but we could always just continue to roll own sparse strips types (and extend them) like we do now.

@LaurenzV
Copy link
Copy Markdown
Contributor

LaurenzV commented Sep 27, 2025

Maybe I am missing something obvious, but how is it backwards-compatible? The PR introduces generic parameters to a public enum, which seems like a pretty breaking change to me, no?" 🤔

@sagudev
Copy link
Copy Markdown
Contributor Author

sagudev commented Sep 27, 2025

Maybe I am missing something obvious, but how is it backwards-compatible? The PR introduces generic parameters to a public enum, which seems like a pretty breaking change to me, no?" 🤔

Generic parameter have default values that are same as before, so they are backwards compatible AFAIK.

@LaurenzV
Copy link
Copy Markdown
Contributor

Ahh okay, fair enough, I missed that.

Copy link
Copy Markdown
Contributor

@LaurenzV LaurenzV left a comment

Choose a reason for hiding this comment

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

I mean to me, that seems reasonable, but I think it might be a good idea to get a draft PR in vello_cpu up working before we actually merge this, to make sure it works as intended.

@sagudev
Copy link
Copy Markdown
Contributor Author

sagudev commented Sep 28, 2025

Hm, I just rebased and docs are failing.

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Copy link
Copy Markdown
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

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

I think this now blocks #140, because I do suspect this is probably still breaking, but only in niche scenarios.
The changes look fine to me

I'm happy enough keeping this out of the changelog; it's not a functionality I particularly want to advertise, because it's a bit messy for our interstitial state.

f
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@nicoburns nicoburns left a comment

Choose a reason for hiding this comment

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

Ah, it hadn't occured to me that this would enable Brush to be used in sparse strips vello. This is now making sense to me.

@sagudev
Copy link
Copy Markdown
Contributor Author

sagudev commented Sep 29, 2025

Ah, it hadn't occured to me that this would enable Brush to be used in sparse strips vello. This is now making sense to me.

This is my main motivation.

Given that CI passes in linebender/vello#1253 and the amount of support for this I am going to land this (so we can unblock release).

@sagudev sagudev added this pull request to the merge queue Sep 29, 2025
Merged via the queue into linebender:main with commit ac2c789 Sep 29, 2025
15 checks passed
@sagudev sagudev deleted the generic-brush branch September 29, 2025 16:42
github-merge-queue Bot pushed a commit that referenced this pull request Sep 30, 2025
A simpler version of #124, to get in before v0.5.0 (which is currently
blocked on #134 anyway).
github-merge-queue Bot pushed a commit to linebender/vello that referenced this pull request Oct 2, 2025
demo for linebender/peniko#134

---------

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.

4 participants