sparse_strips: Introduce Padding type and streamline clip handling#1751
Open
LaurenzV wants to merge 2 commits into
Open
sparse_strips: Introduce Padding type and streamline clip handling#1751LaurenzV wants to merge 2 commits into
Padding type and streamline clip handling#1751LaurenzV wants to merge 2 commits into
Conversation
laurenz-canva
force-pushed
the
laurenz/vello_hybrid_shift_part4
branch
from
July 16, 2026 09:09
bf1abca to
542c495
Compare
laurenz-canva
force-pushed
the
laurenz/vello_hybrid_shift_part4
branch
from
July 16, 2026 09:13
542c495 to
334e626
Compare
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.
This is part 4 in the prep commit series, based on top of #1746.
The first commit introduces a new
PaddingU16type. On current main, we use kurboRectto represent the padding that is derived from a filter. For example, a Rect of (-2, -2, 2, 2,) represents an outward padding of 2 into each direction. This makes somewhat sense, however, we use that same idea to represent a padding usingRectU16. I think in the latter case, it doesn't make that much sense anymore. A RectU16 with dimensions (2, 2, 2, 2) represents the same idea as forRect. But in reality, this is simply a zero-sized rectangle. It doesn't make a lot of sense to useRectU16to represent the idea of a filter padding. Therefore, this commit adds an explicit padding type so that the semantics are clearer. Methods likeintersectandunionthat exist onRectU16don't really make much sense if the rectangle represents a padding, like it currently can.I think using
Rectin the first place is also questionable, but at least left/top padding is represented as negative coordinates, so it makes a bit more sense. This change is necessary because the follow-up commit changes how zero-sized rectangles are handled, but for example for offset filters, it would be valid to have a padding in only one direction, while all other sides are 0.The second commit introduces some changes to how we handle layer clips. To put it briefly, due to the fact that strips always have a fixed height of
Tile::HEIGHTand a width with a multiple ofTile::WIDTH, we often need to ensure that bounding boxes are snapped to tile coordinates. Previously, this was done in various places at different times, so very inconsistently. For Vello CPU, we basically only needed this for filter layers, but for Vello Hybrid we will need to make sure that this is also the case for normal layers.RectU16::INVERTEDis now only used as an internal accumulator to represent "no bounding box yet". However, when returning it to the user we always return an empty rectangle instead. This way, we don't have to special case this everywhere.RectU16::intersectis changed such that it cannot produce negative rectangles anymore, also aligning with the kurbo implementation.Drawable::bboxmust return tile-aligned bounding boxes.snap_to_tile_coorindatespreserved empty bboxes.As a consequence, vello_cpu (and in the future vello_hybrid) do not need to do any snapping anymore. All of this is taken care of at the recorder level. There's some more optimizations we should do in the future to prevent zero-sized nodes from being emitted in the first place, but this change by itself is already large enough that I'm going to leave this as a TODO!
I've tested the combination of all 4 PRs against my PDF suite, and didn't see any regressions!
PR train
vello_cputovello_common#1744 — Move some code fromvello_cputovello_commonvello_common#1745 — Add more new/refactored code intovello_commonPaddingtype and streamline clip handling #1751 — IntroducePaddingand streamline clip handling 👈