diff --git a/src/hb-ot-color-colr-table.cc b/src/hb-ot-color-colr-table.cc index e469fa25b..2172eb61c 100644 --- a/src/hb-ot-color-colr-table.cc +++ b/src/hb-ot-color-colr-table.cc @@ -31,43 +31,17 @@ hb_color_line_get_color_stops (hb_color_line_t *cl, unsigned int *count, hb_color_stop_t *color_stops) { - switch (cl->format) - { - case 4: - return reinterpret_cast *>(cl->base)->get_color_stops (start, count, color_stops); - case 5: - return reinterpret_cast *>(cl->base)->get_color_stops (start, count, color_stops); - case 6: - return reinterpret_cast *>(cl->base)->get_color_stops (start, count, color_stops); - case 7: - return reinterpret_cast *>(cl->base)->get_color_stops (start, count, color_stops); - case 8: - return reinterpret_cast *>(cl->base)->get_color_stops (start, count, color_stops); - case 9: - return reinterpret_cast *>(cl->base)->get_color_stops (start, count, color_stops); - default: assert (0); - } - return 0; + if (cl->is_variable) + return reinterpret_cast *>(cl->base)->get_color_stops (start, count, color_stops); + else + return reinterpret_cast *>(cl->base)->get_color_stops (start, count, color_stops); } hb_paint_extend_t hb_color_line_get_extend (hb_color_line_t *cl) { - switch (cl->format) - { - case 4: - return reinterpret_cast *>(cl->base)->get_extend (); - case 5: - return reinterpret_cast *>(cl->base)->get_extend (); - case 6: - return reinterpret_cast *>(cl->base)->get_extend (); - case 7: - return reinterpret_cast *>(cl->base)->get_extend (); - case 8: - return reinterpret_cast *>(cl->base)->get_extend (); - case 9: - return reinterpret_cast *>(cl->base)->get_extend (); - default: assert (0); - } - return HB_PAINT_EXTEND_PAD; + if (cl->is_variable) + return reinterpret_cast *>(cl->base)->get_extend (); + else + return reinterpret_cast *>(cl->base)->get_extend (); } diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh index 71f669638..4fd1e2baf 100644 --- a/src/hb-ot-color-colr-table.hh +++ b/src/hb-ot-color-colr-table.hh @@ -44,9 +44,10 @@ #define HB_COLRV1_MAX_NESTING_LEVEL 128 #endif + struct hb_color_line_t { const void *base; - OT::HBUINT8 format; + bool is_variable; }; namespace OT { @@ -200,6 +201,8 @@ struct BaseGlyphRecord template struct Variable { + static constexpr bool is_variable = true; + Variable* copy (hb_serialize_context_t *c) const { TRACE_SERIALIZE (this); @@ -248,6 +251,8 @@ struct Variable template struct NoVariable { + static constexpr bool is_variable = false; + static constexpr uint32_t varIdxBase = VarIdx::NO_VARIATION; NoVariable* copy (hb_serialize_context_t *c) const @@ -566,7 +571,7 @@ struct PaintLinearGradient void paint_glyph (hb_paint_context_t *c, uint32_t varIdxBase) const { - hb_color_line_t cl = { this, format }; + hb_color_line_t cl = { &(this+colorLine), Var>::is_variable }; c->funcs->linear_gradient (c->data, &cl, x0 + c->instancer (varIdxBase, 0), @@ -577,18 +582,6 @@ struct PaintLinearGradient y2 + c->instancer (varIdxBase, 5)); } - unsigned int get_color_stops (unsigned int start, - unsigned int *count, - hb_color_stop_t *stops) const - { - return (this+colorLine).get_color_stops (start, count, stops); - } - - hb_paint_extend_t get_extend () const - { - return (this+colorLine).get_extend (); - } - HBUINT8 format; /* format = 4(noVar) or 5 (Var) */ Offset24To> colorLine; /* Offset (from beginning of PaintLinearGradient * table) to ColorLine subtable. */ @@ -625,7 +618,7 @@ struct PaintRadialGradient void paint_glyph (hb_paint_context_t *c, uint32_t varIdxBase) const { - hb_color_line_t cl = { this, format }; + hb_color_line_t cl = { &(this+colorLine), Var>::is_variable }; c->funcs->radial_gradient (c->data, &cl, x0 + c->instancer (varIdxBase, 0), @@ -636,18 +629,6 @@ struct PaintRadialGradient radius1 + c->instancer (varIdxBase, 5)); } - unsigned int get_color_stops (unsigned int start, - unsigned int *count, - hb_color_stop_t *stops) const - { - return (this+colorLine).get_color_stops (start, count, stops); - } - - hb_paint_extend_t get_extend () const - { - return (this+colorLine).get_extend (); - } - HBUINT8 format; /* format = 6(noVar) or 7 (Var) */ Offset24To> colorLine; /* Offset (from beginning of PaintRadialGradient * table) to ColorLine subtable. */ @@ -684,7 +665,7 @@ struct PaintSweepGradient void paint_glyph (hb_paint_context_t *c, uint32_t varIdxBase) const { - hb_color_line_t cl = { this, format }; + hb_color_line_t cl = { &(this+colorLine), Var>::is_variable }; c->funcs->sweep_gradient (c->data, &cl, centerX + c->instancer (varIdxBase, 0), @@ -693,18 +674,6 @@ struct PaintSweepGradient (endAngle.to_float (c->instancer (varIdxBase, 3)) + 1) * (float) M_PI); } - unsigned int get_color_stops (unsigned int start, - unsigned int *count, - hb_color_stop_t *stops) const - { - return (this+colorLine).get_color_stops (start, count, stops); - } - - hb_paint_extend_t get_extend () const - { - return (this+colorLine).get_extend (); - } - HBUINT8 format; /* format = 8(noVar) or 9 (Var) */ Offset24To> colorLine; /* Offset (from beginning of PaintSweepGradient * table) to ColorLine subtable. */