-
Notifications
You must be signed in to change notification settings - Fork 218
vello_common: Store strip data in tile units #1379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
LaurenzV
wants to merge
3
commits into
main
Choose a base branch
from
laurenz/strip_coords
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -285,6 +285,8 @@ impl Wide<MODE_HYBRID> { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| // TODO: Ensure that all of the calculations below are compatible with i16. | ||||||
|
|
||||||
|
Comment on lines
+288
to
+289
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||||||
| impl<const MODE: u8> Wide<MODE> { | ||||||
| /// Create a new container for wide tiles. | ||||||
| fn new_internal(width: u16, height: u16) -> Self { | ||||||
|
|
@@ -438,18 +440,18 @@ impl<const MODE: u8> Wide<MODE> { | |||||
| let strip = &strip_buf[i]; | ||||||
|
|
||||||
| debug_assert!( | ||||||
| strip.y < self.height, | ||||||
| strip.y() < self.height, | ||||||
| "Strips below the viewport should have been culled prior to this stage." | ||||||
| ); | ||||||
|
|
||||||
| // Don't render strips that are outside the viewport width | ||||||
| if strip.x >= self.width { | ||||||
| if strip.x() >= self.width { | ||||||
| continue; | ||||||
| } | ||||||
|
|
||||||
| let next_strip = &strip_buf[i + 1]; | ||||||
| let x0 = strip.x; | ||||||
| let strip_y = strip.strip_y(); | ||||||
| let x0 = strip.x(); | ||||||
| let strip_y = strip.tile_y(); | ||||||
|
|
||||||
| // Skip strips outside the current clip bounding box | ||||||
| if strip_y < bbox.y0() { | ||||||
|
|
@@ -507,10 +509,10 @@ impl<const MODE: u8> Wide<MODE> { | |||||
|
|
||||||
| // If region should be filled and both strips are on the same row, | ||||||
| // generate fill commands for the region between them | ||||||
| if active_fill && strip_y == next_strip.strip_y() { | ||||||
| if active_fill && strip_y == next_strip.tile_y() { | ||||||
| // Clamp the fill to the clip bounding box | ||||||
| x = x1.max(bbox.x0() * WideTile::WIDTH); | ||||||
| let x2 = next_strip.x.min( | ||||||
| let x2 = next_strip.x().min( | ||||||
| self.width | ||||||
| .checked_next_multiple_of(WideTile::WIDTH) | ||||||
| .unwrap_or(u16::MAX), | ||||||
|
|
@@ -808,18 +810,18 @@ impl<const MODE: u8> Wide<MODE> { | |||||
| WideTilesBbox::empty() | ||||||
| } else { | ||||||
| // Calculate the y range from first to last strip in wide tile coordinates | ||||||
| let wtile_y0 = strips[0].strip_y(); | ||||||
| let wtile_y1 = strips[n_strips.saturating_sub(1)].strip_y() + 1; | ||||||
| let wtile_y0 = strips[0].tile_y(); | ||||||
| let wtile_y1 = strips[n_strips.saturating_sub(1)].tile_y() + 1; | ||||||
|
|
||||||
| // Calculate the x range by examining all strips in wide tile coordinates | ||||||
| let mut wtile_x0 = strips[0].x / WideTile::WIDTH; | ||||||
| let mut wtile_x0 = strips[0].x() / WideTile::WIDTH; | ||||||
| let mut wtile_x1 = wtile_x0; | ||||||
| for i in 0..n_strips.saturating_sub(1) { | ||||||
| let strip = &strips[i]; | ||||||
| let next_strip = &strips[i + 1]; | ||||||
| let width = | ||||||
| ((next_strip.alpha_idx() - strip.alpha_idx()) / u32::from(Tile::HEIGHT)) as u16; | ||||||
| let x = strip.x; | ||||||
| let x = strip.x(); | ||||||
| wtile_x0 = wtile_x0.min(x / WideTile::WIDTH); | ||||||
| wtile_x1 = wtile_x1.max((x + width).div_ceil(WideTile::WIDTH)); | ||||||
| } | ||||||
|
|
@@ -848,7 +850,7 @@ impl<const MODE: u8> Wide<MODE> { | |||||
| // Process strips to determine the clipping state for each wide tile | ||||||
| for i in 0..n_strips.saturating_sub(1) { | ||||||
| let strip = &strips[i]; | ||||||
| let strip_y = strip.strip_y(); | ||||||
| let strip_y = strip.tile_y(); | ||||||
|
|
||||||
| // Skip strips before current wide tile row | ||||||
| if strip_y < cur_wtile_y { | ||||||
|
|
@@ -875,7 +877,7 @@ impl<const MODE: u8> Wide<MODE> { | |||||
| } | ||||||
|
|
||||||
| // Process wide tiles to the left of this strip in the same row | ||||||
| let x = strip.x; | ||||||
| let x = strip.x(); | ||||||
| let wtile_x_clamped = (x / WideTile::WIDTH).min(clip_bbox.x1()); | ||||||
| if cur_wtile_x < wtile_x_clamped { | ||||||
| // If winding is zero or doesn't match fill rule, these wide tiles are outside the path | ||||||
|
|
@@ -978,7 +980,7 @@ impl<const MODE: u8> Wide<MODE> { | |||||
| // Process each strip to determine the clipping state for each tile | ||||||
| for i in 0..n_strips.saturating_sub(1) { | ||||||
| let strip = &strips[i]; | ||||||
| let strip_y = strip.strip_y(); | ||||||
| let strip_y = strip.tile_y(); | ||||||
|
|
||||||
| // Skip strips before current tile row | ||||||
| if strip_y < cur_wtile_y { | ||||||
|
|
@@ -1010,7 +1012,7 @@ impl<const MODE: u8> Wide<MODE> { | |||||
| } | ||||||
|
|
||||||
| // Process tiles to the left of this strip in the same row | ||||||
| let x0 = strip.x; | ||||||
| let x0 = strip.x(); | ||||||
| let wtile_x_clamped = (x0 / WideTile::WIDTH).min(clip_bbox.x1()); | ||||||
| if cur_wtile_x < wtile_x_clamped { | ||||||
| // Handle any pending clip pop from previous iteration | ||||||
|
|
@@ -1082,12 +1084,12 @@ impl<const MODE: u8> Wide<MODE> { | |||||
|
|
||||||
| // Handle fill regions between strips based on fill rule | ||||||
| let is_inside = next_strip.fill_gap(); | ||||||
| if is_inside && strip_y == next_strip.strip_y() { | ||||||
| if is_inside && strip_y == next_strip.tile_y() { | ||||||
| if cur_wtile_x >= clip_bbox.x1() { | ||||||
| continue; | ||||||
| } | ||||||
|
|
||||||
| let x2 = next_strip.x; | ||||||
| let x2 = next_strip.x(); | ||||||
| let clipped_x2 = x2.min((cur_wtile_x + 1) * WideTile::WIDTH); | ||||||
| let width = clipped_x2.saturating_sub(clipped_x1); | ||||||
|
|
||||||
|
|
||||||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the suggestion here? 🤔 Or is it buggy on my screen?

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or it's just an empty line 😅