Skip to content
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

Always close fill paths, fix #68 #73

Merged
merged 1 commit into from
Mar 16, 2021

Conversation

ishitatsuyuki
Copy link
Collaborator

@ishitatsuyuki ishitatsuyuki commented Mar 16, 2021

rendering

There are still a few minor glitches visible (even after applying #72), so we should revisit them at a later time. For now, I think this is enough for closing the issue. The glitches are primarily around the edge of the crossing-like structures.

Close #68
Close #74

@eliasnaur
Copy link
Collaborator

Please do leave #68 open, updating the screenshot, or open a new issue so we don't forget.

@ishitatsuyuki
Copy link
Collaborator Author

I opened #74.

Copy link
Contributor

@raphlinus raphlinus left a comment

Choose a reason for hiding this comment

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

This will certainly fix the svg examples, but a better place to fix it would be in render_ctx in the piet backend, as the implicit closepath is implemented by the other piet backends. I'm ok merging this and having an issue to fix it there, if you'd prefer to get a fix in quickly.

@ishitatsuyuki
Copy link
Collaborator Author

ishitatsuyuki commented Mar 16, 2021

You're right, I was concerned as there was no method to mutably close a Shape, but I now see that this could be implemented efficiently within encode_path. I'll push the alternative tomorrow today.

@ishitatsuyuki
Copy link
Collaborator Author

ishitatsuyuki commented Mar 16, 2021

I just pushed the alternative. Edit: rushed a commit message change as well.

@ishitatsuyuki ishitatsuyuki changed the title Always close fill paths in the SVG parser, fix #68 Always close fill paths, fix #68 Mar 16, 2021
@@ -303,6 +303,14 @@ impl PietGpuRenderContext {
}

fn encode_path(&mut self, path: impl Iterator<Item = PathEl>, is_fill: bool) {
if is_fill {
self.encode_path_inner(path.chain(std::iter::once(PathEl::ClosePath)), is_fill)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is also not quite right (and makes me realize a similar issue in the original version) - if there are multiple open subpaths, each one needs an implicit close, not just at the end. Sorry for not communicating this earlier!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! Working on this.

@ishitatsuyuki
Copy link
Collaborator Author

I went with a somewhat weird iterator trick so that it's allocation-free. Hope it's fine.

Apparently the remaining cases of glitches are also fixed with the updated logic. I'll put close #74 in the PR description.

image

Copy link
Contributor

@raphlinus raphlinus left a comment

Choose a reason for hiding this comment

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

Thanks, that looks like a proper fix! I've invited to to commit access to the repo, so hopefully you should be able to merge now.

@ishitatsuyuki ishitatsuyuki merged commit 3557df2 into linebender:master Mar 16, 2021
@ishitatsuyuki ishitatsuyuki deleted the close-path branch March 16, 2021 16:24
@raphlinus
Copy link
Contributor

Sweet, I'm glad my desk-checking caught the additional artifacts without having to investigate. Thanks for iterating til we got it right. I was a bit surprised by the iterator trick, but it seems reasonable to me, especially as it doesn't allocate. (I probably would have done it using lower level logic, the way I would write it in C, but this looks clean and likely just as efficient)

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.

Minor glitches with reschart Garbled output with reschart
3 participants