mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
antialias: LV_ANTIALAS added, x4 atialas removed, LV_UPSCALE_MAP removed
This commit is contained in:
parent
1e57771405
commit
e5dad65949
@ -188,21 +188,6 @@ void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
|
||||
color_t buf[LV_HOR_RES];
|
||||
uint32_t br;
|
||||
area_t act_area;
|
||||
uint8_t ds_shift = 0;
|
||||
uint8_t ds_num = 0;
|
||||
#if LV_DOWNSCALE <= 1 || LV_UPSCALE_MAP == 0
|
||||
ds_shift = 0;
|
||||
ds_num = 1;
|
||||
#elif LV_DOWNSCALE == 2
|
||||
ds_shift = 1;
|
||||
ds_num = 2;
|
||||
#elif LV_DOWNSCALE == 4
|
||||
ds_shift = 2;
|
||||
ds_num = 4;
|
||||
#else
|
||||
#error "LV: not supported LV_DOWNSCALE value"
|
||||
#endif
|
||||
|
||||
|
||||
area_t mask_sub;
|
||||
bool union_ok;
|
||||
@ -215,32 +200,28 @@ void lv_draw_img(const area_t * cords_p, const area_t * mask_p,
|
||||
res = fs_read(&file, &header, sizeof(lv_img_raw_header_t), &br);
|
||||
|
||||
uint32_t start_offset = sizeof(lv_img_raw_header_t);
|
||||
start_offset += (area_get_width(cords_p) >> ds_shift) *
|
||||
((mask_sub.y1 - cords_p->y1) >> ds_shift) * sizeof(color_t); /*First row*/
|
||||
start_offset += ((mask_sub.x1 - cords_p->x1) >> ds_shift) * sizeof(color_t); /*First col*/
|
||||
start_offset += area_get_width(cords_p) *
|
||||
(mask_sub.y1 - cords_p->y1) * sizeof(color_t); /*First row*/
|
||||
start_offset += (mask_sub.x1 - cords_p->x1) * sizeof(color_t); /*First col*/
|
||||
fs_seek(&file, start_offset);
|
||||
|
||||
uint32_t useful_data = (area_get_width(&mask_sub) >> ds_shift) * sizeof(color_t);
|
||||
uint32_t next_row = (area_get_width(cords_p) >> ds_shift) * sizeof(color_t) - useful_data;
|
||||
uint32_t useful_data = area_get_width(&mask_sub) * sizeof(color_t);
|
||||
uint32_t next_row = area_get_width(cords_p) * sizeof(color_t) - useful_data;
|
||||
|
||||
area_cpy(&act_area, &mask_sub);
|
||||
|
||||
/* Round down the start coordinate, because the upscaled images
|
||||
* can start only LV_DOWNSCALE 'y' coordinates */
|
||||
act_area.y1 &= ~(cord_t)(ds_num - 1) ;
|
||||
act_area.y2 = act_area.y1 + ds_num - 1;
|
||||
act_area.y2 = act_area.y1;
|
||||
uint32_t act_pos;
|
||||
|
||||
for(row = mask_sub.y1; row <= mask_sub.y2; row += ds_num) {
|
||||
for(row = mask_sub.y1; row <= mask_sub.y2; row ++) {
|
||||
res = fs_read(&file, buf, useful_data, &br);
|
||||
map_fp(&act_area, &mask_sub, buf, opa, header.transp,
|
||||
imgs_p->objs.color, imgs_p->recolor_opa);
|
||||
fs_tell(&file, &act_pos);
|
||||
fs_seek(&file, act_pos + next_row);
|
||||
act_area.y1 += ds_num;
|
||||
act_area.y2 += ds_num;
|
||||
act_area.y1 ++;
|
||||
act_area.y2 ++;
|
||||
}
|
||||
|
||||
}
|
||||
fs_close(&file);
|
||||
|
||||
|
@ -191,25 +191,14 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
|
||||
/*If there are common part of the three area then draw to the vdb*/
|
||||
if(union_ok == false) return;
|
||||
|
||||
uint8_t ds_shift = 0;
|
||||
#if LV_DOWNSCALE <= 1 || LV_UPSCALE_MAP == 0
|
||||
ds_shift = 0;
|
||||
#elif LV_DOWNSCALE == 2
|
||||
ds_shift = 1;
|
||||
#elif LV_DOWNSCALE == 4
|
||||
ds_shift = 2;
|
||||
#else
|
||||
#error "LV: not supported LV_DOWNSCALE value"
|
||||
#endif
|
||||
|
||||
/*If the map starts OUT of the masked area then calc. the first pixel*/
|
||||
cord_t map_width = area_get_width(cords_p) >> ds_shift;
|
||||
cord_t map_width = area_get_width(cords_p);
|
||||
if(cords_p->y1 < masked_a.y1) {
|
||||
map_p += (uint32_t) map_width * ((masked_a.y1 - cords_p->y1) >> ds_shift);
|
||||
map_p += (uint32_t) map_width * (masked_a.y1 - cords_p->y1);
|
||||
}
|
||||
if(cords_p->x1 < masked_a.x1) {
|
||||
map_p += (masked_a.x1 - cords_p->x1) >> ds_shift;
|
||||
map_p += (masked_a.x1 - cords_p->x1);
|
||||
}
|
||||
|
||||
/*Stores coordinates relative to the act vdb*/
|
||||
@ -222,32 +211,9 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
color_t * vdb_buf_tmp = vdb_p->buf;
|
||||
vdb_buf_tmp += (uint32_t) vdb_width * masked_a.y1; /*Move to the first row*/
|
||||
|
||||
map_p -= (masked_a.x1 >> ds_shift);
|
||||
map_p -= masked_a.x1;
|
||||
|
||||
#if LV_DOWNSCALE > 1 && LV_UPSCALE_MAP != 0
|
||||
cord_t row;
|
||||
cord_t col;
|
||||
cord_t row_cnt = 0;
|
||||
color_t transp_color = LV_COLOR_TRANSP;
|
||||
color_t color_tmp;
|
||||
cord_t map_i;
|
||||
map_p -= map_width; /*Compensate the first row % LV_DOWNSCALE*/
|
||||
for(row = masked_a.y1, row_cnt = 0; row <= masked_a.y2; row++, row_cnt ++) {
|
||||
if(row_cnt % LV_DOWNSCALE == 0) map_p += map_width; /*Next row on the map*/
|
||||
map_i = masked_a.x1 >> ds_shift;
|
||||
map_i--; /*Compensate the first col % LV_DOWNSCALE*/
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col++) {
|
||||
if(col % LV_DOWNSCALE == 0) {
|
||||
map_i++;
|
||||
color_tmp = map_p[map_i];//color_mix(recolor, map_p[map_i], recolor_opa);
|
||||
}
|
||||
if(transp == false || map_p[map_i].full != transp_color.full) {
|
||||
vdb_buf_tmp[col] = color_tmp;//color_mix(color_tmp, vdb_buf_tmp[col], opa);
|
||||
}
|
||||
}
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
#else
|
||||
/*No transparent pixels on the image*/
|
||||
if(transp == false) { /*Simply copy the pixels to the VDB*/
|
||||
cord_t row;
|
||||
|
||||
@ -293,7 +259,7 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
} else {
|
||||
} else { /*Image opacity ut no recolor*/
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
@ -319,7 +285,7 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
map_p += map_width; /*Next row on the map*/
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
} else {
|
||||
} else { /*Image opacity with recolor*/
|
||||
for(row = masked_a.y1; row <= masked_a.y2; row++) {
|
||||
for(col = masked_a.x1; col <= masked_a.x2; col ++) {
|
||||
if(map_p[col].full != transp_color.full) {
|
||||
@ -332,10 +298,8 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
vdb_buf_tmp += vdb_width; /*Next row on the VDB*/
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif /*No upscale and no downscale*/
|
||||
}
|
||||
|
||||
|
||||
@ -343,9 +307,4 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -155,7 +155,7 @@ static void dispi_task(void * param)
|
||||
*/
|
||||
static void dispi_proc_point(lv_dispi_t * dispi_p, cord_t x, cord_t y)
|
||||
{
|
||||
#if LV_DOWNSCALE > 1 && LV_VDB_SIZE != 0
|
||||
#if LV_ANTIALIAS != 0 && LV_VDB_SIZE != 0
|
||||
dispi_p->act_point.x = x * LV_DOWNSCALE;
|
||||
dispi_p->act_point.y = y * LV_DOWNSCALE;
|
||||
#else
|
||||
|
@ -24,11 +24,11 @@
|
||||
#error "LV: LV_HOR_RES and LV_VER_RES must be greater then 0"
|
||||
#endif
|
||||
|
||||
#if LV_DOWNSCALE != 1 && LV_DOWNSCALE != 2 && LV_DOWNSCALE != 4
|
||||
#error "LV: LV_DOWNSCALE can be only 1, 2 or 4"
|
||||
#if LV_DOWNSCALE != 1 && LV_DOWNSCALE != 2
|
||||
#error "LV: LV_DOWNSCALE can be only 1 or 2"
|
||||
#endif
|
||||
|
||||
#if LV_VDB_SIZE == 0 && (LV_DOWNSCALE != 1 || LV_UPSCALE_MAP != 0 || LV_UPSCALE_STYLE != 0)
|
||||
#if LV_VDB_SIZE == 0 && LV_DOWNSCALE != 1
|
||||
#error "LV: If LV_VDB_SIZE == 0 then LV_DOWNSCALE must be 1, LV_UPSCALE_MAP 0, LV_UPSCALE_STYLE 0"
|
||||
#endif
|
||||
|
||||
|
@ -96,11 +96,6 @@ void lv_inv_area(const area_t * area_p)
|
||||
com_area.y1 = com_area.y1 & (~0x1);
|
||||
com_area.x2 = com_area.x2 | 0x1;
|
||||
com_area.y2 = com_area.y2 | 0x1;
|
||||
#elif LV_DOWNSCALE == 4
|
||||
com_area.x1 = com_area.x1 & (~0x3);
|
||||
com_area.y1 = com_area.y1 & (~0x3);
|
||||
com_area.x2 = com_area.x2 | 0x3;
|
||||
com_area.y2 = com_area.y2 | 0x3;
|
||||
#endif
|
||||
|
||||
/*Save only if this area is not in one of the saved areas*/
|
||||
@ -240,8 +235,6 @@ static void lv_refr_area_with_vdb(const area_t * area_p)
|
||||
/*Round the row number with downscale*/
|
||||
#if LV_DOWNSCALE == 2
|
||||
max_row &= (~0x1);
|
||||
#elif LV_DOWNSCALE == 4
|
||||
max_row &= (~0x3);
|
||||
#endif
|
||||
|
||||
/*Refresh all rows*/
|
||||
|
@ -52,11 +52,10 @@ lv_vdb_t * lv_vdb_get(void)
|
||||
*/
|
||||
void lv_vdb_flush(void)
|
||||
{
|
||||
#if LV_DOWNSCALE < 2
|
||||
#if LV_ANTIALIAS == 0
|
||||
disp_area(DISP_ID_ALL, vdb.vdb_area.x1 , vdb.vdb_area.y1, vdb.vdb_area.x2, vdb.vdb_area.y2);
|
||||
disp_map(DISP_ID_ALL, vdb.buf);
|
||||
#elif LV_DOWNSCALE == 2
|
||||
|
||||
#else
|
||||
color_t row_buf[LV_HOR_RES / LV_DOWNSCALE];
|
||||
color_t * row_buf_p;
|
||||
cord_t x;
|
||||
@ -88,55 +87,7 @@ void lv_vdb_flush(void)
|
||||
disp_area(DISP_ID_ALL, vdb.vdb_area.x1 >> 1, y, vdb.vdb_area.x2 >> 1, y);
|
||||
disp_map(DISP_ID_ALL, row_buf);
|
||||
}
|
||||
#elif LV_DOWNSCALE == 4
|
||||
color_t row_buf[LV_HOR_RES / LV_DOWNSCALE];
|
||||
color_t * row_buf_p;
|
||||
cord_t x;
|
||||
cord_t y;
|
||||
cord_t w = area_get_width(&vdb.vdb_area);
|
||||
cord_t i;
|
||||
color_t * buf_p = vdb.buf;
|
||||
for(y = vdb.vdb_area.y1 >> 2; y <= vdb.vdb_area.y2 >> 2; y ++) {
|
||||
i = 0;
|
||||
row_buf_p = row_buf;
|
||||
for(x = vdb.vdb_area.x1; x < vdb.vdb_area.x2; x += 4, i += 4) {
|
||||
row_buf_p->red = (buf_p[i].red + buf_p[i + 1].red +
|
||||
buf_p[i + 2].red + buf_p[i + 3].red +
|
||||
buf_p[i + w].red + buf_p[i + w + 1].red +
|
||||
buf_p[i + w + 2].red + buf_p[i + w + 3].red +
|
||||
buf_p[i + 2 * w].red + buf_p[i + 2 * w + 1].red +
|
||||
buf_p[i + 2 * w + 2].red + buf_p[i + 2 * w + 3].red +
|
||||
buf_p[i + 3 * w].red + buf_p[i + 3 * w + 1].red +
|
||||
buf_p[i + 3 * w + 2].red + buf_p[i + 3 * w + 3].red) >>4 ;
|
||||
row_buf_p->green = (buf_p[i].green + buf_p[i + 1].green +
|
||||
buf_p[i + 2].green + buf_p[i + 3].green +
|
||||
buf_p[i + w].green + buf_p[i + w + 1].green +
|
||||
buf_p[i + w + 2].green + buf_p[i + w + 3].green +
|
||||
buf_p[i + 2 * w].green + buf_p[i + 2 * w + 1].green +
|
||||
buf_p[i + 2 * w + 2].green + buf_p[i + 2 * w + 3].green +
|
||||
buf_p[i + 3 * w].green + buf_p[i + 3 * w + 1].green +
|
||||
buf_p[i + 3 * w + 2].green + buf_p[i + 3 * w + 3].green) >>4 ;
|
||||
|
||||
row_buf_p->blue = (buf_p[i].blue + buf_p[i + 1].blue +
|
||||
buf_p[i + 2].blue + buf_p[i + 3].blue +
|
||||
buf_p[i + w].blue + buf_p[i + w + 1].blue +
|
||||
buf_p[i + w + 2].blue + buf_p[i + w + 3].blue +
|
||||
buf_p[i + 2 * w].blue + buf_p[i + 2 * w + 1].blue +
|
||||
buf_p[i + 2 * w + 2].blue + buf_p[i + 2 * w + 3].blue +
|
||||
buf_p[i + 3 * w].blue + buf_p[i + 3 * w + 1].blue +
|
||||
buf_p[i + 3 * w + 2].blue + buf_p[i + 3 * w + 3].blue) >>4 ;
|
||||
row_buf_p++;
|
||||
}
|
||||
buf_p += LV_DOWNSCALE * w;
|
||||
|
||||
disp_area(DISP_ID_ALL, vdb.vdb_area.x1 >> 2, y, vdb.vdb_area.x2 >> 2, y);
|
||||
disp_map(DISP_ID_ALL, row_buf);
|
||||
}
|
||||
#else
|
||||
#error "LV: Not supported LV_DOWNSCALE"
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
@ -212,10 +212,7 @@ void lv_img_set_file(lv_obj_t * img, const char * fn)
|
||||
ext->w = header.w;
|
||||
ext->h = header.h;
|
||||
ext->transp = header.transp;
|
||||
#if LV_UPSCALE_MAP != 0
|
||||
ext->w *= LV_DOWNSCALE;
|
||||
ext->h *= LV_DOWNSCALE;
|
||||
#endif
|
||||
|
||||
if(fn != NULL) {
|
||||
ext->fn = dm_realloc(ext->fn, strlen(fn) + 1);
|
||||
strcpy(ext->fn, fn);
|
||||
|
Loading…
x
Reference in New Issue
Block a user