提交 84b68e58 编写于 作者: G Garret Rieger

[subset] In hdmx serialize set the correct value of sizeDeviceRecord.

上级 dddf4427
...@@ -53,15 +53,6 @@ struct DeviceRecord ...@@ -53,15 +53,6 @@ struct DeviceRecord
return this->subset_plan->gids_to_retain_sorted.len; return this->subset_plan->gids_to_retain_sorted.len;
} }
inline unsigned int get_size () const
{
unsigned int raw_size = min_size + len () * HBUINT8::static_size;
if (raw_size % 4)
/* Align to 32 bits */
return raw_size + (4 - (raw_size % 4));
return raw_size;
}
inline const HBUINT8& operator [] (unsigned int i) const inline const HBUINT8& operator [] (unsigned int i) const
{ {
if (unlikely (i >= len())) return Null(HBUINT8); if (unlikely (i >= len())) return Null(HBUINT8);
...@@ -70,11 +61,20 @@ struct DeviceRecord ...@@ -70,11 +61,20 @@ struct DeviceRecord
} }
}; };
static inline unsigned int get_size (unsigned int count)
{
unsigned int raw_size = min_size + count * HBUINT8::static_size;
if (raw_size % 4)
/* Align to 32 bits */
return raw_size + (4 - (raw_size % 4));
return raw_size;
}
inline bool serialize (hb_serialize_context_t *c, const SubsetView &subset_view) inline bool serialize (hb_serialize_context_t *c, const SubsetView &subset_view)
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (unlikely (!c->allocate_size<DeviceRecord> (subset_view.get_size()))) if (unlikely (!c->allocate_size<DeviceRecord> (get_size (subset_view.len()))))
return_trace (false); return_trace (false);
this->pixel_size.set (subset_view.source_device_record->pixel_size); this->pixel_size.set (subset_view.source_device_record->pixel_size);
...@@ -93,8 +93,6 @@ struct DeviceRecord ...@@ -93,8 +93,6 @@ struct DeviceRecord
DEFINE_SIZE_MIN (2); DEFINE_SIZE_MIN (2);
}; };
struct hdmx struct hdmx
{ {
...@@ -117,7 +115,7 @@ struct hdmx ...@@ -117,7 +115,7 @@ struct hdmx
this->version.set (source_hdmx->version); this->version.set (source_hdmx->version);
this->num_records.set (source_hdmx->num_records); this->num_records.set (source_hdmx->num_records);
this->size_device_record.set (source_hdmx->size_device_record); this->size_device_record.set (DeviceRecord::get_size (plan->gids_to_retain_sorted.len));
for (unsigned int i = 0; i < source_hdmx->num_records; i++) for (unsigned int i = 0; i < source_hdmx->num_records; i++)
{ {
...@@ -130,6 +128,11 @@ struct hdmx ...@@ -130,6 +128,11 @@ struct hdmx
return_trace (true); return_trace (true);
} }
static inline unsigned int get_subsetted_size (hb_subset_plan_t *plan)
{
return min_size + DeviceRecord::get_size (plan->gids_to_retain_sorted.len);
}
inline bool subset (hb_subset_plan_t *plan) const inline bool subset (hb_subset_plan_t *plan) const
{ {
// TODO(grieger) // TODO(grieger)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册