Closed Bug 1278512 Opened 4 years ago Closed 4 years ago

The path flattening code doesn't generate any vertex in some cases (inflection points at 1.0 or 0.0)

Categories

(Core :: Graphics, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla50
Tracking Status
firefox50 --- fixed

People

(Reporter: nical, Assigned: nical)

References

Details

(Whiteboard: [gfx-noted])

Attachments

(1 file)

FlattenBezier in Path.cpp starts by finding up to two inflection points in the curve (t1 and t2). If there is no inflection point inside the curve we can call FlattenBezierCurveSegment directly, otherwise there is a whole bunch of interesting scenarios handled but not all cases appear to be taken into account, leading to some bezier curves not generating any vertex.

For example the following pseudo-svg:

> moveto 141.0 135.0
> curveto 141.0, 130.0, 140.0, 130.0, 131.0, 130.0
> close

doesn't get flattened properly. We find two inflection points t1=-0.125 and t2=1.0 and this combination does not make use go through any branch that produces vertices.

It looks like we are using strict float comparison against 0.0 and 1.0 in some places where we should be using >= or <=. In particular in the first branch: if an inflection point is exactly at 0.0 or 1.0, I think that we should consider it outside of the curve and be able to call FlattenBezierCurveSegment directly without splitting.
That, or handle these cases explicitly further down the function.
Attachment #8760696 - Flags: review?(bas) → review+
Whiteboard: [gfx-noted]
Pushed by nsilva@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/0e31bd18b553
Fix bezier flattening when the inflection points are on the extremity of the curve. r=Bas
https://hg.mozilla.org/mozilla-central/rev/0e31bd18b553
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
Depends on: 1294969
You need to log in before you can comment on or make changes to this bug.