-
-
Notifications
You must be signed in to change notification settings - Fork 170
gl_engine/tessellator: Improve stroke tessellation quality #3903
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
Conversation
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.
Pull Request Overview
This PR improves stroke tessellation quality in the GL engine by enhancing segment count calculations during the join process. The changes ensure that the transformation matrix is properly considered when computing tessellation segments, resulting in smoother and more accurate stroke rendering that more closely matches the WebGPU engine's output.
Key Changes:
- Updated tessellation methods (
lineTo,close,cap,join,round) to accept and use the transformation matrix parameter - Modified segment count calculation to apply the transformation matrix before computing segments
- Ensured consistent parameter passing throughout the stroke tessellation pipeline
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tvgGlTessellator.h | Updated method signatures to include Matrix parameter for improved tessellation calculations |
| tvgGlTessellator.cpp | Implemented Matrix parameter threading through tessellation methods and updated segment calculation logic |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
cd8d408 to
c8a9d03
Compare
|
@wenjieshen |
c8a9d03 to
e5e8077
Compare
|
@SergeyLebedkin |
hermet
left a comment
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.
@wenjieshen How about retain scale value from Stroker() constructor and access that member value from the round()? Logic will be much simple Thanks.
e5e8077 to
1033d8a
Compare
|
@hermet |
|
@SergeyLebedkin @hermet Thank you for your patience. I checked there is no regression occurring. I think this PR is ready. |
1033d8a to
cf36ea9
Compare
hermet
left a comment
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.
@wenjieshen last feedback thanks!
|
|
||
| // Fixme: just use bezier curve to calculate step count | ||
| auto count = Bezier(prev, curr, radius()).segments(); | ||
| auto count = (Bezier(prev, curr, radius()) * mScale).segments(); |
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.
"multiply" a point on a Bézier curve isn't in the standard sense; Please use this way:
Bezier(prev * mScale, curr * mScale, radius() * mScale).segment()
cf36ea9 to
29a4000
Compare
This patch partially addresses issue thorvg#3665 by improving stroke tessellation quality in the GL engine. The revised algorithm produces smoother and more accurate stroke rendering, aligning more closely with the WebGPU engine’s output. Implementation Details: Enhanced tessellation logic for more precise segment count calculation. Updated cubicTo() to pass the Transform matrix to round() for correct segment computation. Current Status: Resolves the main stroke quality issue from thorvg#3665. The odd-even fill issue described in thorvg#3668 will be addressed in a future update. Related Issues: Partially resolves: thorvg#3665 (GL/WG: poor stroke quality) Related: thorvg#3668 (Engines: excessive stroke width causes inconsistency)
8fdb98c to
900af9f
Compare
|
I ran the Lottie examples five times on each branch (tested on macOS):
Interestingly, this branch shows slightly higher FPS, which isn’t expected. |
This is explained by the fact that it is most likely that the reduction in the size of the Bézier curves is more common than the scale-up, which leads to a reduction in the number of points for tessellation |
Summary
This patch partially resolves issue #3665

by improving stroke tessellation quality in the GL engine.
The updated algorithm produces smoother and more accurate stroke rendering, achieving visual results closer to the WebGPU engine.
Changes
Improved segment count calculation in the tessellation join process.
Updated the member function
lineToandcloseto imitatecubicTologic, passing the Transform matrix as a parameter toroundto ensure proper segment computation.Current Status
Fixes the basic stroke quality problem described in #3665.
The odd–even rendering issue mentioned in #3668
remains and will be addressed in a future patch.
Related Issues
Partially resolves: #3665 (GL/WG: poor stroke quality)
Related: #3668 (Engines: excessive stroke width causes visual inconsistency)