I have quite unique use case for Skia 2D-graphics library, where I require the maximum performance. This puts some limitations to my code.
Requirements:
- Calculate pixel coordinates (x,y) of hundreds of lines from (x0, y0, to x1, y1)
- Each line has same thickness, which is driven by configuration and is usually between [0.1 - 2]
- Each line is evaluated with a scoring function, which will give each line a score by evaluating each of it's pixels in a bitmap.
- Therefore the algorithm works against a rasterized line rather than a vector graphics line
What I need in practice to satisfy these requirements, is to be able to calculate the coordinates of each pixel in the line, but not actually call the SKCanvas.DrawLine() function to rasterize the line into a bitmap, because that is way too expensive for my use case. I've tried Bresenhams and Xiaolin Wu's algorithms to calculate line pixels, but their results differ slightly from what Skia's DrawLine function renders. My use-case requires exact match to what eventually will be rendered to the bitmap, but the actual rendering must be avoided during the line evaluation/scoring step due to performance reasons.
Does Skia expose any light-weight methods to "rasterize" a line, by giving it's pixel coordinates without actually rendering the line on a bitmap?