Arduboy2 icon indicating copy to clipboard operation
Arduboy2 copied to clipboard

Make drawLine smarter on PIXEL_SAFE_MODE

Open Artoria2e5 opened this issue 6 years ago • 0 comments

The current drawLine leaves all the pixel-safety checks to drawPixel, which is not quite optimal for off-screen lines and partially off-screen lines. This commit changes its behavior by having it skip the draw when both ends are off-screen, and also skip when the "current pixel" goes from on-screen to off-screen.

To achieve this end some API changes are done to drawPixel, since it after all does not tell whether a draw has been attempted. A (very internal; not in header) drawPixelMaybe function is now composed of drawPixel's checking part, and a drawPixelRaw for a complete absense of checks in other "safe" functions. The drawPixel signature is unchanged; it is hoped that drawPixelMaybe would be inlined, its returns stripped, exposing the drawPixelRaw call as a tail call.

This PR is probably very unnecessary; I wrote it so that I can stop thinking about how slow a newton solver would be on the Arduboy.

Artoria2e5 avatar May 05 '18 00:05 Artoria2e5