From e04b63e40f6f4dc4acaa75214f5082c8d2ead354 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 18 Jan 2025 02:44:24 -0700 Subject: [PATCH] [hvgl] Implement Part union --- src/hb-aat-var-hvgl-table.hh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/hb-aat-var-hvgl-table.hh b/src/hb-aat-var-hvgl-table.hh index be0272a45..733ac9df7 100644 --- a/src/hb-aat-var-hvgl-table.hh +++ b/src/hb-aat-var-hvgl-table.hh @@ -353,6 +353,30 @@ struct PartComposite DEFINE_SIZE_STATIC (36); }; +struct Part +{ + template + typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const + { + if (unlikely (!c->may_dispatch (this, &u.flags))) return c->no_dispatch_return_value (); + TRACE_DISPATCH (this, u.flags); + switch (u.flags & 1) { + case 0: hb_barrier (); return_trace (c->dispatch (u.shape, std::forward (ds)...)); + case 1: hb_barrier (); return_trace (c->dispatch (u.composite, std::forward (ds)...)); + default:return_trace (c->default_return_value ()); + } + } + + protected: + union { + HBUINT16LE flags; /* Flag identifier */ + PartShape shape; + PartComposite composite; + } u; + public: + DEFINE_SIZE_MIN (2); +}; + } // namespace hvgl } // namespace AAT