[repacker] include LookupList size when calculating size of 16bit space for ext promotion decisions.

This commit is contained in:
Garret Rieger 2022-07-25 19:42:58 +00:00
parent e0607af976
commit 9db3beb721
4 changed files with 21 additions and 4 deletions

View File

@ -111,6 +111,10 @@ struct graph_t
return priority >= 3; return priority >= 3;
} }
size_t table_size () const {
return obj.tail - obj.head;
}
int64_t modified_distance (unsigned order) const int64_t modified_distance (unsigned order) const
{ {
// TODO(garretrieger): once priority is high enough, should try // TODO(garretrieger): once priority is high enough, should try

View File

@ -34,11 +34,14 @@ make_extension_context_t::make_extension_context_t (hb_tag_t table_tag_,
: table_tag (table_tag_), : table_tag (table_tag_),
graph (graph_), graph (graph_),
buffer (buffer_), buffer (buffer_),
lookup_list_index (0),
lookups () lookups ()
{ {
GSTAR* gstar = graph::GSTAR::graph_to_gstar (graph_); GSTAR* gstar = graph::GSTAR::graph_to_gstar (graph_);
if (gstar) if (gstar) {
gstar->find_lookups (graph, lookups); gstar->find_lookups (graph, lookups);
lookup_list_index = gstar->get_lookup_list_index (graph_);
}
unsigned extension_size = OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::static_size; unsigned extension_size = OT::ExtensionFormat1<OT::Layout::GSUB_impl::ExtensionSubst>::static_size;
buffer.alloc (num_non_ext_subtables () * extension_size); buffer.alloc (num_non_ext_subtables () * extension_size);

View File

@ -40,6 +40,7 @@ struct make_extension_context_t
hb_tag_t table_tag; hb_tag_t table_tag;
graph_t& graph; graph_t& graph;
hb_vector_t<char>& buffer; hb_vector_t<char>& buffer;
unsigned lookup_list_index;
hb_hashmap_t<unsigned, graph::Lookup*> lookups; hb_hashmap_t<unsigned, graph::Lookup*> lookups;
HB_INTERNAL make_extension_context_t (hb_tag_t table_tag_, HB_INTERNAL make_extension_context_t (hb_tag_t table_tag_,
@ -224,12 +225,17 @@ struct GSTAR : public OT::GSUBGPOS
} }
} }
unsigned get_lookup_list_index (graph_t& graph)
{
return graph.index_for_offset (graph.root_idx (),
get_lookup_list_field_offset());
}
template<typename Types> template<typename Types>
void find_lookups (graph_t& graph, void find_lookups (graph_t& graph,
hb_hashmap_t<unsigned, Lookup*>& lookups /* OUT */) hb_hashmap_t<unsigned, Lookup*>& lookups /* OUT */)
{ {
unsigned lookup_list_idx = graph.index_for_offset (graph.root_idx (), unsigned lookup_list_idx = get_lookup_list_index (graph);
get_lookup_list_field_offset());
const LookupList<Types>* lookupList = const LookupList<Types>* lookupList =
(const LookupList<Types>*) graph.object (lookup_list_idx).head; (const LookupList<Types>*) graph.object (lookup_list_idx).head;

View File

@ -74,6 +74,8 @@ bool _promote_extensions_if_needed (graph::make_extension_context_t& ext_context
// TODO(garretrieger): also support extension promotion during iterative resolution phase, then // TODO(garretrieger): also support extension promotion during iterative resolution phase, then
// we can use a less conservative threshold here. // we can use a less conservative threshold here.
if (!ext_context.lookups) return true;
hb_vector_t<hb_pair_t<unsigned, size_t>> lookup_sizes; hb_vector_t<hb_pair_t<unsigned, size_t>> lookup_sizes;
lookup_sizes.alloc (ext_context.lookups.get_population ()); lookup_sizes.alloc (ext_context.lookups.get_population ());
@ -88,7 +90,9 @@ bool _promote_extensions_if_needed (graph::make_extension_context_t& ext_context
lookup_sizes.qsort (compare_sizes); lookup_sizes.qsort (compare_sizes);
size_t accumlated_bytes = 0; size_t accumlated_bytes =
ext_context.graph.vertices_[ext_context.lookup_list_index].table_size ();
for (auto p : lookup_sizes) for (auto p : lookup_sizes)
{ {
unsigned lookup_index = p.first; unsigned lookup_index = p.first;