extmod/modframebuf: Allow blit source to be a subclass of FrameBuffer.

This commit is contained in:
Jim Mussared
2020-02-19 22:45:32 +11:00
committed by Damien George
parent f6d99bc795
commit f8449dd092
3 changed files with 35 additions and 1 deletions

View File

@@ -18,3 +18,25 @@ fb = FB(n=3)
fb.pixel(0, 0, 0x0102)
fb.foo()
print(bytes(fb))
# Test that blitting a subclass works.
fb2 = framebuf.FrameBuffer(bytearray(2 * 3 * 3), 3, 3, framebuf.RGB565)
fb.fill(0)
fb.pixel(0, 0, 0x0506)
fb.pixel(2, 2, 0x0708)
fb2.blit(fb, 0, 0)
print(bytes(fb2))
# Test that blitting something that isn't a subclass fails with TypeError.
class NotAFrameBuf:
pass
try:
fb.blit(NotAFrameBuf(), 0, 0)
except TypeError:
print('TypeError')
try:
fb.blit(None, 0, 0)
except TypeError:
print('TypeError')

View File

@@ -1 +1,4 @@
b'\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x03\x04\x03\x04\x03'
b'\x06\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x07'
TypeError
TypeError