[pathops] Simplify trivial paths to empty
One of the things Simplify does is remove zero area parts of contours
(coincidence). To speed up the common case of a convex path (like
rectangles) Simplify calls out to SkPath::isConvex and currently takes
this to mean that the input path is already simple enough. However,
SkPath::isConvex returns true for paths where all the points are
colinear. As a result, Simplify has not been simplifying paths with all
points colinear to nothing, instead returning them unchanged.
This adds a check after SkPath::isConvex to check if all the points are
colinear and returns the empty path (instead of the original path) if
so. This does not attempt to fix any issues where SkPath::isConvex
returns true but the path contains zero length segments or excessive
moveTos as these generally do not affect any drawing.
Change-Id: I9ca519017cf8a394c0173301bf72b743adb6ae7e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/763419
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
4 files changed