LV_FONT_ANTIALIAS added

This commit is contained in:
Kiss-Vamosi Gabor
2017-03-20 07:07:05 +01:00
parent 1696d77516
commit 7f49404d62
8 changed files with 92 additions and 32 deletions

View File

@@ -2,7 +2,15 @@
* @file lv_vdraw.c
*
*/
#include "lv_conf.h"
#include <lv_conf.h>
#include <lvgl/lv_misc/area.h>
#include <lvgl/lv_misc/font.h>
#include <misc/others/color.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#if LV_VDB_SIZE != 0
#include <stddef.h>
@@ -140,10 +148,12 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
uint8_t col_bit;
uint8_t col_byte_cnt;
/* Calculate the col/row start/end on the map
* If font anti alaiassing is enabled use the reduced letter sizes*/
cord_t col_start = pos_p->x > mask_p->x1 ? 0 : mask_p->x1 - pos_p->x;
cord_t col_end = pos_p->x + letter_w < mask_p->x2 ? letter_w : mask_p->x2 - pos_p->x + 1;
cord_t col_end = pos_p->x + (letter_w >> LV_FONT_ANTIALIAS) < mask_p->x2 ? (letter_w >> LV_FONT_ANTIALIAS) : mask_p->x2 - pos_p->x + 1;
cord_t row_start = pos_p->y > mask_p->y1 ? 0 : mask_p->y1 - pos_p->y;
cord_t row_end = pos_p->y + letter_h < mask_p->y2 ? letter_h : mask_p->y2 - pos_p->y + 1;
cord_t row_end = pos_p->y + (letter_h >> LV_FONT_ANTIALIAS) < mask_p->y2 ? (letter_h >> LV_FONT_ANTIALIAS) : mask_p->y2 - pos_p->y + 1;
/*Set a pointer on VDB to the first pixel of the letter*/
vdb_buf_tmp += ((pos_p->y - vdb_p->vdb_area.y1) * vdb_width)
@@ -153,8 +163,53 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
vdb_buf_tmp += (row_start * vdb_width) + col_start;
/*Move on the map too*/
map_p += (row_start * font_p->width_byte) + (col_start>>3);
map_p += ((row_start << LV_FONT_ANTIALIAS) * font_p->width_byte) + ((col_start << LV_FONT_ANTIALIAS) >> 3);
#if LV_FONT_ANTIALIAS != 0
const uint8_t * map1_p = map_p;
const uint8_t * map2_p = map_p + font_p->width_byte;
uint8_t px_cnt;
for(row = row_start; row < row_end; row ++) {
col_byte_cnt = 0;
col_bit = 7 - ((col_start << LV_FONT_ANTIALIAS) % 8);
for(col = col_start; col < col_end; col ++) {
px_cnt = 0;
if((*map1_p & (1 << col_bit)) != 0) px_cnt++;
if((*map2_p & (1 << col_bit)) != 0) px_cnt++;
if(col_bit != 0) col_bit --;
else {
col_bit = 7;
col_byte_cnt ++;
map1_p ++;
map2_p ++;
}
if((*map1_p & (1 << col_bit)) != 0) px_cnt++;
if((*map2_p & (1 << col_bit)) != 0) px_cnt++;
if(col_bit != 0) col_bit --;
else {
col_bit = 7;
col_byte_cnt ++;
map1_p ++;
map2_p ++;
}
if(px_cnt != 0) {
if(opa == OPA_COVER) *vdb_buf_tmp = color_mix(color, *vdb_buf_tmp, 63*px_cnt);
else *vdb_buf_tmp = color_mix(color, *vdb_buf_tmp, opa);
}
vdb_buf_tmp++;
}
map1_p += font_p->width_byte;
map2_p += font_p->width_byte;
map1_p += font_p->width_byte - col_byte_cnt;
map2_p += font_p->width_byte - col_byte_cnt;
vdb_buf_tmp += vdb_width - ((col_end) - (col_start)); /*Next row in VDB*/
}
#else
for(row = row_start; row < row_end; row ++) {
col_byte_cnt = 0;
col_bit = 7 - (col_start % 8);
@@ -164,9 +219,9 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
if(opa == OPA_COVER) *vdb_buf_tmp = color;
else *vdb_buf_tmp = color_mix(color, *vdb_buf_tmp, opa);
}
vdb_buf_tmp++;
/*Use a col. more times depending on LV_UPSCALE_FONT*/
vdb_buf_tmp++;
if(col_bit != 0) col_bit --;
else {
col_bit = 7;
@@ -178,6 +233,7 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
map_p += font_p->width_byte - col_byte_cnt;
vdb_buf_tmp += vdb_width - (col_end - col_start); /*Next row in VDB*/
}
#endif
}
/**