[fontations] Hook up to benchmark-font

This commit is contained in:
Behdad Esfahbod 2025-03-04 18:43:19 -07:00 committed by Khaled Hosny
parent ea5a14f7bc
commit e054db4ae2
3 changed files with 21 additions and 3 deletions

View file

@ -21,7 +21,7 @@ struct test_input_t
static test_input_t *tests = default_tests;
static unsigned num_tests = sizeof (default_tests) / sizeof (default_tests[0]);
enum backend_t { HARFBUZZ, FREETYPE, CORETEXT };
enum backend_t { HARFBUZZ, FREETYPE, FONTATIONS, CORETEXT };
enum operation_t
{
@ -112,6 +112,12 @@ static void BM_Font (benchmark::State &state,
#endif
break;
case FONTATIONS:
#ifdef HAVE_FONTATIONS
hb_fontations_font_set_funcs (font);
#endif
break;
case CORETEXT:
#ifdef HAVE_CORETEXT
hb_coretext_font_set_funcs (font);
@ -216,6 +222,12 @@ static void BM_Font (benchmark::State &state,
#endif
break;
case FONTATIONS:
#ifdef HAVE_FONTATIONS
hb_fontations_font_set_funcs (font);
#endif
break;
case CORETEXT:
#ifdef HAVE_CORETEXT
hb_coretext_font_set_funcs (font);
@ -276,6 +288,9 @@ static void test_operation (operation_t op,
#ifdef HAVE_FREETYPE
test_backend (FREETYPE, "ft", is_var, op, op_name, time_unit, test_input);
#endif
#ifdef HAVE_FONTATIONS
test_backend (FONTATIONS, "fontations", is_var, op, op_name, time_unit, test_input);
#endif
#ifdef HAVE_CORETEXT
test_backend (CORETEXT, "coretext", is_var, op, op_name, time_unit, test_input);
#endif

View file

@ -36,6 +36,9 @@
#ifdef HAVE_FREETYPE
#include <hb-ft.h>
#endif
#ifdef HAVE_FONTATIONS
#include <hb-fontations.h>
#endif
#ifdef HAVE_CORETEXT
#include <hb-coretext.h>
#endif

View file

@ -268,7 +268,7 @@ extern "C" fn _hb_fontations_draw_glyph(
let _ = outline_glyph.draw(draw_settings, &mut pen);
}
fn _hb_fontations_font_funcs_create() -> *mut hb_font_funcs_t {
fn _hb_fontations_font_funcs_get() -> *mut hb_font_funcs_t {
static static_ffuncs: AtomicPtr<hb_font_funcs_t> = AtomicPtr::new(null_mut());
loop {
@ -334,7 +334,7 @@ fn _hb_fontations_font_funcs_create() -> *mut hb_font_funcs_t {
// A helper to attach these funcs to a hb_font_t
#[no_mangle]
pub extern "C" fn hb_fontations_font_set_funcs(font: *mut hb_font_t) {
let ffuncs = _hb_fontations_font_funcs_create();
let ffuncs = _hb_fontations_font_funcs_get();
let face_index = unsafe { hb_face_get_index(hb_font_get_face(font)) };
let face_blob = unsafe { hb_face_reference_blob(hb_font_get_face(font)) };