[subset] use the accelerator in the subsetting benchmark.

This commit is contained in:
Garret Rieger 2022-10-13 21:38:54 +00:00
parent 01481db582
commit f4903defc4
2 changed files with 38 additions and 2 deletions

View File

@ -97,6 +97,40 @@ void AddGlyphs(unsigned num_glyphs_in_font,
} }
} }
// Preprocess face and populate the subset accelerator on it to speed up
// the subsetting operations.
static hb_face_t* preprocess_face(hb_face_t* face)
{
hb_subset_input_t* input = hb_subset_input_create_or_fail ();
hb_set_clear (hb_subset_input_set(input, HB_SUBSET_SETS_UNICODE));
hb_set_invert (hb_subset_input_set(input, HB_SUBSET_SETS_UNICODE));
hb_set_clear (hb_subset_input_set(input,
HB_SUBSET_SETS_LAYOUT_FEATURE_TAG));
hb_set_invert (hb_subset_input_set(input,
HB_SUBSET_SETS_LAYOUT_FEATURE_TAG));
hb_set_clear (hb_subset_input_set(input,
HB_SUBSET_SETS_LAYOUT_SCRIPT_TAG));
hb_set_invert (hb_subset_input_set(input,
HB_SUBSET_SETS_LAYOUT_SCRIPT_TAG));
hb_set_clear (hb_subset_input_set(input,
HB_SUBSET_SETS_NAME_ID));
hb_set_invert (hb_subset_input_set(input,
HB_SUBSET_SETS_NAME_ID));
hb_subset_input_set_flags(input,
HB_SUBSET_FLAGS_ADD_ACCELERATOR_DATA);
hb_face_t* subset = hb_subset_or_fail (face, input);
hb_face_destroy (face);
hb_subset_input_destroy (input);
return subset;
}
/* benchmark for subsetting a font */ /* benchmark for subsetting a font */
static void BM_subset (benchmark::State &state, static void BM_subset (benchmark::State &state,
operation_t operation, operation_t operation,
@ -110,6 +144,8 @@ static void BM_subset (benchmark::State &state,
assert (blob); assert (blob);
face = hb_face_create (blob, 0); face = hb_face_create (blob, 0);
hb_blob_destroy (blob); hb_blob_destroy (blob);
face = preprocess_face (face);
} }
hb_subset_input_t* input = hb_subset_input_create_or_fail (); hb_subset_input_t* input = hb_subset_input_create_or_fail ();

View File

@ -98,8 +98,8 @@ typedef enum { /*< flags >*/
HB_SUBSET_FLAGS_GLYPH_NAMES = 0x00000080u, HB_SUBSET_FLAGS_GLYPH_NAMES = 0x00000080u,
HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES = 0x00000100u, HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES = 0x00000100u,
HB_SUBSET_FLAGS_ADD_ACCELERATOR_DATA = 0x00000200u, HB_SUBSET_FLAGS_ADD_ACCELERATOR_DATA = 0x00000200u,
HB_SUBSET_FLAGS_PATCH_MODE = 0x00000400u, // Not supported yet: HB_SUBSET_FLAGS_PATCH_MODE = 0x00000400u,
HB_SUBSET_FLAGS_OMIT_GLYF = 0x00000800u, // Not supported yet: HB_SUBSET_FLAGS_OMIT_GLYF = 0x00000800u,
} hb_subset_flags_t; } hb_subset_flags_t;
/** /**