mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-21 06:51:01 +01:00
[hvgl] Use a common "scratch" vector
To avoid reallocation.
This commit is contained in:
1 parent
de0e1bddff
commit
a2fc952342
2 files changed
+16
-7
No files matched your search
@@ -76,6 +76,7 @@ PartShape::get_path_at (const struct hvgl &hvgl,
|
||||
hb_draw_session_t &draw_session,
|
||||
hb_array_t<const float> coords,
|
||||
hb_array_t<hb_transform_t> transforms,
|
||||
hb_vector_t<double> &scratch,
|
||||
signed *nodes_left,
|
||||
signed *edges_left,
|
||||
signed depth_left) const
|
||||
@@ -88,7 +89,7 @@ PartShape::get_path_at (const struct hvgl &hvgl,
|
||||
const auto &coordinates = StructAfter<decltype (coordinatesX)> (padding, this);
|
||||
|
||||
auto a = coordinates.get_coords (segmentCount);
|
||||
auto v = hb_vector_t<double> ();
|
||||
auto &v = scratch;
|
||||
|
||||
#ifdef __BYTE_ORDER
|
||||
constexpr bool le = __BYTE_ORDER == __LITTLE_ENDIAN;
|
||||
@@ -101,7 +102,7 @@ PartShape::get_path_at (const struct hvgl &hvgl,
|
||||
if (le)
|
||||
{
|
||||
// Endianness matches; Faster to memcpy().
|
||||
v.resize_exact (a.length, false);
|
||||
v.resize (a.length);
|
||||
memcpy (v.arrayZ, a.arrayZ, v.length * sizeof (a[0]));
|
||||
}
|
||||
else
|
||||
@@ -443,6 +444,7 @@ PartComposite::get_path_at (const struct hvgl &hvgl,
|
||||
hb_draw_session_t &draw_session,
|
||||
hb_array_t<float> coords,
|
||||
hb_array_t<hb_transform_t> transforms,
|
||||
hb_vector_t<double> &scratch,
|
||||
signed *nodes_left,
|
||||
signed *edges_left,
|
||||
signed depth_left) const
|
||||
@@ -479,7 +481,7 @@ PartComposite::get_path_at (const struct hvgl &hvgl,
|
||||
hvgl.get_part_path_at (subPart.partIndex,
|
||||
draw_session, coords_tail.sub_array (subPart.treeAxisIndex),
|
||||
transforms_tail.sub_array (subPart.treeTransformIndex),
|
||||
nodes_left, edges_left, depth_left);
|
||||
scratch, nodes_left, edges_left, depth_left);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +103,7 @@ struct PartShape
|
||||
hb_draw_session_t &draw_session,
|
||||
hb_array_t<const float> coords,
|
||||
hb_array_t<hb_transform_t> transforms,
|
||||
hb_vector_t<double> &scratch,
|
||||
signed *nodes_left,
|
||||
signed *edges_left,
|
||||
signed depth_left) const;
|
||||
@@ -331,6 +332,7 @@ struct PartComposite
|
||||
hb_draw_session_t &draw_session,
|
||||
hb_array_t<float> coords,
|
||||
hb_array_t<hb_transform_t> transforms,
|
||||
hb_vector_t<double> &scratch,
|
||||
signed *nodes_left,
|
||||
signed *edges_left,
|
||||
signed depth_left) const;
|
||||
@@ -407,13 +409,14 @@ struct Part
|
||||
hb_draw_session_t &draw_session,
|
||||
hb_array_t<float> coords,
|
||||
hb_array_t<hb_transform_t> transforms,
|
||||
hb_vector_t<double> &scratch,
|
||||
signed *nodes_left,
|
||||
signed *edges_left,
|
||||
signed depth_left) const
|
||||
{
|
||||
switch (u.flags & 1) {
|
||||
case 0: hb_barrier(); u.shape.get_path_at (hvgl, draw_session, coords, transforms, nodes_left, edges_left, depth_left); break;
|
||||
case 1: hb_barrier(); u.composite.get_path_at (hvgl, draw_session, coords, transforms, nodes_left, edges_left, depth_left); break;
|
||||
case 0: hb_barrier(); u.shape.get_path_at (hvgl, draw_session, coords, transforms, scratch, nodes_left, edges_left, depth_left); break;
|
||||
case 1: hb_barrier(); u.composite.get_path_at (hvgl, draw_session, coords, transforms, scratch, nodes_left, edges_left, depth_left); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,6 +514,7 @@ struct hvgl
|
||||
hb_draw_session_t &draw_session,
|
||||
hb_array_t<float> coords,
|
||||
hb_array_t<hb_transform_t> transforms,
|
||||
hb_vector_t<double> &scratch,
|
||||
signed *nodes_left,
|
||||
signed *edges_left,
|
||||
signed depth_left) const
|
||||
@@ -529,7 +533,7 @@ struct hvgl
|
||||
const auto &parts = StructAtOffset<hvgl_impl::PartsIndex> (this, partsOff);
|
||||
const auto &part = parts.get (part_id, partCount);
|
||||
|
||||
part.get_path_at (*this, draw_session, coords, transforms, nodes_left, edges_left, depth_left);
|
||||
part.get_path_at (*this, draw_session, coords, transforms, scratch, nodes_left, edges_left, depth_left);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -575,7 +579,10 @@ struct hvgl
|
||||
return true;
|
||||
}
|
||||
|
||||
return get_part_path_at (gid, draw_session, coords_f, transforms, &stack_nodes_left, edges_left, depth_left);
|
||||
hb_vector_t<double> scratch;
|
||||
scratch.alloc (128);
|
||||
|
||||
return get_part_path_at (gid, draw_session, coords_f, transforms, scratch, &stack_nodes_left, edges_left, depth_left);
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
Reference in new issue
Block a user