+
Skip to content

common: share stroke dasher #3581

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

Closed

Conversation

SergeyLebedkin
Copy link
Member

@SergeyLebedkin SergeyLebedkin commented Jun 28, 2025

Move stroke dasher to the common code space to create an abillity to use it on the cross API renderers (wg and gl).
Stroke dasher is a path-to-path operation, same as path trim, so can be placed to the common space.

issue: #3557

@SergeyLebedkin SergeyLebedkin self-assigned this Jun 28, 2025
@SergeyLebedkin SergeyLebedkin added refactoring Code refactoring / Exceptional handles gl OpenGL/WebGL render backend labels Jun 28, 2025
@github-actions github-actions bot added the renderer Core rendering label Jun 28, 2025
@hermet
Copy link
Member

hermet commented Jun 28, 2025

tvgRender has been introduced as an interface similar to HAL or RHI, but This one is more of a helper function. In fact, a single function like bool genDashPath(const RenderPath& in, RenderPath& out); might be sufficient for this purpose. The question is: where would be the most appropriate place to include it...

@hermet
Copy link
Member

hermet commented Jun 28, 2025

Additionally, perhaps we can also replace the software ver. with this as well.

@SergeyLebedkin
Copy link
Member Author

tvgRender has been introduced as an interface similar to HAL or RHI, but This one is more of a helper function. In fact, a single function like bool genDashPath(const RenderPath& in, RenderPath& out); might be sufficient for this purpose. The question is: where would be the most appropriate place to include it...

thats a good point and good question.
we can hide inplementation in render.cpp file and make a function as a public interface like bool genDashPath(const RenderPath& in, RenderPath& out, ...);

@SergeyLebedkin
Copy link
Member Author

SergeyLebedkin commented Jun 28, 2025

Additionally, perhaps we can also replace the software ver. with this as well.

As I can see dashers for gl and sw is mostly similar. The difference is in output format.
gl version: path-to-path conversion (RenderPath to RenderPath)
sw version: path-to-outline conversion (RenderPath to SwOutline)wg
wg version (current): outline-to-outline conversion (WgVertexBuffer to WgVertexBuffer, will be get rided)

@hermet
Copy link
Member

hermet commented Jun 30, 2025

@SergeyLebedkin Please consider this interface:

bool RenderShape::strokeDash(RenderPath& out) const

@SergeyLebedkin
Copy link
Member Author

@SergeyLebedkin Please consider this interface:

bool RenderShape::strokeDash(RenderPath& out) const

whats do you mean consider? this dasher uses all settings for dashing

@hermet
Copy link
Member

hermet commented Jul 14, 2025

@SergeyLebedkin I suggest defining a common internal interface (strokeDash()) for the Dash Stroker. The RenderPath& out parameter could be used to return the dash path data.

MOve stroke dasher to the common code space to create an abillity to use it on the cross API renderers (wg and gl)
stroke dasher is a path-to-path operation, same as path trim, so can be placed to the common space
@SergeyLebedkin SergeyLebedkin force-pushed the common_share_stroke_dasher branch from e73e61c to 235ed47 Compare July 16, 2025 18:51
@SergeyLebedkin
Copy link
Member Author

OK. So now RenderShape can generate dashed path by himself.
Dashing mechanics fully hiden from the user but can be used in gl and wg renderers

@hermet hermet requested a review from Copilot July 17, 2025 01:57
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Moves stroke dasher functionality from renderer-specific code to common space for cross-API renderer compatibility. The stroke dasher performs path-to-path operations similar to path trim, making it suitable for the common code space.

  • Relocates the DashStroke class from GL renderer to common RenderDashPath class in tvgRender.cpp
  • Adds strokeDash() method to RenderShape for centralized dash stroke handling
  • Simplifies stroke processing logic in GL renderer by using the common implementation

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/renderer/tvgRender.h Adds strokeDash method declaration to RenderShape class
src/renderer/tvgRender.cpp Implements RenderDashPath class and strokeDash method for common dash stroke functionality
src/renderer/gl_engine/tvgGlTessellator.h Removes DashStroke class and doDashStroke method declarations
src/renderer/gl_engine/tvgGlTessellator.cpp Removes DashStroke implementation and updates stroke method to use common dash functionality
src/renderer/gl_engine/tvgGlGeometry.cpp Simplifies tessellation logic by removing path preprocessing and delegating to stroker

}

if (mCurrLen < 0.1f) {
Copy link
Preview

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

Magic number 0.1f should be replaced with a named constant for clarity and maintainability.

Suggested change
if (mCurrLen < 0.1f) {
if (mCurrLen < MIN_CURR_LEN_THRESHOLD) {

Copilot uses AI. Check for mistakes.

}

if (mCurrLen < 0.1f) {
Copy link
Preview

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

Magic number 0.1f should be replaced with a named constant for clarity and maintainability. This appears to be duplicated from line 753.

Suggested change
if (mCurrLen < 0.1f) {
if (mCurrLen < MIN_CURR_LEN_THRESHOLD) {

Copilot uses AI. Check for mistakes.

@hermet
Copy link
Member

hermet commented Jul 18, 2025

duplicated: #3624

@hermet hermet closed this Jul 18, 2025
@hermet hermet added the invalid This doesn't seem right label Jul 18, 2025
@SergeyLebedkin SergeyLebedkin deleted the common_share_stroke_dasher branch July 18, 2025 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gl OpenGL/WebGL render backend invalid This doesn't seem right refactoring Code refactoring / Exceptional handles renderer Core rendering
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载