summaryrefslogtreecommitdiff
path: root/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2021-08-29 04:06:16 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2021-08-29 04:06:16 +0000
commite2861beed768a741fd41e8df0ab6a74f5b583d05 (patch)
treec4fcc6aa758b08701034e3be0e6abdcab99c64ad /Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh
parent28456f9ecb080a4c3c43336b6dfb5d72a9cc528a (diff)
harfbuzz 2.9.0
git-svn-id: svn://tug.org/texlive/trunk@60356 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh')
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh112
1 files changed, 111 insertions, 1 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh
index 2fa99dead74..9ee4bafb2a7 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh
+++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cpal-table.hh
@@ -39,7 +39,6 @@
*/
#define HB_OT_TAG_CPAL HB_TAG('C','P','A','L')
-
namespace OT {
@@ -74,6 +73,39 @@ struct CPALV1Tail
}
public:
+ bool serialize (hb_serialize_context_t *c,
+ unsigned palette_count,
+ unsigned color_count,
+ const void *base,
+ const hb_map_t *color_index_map) const
+ {
+ TRACE_SERIALIZE (this);
+ auto *out = c->allocate_size<CPALV1Tail> (static_size);
+ if (unlikely (!out)) return_trace (false);
+
+ out->paletteFlagsZ.serialize_copy (c, paletteFlagsZ, base, 0, hb_serialize_context_t::Head, palette_count);
+ out->paletteLabelsZ.serialize_copy (c, paletteLabelsZ, base, 0, hb_serialize_context_t::Head, palette_count);
+
+ const hb_array_t<const NameID> colorLabels = (base+colorLabelsZ).as_array (color_count);
+ if (colorLabelsZ)
+ {
+ c->push ();
+ for (const auto _ : colorLabels)
+ {
+ if (!color_index_map->has (_)) continue;
+ NameID new_color_idx;
+ new_color_idx = color_index_map->get (_);
+ if (!c->copy<NameID> (new_color_idx))
+ {
+ c->pop_discard ();
+ return_trace (false);
+ }
+ }
+ c->add_link (out->colorLabelsZ, c->pop_pack ());
+ }
+ return_trace (true);
+ }
+
bool sanitize (hb_sanitize_context_t *c,
const void *base,
unsigned int palette_count,
@@ -157,6 +189,84 @@ struct CPAL
}
public:
+ bool serialize (hb_serialize_context_t *c,
+ const hb_array_t<const BGRAColor> &color_records,
+ const hb_array_t<const HBUINT16> &color_record_indices,
+ const hb_map_t &color_record_index_map,
+ const hb_set_t &retained_color_record_indices) const
+ {
+ TRACE_SERIALIZE (this);
+
+ for (const auto idx : color_record_indices)
+ {
+ HBUINT16 new_idx;
+ if (idx == 0) new_idx = 0;
+ else new_idx = color_record_index_map.get (idx);
+ if (!c->copy<HBUINT16> (new_idx)) return_trace (false);
+ }
+
+ c->push ();
+ for (const auto _ : retained_color_record_indices.iter ())
+ {
+ if (!c->copy<BGRAColor> (color_records[_]))
+ {
+ c->pop_discard ();
+ return_trace (false);
+ }
+ }
+ c->add_link (colorRecordsZ, c->pop_pack ());
+ return_trace (true);
+ }
+
+ bool subset (hb_subset_context_t *c) const
+ {
+ TRACE_SUBSET (this);
+ const hb_map_t *color_index_map = c->plan->colr_palettes;
+ if (color_index_map->is_empty ()) return_trace (false);
+
+ hb_set_t retained_color_indices;
+ for (const auto _ : color_index_map->keys ())
+ {
+ if (_ == 0xFFFF) continue;
+ retained_color_indices.add (_);
+ }
+ if (retained_color_indices.is_empty ()) return_trace (false);
+
+ auto *out = c->serializer->start_embed (*this);
+ if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
+
+ out->version = version;
+ out->numColors = retained_color_indices.get_population ();
+ out->numPalettes = numPalettes;
+
+ const hb_array_t<const HBUINT16> colorRecordIndices = colorRecordIndicesZ.as_array (numPalettes);
+ hb_map_t color_record_index_map;
+ hb_set_t retained_color_record_indices;
+
+ unsigned record_count = 0;
+ for (const auto first_color_record_idx : colorRecordIndices)
+ {
+ for (unsigned retained_color_idx : retained_color_indices.iter ())
+ {
+ unsigned color_record_idx = first_color_record_idx + retained_color_idx;
+ if (color_record_index_map.has (color_record_idx)) continue;
+ color_record_index_map.set (color_record_idx, record_count);
+ retained_color_record_indices.add (color_record_idx);
+ record_count++;
+ }
+ }
+
+ out->numColorRecords = record_count;
+ const hb_array_t<const BGRAColor> color_records = (this+colorRecordsZ).as_array (numColorRecords);
+ if (!out->serialize (c->serializer, color_records, colorRecordIndices, color_record_index_map, retained_color_record_indices))
+ return_trace (false);
+
+ if (version == 1)
+ return_trace (v1 ().serialize (c->serializer, numPalettes, numColors, this, color_index_map));
+
+ return_trace (true);
+ }
+
bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);