根据林伟大佬的优化方式进行了合并比较

来源在此:https://www.zhihu.com/question/264505093/answer/281849883
This commit is contained in:
anod 2022-10-15 07:36:59 +08:00
parent 479e6eb9cc
commit c1e79ef7a8
3 changed files with 5 additions and 3 deletions

View File

@ -292,7 +292,8 @@ static int render_unicode(FHandle fd, int *x, unsigned width, unsigned height, u
for (int j = 0; j < bbx[0]; ++j) for (int j = 0; j < bbx[0]; ++j)
{ {
int tx = cx+j, ty = cy-i; int tx = cx+j, ty = cy-i;
if( 0 <= ty && ty < (int)height && 0 <= tx && tx < (int)width ) // see: https://www.zhihu.com/question/264505093/answer/281849883
if( ( tx | ((int)width-tx) | ty | ((int)height-ty) ) > 0 ) // 0 <= tx && tx < width && 0 <= ty && ty <= height
{ {
if( BIT_AT_POS(glyph, bbx[0] * i + j) ) if( BIT_AT_POS(glyph, bbx[0] * i + j) )
{ {

View File

@ -34,7 +34,9 @@ static void set_screen_color( acf_callerdata_t data, acf_position_t tx, acf_posi
int x = tx + draw_data[0]; int x = tx + draw_data[0];
int y = ty + draw_data[1]; int y = ty + draw_data[1];
if( 0 <= x && x < draw_data[2] && 0 <= y && y < draw_data[3] )
// see: https://www.zhihu.com/question/264505093/answer/281849883
if( ( x | (draw_data[2]-x) | y | (draw_data[3]-y) ) > 0 ) // 0 <= x && x < draw_data[2] && 0 <= y && y < draw_data[3]
{ {
frame[ x*draw_data[3] + (draw_data[3]-1-y) ] = (u16)draw_data[4]; frame[ x*draw_data[3] + (draw_data[3]-1-y) ] = (u16)draw_data[4];
} }

View File

@ -224,7 +224,6 @@ Result browseFiles(const char *const basePath, char selected[512])
break; break;
} }
} }
screenClean();
end: end:
free(dList); free(dList);