From a514ec1ac76dbf5774dbabb7f9accda770d54115 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Mon, 22 Jan 2024 15:18:42 -0800 Subject: [PATCH] dont submit draws for any empty glyphs --- src/draw/draw.c | 6 +++--- src/font_provider/dwrite/font_provider_dwrite.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/draw/draw.c b/src/draw/draw.c index fb389b7f..1092ffb8 100644 --- a/src/draw/draw.c +++ b/src/draw/draw.c @@ -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); } diff --git a/src/font_provider/dwrite/font_provider_dwrite.cpp b/src/font_provider/dwrite/font_provider_dwrite.cpp index 5684c417..b5980863 100644 --- a/src/font_provider/dwrite/font_provider_dwrite.cpp +++ b/src/font_provider/dwrite/font_provider_dwrite.cpp @@ -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(); }