+
Skip to content

Conversation

mgrudzinska
Copy link
Collaborator

@mgrudzinska mgrudzinska commented Jun 9, 2025

Previously, the rounding modifier was always applied
first, which led to incorrect results when a different
modifier order was expected.
This update removes that limitation and enables modifiers
to be applied in any order.

Additionally, the code now prevents an infinite loop that
occurred when the rounded corners modifier was applied
multiple times (a cycle where next was set to this).

&

Enables applying modifiers to rectangles in any order,
with the exception that if roundness is the first modifier,
it can be applied before the rectangle’s path is constructed.

&

Refactoring ellipse/polygon/star update to prepare for
chained modifiers.

before:
Zrzut ekranu 2025-06-12 o 01 02 14

after (only after #3556 is applied):
Zrzut ekranu 2025-06-12 o 01 01 02

samples:
star_or.json
star_ro.json
path_or.json
path_ro.json

@mgrudzinska mgrudzinska self-assigned this Jun 9, 2025
@mgrudzinska mgrudzinska added enhancement Improve features lottie Lottie animation labels Jun 9, 2025
@hermet hermet requested a review from Copilot June 10, 2025 10:28
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@mgrudzinska mgrudzinska marked this pull request as ready for review June 11, 2025 23:18
@mgrudzinska mgrudzinska requested a review from hermet June 11, 2025 23:38
@mgrudzinska mgrudzinska marked this pull request as draft June 11, 2025 23:45
@mgrudzinska mgrudzinska marked this pull request as ready for review June 11, 2025 23:45
Copy link
Member

@hermet hermet left a comment

Choose a reason for hiding this comment

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

Please check comments:
For optimal maintenance and size, how about replacing all LineTo usage with CubicTo?
Then we wouldn't need additional line handling in certain cases.

@mgrudzinska
Copy link
Collaborator Author

mgrudzinska commented Jun 16, 2025

Please check comments: For optimal maintenance and size, how about replacing all LineTo usage with CubicTo? Then we wouldn't need additional line handling in certain cases.

@hermet please check now. I removed support for 'lineTo' everywhere I could. but since we have polygons and rectangles, it was not possible to remove all lineTo cases.

@mgrudzinska
Copy link
Collaborator Author

@hermet please check now. I removed support for 'lineTo' everywhere I could. but since we have polygons and rectangles, it was not possible to remove all lineTo cases.

the above is outdated already.
this pr contains changes only with chaining - as a result if #3556 is not applied, samples with the very first modifier other than the round corners may render wrong/not at all.

LottieModifier* next = nullptr;
RenderPath* buffer;
Type type;
bool chained = false;
Copy link
Member

Choose a reason for hiding this comment

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

This variable looks an unnecessary complexity. doesn't mean a valid next chained?

Copy link
Collaborator Author

@mgrudzinska mgrudzinska Jun 19, 2025

Choose a reason for hiding this comment

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

@hermet can you please rephrase this sentence: "doesn't mean a valid next chained?"?
I introduced it to handle cases a->b->...->a

current chain add inside decorate
a b a->chaining = true; return b->a
b->a c b->chaining = true; return c->b->a
c->b->a a a->chaining == true; return c->b->a
without chaining check:
c->b->a a c->chaining = true; return a->c->b->a->.... - CYCLE

Copy link
Member

Choose a reason for hiding this comment

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

Got it, Do you have any sample where the exception occurs at line 53?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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


if (r == 0.0f) {
if (ctx->roundness) ctx->roundness->modifyRect(size, r);
//roundness is the first modifier -> it can be applied before the shape's path is established
Copy link
Member

@hermet hermet Jun 19, 2025

Choose a reason for hiding this comment

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

I think this can be delegated to the relying modifier itself, allowing it to properly handle the logic internally by receiving the current shape target.

ie:
//modifies could query the target type (rect, ellipse, path, polystar, etc)
modifyPath(... LottieShape* target)

you could also improve all the if-else condition other places with the above approach.

}
this->chained = true;

//just in the order.
Copy link
Member

Choose a reason for hiding this comment

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

Rather change the method concept, Please consider modifying the callers.

LottieModifier* next = nullptr;
RenderPath* buffer;
Type type;
bool chained = false;
Copy link
Member

Choose a reason for hiding this comment

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

Got it, Do you have any sample where the exception occurs at line 53?

@hermet hermet force-pushed the main branch 3 times, most recently from 9b6c8bc to a6ffb7a Compare June 23, 2025 07:12
Previously, the rounding modifier was always applied
first, which led to incorrect results when a different
modifier order was expected.
This update removes that limitation and enables modifiers
to be applied in any order.

Additionally, the code now prevents an infinite loop that
occurred when the rounded corners modifier was applied
multiple times (a cycle where next was set to this).
Enables applying modifiers to rectangles in any order.
Refactoring ellipse/polygon/star update to prepare for
chained modifiers.
@hermet hermet force-pushed the main branch 6 times, most recently from 7ceb794 to 43923a5 Compare June 25, 2025 15:59
@hermet hermet force-pushed the main branch 4 times, most recently from 9ddde24 to dac61de Compare August 5, 2025 04:06
@hermet hermet force-pushed the main branch 9 times, most recently from 30c82d7 to 0c3e8ff Compare September 3, 2025 17:59
@hermet hermet force-pushed the main branch 2 times, most recently from 7b0fe6f to 811aac3 Compare September 22, 2025 16:00
@hermet hermet force-pushed the main branch 5 times, most recently from d471af2 to 0aaa738 Compare October 13, 2025 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improve features lottie Lottie animation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

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