[COLRv1] Optimize PaintColrLayers instead of PaintComposite

See https://github.com/googlefonts/colr-gradients-spec/issues/369#issuecomment-1816913943
and onwards.
This commit is contained in:
Behdad Esfahbod 2025-02-26 14:40:02 -07:00
parent 4d3642c188
commit 17a83b748e
2 changed files with 4 additions and 4 deletions

View file

@ -1511,10 +1511,12 @@ struct PaintComposite
void paint_glyph (hb_paint_context_t *c) const
{
TRACE_PAINT (this);
c->funcs->push_group (c->data);
c->recurse (this+backdrop);
c->funcs->push_group (c->data);
c->recurse (this+src);
c->funcs->pop_group (c->data, (hb_paint_composite_mode_t) (int) mode);
c->funcs->pop_group (c->data, HB_PAINT_COMPOSITE_MODE_SRC_OVER);
}
HBUINT8 format; /* format = 32 */
@ -2714,9 +2716,7 @@ void PaintColrLayers::paint_glyph (hb_paint_context_t *c) const
return;
const Paint &paint = paint_offset_lists.get_paint (i);
c->funcs->push_group (c->data);
c->recurse (paint);
c->funcs->pop_group (c->data, HB_PAINT_COMPOSITE_MODE_SRC_OVER);
}
}

View file

@ -229,9 +229,7 @@ _hb_ft_paint (hb_ft_paint_context_t *c,
if (unlikely (!node.visit ((uintptr_t) other_paint.p)))
continue;
c->funcs->push_group (c->data);
c->recurse (other_paint);
c->funcs->pop_group (c->data, HB_PAINT_COMPOSITE_MODE_SRC_OVER);
}
}
break;
@ -451,10 +449,12 @@ _hb_ft_paint (hb_ft_paint_context_t *c,
break;
case FT_COLR_PAINTFORMAT_COMPOSITE:
{
c->funcs->push_group (c->data);
c->recurse (paint.u.composite.backdrop_paint);
c->funcs->push_group (c->data);
c->recurse (paint.u.composite.source_paint);
c->funcs->pop_group (c->data, _hb_ft_paint_composite_mode (paint.u.composite.composite_mode));
c->funcs->pop_group (c->data, HB_PAINT_COMPOSITE_MODE_SRC_OVER);
}
break;