mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
feat(draw): add lv_draw_sw_rgb565_swap
This commit is contained in:
parent
91edcf0930
commit
d4613aecbe
@ -239,4 +239,38 @@ static void execute_drawing(lv_draw_sw_unit_t * u)
|
||||
|
||||
}
|
||||
|
||||
|
||||
void lv_draw_sw_rgb565_swap(void * buf, int32_t buf_size_px)
|
||||
{
|
||||
uint32_t u32_cnt = buf_size_px / 2;
|
||||
uint16_t * buf16 = buf;
|
||||
uint32_t * buf32 = buf;
|
||||
|
||||
while(u32_cnt >= 8) {
|
||||
buf32[0] = ((uint32_t)(buf32[0] & 0xff00ff00) >> 8) + ((uint32_t)(buf32[0] & 0x00ff00ff) << 8);
|
||||
buf32[1] = ((uint32_t)(buf32[1] & 0xff00ff00) >> 8) + ((uint32_t)(buf32[1] & 0x00ff00ff) << 8);
|
||||
buf32[2] = ((uint32_t)(buf32[2] & 0xff00ff00) >> 8) + ((uint32_t)(buf32[2] & 0x00ff00ff) << 8);
|
||||
buf32[3] = ((uint32_t)(buf32[3] & 0xff00ff00) >> 8) + ((uint32_t)(buf32[3] & 0x00ff00ff) << 8);
|
||||
buf32[4] = ((uint32_t)(buf32[4] & 0xff00ff00) >> 8) + ((uint32_t)(buf32[4] & 0x00ff00ff) << 8);
|
||||
buf32[5] = ((uint32_t)(buf32[5] & 0xff00ff00) >> 8) + ((uint32_t)(buf32[5] & 0x00ff00ff) << 8);
|
||||
buf32[6] = ((uint32_t)(buf32[6] & 0xff00ff00) >> 8) + ((uint32_t)(buf32[6] & 0x00ff00ff) << 8);
|
||||
buf32[7] = ((uint32_t)(buf32[7] & 0xff00ff00) >> 8) + ((uint32_t)(buf32[7] & 0x00ff00ff) << 8);
|
||||
buf32 += 8;
|
||||
u32_cnt -= 8;
|
||||
}
|
||||
|
||||
while(u32_cnt) {
|
||||
*buf32 = ((uint32_t)(*buf32 & 0xff00ff00) >> 8) + ((uint32_t)(*buf32 & 0x00ff00ff) << 8);
|
||||
buf32++;
|
||||
u32_cnt--;
|
||||
}
|
||||
|
||||
if(buf_size_px & 0x1) {
|
||||
uint32_t e = buf_size_px - 1;
|
||||
buf16[e] = ((buf16[e] & 0xff00) >> 8) + ((buf16[e] & 0x00ff) << 8);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /*LV_USE_DRAW_SW*/
|
||||
|
@ -82,6 +82,15 @@ void lv_draw_sw_transform(lv_draw_unit_t * draw_unit, const lv_area_t * dest_are
|
||||
int32_t src_w, int32_t src_h, int32_t src_stride,
|
||||
const lv_draw_image_dsc_t * draw_dsc, const lv_draw_image_sup_t * sup, lv_color_format_t cf, void * dest_buf);
|
||||
|
||||
|
||||
/**
|
||||
* Swap the upper and lower byte of an RGB565 buffer.
|
||||
* Might be required if a 8bit parallel port or an SPI port send the bytes in the wrong order.
|
||||
* The bytes will be swapped in place.
|
||||
* @param buf_size_px number of pixels in the buffer
|
||||
*/
|
||||
void lv_draw_sw_rgb565_swap(void * buf, int32_t buf_size_px);
|
||||
|
||||
/***********************
|
||||
* GLOBAL VARIABLES
|
||||
***********************/
|
||||
|
@ -44,8 +44,6 @@ const lv_color_filter_dsc_t lv_color_filter_shade = {.filter_cb = lv_color_filte
|
||||
uint8_t lv_color_format_get_bpp(lv_color_format_t cf)
|
||||
{
|
||||
switch(cf) {
|
||||
case LV_COLOR_FORMAT_NATIVE_REVERSED:
|
||||
return LV_COLOR_DEPTH / 8;
|
||||
case LV_COLOR_FORMAT_I1:
|
||||
case LV_COLOR_FORMAT_A1:
|
||||
return 1;
|
||||
|
@ -117,9 +117,6 @@ enum _lv_color_format_t {
|
||||
LV_COLOR_FORMAT_ARGB8888 = 0x10,
|
||||
LV_COLOR_FORMAT_XRGB8888 = 0x11,
|
||||
|
||||
/*Miscellaneous formats*/
|
||||
LV_COLOR_FORMAT_NATIVE_REVERSED = 0x1A,
|
||||
|
||||
/*Formats not supported by software renderer but kept here so GPU can use it*/
|
||||
LV_COLOR_FORMAT_A1 = 0x0B,
|
||||
LV_COLOR_FORMAT_A2 = 0x0C,
|
||||
|
Loading…
x
Reference in New Issue
Block a user