diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2020-02-19 22:45:32 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2020-02-21 13:32:48 +1100 |
commit | f8449dd092cb3ab7c74686db972500dc194613f7 (patch) | |
tree | 9d82a35bf73a94eedad3dd7e8e77eea7882b237b /extmod/modframebuf.c | |
parent | f6d99bc7952d5854fc5822d9cf54b792794f6da7 (diff) |
extmod/modframebuf: Allow blit source to be a subclass of FrameBuffer.
Diffstat (limited to 'extmod/modframebuf.c')
-rw-r--r-- | extmod/modframebuf.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/extmod/modframebuf.c b/extmod/modframebuf.c index 416431cd6..07b4a249f 100644 --- a/extmod/modframebuf.c +++ b/extmod/modframebuf.c @@ -41,6 +41,10 @@ typedef struct _mp_obj_framebuf_t { uint8_t format; } mp_obj_framebuf_t; +#if !MICROPY_ENABLE_DYNRUNTIME +STATIC const mp_obj_type_t mp_type_framebuf; +#endif + typedef void (*setpixel_t)(const mp_obj_framebuf_t*, int, int, uint32_t); typedef uint32_t (*getpixel_t)(const mp_obj_framebuf_t*, int, int); typedef void (*fill_rect_t)(const mp_obj_framebuf_t *, int, int, int, int, uint32_t); @@ -469,7 +473,12 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_line_obj, 6, 6, framebuf_lin STATIC mp_obj_t framebuf_blit(size_t n_args, const mp_obj_t *args) { mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]); - mp_obj_framebuf_t *source = MP_OBJ_TO_PTR(args[1]); + mp_obj_t source_in = mp_obj_cast_to_native_base(args[1], MP_OBJ_FROM_PTR(&mp_type_framebuf)); + if (source_in == MP_OBJ_NULL) { + mp_raise_TypeError(NULL); + } + mp_obj_framebuf_t *source = MP_OBJ_TO_PTR(source_in); + mp_int_t x = mp_obj_get_int(args[2]); mp_int_t y = mp_obj_get_int(args[3]); mp_int_t key = -1; |