draw565: Optimize the font rendering
This is a big one... more than 4x increase in font rendering performance!
This commit is contained in:
parent
031d139b7c
commit
69bc452c65
1 changed files with 5 additions and 3 deletions
|
@ -47,17 +47,19 @@ def _bounding_box(s, font):
|
||||||
|
|
||||||
return (w, h)
|
return (w, h)
|
||||||
|
|
||||||
|
@micropython.native
|
||||||
def _draw_glyph(display, glyph, x, y, bgfg):
|
def _draw_glyph(display, glyph, x, y, bgfg):
|
||||||
(px, h, w) = glyph
|
(px, h, w) = glyph
|
||||||
|
|
||||||
buf = memoryview(display.linebuffer)[0:2*(w+1)]
|
buf = memoryview(display.linebuffer)[0:2*(w+1)]
|
||||||
bytes_per_row = (w + 7) // 8
|
|
||||||
|
|
||||||
for row in range(h):
|
|
||||||
_bitblit(buf, px[row*bytes_per_row:], bgfg, w)
|
|
||||||
buf[2*w] = 0
|
buf[2*w] = 0
|
||||||
buf[2*w + 1] = 0
|
buf[2*w + 1] = 0
|
||||||
display.rawblit(buf, x, y+row, w+1, 1)
|
bytes_per_row = (w + 7) // 8
|
||||||
|
|
||||||
|
display.set_window(x, y, w+1, h)
|
||||||
|
for row in range(h):
|
||||||
|
_bitblit(buf, px[row*bytes_per_row:], bgfg, w)
|
||||||
|
display.write_data(buf)
|
||||||
|
|
||||||
class Draw565(object):
|
class Draw565(object):
|
||||||
"""Drawing library for RGB565 displays.
|
"""Drawing library for RGB565 displays.
|
||||||
|
|
Loading…
Add table
Reference in a new issue