Detect that edges are all hz or vertical :
- v lines or rectangles are "constant"
- Use 1px row and repeat it directly until new edges to compute tiles.
- If the line or height is high, it will compute only 1px row mask instead of (y2 - y1) pix * 8 (subpixels) !
That would be a huge win.