vello_hybrid: Support extend modes for external texture rects - #1813
Merged
Conversation
laurenz-canva
force-pushed
the
laurenz/texture_rect
branch
from
August 12, 2026 12:28
2d81dd9 to
8d8312d
Compare
grebmeg
approved these changes
Aug 12, 2026
Comment on lines
+19
to
+22
| pub source_region: RectU16, | ||
|
|
||
| /// Destination rectangle in local scene coordinates. | ||
| pub destination_rect: Rect, |
Collaborator
There was a problem hiding this comment.
Could we rename these to source_rect and destination_rect for consistency, since both values are rectangles? src_rect and dst_rect would also be concise.
Collaborator
Author
There was a problem hiding this comment.
Ended up doing dest instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on #1812.
Context
The main reason for opening this PR is that currently, the external texture rect API has no way of supporting other extend modes. This PR proposes tweaking the existing API for drawing external texture rects such that this use case can be accommodated.
Implementation
It took me a while to figure out what the best way of implementing this is. Ultimately, I arrived at the conclusion that we should change the existing
draw_texture_rectsAPI to instead have a singledraw_texture_rectAPI. I presume the original motivation for having the ability to submit multiple texture rectangles at once is performance. However, if you look at the actual implementation, the bulk of the work happens inside of the loop that iterates over each rectangles. Only very little work is lifted outside of the loop, so I don’t see any performance benefit in having a batched method for this. On the other hand, by making the API only take a single texture rect, we can make it more consistent with how other methods work and more easily add support for the missing features. For example, theScene::paint_transformfield now actually serves a purpose for external textures.In order to get what we need, I also changed the API to taking two different rectangles: A source and a destination rectangle. The source rectangle defines what the area is we want to sample, and the destination (as well as path/paint transform) how it’s mapped into the actual scene. Any pixel that would fall outside of the source region but still be visible in the destination region is sampled according to the extend mode.
This PR was done with assistance of GPT 5.6 Sol.
Also CC @tomcur since he designed the original API.