8000 lottie: use cubics instead of lines by mgrudzinska · Pull Request #3551 · thorvg/thorvg · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

lottie: use cubics instead of lines #3551

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
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

lottie: use cubics instead of lines #3551

wants to merge 1 commit into from

Conversation

mgrudzinska
Copy link
Collaborator

115 lines added
74 lines removed
(in pucker bloat I can remove 14 lines because of this changes

pros:

  • _appendRect fun - I added one extra cubic command to close the shape using cubics. thank that in pucker bloat no extra support for rectangles is necessary - easier to implement

cons:

  • more points - but it is not observed in increased memory usage, so not really a con

@mgrudzinska mgrudzinska self-assigned this Jun 17, 2025
@github-actions github-actions bot added the lottie Lottie animation label Jun 17, 2025
@hermet hermet requested a review from Copilot June 19, 2025 03:08
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

This PR refactors Lottie's path-building logic by switching from line commands to cubic commands, simplifying rectangle drawing and rounding of corners.

  • Updated signature of the line() function in LottieOffsetModifier to remove the degenerated flag.
  • Replaced several direct push of LineTo commands with a new _cubic helper across modifier and builder files.
  • Refactored rectangle and star/polygon path methods in LottieBuilder to use cubic commands, reducing special-case handling.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/loaders/lottie/tvgLottieModifier.h Updated the line() function signature to remove the extra parameter
src/loaders/lottie/tvgLottieModifier.cpp Modified path construction functions (line, corner) to use _cubic helper
src/loaders/lottie/tvgLottieBuilder.cpp Reworked rectangle and star/polygon drawing using cubicTo instead of lineTo
Comments suppressed due to low confidence (3)

src/loaders/lottie/tvgLottieModifier.h:105

  • The removal of the 'bool degenerated' parameter from the line() function signature may affect degenerated case handling; please verify that the new signature preserves the intended behavior.
    void line(RenderPath& out, PathCommand* inCmds, uint32_t inCmdsCnt, Point* inPts, uint32_t& curPt, uint32_t curCmd, State& state, float offset);

src/loaders/lottie/tvgLottieBuilder.cpp:646

  • [nitpick] Replacing a simple lineTo with cubicTo for straight segments may be confusing to future maintainers; consider adding a comment to explain the rationale behind this change.
            shape->cubicTo(SHAPE(shape)->rs.path.pts.last().x, SHAPE(shape)->rs.path.pts.last().y, in.x, in.y, in.x, in.y);

src/loaders/lottie/tvgLottieModifier.cpp:148

  • The removal of the previous conditional check on the command type before computing state.line may alter offset adjustments in cases where the previous command was not a LineTo; please confirm that this change is intentional.
    state.line = _offset(inPts[curPt - 1], inPts[curPt], offset);

@hermet hermet added the refactoring Code refactoring / Exceptional handles label Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lottie Lottie animation refactoring Code refactoring / Exceptional handles
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0