[subset] Rename src_base args to base to match sanitize methods
So it will become easier to follow that serialize methods signatures should match with their sanitize methods counterparts.
This commit is contained in:
parent
188a0a47c2
commit
07acd1a042
|
@ -313,10 +313,8 @@ struct OffsetTo : Offset<OffsetType, has_null>
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ...Ts>
|
template <typename ...Ts>
|
||||||
bool serialize_subset (hb_subset_context_t *c,
|
bool serialize_subset (hb_subset_context_t *c, const OffsetTo& src,
|
||||||
const OffsetTo& src,
|
const void *src_base, Ts&&... ds)
|
||||||
const void *src_base,
|
|
||||||
Ts&&... ds)
|
|
||||||
{
|
{
|
||||||
*this = 0;
|
*this = 0;
|
||||||
if (src.is_null ())
|
if (src.is_null ())
|
||||||
|
@ -341,10 +339,8 @@ struct OffsetTo : Offset<OffsetType, has_null>
|
||||||
* Can't compile: whence = hb_serialize_context_t::Head followed by Ts&&...
|
* Can't compile: whence = hb_serialize_context_t::Head followed by Ts&&...
|
||||||
*/
|
*/
|
||||||
template <typename ...Ts>
|
template <typename ...Ts>
|
||||||
bool serialize_copy (hb_serialize_context_t *c,
|
bool serialize_copy (hb_serialize_context_t *c, const OffsetTo& src,
|
||||||
const OffsetTo& src,
|
const void *src_base, unsigned dst_bias,
|
||||||
const void *src_base,
|
|
||||||
unsigned dst_bias,
|
|
||||||
hb_serialize_context_t::whence_t whence,
|
hb_serialize_context_t::whence_t whence,
|
||||||
Ts&&... ds)
|
Ts&&... ds)
|
||||||
{
|
{
|
||||||
|
@ -361,10 +357,8 @@ struct OffsetTo : Offset<OffsetType, has_null>
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool serialize_copy (hb_serialize_context_t *c,
|
bool serialize_copy (hb_serialize_context_t *c, const OffsetTo& src,
|
||||||
const OffsetTo& src,
|
const void *src_base, unsigned dst_bias = 0)
|
||||||
const void *src_base,
|
|
||||||
unsigned dst_bias = 0)
|
|
||||||
{ return serialize_copy (c, src, src_base, dst_bias, hb_serialize_context_t::Head); }
|
{ return serialize_copy (c, src, src_base, dst_bias, hb_serialize_context_t::Head); }
|
||||||
|
|
||||||
bool sanitize_shallow (hb_sanitize_context_t *c, const void *base) const
|
bool sanitize_shallow (hb_sanitize_context_t *c, const void *base) const
|
||||||
|
|
|
@ -892,7 +892,7 @@ struct VariationSelectorRecord
|
||||||
const hb_set_t *unicodes,
|
const hb_set_t *unicodes,
|
||||||
const hb_set_t *glyphs,
|
const hb_set_t *glyphs,
|
||||||
const hb_map_t *glyph_map,
|
const hb_map_t *glyph_map,
|
||||||
const void *src_base) const
|
const void *base) const
|
||||||
{
|
{
|
||||||
auto snap = c->snapshot ();
|
auto snap = c->snapshot ();
|
||||||
auto *out = c->embed<VariationSelectorRecord> (*this);
|
auto *out = c->embed<VariationSelectorRecord> (*this);
|
||||||
|
@ -905,7 +905,7 @@ struct VariationSelectorRecord
|
||||||
if (nonDefaultUVS != 0)
|
if (nonDefaultUVS != 0)
|
||||||
{
|
{
|
||||||
c->push ();
|
c->push ();
|
||||||
if (c->copy (src_base+nonDefaultUVS, unicodes, glyphs, glyph_map))
|
if (c->copy (base+nonDefaultUVS, unicodes, glyphs, glyph_map))
|
||||||
non_default_uvs_objidx = c->pop_pack ();
|
non_default_uvs_objidx = c->pop_pack ();
|
||||||
else c->pop_discard ();
|
else c->pop_discard ();
|
||||||
}
|
}
|
||||||
|
@ -914,7 +914,7 @@ struct VariationSelectorRecord
|
||||||
if (defaultUVS != 0)
|
if (defaultUVS != 0)
|
||||||
{
|
{
|
||||||
c->push ();
|
c->push ();
|
||||||
if (c->copy (src_base+defaultUVS, unicodes))
|
if (c->copy (base+defaultUVS, unicodes))
|
||||||
default_uvs_objidx = c->pop_pack ();
|
default_uvs_objidx = c->pop_pack ();
|
||||||
else c->pop_discard ();
|
else c->pop_discard ();
|
||||||
}
|
}
|
||||||
|
@ -956,7 +956,7 @@ struct CmapSubtableFormat14
|
||||||
const hb_set_t *unicodes,
|
const hb_set_t *unicodes,
|
||||||
const hb_set_t *glyphs,
|
const hb_set_t *glyphs,
|
||||||
const hb_map_t *glyph_map,
|
const hb_map_t *glyph_map,
|
||||||
const void *src_base)
|
const void *base)
|
||||||
{
|
{
|
||||||
auto snap = c->snapshot ();
|
auto snap = c->snapshot ();
|
||||||
unsigned table_initpos = c->length ();
|
unsigned table_initpos = c->length ();
|
||||||
|
@ -965,7 +965,7 @@ struct CmapSubtableFormat14
|
||||||
if (unlikely (!c->extend_min (*this))) return;
|
if (unlikely (!c->extend_min (*this))) return;
|
||||||
this->format = 14;
|
this->format = 14;
|
||||||
|
|
||||||
auto src_tbl = reinterpret_cast<const CmapSubtableFormat14*> (src_base);
|
auto src_tbl = reinterpret_cast<const CmapSubtableFormat14*> (base);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some versions of OTS require that offsets are in order. Due to the use
|
* Some versions of OTS require that offsets are in order. Due to the use
|
||||||
|
@ -983,8 +983,7 @@ struct CmapSubtableFormat14
|
||||||
hb_vector_t<hb_pair_t<unsigned, unsigned>> obj_indices;
|
hb_vector_t<hb_pair_t<unsigned, unsigned>> obj_indices;
|
||||||
for (int i = src_tbl->record.len - 1; i >= 0; i--)
|
for (int i = src_tbl->record.len - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
hb_pair_t<unsigned, unsigned> result =
|
hb_pair_t<unsigned, unsigned> result = src_tbl->record[i].copy (c, unicodes, glyphs, glyph_map, base);
|
||||||
src_tbl->record[i].copy (c, unicodes, glyphs, glyph_map, src_base);
|
|
||||||
if (result.first || result.second)
|
if (result.first || result.second)
|
||||||
obj_indices.push (result);
|
obj_indices.push (result);
|
||||||
}
|
}
|
||||||
|
@ -1102,12 +1101,12 @@ struct CmapSubtable
|
||||||
Iterator it,
|
Iterator it,
|
||||||
unsigned format,
|
unsigned format,
|
||||||
const hb_subset_plan_t *plan,
|
const hb_subset_plan_t *plan,
|
||||||
const void *src_base)
|
const void *base)
|
||||||
{
|
{
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case 4: u.format4.serialize (c, it); return;
|
case 4: return u.format4.serialize (c, it);
|
||||||
case 12: u.format12.serialize (c, it); return;
|
case 12: return u.format12.serialize (c, it);
|
||||||
case 14: u.format14.serialize (c, plan->unicodes, plan->_glyphset, plan->glyph_map, src_base); return;
|
case 14: return u.format14.serialize (c, plan->unicodes, plan->_glyphset, plan->glyph_map, base);
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1168,7 +1167,7 @@ struct EncodingRecord
|
||||||
EncodingRecord* copy (hb_serialize_context_t *c,
|
EncodingRecord* copy (hb_serialize_context_t *c,
|
||||||
Iterator it,
|
Iterator it,
|
||||||
unsigned format,
|
unsigned format,
|
||||||
const void *src_base,
|
const void *base,
|
||||||
const hb_subset_plan_t *plan,
|
const hb_subset_plan_t *plan,
|
||||||
/* INOUT */ unsigned *objidx) const
|
/* INOUT */ unsigned *objidx) const
|
||||||
{
|
{
|
||||||
|
@ -1182,7 +1181,7 @@ struct EncodingRecord
|
||||||
{
|
{
|
||||||
CmapSubtable *cmapsubtable = c->push<CmapSubtable> ();
|
CmapSubtable *cmapsubtable = c->push<CmapSubtable> ();
|
||||||
unsigned origin_length = c->length ();
|
unsigned origin_length = c->length ();
|
||||||
cmapsubtable->serialize (c, it, format, plan, &(src_base+subtable));
|
cmapsubtable->serialize (c, it, format, plan, &(base+subtable));
|
||||||
if (c->length () - origin_length > 0) *objidx = c->pop_pack ();
|
if (c->length () - origin_length > 0) *objidx = c->pop_pack ();
|
||||||
else c->pop_discard ();
|
else c->pop_discard ();
|
||||||
}
|
}
|
||||||
|
@ -1214,7 +1213,7 @@ struct cmap
|
||||||
void serialize (hb_serialize_context_t *c,
|
void serialize (hb_serialize_context_t *c,
|
||||||
Iterator it,
|
Iterator it,
|
||||||
EncodingRecIter encodingrec_iter,
|
EncodingRecIter encodingrec_iter,
|
||||||
const void *src_base,
|
const void *base,
|
||||||
const hb_subset_plan_t *plan)
|
const hb_subset_plan_t *plan)
|
||||||
{
|
{
|
||||||
if (unlikely (!c->extend_min ((*this)))) return;
|
if (unlikely (!c->extend_min ((*this)))) return;
|
||||||
|
@ -1225,13 +1224,13 @@ struct cmap
|
||||||
for (const EncodingRecord& _ : encodingrec_iter)
|
for (const EncodingRecord& _ : encodingrec_iter)
|
||||||
{
|
{
|
||||||
hb_set_t unicodes_set;
|
hb_set_t unicodes_set;
|
||||||
(src_base+_.subtable).collect_unicodes (&unicodes_set);
|
(base+_.subtable).collect_unicodes (&unicodes_set);
|
||||||
|
|
||||||
unsigned format = (src_base+_.subtable).u.format;
|
unsigned format = (base+_.subtable).u.format;
|
||||||
|
|
||||||
if (format == 4) c->copy (_, + it | hb_filter (unicodes_set, hb_first), 4u, src_base, plan, &format4objidx);
|
if (format == 4) c->copy (_, + it | hb_filter (unicodes_set, hb_first), 4u, base, plan, &format4objidx);
|
||||||
else if (format == 12) c->copy (_, + it | hb_filter (unicodes_set, hb_first), 12u, src_base, plan, &format12objidx);
|
else if (format == 12) c->copy (_, + it | hb_filter (unicodes_set, hb_first), 12u, base, plan, &format12objidx);
|
||||||
else if (format == 14) c->copy (_, it, 14u, src_base, plan, &format14objidx);
|
else if (format == 14) c->copy (_, it, 14u, base, plan, &format14objidx);
|
||||||
}
|
}
|
||||||
|
|
||||||
c->check_assign(this->encodingRecord.len, (c->length () - cmap::min_size)/EncodingRecord::static_size);
|
c->check_assign(this->encodingRecord.len, (c->length () - cmap::min_size)/EncodingRecord::static_size);
|
||||||
|
|
|
@ -628,7 +628,7 @@ struct BitmapSizeTable
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
subset (hb_subset_context_t *c, const void *src_base,
|
subset (hb_subset_context_t *c, const void *base,
|
||||||
const char *cbdt, unsigned int cbdt_length,
|
const char *cbdt, unsigned int cbdt_length,
|
||||||
hb_vector_t<char> *cbdt_prime /* INOUT */) const
|
hb_vector_t<char> *cbdt_prime /* INOUT */) const
|
||||||
{
|
{
|
||||||
|
@ -647,7 +647,7 @@ struct BitmapSizeTable
|
||||||
|
|
||||||
if (!out_table->indexSubtableArrayOffset.serialize_subset (c,
|
if (!out_table->indexSubtableArrayOffset.serialize_subset (c,
|
||||||
indexSubtableArrayOffset,
|
indexSubtableArrayOffset,
|
||||||
src_base,
|
base,
|
||||||
&bitmap_size_context))
|
&bitmap_size_context))
|
||||||
return_trace (false);
|
return_trace (false);
|
||||||
if (!bitmap_size_context.size ||
|
if (!bitmap_size_context.size ||
|
||||||
|
|
|
@ -142,68 +142,62 @@ struct hb_subset_layout_context_t :
|
||||||
template<typename OutputArray>
|
template<typename OutputArray>
|
||||||
struct subset_offset_array_t
|
struct subset_offset_array_t
|
||||||
{
|
{
|
||||||
subset_offset_array_t
|
subset_offset_array_t (hb_subset_context_t *subset_context_,
|
||||||
(hb_subset_context_t *subset_context,
|
OutputArray& out_,
|
||||||
OutputArray& out,
|
const void *base_) : subset_context (subset_context_),
|
||||||
const void *src_base)
|
out (out_), base (base_) {}
|
||||||
: _subset_context(subset_context), _out (out), _src_base (src_base) {}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool
|
bool operator () (T&& offset)
|
||||||
operator ()
|
|
||||||
(T&& offset)
|
|
||||||
{
|
{
|
||||||
auto *o = _out.serialize_append (_subset_context->serializer);
|
auto *o = out.serialize_append (subset_context->serializer);
|
||||||
if (unlikely (!o)) return false;
|
if (unlikely (!o)) return false;
|
||||||
auto snap = _subset_context->serializer->snapshot ();
|
auto snap = subset_context->serializer->snapshot ();
|
||||||
bool ret = o->serialize_subset (_subset_context, offset, _src_base);
|
bool ret = o->serialize_subset (subset_context, offset, base);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
_out.pop ();
|
out.pop ();
|
||||||
_subset_context->serializer->revert (snap);
|
subset_context->serializer->revert (snap);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
hb_subset_context_t *_subset_context;
|
hb_subset_context_t *subset_context;
|
||||||
OutputArray &_out;
|
OutputArray &out;
|
||||||
const void *_src_base;
|
const void *base;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template<typename OutputArray, typename Arg>
|
template<typename OutputArray, typename Arg>
|
||||||
struct subset_offset_array_arg_t
|
struct subset_offset_array_arg_t
|
||||||
{
|
{
|
||||||
subset_offset_array_arg_t
|
subset_offset_array_arg_t (hb_subset_context_t *subset_context_,
|
||||||
(hb_subset_context_t *subset_context,
|
OutputArray& out_,
|
||||||
OutputArray& out,
|
const void *base_,
|
||||||
const void *src_base,
|
Arg &&arg_) : subset_context (subset_context_), out (out_),
|
||||||
Arg &&arg)
|
base (base_), arg (arg_) {}
|
||||||
: _subset_context(subset_context), _out (out), _src_base (src_base), _arg (arg) {}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool
|
bool operator () (T&& offset)
|
||||||
operator ()
|
|
||||||
(T&& offset)
|
|
||||||
{
|
{
|
||||||
auto *o = _out.serialize_append (_subset_context->serializer);
|
auto *o = out.serialize_append (subset_context->serializer);
|
||||||
if (unlikely (!o)) return false;
|
if (unlikely (!o)) return false;
|
||||||
auto snap = _subset_context->serializer->snapshot ();
|
auto snap = subset_context->serializer->snapshot ();
|
||||||
bool ret = o->serialize_subset (_subset_context, offset, _src_base, _arg);
|
bool ret = o->serialize_subset (subset_context, offset, base, arg);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
_out.pop ();
|
out.pop ();
|
||||||
_subset_context->serializer->revert (snap);
|
subset_context->serializer->revert (snap);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
hb_subset_context_t *_subset_context;
|
hb_subset_context_t *subset_context;
|
||||||
OutputArray &_out;
|
OutputArray &out;
|
||||||
const void *_src_base;
|
const void *base;
|
||||||
Arg &&_arg;
|
Arg &&arg;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -215,52 +209,40 @@ struct
|
||||||
{
|
{
|
||||||
template<typename OutputArray>
|
template<typename OutputArray>
|
||||||
subset_offset_array_t<OutputArray>
|
subset_offset_array_t<OutputArray>
|
||||||
operator ()
|
operator () (hb_subset_context_t *subset_context, OutputArray& out,
|
||||||
(hb_subset_context_t *subset_context,
|
const void *base) const
|
||||||
OutputArray& out,
|
{ return subset_offset_array_t<OutputArray> (subset_context, out, base); }
|
||||||
const void *src_base) const
|
|
||||||
{
|
|
||||||
return subset_offset_array_t<OutputArray> (subset_context, out, src_base);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Variant with one extra argument passed to serialize_subset */
|
/* Variant with one extra argument passed to serialize_subset */
|
||||||
template<typename OutputArray, typename Arg>
|
template<typename OutputArray, typename Arg>
|
||||||
subset_offset_array_arg_t<OutputArray, Arg>
|
subset_offset_array_arg_t<OutputArray, Arg>
|
||||||
operator ()
|
operator () (hb_subset_context_t *subset_context, OutputArray& out,
|
||||||
(hb_subset_context_t *subset_context,
|
const void *base, Arg &&arg) const
|
||||||
OutputArray& out,
|
{ return subset_offset_array_arg_t<OutputArray, Arg> (subset_context, out, base, arg); }
|
||||||
const void *src_base,
|
|
||||||
Arg &&arg) const
|
|
||||||
{
|
|
||||||
return subset_offset_array_arg_t<OutputArray, Arg> (subset_context, out, src_base, arg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
HB_FUNCOBJ (subset_offset_array);
|
HB_FUNCOBJ (subset_offset_array);
|
||||||
|
|
||||||
template<typename OutputArray>
|
template<typename OutputArray>
|
||||||
struct subset_record_array_t
|
struct subset_record_array_t
|
||||||
{
|
{
|
||||||
subset_record_array_t
|
subset_record_array_t (hb_subset_layout_context_t *c_, OutputArray* out_,
|
||||||
(hb_subset_layout_context_t *c,
|
const void *base_) : subset_layout_context (c_),
|
||||||
OutputArray* out,
|
out (out_), base (base_) {}
|
||||||
const void *src_base)
|
|
||||||
: _subset_layout_context(c), _out (out), _src_base (src_base) {}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void
|
void
|
||||||
operator ()
|
operator () (T&& record)
|
||||||
(T&& record)
|
|
||||||
{
|
{
|
||||||
auto snap = _subset_layout_context->subset_context->serializer->snapshot ();
|
auto snap = subset_layout_context->subset_context->serializer->snapshot ();
|
||||||
bool ret = record.subset (_subset_layout_context, _src_base);
|
bool ret = record.subset (subset_layout_context, base);
|
||||||
if (!ret) _subset_layout_context->subset_context->serializer->revert (snap);
|
if (!ret) subset_layout_context->subset_context->serializer->revert (snap);
|
||||||
else _out->len++;
|
else out->len++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
hb_subset_layout_context_t *_subset_layout_context;
|
hb_subset_layout_context_t *subset_layout_context;
|
||||||
OutputArray *_out;
|
OutputArray *out;
|
||||||
const void *_src_base;
|
const void *base;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -271,13 +253,9 @@ struct
|
||||||
{
|
{
|
||||||
template<typename OutputArray>
|
template<typename OutputArray>
|
||||||
subset_record_array_t<OutputArray>
|
subset_record_array_t<OutputArray>
|
||||||
operator ()
|
operator () (hb_subset_layout_context_t *c, OutputArray* out,
|
||||||
(hb_subset_layout_context_t *c,
|
const void *base) const
|
||||||
OutputArray* out,
|
{ return subset_record_array_t<OutputArray> (c, out, base); }
|
||||||
const void *src_base) const
|
|
||||||
{
|
|
||||||
return subset_record_array_t<OutputArray> (c, out, src_base);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
HB_FUNCOBJ (subset_record_array);
|
HB_FUNCOBJ (subset_record_array);
|
||||||
|
|
||||||
|
@ -302,13 +280,12 @@ struct Record
|
||||||
{
|
{
|
||||||
int cmp (hb_tag_t a) const { return tag.cmp (a); }
|
int cmp (hb_tag_t a) const { return tag.cmp (a); }
|
||||||
|
|
||||||
bool subset (hb_subset_layout_context_t *c,
|
bool subset (hb_subset_layout_context_t *c, const void *base) const
|
||||||
const void *src_base) const
|
|
||||||
{
|
{
|
||||||
TRACE_SUBSET (this);
|
TRACE_SUBSET (this);
|
||||||
auto *out = c->subset_context->serializer->embed (this);
|
auto *out = c->subset_context->serializer->embed (this);
|
||||||
if (unlikely (!out)) return_trace (false);
|
if (unlikely (!out)) return_trace (false);
|
||||||
bool ret = out->offset.serialize_subset (c->subset_context, offset, src_base, c, &tag);
|
bool ret = out->offset.serialize_subset (c->subset_context, offset, base, c, &tag);
|
||||||
return_trace (ret);
|
return_trace (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2597,15 +2574,14 @@ struct FeatureTableSubstitutionRecord
|
||||||
feature_indexes->add (featureIndex);
|
feature_indexes->add (featureIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool subset (hb_subset_layout_context_t *c,
|
bool subset (hb_subset_layout_context_t *c, const void *base) const
|
||||||
const void *src_base) const
|
|
||||||
{
|
{
|
||||||
TRACE_SUBSET (this);
|
TRACE_SUBSET (this);
|
||||||
auto *out = c->subset_context->serializer->embed (this);
|
auto *out = c->subset_context->serializer->embed (this);
|
||||||
if (unlikely (!out)) return_trace (false);
|
if (unlikely (!out)) return_trace (false);
|
||||||
|
|
||||||
out->featureIndex = c->feature_index_map->get (featureIndex);
|
out->featureIndex = c->feature_index_map->get (featureIndex);
|
||||||
bool ret = out->feature.serialize_subset (c->subset_context, feature, src_base, c);
|
bool ret = out->feature.serialize_subset (c->subset_context, feature, base, c);
|
||||||
return_trace (ret);
|
return_trace (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2703,16 +2679,15 @@ struct FeatureVariationRecord
|
||||||
(base+substitutions).closure_features (lookup_indexes, feature_indexes);
|
(base+substitutions).closure_features (lookup_indexes, feature_indexes);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool subset (hb_subset_layout_context_t *c,
|
bool subset (hb_subset_layout_context_t *c, const void *base) const
|
||||||
const void *src_base) const
|
|
||||||
{
|
{
|
||||||
TRACE_SUBSET (this);
|
TRACE_SUBSET (this);
|
||||||
auto *out = c->subset_context->serializer->embed (this);
|
auto *out = c->subset_context->serializer->embed (this);
|
||||||
if (unlikely (!out)) return_trace (false);
|
if (unlikely (!out)) return_trace (false);
|
||||||
|
|
||||||
out->conditions.serialize_subset (c->subset_context, conditions, src_base);
|
out->conditions.serialize_subset (c->subset_context, conditions, base);
|
||||||
|
|
||||||
bool ret = out->substitutions.serialize_subset (c->subset_context, substitutions, src_base, c);
|
bool ret = out->substitutions.serialize_subset (c->subset_context, substitutions, base, c);
|
||||||
return_trace (ret);
|
return_trace (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ struct ValueFormat : HBUINT16
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void serialize_copy (hb_serialize_context_t *c, const void *src_base, const Value *values) const
|
void serialize_copy (hb_serialize_context_t *c, const void *base, const Value *values) const
|
||||||
{
|
{
|
||||||
unsigned int format = *this;
|
unsigned int format = *this;
|
||||||
if (!format) return;
|
if (!format) return;
|
||||||
|
@ -170,10 +170,10 @@ struct ValueFormat : HBUINT16
|
||||||
if (format & xAdvance) c->copy (*values++);
|
if (format & xAdvance) c->copy (*values++);
|
||||||
if (format & yAdvance) c->copy (*values++);
|
if (format & yAdvance) c->copy (*values++);
|
||||||
|
|
||||||
if (format & xPlaDevice) copy_device (c, src_base, values++);
|
if (format & xPlaDevice) copy_device (c, base, values++);
|
||||||
if (format & yPlaDevice) copy_device (c, src_base, values++);
|
if (format & yPlaDevice) copy_device (c, base, values++);
|
||||||
if (format & xAdvDevice) copy_device (c, src_base, values++);
|
if (format & xAdvDevice) copy_device (c, base, values++);
|
||||||
if (format & yAdvDevice) copy_device (c, src_base, values++);
|
if (format & yAdvDevice) copy_device (c, base, values++);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -194,7 +194,7 @@ struct ValueFormat : HBUINT16
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool copy_device (hb_serialize_context_t *c, const void *src_base, const Value *src_value) const
|
bool copy_device (hb_serialize_context_t *c, const void *base, const Value *src_value) const
|
||||||
{
|
{
|
||||||
Value *dst_value = c->copy (*src_value);
|
Value *dst_value = c->copy (*src_value);
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ struct ValueFormat : HBUINT16
|
||||||
|
|
||||||
*dst_value = 0;
|
*dst_value = 0;
|
||||||
c->push ();
|
c->push ();
|
||||||
if ((src_base + get_device (src_value)).copy (c))
|
if ((base + get_device (src_value)).copy (c))
|
||||||
{
|
{
|
||||||
c->add_link (*dst_value, c->pop_pack ());
|
c->add_link (*dst_value, c->pop_pack ());
|
||||||
return true;
|
return true;
|
||||||
|
@ -523,17 +523,15 @@ struct MarkRecord
|
||||||
return_trace (c->check_struct (this) && markAnchor.sanitize (c, base));
|
return_trace (c->check_struct (this) && markAnchor.sanitize (c, base));
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkRecord *copy (hb_serialize_context_t *c,
|
MarkRecord *copy (hb_serialize_context_t *c, const void *base,
|
||||||
const void *src_base,
|
unsigned dst_bias, const hb_map_t *klass_mapping) const
|
||||||
unsigned dst_bias,
|
|
||||||
const hb_map_t *klass_mapping) const
|
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
auto *out = c->embed (this);
|
auto *out = c->embed (this);
|
||||||
if (unlikely (!out)) return_trace (nullptr);
|
if (unlikely (!out)) return_trace (nullptr);
|
||||||
|
|
||||||
out->klass = klass_mapping->get (klass);
|
out->klass = klass_mapping->get (klass);
|
||||||
out->markAnchor.serialize_copy (c, markAnchor, src_base, dst_bias);
|
out->markAnchor.serialize_copy (c, markAnchor, base, dst_bias);
|
||||||
return_trace (out);
|
return_trace (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,13 +584,13 @@ struct MarkArray : ArrayOf<MarkRecord> /* Array of MarkRecords--in Coverage orde
|
||||||
hb_requires (hb_is_source_of (Iterator, MarkRecord))>
|
hb_requires (hb_is_source_of (Iterator, MarkRecord))>
|
||||||
bool serialize (hb_serialize_context_t *c,
|
bool serialize (hb_serialize_context_t *c,
|
||||||
const hb_map_t *klass_mapping,
|
const hb_map_t *klass_mapping,
|
||||||
const void *src_base,
|
const void *base,
|
||||||
Iterator it)
|
Iterator it)
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
if (unlikely (!c->extend_min (*this))) return_trace (false);
|
if (unlikely (!c->extend_min (*this))) return_trace (false);
|
||||||
if (unlikely (!c->check_assign (len, it.len ()))) return_trace (false);
|
if (unlikely (!c->check_assign (len, it.len ()))) return_trace (false);
|
||||||
c->copy_all (it, src_base, c->to_bias (this), klass_mapping);
|
c->copy_all (it, base, c->to_bias (this), klass_mapping);
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -875,7 +873,7 @@ struct PairValueRecord
|
||||||
|
|
||||||
struct serialize_closure_t
|
struct serialize_closure_t
|
||||||
{
|
{
|
||||||
const void *src_base;
|
const void *base;
|
||||||
const ValueFormat *valueFormats;
|
const ValueFormat *valueFormats;
|
||||||
unsigned len1; /* valueFormats[0].get_len() */
|
unsigned len1; /* valueFormats[0].get_len() */
|
||||||
const hb_map_t *glyph_map;
|
const hb_map_t *glyph_map;
|
||||||
|
@ -890,8 +888,8 @@ struct PairValueRecord
|
||||||
|
|
||||||
out->secondGlyph = (*closure->glyph_map)[secondGlyph];
|
out->secondGlyph = (*closure->glyph_map)[secondGlyph];
|
||||||
|
|
||||||
closure->valueFormats[0].serialize_copy (c, closure->src_base, &values[0]);
|
closure->valueFormats[0].serialize_copy (c, closure->base, &values[0]);
|
||||||
closure->valueFormats[1].serialize_copy (c, closure->src_base, &values[closure->len1]);
|
closure->valueFormats[1].serialize_copy (c, closure->base, &values[closure->len1]);
|
||||||
|
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
@ -1337,15 +1335,14 @@ struct EntryExitRecord
|
||||||
return_trace (entryAnchor.sanitize (c, base) && exitAnchor.sanitize (c, base));
|
return_trace (entryAnchor.sanitize (c, base) && exitAnchor.sanitize (c, base));
|
||||||
}
|
}
|
||||||
|
|
||||||
EntryExitRecord* copy (hb_serialize_context_t *c,
|
EntryExitRecord* copy (hb_serialize_context_t *c, const void *base) const
|
||||||
const void *src_base) const
|
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
auto *out = c->embed (this);
|
auto *out = c->embed (this);
|
||||||
if (unlikely (!out)) return_trace (nullptr);
|
if (unlikely (!out)) return_trace (nullptr);
|
||||||
|
|
||||||
out->entryAnchor.serialize_copy (c, entryAnchor, src_base);
|
out->entryAnchor.serialize_copy (c, entryAnchor, base);
|
||||||
out->exitAnchor.serialize_copy (c, exitAnchor, src_base);
|
out->exitAnchor.serialize_copy (c, exitAnchor, base);
|
||||||
return_trace (out);
|
return_trace (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1480,9 +1477,7 @@ struct CursivePosFormat1
|
||||||
|
|
||||||
template <typename Iterator,
|
template <typename Iterator,
|
||||||
hb_requires (hb_is_iterator (Iterator))>
|
hb_requires (hb_is_iterator (Iterator))>
|
||||||
void serialize (hb_serialize_context_t *c,
|
void serialize (hb_serialize_context_t *c, Iterator it, const void *base)
|
||||||
Iterator it,
|
|
||||||
const void *src_base)
|
|
||||||
{
|
{
|
||||||
if (unlikely (!c->extend_min ((*this)))) return;
|
if (unlikely (!c->extend_min ((*this)))) return;
|
||||||
this->format = 1;
|
this->format = 1;
|
||||||
|
@ -1490,7 +1485,7 @@ struct CursivePosFormat1
|
||||||
|
|
||||||
for (const EntryExitRecord& entry_record : + it
|
for (const EntryExitRecord& entry_record : + it
|
||||||
| hb_map (hb_second))
|
| hb_map (hb_second))
|
||||||
c->copy (entry_record, src_base);
|
c->copy (entry_record, base);
|
||||||
|
|
||||||
auto glyphs =
|
auto glyphs =
|
||||||
+ it
|
+ it
|
||||||
|
|
|
@ -2783,9 +2783,7 @@ struct ChainContextFormat3
|
||||||
|
|
||||||
template<typename Iterator,
|
template<typename Iterator,
|
||||||
hb_requires (hb_is_iterator (Iterator))>
|
hb_requires (hb_is_iterator (Iterator))>
|
||||||
bool serialize_coverage_offsets (hb_subset_context_t *c,
|
bool serialize_coverage_offsets (hb_subset_context_t *c, Iterator it, const void* base) const
|
||||||
Iterator it,
|
|
||||||
const void* src_base) const
|
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
auto *out = c->serializer->start_embed<OffsetArrayOf<Coverage>> ();
|
auto *out = c->serializer->start_embed<OffsetArrayOf<Coverage>> ();
|
||||||
|
@ -2793,7 +2791,7 @@ struct ChainContextFormat3
|
||||||
if (unlikely (!c->serializer->allocate_size<HBUINT16> (HBUINT16::static_size))) return_trace (false);
|
if (unlikely (!c->serializer->allocate_size<HBUINT16> (HBUINT16::static_size))) return_trace (false);
|
||||||
|
|
||||||
+ it
|
+ it
|
||||||
| hb_apply (subset_offset_array (c, *out, src_base))
|
| hb_apply (subset_offset_array (c, *out, base))
|
||||||
;
|
;
|
||||||
|
|
||||||
return_trace (out->len);
|
return_trace (out->len);
|
||||||
|
|
|
@ -97,13 +97,12 @@ struct NameRecord
|
||||||
return UNSUPPORTED;
|
return UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NameRecord* copy (hb_serialize_context_t *c,
|
NameRecord* copy (hb_serialize_context_t *c, const void *base) const
|
||||||
const void *src_base) const
|
|
||||||
{
|
{
|
||||||
TRACE_SERIALIZE (this);
|
TRACE_SERIALIZE (this);
|
||||||
auto *out = c->embed (this);
|
auto *out = c->embed (this);
|
||||||
if (unlikely (!out)) return_trace (nullptr);
|
if (unlikely (!out)) return_trace (nullptr);
|
||||||
out->offset.serialize_copy (c, offset, src_base, 0, hb_serialize_context_t::Tail, length);
|
out->offset.serialize_copy (c, offset, base, 0, hb_serialize_context_t::Tail, length);
|
||||||
return_trace (out);
|
return_trace (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue