mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-19 14:01:10 +01:00
[subset/hdmx] Speed up more for retaingids
This commit is contained in:
1 parent
a3f7ed709b
commit
4d4792ce3d
1 file changed
+21
-16
+21
-16
@@ -46,21 +46,23 @@ struct DeviceRecord
|
||||
|
||||
template<typename Iterator,
|
||||
hb_requires (hb_is_iterator (Iterator))>
|
||||
bool serialize (hb_serialize_context_t *c, unsigned pixelSize, Iterator it)
|
||||
bool serialize (hb_serialize_context_t *c,
|
||||
unsigned pixelSize,
|
||||
Iterator it,
|
||||
const hb_vector_t<hb_codepoint_pair_t> new_to_old_gid_list,
|
||||
unsigned num_glyphs)
|
||||
{
|
||||
TRACE_SERIALIZE (this);
|
||||
|
||||
unsigned length = it.len ();
|
||||
|
||||
if (unlikely (!c->extend_size (this, get_size (length), false))) return_trace (false);
|
||||
if (unlikely (!c->extend (this, num_glyphs))) return_trace (false);
|
||||
|
||||
this->pixelSize = pixelSize;
|
||||
this->maxWidth =
|
||||
+ it
|
||||
| hb_reduce (hb_max, 0u);
|
||||
|
||||
+ it
|
||||
| hb_sink (widthsZ.as_array (length));
|
||||
for (auto &_ : new_to_old_gid_list)
|
||||
widthsZ[_.first] = *it++;
|
||||
|
||||
return_trace (true);
|
||||
}
|
||||
@@ -89,7 +91,11 @@ struct hdmx
|
||||
|
||||
template<typename Iterator,
|
||||
hb_requires (hb_is_iterator (Iterator))>
|
||||
bool serialize (hb_serialize_context_t *c, unsigned version, Iterator it)
|
||||
bool serialize (hb_serialize_context_t *c,
|
||||
unsigned version,
|
||||
Iterator it,
|
||||
const hb_vector_t<hb_codepoint_pair_t> new_to_old_gid_list,
|
||||
unsigned num_glyphs)
|
||||
{
|
||||
TRACE_SERIALIZE (this);
|
||||
|
||||
@@ -97,10 +103,10 @@ struct hdmx
|
||||
|
||||
this->version = version;
|
||||
this->numRecords = it.len ();
|
||||
this->sizeDeviceRecord = DeviceRecord::get_size (it ? (*it).second.len () : 0);
|
||||
this->sizeDeviceRecord = DeviceRecord::get_size (num_glyphs);
|
||||
|
||||
for (const hb_item_type<Iterator>& _ : +it)
|
||||
c->start_embed<DeviceRecord> ()->serialize (c, _.first, _.second);
|
||||
c->start_embed<DeviceRecord> ()->serialize (c, _.first, _.second, new_to_old_gid_list, num_glyphs);
|
||||
|
||||
return_trace (c->successful ());
|
||||
}
|
||||
@@ -121,20 +127,19 @@ struct hdmx
|
||||
&StructAtOffset<DeviceRecord> (&firstDeviceRecord,
|
||||
_ * sizeDeviceRecord);
|
||||
auto row =
|
||||
+ hb_range (c->plan->num_output_glyphs ())
|
||||
| hb_map (c->plan->reverse_glyph_map)
|
||||
| hb_map ([this, c, device_record] (hb_codepoint_t _)
|
||||
+ hb_iter (c->plan->new_to_old_gid_list)
|
||||
| hb_map ([this, c, device_record] (hb_codepoint_pair_t _)
|
||||
{
|
||||
if (_ == HB_MAP_VALUE_INVALID)
|
||||
return Null (HBUINT8);
|
||||
return device_record->widthsZ.as_array (get_num_glyphs ()) [_];
|
||||
return device_record->widthsZ.as_array (get_num_glyphs ()) [_.second];
|
||||
})
|
||||
;
|
||||
return hb_pair ((unsigned) device_record->pixelSize, +row);
|
||||
})
|
||||
;
|
||||
|
||||
hdmx_prime->serialize (c->serializer, version, it);
|
||||
hdmx_prime->serialize (c->serializer, version, it,
|
||||
c->plan->new_to_old_gid_list,
|
||||
c->plan->num_output_glyphs ());
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user