From fd69c0e2397b5665769baceabf902fea01b81008 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Wed, 27 Sep 2023 11:21:59 -0700 Subject: [PATCH] Speed improvements by making larger buffer --- displayio/_display.py | 4 +++- displayio/_palette.py | 8 +++++--- displayio/_tilegrid.py | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/displayio/_display.py b/displayio/_display.py index d7d04cf..022103d 100644 --- a/displayio/_display.py +++ b/displayio/_display.py @@ -328,7 +328,6 @@ class Display: def _refresh_area(self, area) -> bool: """Loop through dirty areas and redraw that area.""" # pylint: disable=too-many-locals - buffer_size = 128 clipped = Area() # Clip the area to the display by overlapping the areas. @@ -340,6 +339,9 @@ class Display: pixels_per_word = 32 // self._core.colorspace.depth pixels_per_buffer = clipped.size() + # We should have lots of memory + buffer_size = clipped.size() // pixels_per_word + subrectangles = 1 # for SH1107 and other boundary constrained controllers # write one single row at a time diff --git a/displayio/_palette.py b/displayio/_palette.py index c00d454..a017254 100644 --- a/displayio/_palette.py +++ b/displayio/_palette.py @@ -98,21 +98,23 @@ class Palette: self._colors[palette_index].transparent = False self._needs_refresh = True + """ def _get_palette(self): - """Generate a palette for use with PIL""" + # Generate a palette for use with PIL palette = [] for color in self._colors: palette += color.rgba()[0:3] return palette def _get_alpha_palette(self): - """Generate an alpha channel palette with white being - opaque and black being transparent""" + # Generate an alpha channel palette with white being + # opaque and black being transparent palette = [] for color in self._colors: for _ in range(3): palette += [0 if color.transparent else 0xFF] return palette + """ def _get_color( self, diff --git a/displayio/_tilegrid.py b/displayio/_tilegrid.py index 6705601..dc392b9 100644 --- a/displayio/_tilegrid.py +++ b/displayio/_tilegrid.py @@ -400,6 +400,7 @@ class TileGrid: # Reverse the shift by subtracting it from the leftmost shift shift = (pixels_per_byte - 1) * colorspace.depth - shift buffer[offset // pixels_per_byte] |= output_pixel.pixel << shift + return full_coverage def _finish_refresh(self): -- 2.49.0