[repacker] put each 32 bit subgraph into it's own packing space.
Each subgraph pointed to by a 32 bit offset should be packed into it's own space. This adds a space property to vertices which affects the distance calculation. This effectively places the distances for all of the nodes of a 32 bit subgraph into a distinct range. Thus all of the nodes of the subgraph will be packed together.
diff --git a/src/hb-repacker.hh b/src/hb-repacker.hh
index 97b902a..4523601 100644
--- a/src/hb-repacker.hh
+++ b/src/hb-repacker.hh
@@ -40,6 +40,7 @@
{
vertex_t () :
distance (0),
+ space (1),
incoming_edges (0),
start (0),
end (0),
@@ -49,6 +50,7 @@
hb_serialize_context_t::object_t obj;
int64_t distance;
+ int64_t space;
unsigned incoming_edges;
unsigned start;
unsigned end;
@@ -336,6 +338,7 @@
bool made_changes = false;
hb_set_t target_links;
unsigned root_index = root_idx ();
+ int64_t next_space = 1;
for (unsigned i = 0; i <= root_index; i++)
{
if (i == root_index && root_idx () > i)
@@ -345,7 +348,12 @@
for (auto& l : vertices_[i].obj.links)
{
if (l.width == 4 && !l.is_signed)
- made_changes = isolate_subgraph (l.objidx) || made_changes;
+ {
+ isolate_subgraph (l.objidx);
+ vertices_[l.objidx].space = next_space++;
+ distance_invalid = true;
+ made_changes = true;
+ }
}
}
return made_changes;
@@ -635,7 +643,7 @@
const auto& child = vertices_[link.objidx].obj;
int64_t child_weight = child.tail - child.head +
- ((int64_t) 1 << (link.width * 8));
+ ((int64_t) 1 << (link.width * 8)) * vertices_[link.objidx].space;
int64_t child_distance = next_distance + child_weight;
if (child_distance < vertices_[link.objidx].distance)
diff --git a/src/test-repacker.cc b/src/test-repacker.cc
index 4d2f347..eb5447d 100644
--- a/src/test-repacker.cc
+++ b/src/test-repacker.cc
@@ -520,6 +520,9 @@
free (out_buffer);
}
+// TODO(grieger): test for recursively duplicated nodes during isolation.
+// TODO(grieger): test that isolated subgraphs are packed tightly within the subgraph.
+
// TODO(garretrieger): update will_overflow tests to check the overflows array.
// TODO(garretrieger): add a test(s) using a real font.
// TODO(garretrieger): add tests for priority raising.