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

View File

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

View File

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