From: Melissa LeBlanc-Williams Date: Mon, 29 Jun 2020 21:18:35 +0000 (-0700) Subject: Merge pull request #25 from makermelissa/optimization X-Git-Tag: 0.4.1 X-Git-Url: https://git.ayoreis.com/hackapet/Adafruit_Blinka_Displayio.git/commitdiff_plain/1e01f5eee6a316b5e0df9448243833daab98ca5e?hp=e74f23cb01a08dcc664aa6f36527e6d987322dfb Merge pull request #25 from makermelissa/optimization Divide by zero and speed up bug fixes --- diff --git a/displayio/display.py b/displayio/display.py index eb3d635..b9f86dc 100644 --- a/displayio/display.py +++ b/displayio/display.py @@ -213,6 +213,8 @@ class Display: When auto refresh is on, updates the display immediately. (The display will also update without calls to this.) """ + self._subrectangles = [] + # Go through groups and and add each to buffer if self._current_group is not None: buffer = Image.new("RGBA", (self._width, self._height)) @@ -221,8 +223,9 @@ class Display: # save image to buffer (or probably refresh buffer so we can compare) self._buffer.paste(buffer) - # Eventually calculate dirty rectangles here - self._subrectangles.append(Rectangle(0, 0, self._width, self._height)) + if self._current_group is not None: + # Eventually calculate dirty rectangles here + self._subrectangles.append(Rectangle(0, 0, self._width, self._height)) for area in self._subrectangles: self._refresh_display_area(area) diff --git a/displayio/tilegrid.py b/displayio/tilegrid.py index 774dd77..c88498d 100644 --- a/displayio/tilegrid.py +++ b/displayio/tilegrid.py @@ -103,10 +103,10 @@ class TileGrid: tile_width = bitmap_width if tile_height is None: tile_height = bitmap_height - if bitmap_width % tile_width != 0: + if tile_width > 0 and bitmap_width % tile_width != 0: raise ValueError("Tile width must exactly divide bitmap width") self._tile_width = tile_width - if bitmap_height % tile_height != 0: + if tile_height > 0 and bitmap_height % tile_height != 0: raise ValueError("Tile height must exactly divide bitmap height") self._tile_height = tile_height if not 0 <= default_tile <= 255: