I have written my own poly-line class that essentially keeps a list of points that can be modified using a Matrix. The poly lines can be added to other poly lines and joined at common endpoints. The poly line will represent a polygon when the end point equals the starting point.
I then have a method to turn my polygon into a Path object by iterating the list of points with a series of lineTo() calls. This path is then applied to a canvas as a clip path in my View's onDraw method.
It works perfect for complex polygons and I can draw that path to verify it's accuracy.
So far so good, except that I'm noticing issues when I have a compound polygon with an irregular hole in the middle. I should probably stop calling it a polygon at this point since it is a polygon inside another polygon.
For example consider the diagram below where the outer box and "castle" looking shape in the middle are both parts of the same Path object that is used as a clip-path. The # represent painted area.
+---------+
|#########|
|#+-+#+-+#|
|#| |#| |#|
|#| +-+ |#|
|#| |#|
|#+-----+#|
|#########|
+---------+
I expect that everything outside of the outer box and inside the inner "castle" shape to be clipped. The issue I'm seeing is that the inside shape isn't being clipped, properly. Seems to be an issue with the ray-tracing algorithm.
Any ideas would be helpful.
EDIT: Also, I tried testing every Region.Op mode, and none of them solved the problem. I suspect I'll need to put measures in place to detect if there is a "hole" and do something creative.