From 58b5c0378ec3d5421a4af2bfed0434e3a286a1b0 Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Mon, 29 Mar 2021 22:16:43 +0100 Subject: [PATCH] draw565: Optimize the string drawing Currently there is a redundant fill operation issued for every character drawn. This was added to draw the background colours correctly but the change did not account for the optimized character rendering in _draw_glyph(). This results in ~15% performance improvement for character rendering Fixes: cc34c5d46de9 ("draw565: Fix wrong background color of strings") Signed-off-by: Daniel Thompson --- wasp/draw565.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/wasp/draw565.py b/wasp/draw565.py index c84b1ec..f831b04 100644 --- a/wasp/draw565.py +++ b/wasp/draw565.py @@ -87,8 +87,8 @@ def _draw_glyph(display, glyph, x, y, bgfg): (px, h, w) = glyph buf = display.linebuffer[0:2*(w+1)] - buf[2*w] = 0 - buf[2*w + 1] = 0 + buf[2*w] = bgfg >> 24 + buf[2*w + 1] = (bgfg >> 16) & 0xff bytes_per_row = (w + 7) // 8 display.set_window(x, y, w+1, h) @@ -324,7 +324,6 @@ class Draw565(object): for ch in s: glyph = font.get_ch(ch) _draw_glyph(display, glyph, x, y, bgfg) - self.fill(bg, x+glyph[2], y, 1, glyph[1]) x += glyph[2] + 1 if width: