[colr][feat][meta] Port sub_array iteration to dagger (#1868)

This commit is contained in:
Ebrahim Byagowi 2019-07-30 04:44:23 +04:30 committed by GitHub
parent 9f2b4956b4
commit e5cf9718c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 30 deletions

View File

@ -47,17 +47,16 @@ struct SettingName
hb_aat_layout_feature_selector_t get_selector () const
{ return (hb_aat_layout_feature_selector_t) (unsigned) setting; }
void get_info (hb_aat_layout_feature_selector_info_t *s,
hb_aat_layout_feature_selector_t default_selector) const
hb_aat_layout_feature_selector_info_t get_info (hb_aat_layout_feature_selector_t default_selector) const
{
s->name_id = nameIndex;
s->enable = (hb_aat_layout_feature_selector_t) (unsigned int) setting;
s->disable = default_selector == HB_AAT_LAYOUT_FEATURE_SELECTOR_INVALID ?
(hb_aat_layout_feature_selector_t) (s->enable + 1) :
default_selector;
s->reserved = 0;
return {
nameIndex,
(hb_aat_layout_feature_selector_t) (unsigned int) setting,
default_selector == HB_AAT_LAYOUT_FEATURE_SELECTOR_INVALID
? (hb_aat_layout_feature_selector_t) (setting + 1)
: default_selector,
0
};
}
bool sanitize (hb_sanitize_context_t *c) const
@ -117,9 +116,10 @@ struct FeatureName
if (selectors_count)
{
hb_array_t<const SettingName> arr = settings_table.sub_array (start_offset, selectors_count);
for (unsigned int i = 0; i < arr.length; i++)
settings_table[start_offset + i].get_info (&selectors[i], default_selector);
+ settings_table.sub_array (start_offset, selectors_count)
| hb_map ([=] (const SettingName& setting) { return setting.get_info (default_selector); })
| hb_sink (hb_array (selectors, *selectors_count))
;
}
return settings_table.length;
}
@ -162,13 +162,12 @@ struct feat
unsigned int *count,
hb_aat_layout_feature_type_t *features) const
{
unsigned int feature_count = featureNameCount;
if (count && *count)
if (count)
{
unsigned int len = hb_min (feature_count - start_offset, *count);
for (unsigned int i = 0; i < len; i++)
features[i] = namesZ[i + start_offset].get_feature_type ();
*count = len;
+ namesZ.as_array (featureNameCount).sub_array (start_offset, count)
| hb_map (&FeatureName::get_feature_type)
| hb_sink (hb_array (features, *count))
;
}
return featureNameCount;
}

View File

@ -39,13 +39,15 @@ namespace OT {
struct LayerRecord
{
operator hb_ot_color_layer_t () const { return {glyphId, colorIdx}; }
bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this));
}
public:
protected:
GlyphID glyphId; /* Glyph ID of layer glyph */
Index colorIdx; /* Index value to use with a
* selected color palette.
@ -103,13 +105,9 @@ struct COLR
record.numLayers);
if (count)
{
hb_array_t<const LayerRecord> segment_layers = glyph_layers.sub_array (start_offset, *count);
*count = segment_layers.length;
for (unsigned int i = 0; i < segment_layers.length; i++)
{
layers[i].glyph = segment_layers.arrayZ[i].glyphId;
layers[i].color_index = segment_layers.arrayZ[i].colorIdx;
}
+ glyph_layers.sub_array (start_offset, count)
| hb_sink (hb_array (layers, *count))
;
}
return glyph_layers.length;
}

View File

@ -84,9 +84,11 @@ struct meta
{
if (count)
{
hb_array_t<const DataMap> arr = table->dataMaps.sub_array (start_offset, count);
for (unsigned int i = 0; i < arr.length; i++)
entries[i] = (hb_ot_meta_tag_t) arr[i].get_tag ();
+ table->dataMaps.sub_array (start_offset, count)
| hb_map (&DataMap::get_tag)
| hb_map ([](hb_tag_t tag) { return (hb_ot_meta_tag_t) tag; })
| hb_sink (hb_array (entries, *count))
;
}
return table->dataMaps.len;
}