On Fri Feb 9 21:51:46 2024 +0000, Esme Povirk wrote:
Doable, but it wouldn't be very efficient for cases where we need more than a 1x1 rasterization, and once we have that we may as well use it for the hit-testing (effectively a 1x1 rasterization) as well. A bounding box calculation is theoretically useful for path/region fills because it allows us to reduce the number of pixels we need to consider.
I don't understand what you mean by 1x1 rasterization. The only case where I see rasterization being somehow complicated is for a path region, where the path is traced to convert it to a region, to decide whether a point is within it.
Every other region type, or combined region type, can decide whether a point is within it with a simple recursive traversal, the same way `get_region_hrgn` traverses the tree but without even having to compute and combine GDI regions.
Even without bounding boxes I don't think this would be very costly, and only the path tracing probably is?
Anyway, I don't know what GDI+ expects in term of logic, in the case of a path region, like does it actually expect the path to be rasterized and any point inside a pixel from the region edges to be considered inside the region even though it's mathematically outside the path? If not, and if the mathematical result is actually expected there's a very simple way to do it with standard "point in polygon" algorithm (basically only a matter of computing and counting segment intersections with every segment in the path).
The algorithm is actually defined in the FillMode documentation, as it depends on the kind of filling used: https://learn.microsoft.com/en-us/windows/win32/api/gdiplusenums/ne-gdipluse...
Bounding boxes may be useful, as an optimization, to quickly exclude points that are outside region components, and avoid useless recursive calls, but somehow I don't feel like this is the most common case. Though, doing it may be useful but I think it would be much easier to precompute and keep the bounding boxes on every node as they are created, which should be pretty easy as well and much more efficient than recomputing them.