-
Notifications
You must be signed in to change notification settings - Fork 6k
[web] Fix conic to quad conversion assertion. #18811
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.
LGTM but the second part of the assert in the toQuads method seems to belong in the _computeSubdivisionCount method?
@@ -33,7 +33,7 @@ class Conic { | |||
|
|||
// Split conic into quads, writes quad coordinates into [_pointList] and | |||
// returns number of quads. | |||
assert(subdivideCount > 0); | |||
assert(subdivideCount >= 0 && subdivideCount <= _maxSubdivisionCount); |
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.
Isn't subdivideCount <= _maxSubdivisionCount
guaranteed by the implementation of _computeSubdivisionCount
?
The documentation of _computeSubdivisionCount
says: The number of subdivisions never exceed _maxSubdivisionCount
Should the second half of this assert be moved to the _countSubdivisionCount method, so the postcondition in the documentation is "guaranteed"?
assert(pow2 <= _maxSubdivisionCount);
return pow2;
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.
Added check here to make sure if implementation breaks, this will throw.
Description
When computing subdivision count for quad approximation of conic, if initial error rate is below tolerance, debug build throws assertion and fails to construct path.
Related Issues
Related to refactor for flutter/flutter#44572
Tests
Added test case to test/path_test.dart
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.Breaking Change
Did any tests fail when you ran them? Please read [handling breaking changes].