dont submit draws for any empty glyphs

This commit is contained in:
Ryan Fleury
2024-01-22 15:18:42 -08:00
parent 68eacca361
commit a514ec1ac7
2 changed files with 9 additions and 4 deletions
+3 -3
View File
@@ -528,7 +528,7 @@ d_text_run(Vec2F32 p, Vec4F32 color, F_Run run)
p.y + piece->offset.y,
p.x + piece->offset.x + advance + size.x,
p.y + piece->offset.y + size.y);
if(!r_handle_match(texture, r_handle_zero()))
if(size.x != 0 && size.y != 0 && !r_handle_match(texture, r_handle_zero()))
{
d_img(dst, src, texture, color, 0, 0, 0);
}
@@ -598,7 +598,7 @@ d_truncated_text_run(Vec2F32 p, Vec4F32 color, F32 max_x, F_Run text_run, F_Run
p.y + piece->offset.y,
p.x + piece->offset.x + advance + size.x,
p.y + piece->offset.y + size.y);
if(!r_handle_match(texture, r_handle_zero()))
if(size.x != 0 && size.y != 0 && !r_handle_match(texture, r_handle_zero()))
{
d_img(dst, src, texture, color, 0, 0, 0);
}
@@ -625,7 +625,7 @@ d_truncated_text_run(Vec2F32 p, Vec4F32 color, F32 max_x, F_Run text_run, F_Run
ellipses_p.y + piece->offset.y,
ellipses_p.x + piece->offset.x + advance + size.x,
ellipses_p.y + piece->offset.y + size.y);
if(!r_handle_match(texture, r_handle_zero()))
if(size.x != 0 && size.y != 0 && !r_handle_match(texture, r_handle_zero()))
{
d_img(dst, src, texture, ellipses_color, 0, 0, 0);
}
@@ -420,7 +420,7 @@ fp_raster(Arena *arena, FP_Handle font_handle, F32 size, FP_RasterMode mode, Str
U64 in_pitch = (U64)dib.dsBm.bmWidthBytes;
U8 *out_data = (U8 *)result.atlas;
U64 out_pitch = atlas_dim.x * 4;
U64 color_sum = 0;
U8 *in_line = (U8 *)in_data;
U8 *out_line = out_data;
for(U64 y = 0; y < atlas_dim.y; y += 1)
@@ -434,12 +434,17 @@ fp_raster(Arena *arena, FP_Handle font_handle, F32 size, FP_RasterMode mode, Str
out_pixel[1] = 255;
out_pixel[2] = 255;
out_pixel[3] = in_pixel_byte;
color_sum += in_pixel_byte;
in_pixel += 4;
out_pixel += 4;
}
in_line += in_pitch;
out_line += out_pitch;
}
if(color_sum == 0)
{
result.atlas_dim = v2s16(0, 0);
}
}
render_target->Release();
}