diff --git a/src/hb-ot-color-colr-table.cc b/src/hb-ot-color-colr-table.cc new file mode 100644 index 000000000..45884d4b3 --- /dev/null +++ b/src/hb-ot-color-colr-table.cc @@ -0,0 +1,73 @@ +#include "hb-ot-color-colr-table.hh" + +namespace OT { + +void PaintColrLayers::paint_glyph (hb_paint_context_t *c) const +{ + const LayerList &paint_offset_lists = c->get_colr_table ()->get_layerList (); + for (unsigned i = firstLayerIndex; i < firstLayerIndex + numLayers; i++) + { + const Paint &paint = std::addressof (paint_offset_lists) + paint_offset_lists[i]; + c->funcs->push_group (c->data); + paint_glyph_dispatch (&paint, c); + c->funcs->pop_group (c->data, HB_PAINT_COMPOSITE_MODE_SRC_OVER); + } +} + +void PaintColrGlyph::paint_glyph (hb_paint_context_t *c) const +{ + const COLR *colr_table = c->get_colr_table (); + const Paint *paint = colr_table->get_base_glyph_paint (gid); + + if (paint) + paint_glyph_dispatch (paint, c); +} + +} + +unsigned int +hb_color_line_get_color_stops (hb_color_line_t *cl, + unsigned int start, + 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; +} + +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; +} diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh index 47d484c7d..786cfe767 100644 --- a/src/hb-ot-color-colr-table.hh +++ b/src/hb-ot-color-colr-table.hh @@ -1916,8 +1916,13 @@ struct COLR { const BaseGlyphList &baseglyph_paintrecords = this+baseGlyphList; const BaseGlyphPaintRecord* record = get_base_glyph_paintrecord (glyph); - const Paint &paint = &baseglyph_paintrecords+record->paint; - return &paint; + if (record) + { + const Paint &paint = &baseglyph_paintrecords+record->paint; + return &paint; + } + else + return nullptr; } bool