diff --git a/src/draw/eve/lv_draw_eve_image.c b/src/draw/eve/lv_draw_eve_image.c index 355e90fbb7..1c6d999dd1 100644 --- a/src/draw/eve/lv_draw_eve_image.c +++ b/src/draw/eve/lv_draw_eve_image.c @@ -107,11 +107,11 @@ void lv_draw_eve_image(lv_draw_task_t * t, const lv_draw_image_dsc_t * draw_dsc, } lv_eve_primitive(LV_EVE_PRIMITIVE_BITMAPS); - EVE_cmd_dl_burst(BITMAP_SOURCE(ramg_addr)); + lv_eve_bitmap_source(ramg_addr); /*real height and width is mandatory for rotation and scale (Clip Area)*/ - EVE_cmd_dl_burst(BITMAP_SIZE(EVE_NEAREST, EVE_BORDER, EVE_BORDER, src_w, src_h)); + lv_eve_bitmap_size(EVE_NEAREST, EVE_BORDER, EVE_BORDER, src_w, src_h); - EVE_cmd_dl_burst(BITMAP_LAYOUT(eve_format, eve_stride, src_h)); + lv_eve_bitmap_layout(eve_format, eve_stride, src_h); if(draw_dsc->rotation || draw_dsc->scale_x != LV_SCALE_NONE || draw_dsc->scale_y != LV_SCALE_NONE) { EVE_cmd_dl_burst(CMD_LOADIDENTITY); diff --git a/src/draw/eve/lv_draw_eve_letter.c b/src/draw/eve/lv_draw_eve_letter.c index 0765ccfce3..18dc341598 100644 --- a/src/draw/eve/lv_draw_eve_letter.c +++ b/src/draw/eve/lv_draw_eve_letter.c @@ -155,10 +155,10 @@ static void lv_draw_eve_letter_cb(lv_draw_task_t * t, lv_draw_glyph_dsc_t * glyp lv_eve_color_opa(glyph_draw_dsc->opa); lv_eve_color(glyph_draw_dsc->color); - EVE_cmd_dl_burst(BITMAP_SOURCE(ramg_addr)); + lv_eve_bitmap_source(ramg_addr); - EVE_cmd_dl_burst(BITMAP_SIZE(EVE_NEAREST, EVE_BORDER, EVE_BORDER, g_box_w, g_box_h)); - EVE_cmd_dl_burst(BITMAP_LAYOUT(bpp_eve, g_aligned_stride, g_box_h)); + lv_eve_bitmap_size(EVE_NEAREST, EVE_BORDER, EVE_BORDER, g_box_w, g_box_h); + lv_eve_bitmap_layout(bpp_eve, g_aligned_stride, g_box_h); lv_eve_vertex_2f(glyph_draw_dsc->letter_coords->x1, glyph_draw_dsc->letter_coords->y1); } diff --git a/src/draw/eve/lv_eve.c b/src/draw/eve/lv_eve.c index 16f8ddaba7..145c4c7f25 100644 --- a/src/draw/eve/lv_eve.c +++ b/src/draw/eve/lv_eve.c @@ -55,6 +55,8 @@ static lv_eve_drawing_context_t ct = { static lv_eve_drawing_context_t ct_temp; +static lv_eve_drawing_state_t st; + /********************** * MACROS **********************/ @@ -215,6 +217,45 @@ void lv_eve_mask_round(int16_t coord_x1, int16_t coord_y1, int16_t coord_x2, int lv_eve_blend_func(EVE_DST_ALPHA, EVE_ONE_MINUS_DST_ALPHA); } +void lv_eve_bitmap_source(uint32_t addr) +{ + uint32_t bitmap_source = BITMAP_SOURCE(addr); + if(st.bitmap_source != bitmap_source) { + EVE_cmd_dl_burst(bitmap_source); + st.bitmap_source = bitmap_source; + } +} + +void lv_eve_bitmap_size(uint8_t filter, uint8_t wrapx, uint8_t wrapy, uint16_t width, uint16_t height) +{ + uint32_t bitmap_size = BITMAP_SIZE(filter, wrapx, wrapy, width, height); + if(st.bitmap_size != bitmap_size) { + EVE_cmd_dl_burst(bitmap_size); + st.bitmap_size = bitmap_size; + } + /* set the high bits too, of the width and height */ + uint32_t bitmap_size_h = BITMAP_SIZE_H(width, height); + if(st.bitmap_size_h != bitmap_size_h) { + EVE_cmd_dl_burst(bitmap_size_h); + st.bitmap_size_h = bitmap_size_h; + } +} + +void lv_eve_bitmap_layout(uint8_t format, uint16_t linestride, uint16_t height) +{ + uint32_t bitmap_layout = BITMAP_LAYOUT(format, linestride, height); + if(st.bitmap_layout != bitmap_layout) { + EVE_cmd_dl_burst(bitmap_layout); + st.bitmap_layout = bitmap_layout; + } + /* set the high bits too, of the linestride and height */ + uint32_t bitmap_layout_h = BITMAP_LAYOUT_H(linestride, height); + if(st.bitmap_layout_h != bitmap_layout_h) { + EVE_cmd_dl_burst(bitmap_layout_h); + st.bitmap_layout_h = bitmap_layout_h; + } +} + /********************** diff --git a/src/draw/eve/lv_eve.h b/src/draw/eve/lv_eve.h index bd5e5df5fa..b48bd11519 100644 --- a/src/draw/eve/lv_eve.h +++ b/src/draw/eve/lv_eve.h @@ -63,6 +63,17 @@ typedef struct { uint16_t scy; } lv_eve_drawing_context_t; +/* drawing context that is not saved and restored + * by SAVE_CONTEXT and RESTORE_CONTEXT + */ +typedef struct { + uint32_t bitmap_source; + uint32_t bitmap_size; + uint32_t bitmap_size_h; + uint32_t bitmap_layout; + uint32_t bitmap_layout_h; +} lv_eve_drawing_state_t; + /********************** * GLOBAL PROTOTYPES **********************/ @@ -86,6 +97,33 @@ void lv_eve_draw_rect_simple(int16_t coord_x1, int16_t coord_y1, int16_t coord_x uint16_t radius); void lv_eve_mask_round(int16_t coord_x1, int16_t coord_y1, int16_t coord_x2, int16_t coord_y2, int16_t radius); +/** + * Set the bitmap source to `addr`. SPI transmission will occur unless it is already set to this value. + * The bitmap source is not part of the saved and restored context. + * @param addr the remote EVE memory address to set as the bitmap source + */ +void lv_eve_bitmap_source(uint32_t addr); + +/** + * Set the bitmap size and sampling parameters. SPI transmission will occur unless the currently set parameters are already these. + * The bitmap size is not part of the saved and restored context. + * @param filter the sampling method. Either EVE_NEAREST or EVE_BILINEAR + * @param wrapx the out of bounds sampling behavior in the X direction. Either EVE_BORDER or EVE_REPEAT + * @param wrapy the out of bounds sampling behavior in the Y direction. Either EVE_BORDER or EVE_REPEAT + * @param width the width of the bitmap in pixels + * @param height the height of the bitmap in pixels + */ +void lv_eve_bitmap_size(uint8_t filter, uint8_t wrapx, uint8_t wrapy, uint16_t width, uint16_t height); + +/** + * Set the bitmap format/layout parameters. SPI transmission will occur unless the currently set parameters are already these. + * The bitmap layout is not part of the saved and restored context. + * @param format an eve color format value like EVE_RGB565 + * @param linestride the stride of the bitmap rows in bytes + * @param height the number of rows in the bitmap + */ +void lv_eve_bitmap_layout(uint8_t format, uint16_t linestride, uint16_t height); + /********************** * EXTERN VARIABLES **********************/