From bbe14417ad7fcc80b49d0e8426ad757fc7689ccc Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Thu, 11 Aug 2022 22:53:30 +0000 Subject: [PATCH] [repacker] Begin implementing MarkBasePosFormat1::shrink. --- src/graph/markbasepos-graph.hh | 72 ++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/src/graph/markbasepos-graph.hh b/src/graph/markbasepos-graph.hh index 652dc2d92..c269fba97 100644 --- a/src/graph/markbasepos-graph.hh +++ b/src/graph/markbasepos-graph.hh @@ -204,6 +204,18 @@ struct MarkBasePosFormat1 : public OT::Layout::GPOS_impl::MarkBasePosFormat1_2 mark_array_links; hb_hashmap_t base_array_links; + hb_set_t marks_for (unsigned start, unsigned end) + { + hb_set_t marks; + for (unsigned klass = start; klass < end; klass++) + { + + class_to_info[klass].marks.iter () + | hb_sink (marks) + ; + } + return marks; + } + unsigned original_count () { return thiz->classCount; @@ -259,37 +271,38 @@ struct MarkBasePosFormat1 : public OT::Layout::GPOS_impl::MarkBasePosFormat1_2= old_count) return true; - pairSet.len = count; - c.graph.vertices_[this_index].obj.tail -= (old_count - count) * SmallTypes::size; + classCount = count; - unsigned coverage_id = c.graph.mutable_index_for_offset (this_index, &coverage); - unsigned coverage_size = c.graph.vertices_[coverage_id].table_size (); - auto& coverage_v = c.graph.vertices_[coverage_id]; - - Coverage* coverage_table = (Coverage*) coverage_v.obj.head; - if (!coverage_table || !coverage_table->sanitize (coverage_v)) + auto mark_coverage = sc.c.graph.as_table (this_index, + &markCoverage); + if (!mark_coverage) return false; + hb_set_t marks = sc.marks_for (0, count); + auto new_coverage = + + hb_zip (hb_range (), mark_coverage.table->iter ()) + | hb_filter (marks, hb_first) + | hb_map_retains_sorting (hb_second) + ; + if (!Coverage::make_coverage (sc.c, + new_coverage, + mark_coverage.index, + 4 + 2 * marks.get_population ())) return false; - auto new_coverage = - + hb_zip (coverage_table->iter (), hb_range ()) - | hb_filter ([&] (hb_pair_t p) { - return p.second < count; - }) - | hb_map_retains_sorting (hb_first) - ; + // TODO: markArray, baseArray + /* + return Coverage::make_coverage (c, new_coverage, coverage_id, coverage_size); */ @@ -305,8 +318,6 @@ struct MarkBasePosFormat1 : public OT::Layout::GPOS_impl::MarkBasePosFormat1_2::static_size; @@ -322,18 +333,19 @@ struct MarkBasePosFormat1 : public OT::Layout::GPOS_impl::MarkBasePosFormat1_2baseCoverage), prime_id, base_coverage_id); graph.duplicate (prime_id, base_coverage_id); - hb_set_t marks; - for (unsigned klass = start; klass < end; klass++) - { - + sc.class_to_info[klass].marks.iter () - | hb_sink (marks) - ; - } - + auto mark_coverage = sc.c.graph.as_table (this_index, + &markCoverage); + if (!mark_coverage) return false; + hb_set_t marks = sc.marks_for (start, end); + auto new_coverage = + + hb_zip (hb_range (), mark_coverage.table->iter ()) + | hb_filter (marks, hb_first) + | hb_map_retains_sorting (hb_second) + ; if (!Coverage::add_coverage (sc.c, prime_id, 2, - + marks.iter (), + + new_coverage, marks.get_population () * 2 + 4)) return -1;