mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-12-01 10:34:23 +01:00
[tuplevar] Use pool for duplicating
This commit is contained in:
1 parent
53243ad27e
commit
f5fdf42615
3 files changed
+33
-11
No files matched your search
+21
-6
@@ -261,7 +261,7 @@ struct tuple_delta_t
|
||||
hb_vector_t<F2DOT14> compiled_peak_coords;
|
||||
hb_vector_t<F2DOT14> compiled_interm_coords;
|
||||
|
||||
tuple_delta_t () = default;
|
||||
tuple_delta_t (hb_alloc_pool_t *pool = nullptr) {}
|
||||
tuple_delta_t (const tuple_delta_t& o) = default;
|
||||
tuple_delta_t& operator = (const tuple_delta_t& o) = default;
|
||||
|
||||
@@ -285,6 +285,18 @@ struct tuple_delta_t
|
||||
return *this;
|
||||
}
|
||||
|
||||
void copy_from (const tuple_delta_t& o, hb_alloc_pool_t *pool = nullptr)
|
||||
{
|
||||
axis_tuples = o.axis_tuples;
|
||||
indices.allocate_from_pool (pool, o.indices);
|
||||
deltas_x.allocate_from_pool (pool, o.deltas_x);
|
||||
deltas_y.allocate_from_pool (pool, o.deltas_y);
|
||||
compiled_tuple_header.allocate_from_pool (pool, o.compiled_tuple_header);
|
||||
compiled_deltas.allocate_from_pool (pool, o.compiled_deltas);
|
||||
compiled_peak_coords.allocate_from_pool (pool, o.compiled_peak_coords);
|
||||
compiled_interm_coords.allocate_from_pool (pool, o.compiled_interm_coords);
|
||||
}
|
||||
|
||||
void remove_axis (hb_tag_t axis_tag)
|
||||
{ axis_tuples.del (axis_tag); }
|
||||
|
||||
@@ -342,7 +354,8 @@ struct tuple_delta_t
|
||||
void change_tuple_var_axis_limit (hb_tag_t axis_tag, Triple axis_limit,
|
||||
TripleDistances axis_triple_distances,
|
||||
hb_vector_t<tuple_delta_t>& out,
|
||||
rebase_tent_result_scratch_t &scratch)
|
||||
rebase_tent_result_scratch_t &scratch,
|
||||
hb_alloc_pool_t *pool = nullptr)
|
||||
{
|
||||
// May move *this out.
|
||||
|
||||
@@ -372,7 +385,7 @@ struct tuple_delta_t
|
||||
|
||||
tuple_delta_t new_var;
|
||||
if (i < solutions.length - 1)
|
||||
new_var = *this;
|
||||
new_var.copy_from (*this, pool);
|
||||
else
|
||||
new_var = std::move (*this);
|
||||
|
||||
@@ -1064,7 +1077,8 @@ struct TupleVariationData
|
||||
}
|
||||
|
||||
bool change_tuple_variations_axis_limits (const hb_hashmap_t<hb_tag_t, Triple>& normalized_axes_location,
|
||||
const hb_hashmap_t<hb_tag_t, TripleDistances>& axes_triple_distances)
|
||||
const hb_hashmap_t<hb_tag_t, TripleDistances>& axes_triple_distances,
|
||||
hb_alloc_pool_t *pool = nullptr)
|
||||
{
|
||||
/* sort axis_tag/axis_limits, make result deterministic */
|
||||
hb_vector_t<hb_tag_t> axis_tags;
|
||||
@@ -1091,7 +1105,7 @@ struct TupleVariationData
|
||||
for (tuple_delta_t& var : tuple_vars)
|
||||
{
|
||||
// This may move var out.
|
||||
var.change_tuple_var_axis_limit (axis_tag, *axis_limit, axis_triple_distances, out, scratch);
|
||||
var.change_tuple_var_axis_limit (axis_tag, *axis_limit, axis_triple_distances, out, scratch, pool);
|
||||
if (!out) continue;
|
||||
|
||||
unsigned new_len = new_vars.length + out.length;
|
||||
@@ -1232,11 +1246,12 @@ struct TupleVariationData
|
||||
bool instantiate (const hb_hashmap_t<hb_tag_t, Triple>& normalized_axes_location,
|
||||
const hb_hashmap_t<hb_tag_t, TripleDistances>& axes_triple_distances,
|
||||
optimize_scratch_t &scratch,
|
||||
hb_alloc_pool_t *pool = nullptr,
|
||||
contour_point_vector_t* contour_points = nullptr,
|
||||
bool optimize = false)
|
||||
{
|
||||
if (!tuple_vars) return true;
|
||||
if (!change_tuple_variations_axis_limits (normalized_axes_location, axes_triple_distances))
|
||||
if (!change_tuple_variations_axis_limits (normalized_axes_location, axes_triple_distances, pool))
|
||||
return false;
|
||||
/* compute inferred deltas only for gvar */
|
||||
if (contour_points)
|
||||
|
||||
@@ -150,7 +150,7 @@ struct glyph_variations_t
|
||||
contour_point_vector_t *all_points;
|
||||
if (!plan->new_gid_contour_points_map.has (new_gid, &all_points))
|
||||
return false;
|
||||
if (!glyph_variations[i].instantiate (plan->axes_location, plan->axes_triple_distances, scratch, all_points, iup_optimize))
|
||||
if (!glyph_variations[i].instantiate (plan->axes_location, plan->axes_triple_distances, scratch, &pool, all_points, iup_optimize))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
+11
-4
@@ -417,7 +417,6 @@ struct hb_vector_t
|
||||
void
|
||||
copy_array (hb_array_t<Type> other)
|
||||
{
|
||||
assert ((int) (length + other.length) <= allocated);
|
||||
hb_memcpy ((void *) (arrayZ + length), (const void *) other.arrayZ, other.length * item_size);
|
||||
length += other.length;
|
||||
}
|
||||
@@ -426,7 +425,6 @@ struct hb_vector_t
|
||||
void
|
||||
copy_array (hb_array_t<const Type> other)
|
||||
{
|
||||
assert ((int) (length + other.length) <= allocated);
|
||||
hb_memcpy ((void *) (arrayZ + length), (const void *) other.arrayZ, other.length * item_size);
|
||||
length += other.length;
|
||||
}
|
||||
@@ -436,7 +434,6 @@ struct hb_vector_t
|
||||
void
|
||||
copy_array (hb_array_t<const Type> other)
|
||||
{
|
||||
assert ((int) (length + other.length) <= allocated);
|
||||
for (unsigned i = 0; i < other.length; i++)
|
||||
new (std::addressof (arrayZ[length + i])) Type (other.arrayZ[i]);
|
||||
length += other.length;
|
||||
@@ -449,7 +446,6 @@ struct hb_vector_t
|
||||
void
|
||||
copy_array (hb_array_t<const Type> other)
|
||||
{
|
||||
assert ((int) (length + other.length) <= allocated);
|
||||
for (unsigned i = 0; i < other.length; i++)
|
||||
{
|
||||
new (std::addressof (arrayZ[length + i])) Type ();
|
||||
@@ -572,6 +568,17 @@ struct hb_vector_t
|
||||
return resize_full ((int) size, initialize, true);
|
||||
}
|
||||
|
||||
template <typename allocator_t>
|
||||
HB_ALWAYS_INLINE_VECTOR_ALLOCS
|
||||
bool allocate_from_pool (allocator_t *allocator, const hb_vector_t &other)
|
||||
{
|
||||
if (unlikely (!allocate_from_pool (allocator, other.length, false)))
|
||||
return false;
|
||||
length = 0;
|
||||
copy_array (other.as_array ());
|
||||
return true;
|
||||
}
|
||||
|
||||
HB_ALWAYS_INLINE_VECTOR_ALLOCS
|
||||
bool resize_full (int size_, bool initialize, bool exact)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user