mirror of https://github.com/MLXXXp/Arduboy2.git
Fix off screen tests for bitmap functions
Issue reported by @MrBlinky For drawBitmap(), drawSlowXYBitmap() and drawCompressed() the initial check for the bitmap being entirely off screen would sometimes consider a bitmap to be partially on screen when it is only one pixel above or to the left of the screen. This would result in unnecessarily doing the work to draw the bitmap when none of it would be visible.
This commit is contained in:
parent
0adb83693a
commit
205e84eae6
|
@ -819,7 +819,7 @@ void Arduboy2Base::drawBitmap
|
||||||
uint8_t color)
|
uint8_t color)
|
||||||
{
|
{
|
||||||
// no need to draw at all if we're offscreen
|
// no need to draw at all if we're offscreen
|
||||||
if (x+w < 0 || x > WIDTH-1 || y+h < 0 || y > HEIGHT-1)
|
if (x + w <= 0 || x > WIDTH - 1 || y + h <= 0 || y > HEIGHT - 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int yOffset = abs(y) % 8;
|
int yOffset = abs(y) % 8;
|
||||||
|
@ -864,7 +864,7 @@ void Arduboy2Base::drawSlowXYBitmap
|
||||||
(int16_t x, int16_t y, const uint8_t *bitmap, uint8_t w, uint8_t h, uint8_t color)
|
(int16_t x, int16_t y, const uint8_t *bitmap, uint8_t w, uint8_t h, uint8_t color)
|
||||||
{
|
{
|
||||||
// no need to draw at all of we're offscreen
|
// no need to draw at all of we're offscreen
|
||||||
if (x+w < 0 || x > WIDTH-1 || y+h < 0 || y > HEIGHT-1)
|
if (x + w <= 0 || x > WIDTH - 1 || y + h <= 0 || y > HEIGHT - 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int16_t xi, yi, byteWidth = (w + 7) / 8;
|
int16_t xi, yi, byteWidth = (w + 7) / 8;
|
||||||
|
@ -923,7 +923,7 @@ void Arduboy2Base::drawCompressed(int16_t sx, int16_t sy, const uint8_t *bitmap,
|
||||||
uint8_t spanColour = (uint8_t)cs.readBits(1); // starting colour
|
uint8_t spanColour = (uint8_t)cs.readBits(1); // starting colour
|
||||||
|
|
||||||
// no need to draw at all if we're offscreen
|
// no need to draw at all if we're offscreen
|
||||||
if ((sx + width < 0) || (sx > WIDTH - 1) || (sy + height < 0) || (sy > HEIGHT - 1))
|
if ((sx + width <= 0) || (sx > WIDTH - 1) || (sy + height <= 0) || (sy > HEIGHT - 1))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// sy = sy - (frame * height);
|
// sy = sy - (frame * height);
|
||||||
|
|
Loading…
Reference in New Issue