mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-25 17:01:17 +01:00
[depend] Address review feedback: typedef depend contexts, fix fuzzer font set
- ContextDependLookupContext / ChainContextDependLookupContext: replace duplicate struct definitions with typedefs of their Closure counterparts, removing the now-unnecessary reinterpret_casts and layout-identity comments - test/fuzzing/meson.build: switch depend-closure-parity from api_fonts_glob to subset_fonts_glob; remove api_fonts_glob (the fuzzer produces malformed fonts anyway, per behdad review) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
4753f010c6
commit
0cf8d384b5
2 files changed
+12
-32
No files matched your search
@@ -2246,14 +2246,7 @@ struct ContextClosureLookupContext
|
||||
void *intersected_glyphs_cache;
|
||||
};
|
||||
|
||||
struct ContextDependLookupContext
|
||||
{
|
||||
ContextClosureFuncs funcs;
|
||||
ContextFormat context_format;
|
||||
const void *intersects_data;
|
||||
void *intersects_cache;
|
||||
void *intersected_glyphs_cache;
|
||||
};
|
||||
typedef ContextClosureLookupContext ContextDependLookupContext;
|
||||
|
||||
struct ContextCollectGlyphsLookupContext
|
||||
{
|
||||
@@ -2311,11 +2304,9 @@ static inline void context_depend_lookup (hb_depend_context_t *c,
|
||||
unsigned value, /* Index of first glyph in Coverage or Class value in ClassDef table */
|
||||
ContextDependLookupContext &lookup_context)
|
||||
{
|
||||
// ContextDependLookupContext has the same layout as ContextClosureLookupContext
|
||||
auto &closure_lookup_context = reinterpret_cast<ContextClosureLookupContext &>(lookup_context);
|
||||
if (!context_intersects (c->glyphs,
|
||||
inputCount, input,
|
||||
closure_lookup_context))
|
||||
lookup_context))
|
||||
return;
|
||||
|
||||
/* Build preliminary_context (empty for ContextSubst - no backtrack/lookahead) */
|
||||
@@ -2875,7 +2866,7 @@ struct ContextFormat1_4
|
||||
if (unlikely (!cur_active_glyphs)) return;
|
||||
get_coverage ().intersect_set (*c->glyphs, *cur_active_glyphs);
|
||||
|
||||
struct ContextDependLookupContext lookup_context = {
|
||||
ContextDependLookupContext lookup_context = {
|
||||
{intersects_glyph, intersected_glyph},
|
||||
ContextFormat::SimpleContext,
|
||||
nullptr,
|
||||
@@ -3075,7 +3066,7 @@ struct ContextFormat2_5
|
||||
|
||||
hb_map_t cache;
|
||||
intersected_class_cache_t intersected_cache;
|
||||
struct ContextDependLookupContext lookup_context = {
|
||||
ContextDependLookupContext lookup_context = {
|
||||
{intersects_class, intersected_class_glyphs},
|
||||
ContextFormat::ClassBasedContext,
|
||||
&class_def,
|
||||
@@ -3347,7 +3338,7 @@ struct ContextFormat3
|
||||
get_coverage ().intersect_set (*c->glyphs, *cur_active_glyphs);
|
||||
|
||||
const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount));
|
||||
struct ContextDependLookupContext lookup_context = {
|
||||
ContextDependLookupContext lookup_context = {
|
||||
{intersects_coverage, intersected_coverage_glyphs},
|
||||
ContextFormat::CoverageBasedContext,
|
||||
this,
|
||||
@@ -3541,14 +3532,7 @@ struct ChainContextClosureLookupContext
|
||||
void *intersected_glyphs_cache;
|
||||
};
|
||||
|
||||
struct ChainContextDependLookupContext
|
||||
{
|
||||
ContextClosureFuncs funcs;
|
||||
ContextFormat context_format;
|
||||
const void *intersects_data[3];
|
||||
void *intersects_cache[3];
|
||||
void *intersected_glyphs_cache;
|
||||
};
|
||||
typedef ChainContextClosureLookupContext ChainContextDependLookupContext;
|
||||
|
||||
struct ChainContextCollectGlyphsLookupContext
|
||||
{
|
||||
@@ -3632,13 +3616,11 @@ static inline void chain_context_depend_lookup (hb_depend_context_t *c,
|
||||
unsigned value,
|
||||
ChainContextDependLookupContext &lookup_context)
|
||||
{
|
||||
// ChainContextDependLookupContext has the same layout as ChainContextClosureLookupContext
|
||||
auto &closure_lookup_context = reinterpret_cast<ChainContextClosureLookupContext &>(lookup_context);
|
||||
if (!chain_context_intersects (c->glyphs,
|
||||
backtrackCount, backtrack,
|
||||
inputCount, input,
|
||||
lookaheadCount, lookahead,
|
||||
closure_lookup_context))
|
||||
lookup_context))
|
||||
return;
|
||||
|
||||
/* Build context information - extract backtrack and lookahead glyphs */
|
||||
@@ -4354,7 +4336,7 @@ struct ChainContextFormat1_4
|
||||
if (unlikely (!cur_active_glyphs)) return;
|
||||
get_coverage ().intersect_set (*c->glyphs, *cur_active_glyphs);
|
||||
|
||||
struct ChainContextDependLookupContext lookup_context = {
|
||||
ChainContextDependLookupContext lookup_context = {
|
||||
{intersects_glyph, intersected_glyph},
|
||||
ContextFormat::SimpleContext,
|
||||
{nullptr, nullptr, nullptr},
|
||||
@@ -4558,7 +4540,7 @@ struct ChainContextFormat2_5
|
||||
|
||||
hb_map_t caches[3] = {};
|
||||
intersected_class_cache_t intersected_cache;
|
||||
struct ChainContextDependLookupContext lookup_context = {
|
||||
ChainContextDependLookupContext lookup_context = {
|
||||
{intersects_class, intersected_class_glyphs},
|
||||
ContextFormat::ClassBasedContext,
|
||||
{&backtrack_class_def,
|
||||
@@ -4893,7 +4875,7 @@ struct ChainContextFormat3
|
||||
|
||||
const auto &lookahead = StructAfter<decltype (lookaheadX)> (input);
|
||||
const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
|
||||
struct ChainContextDependLookupContext lookup_context = {
|
||||
ChainContextDependLookupContext lookup_context = {
|
||||
{intersects_coverage, intersected_coverage_glyphs},
|
||||
ContextFormat::CoverageBasedContext,
|
||||
{this, this, this},
|
||||
|
||||
@@ -121,12 +121,10 @@ glob_cmd = find_program('glob.py', required: true)
|
||||
fonts_glob = run_command(glob_cmd, meson.current_source_dir() / 'fonts', check:true).stdout().strip().split('\n')
|
||||
subset_fonts_glob = run_command(glob_cmd, meson.current_source_dir() / '..' / 'subset' / 'data' / 'fonts', check:true).stdout().strip().split('\n')
|
||||
graphs_glob = run_command(glob_cmd, meson.current_source_dir() / 'graphs', check:true).stdout().strip().split('\n')
|
||||
# Use well-formed API test fonts for depend fuzzer (not malformed clusterfuzz fonts)
|
||||
api_fonts_glob = run_command(glob_cmd, meson.current_source_dir() / '..' / 'api' / 'fonts', check:true).stdout().strip().split('\n')
|
||||
|
||||
# Chunk the glob lists to avoid command line length limits, and for parallelization
|
||||
chunk_size = 64
|
||||
foreach glob_name : ['fonts_glob', 'subset_fonts_glob', 'graphs_glob', 'api_fonts_glob']
|
||||
foreach glob_name : ['fonts_glob', 'subset_fonts_glob', 'graphs_glob']
|
||||
glob = get_variable(glob_name)
|
||||
chunks = []
|
||||
chunk = []
|
||||
@@ -229,7 +227,7 @@ endif
|
||||
|
||||
if conf.get('HB_EXPERIMENTAL_API', 0) == 1
|
||||
i = 0
|
||||
foreach chunk : api_fonts_glob_chunks
|
||||
foreach chunk : subset_fonts_glob_chunks
|
||||
test('depend-closure-parity-chunk-@0@'.format(i),
|
||||
hb_depend_closure_parity_exe,
|
||||
args: ['-s', '42'] + chunk,
|
||||
|
||||
Reference in new issue
Block a user