[repacker] track estimated coverage size during PairPosFormat1 split point analysis.

This commit is contained in:
Garret Rieger 2022-08-05 22:30:37 +00:00
parent b37e8bef0e
commit dde0a2b071
1 changed files with 12 additions and 10 deletions

View File

@ -53,25 +53,27 @@ struct PairPosFormat1 : public OT::Layout::GPOS_impl::PairPosFormat1_3<SmallType
const unsigned coverage_id = c.graph.index_for_offset (this_index, &coverage); const unsigned coverage_id = c.graph.index_for_offset (this_index, &coverage);
const unsigned coverage_size = c.graph.vertices_[coverage_id].table_size (); const unsigned coverage_size = c.graph.vertices_[coverage_id].table_size ();
const unsigned base_size = OT::Layout::GPOS_impl::PairPosFormat1_3<SmallTypes>::min_size const unsigned base_size = OT::Layout::GPOS_impl::PairPosFormat1_3<SmallTypes>::min_size;
+ coverage_size;
unsigned partial_coverage_size = 4;
unsigned accumulated = base_size; unsigned accumulated = base_size;
hb_vector_t<unsigned> split_points; hb_vector_t<unsigned> split_points;
for (unsigned i = 0; i < pairSet.len; i++) for (unsigned i = 0; i < pairSet.len; i++)
{ {
unsigned pair_set_index = pair_set_graph_index (c, this_index, i); unsigned pair_set_index = pair_set_graph_index (c, this_index, i);
accumulated += c.graph.find_subgraph_size (pair_set_index, visited); unsigned accumulated_delta =
accumulated += SmallTypes::size; // for PairSet offset. c.graph.find_subgraph_size (pair_set_index, visited) +
SmallTypes::size; // for PairSet offset.
partial_coverage_size += OT::HBUINT16::static_size;
// TODO(garretrieger): don't count the size of the largest pairset against the limit, since accumulated += accumulated_delta;
// it will be packed last in the order and does not contribute to unsigned total = accumulated + hb_min (partial_coverage_size, coverage_size);
// the 64kb limit.
if (accumulated > (1 << 16)) if (total >= (1 << 16))
{ {
split_points.push (i); split_points.push (i);
accumulated = base_size; accumulated = base_size + accumulated_delta;
partial_coverage_size = 6;
visited.clear (); // node sharing isn't allowed between splits. visited.clear (); // node sharing isn't allowed between splits.
} }
} }
@ -267,7 +269,7 @@ struct PairPosFormat2 : public OT::Layout::GPOS_impl::PairPosFormat2_4<SmallType
+ coverage_size + class_def_1_size + class_def_2_size + coverage_size + class_def_1_size + class_def_2_size
// The largest object will pack last and can exceed the size limit. // The largest object will pack last and can exceed the size limit.
- hb_max (hb_max (coverage_size, class_def_1_size), class_def_2_size); - hb_max (hb_max (coverage_size, class_def_1_size), class_def_2_size);
if (total > (1 << 16)) if (total >= (1 << 16))
{ {
split_points.push (i); split_points.push (i);
// split does not include i, so add the size for i when we reset the size counters. // split does not include i, so add the size for i when we reset the size counters.