flutter icon indicating copy to clipboard operation
flutter copied to clipboard

[Impeller] Tessellation for Bezier curves doesn't look too great when scaled.

Open dnfield opened this issue 3 years ago • 2 comments

TEST_F(EntityTest, BezierCircleScaled) {
  Entity entity;
  auto path = PathBuilder{}
                  .MoveTo({97.325, 34.818})
                  .CubicCurveTo({98.50862885295136, 34.81812293973836},
                                {99.46822048142015, 33.85863261475589},
                                {99.46822048142015, 32.67499810206613})
                  .CubicCurveTo({99.46822048142015, 31.491363589376355},
                                {98.50862885295136, 30.53187326439389},
                                {97.32499434685802, 30.531998226542708})
                  .CubicCurveTo({96.14153655073771, 30.532123170035373},
                                {95.18222070648729, 31.491540299350355},
                                {95.18222070648729, 32.67499810206613})
                  .CubicCurveTo({95.18222070648729, 33.85845590478189},
                                {96.14153655073771, 34.81787303409686},
                                {97.32499434685802, 34.81799797758954})
                  .Close()
                  .TakePath();
  entity.SetPath(path);
  entity.SetTransformation(Matrix::MakeScale({20.0, 20.0, 1.0}).Translate({-80, -15, 0}));
  entity.SetContents(SolidColorContents::Make(Color::Red()));
  ASSERT_TRUE(OpenPlaygroundHere(entity));
}

At the current values for SmoothingApproximation:

image

If I change SmoothingApproximation.scale to 0.01 it looks much better, but also is more expensive to calculate.

We should probably have this be adaptive so that when people scale into paths they still look good.

@Chinmaygarde @bdero fyi

dnfield avatar Mar 08 '22 18:03 dnfield

Right, the approximation is just an arbitrary number right now. Will have to be adaptive or precomputed for known paths.

chinmaygarde avatar Mar 08 '22 18:03 chinmaygarde

Update: We have some support for adaptive subdivision now but it is not uniformly applied. The next step is to do a pass for all geometry types.

chinmaygarde avatar Dec 09 '22 21:12 chinmaygarde

Closing this since https://github.com/flutter/engine/pull/38497 Fix this ^_^

luckysmg avatar Jan 06 '23 09:01 luckysmg

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

github-actions[bot] avatar Mar 04 '23 12:03 github-actions[bot]