mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-13 00:32:59 +00:00
[COLR] Optimize palette access
This commit is contained in:
parent
016e78b683
commit
ed76c8559e
2 changed files with 13 additions and 6 deletions
|
@ -34,6 +34,8 @@
|
|||
#include "../../../hb-paint.hh"
|
||||
#include "../../../hb-paint-extents.hh"
|
||||
|
||||
#include "../CPAL/CPAL.hh"
|
||||
|
||||
/*
|
||||
* COLR -- Color
|
||||
* https://docs.microsoft.com/en-us/typography/opentype/spec/colr
|
||||
|
@ -66,7 +68,7 @@ public:
|
|||
hb_paint_funcs_t *funcs;
|
||||
void *data;
|
||||
hb_font_t *font;
|
||||
unsigned int palette_index;
|
||||
hb_array_t<const BGRAColor> palette;
|
||||
hb_color_t foreground;
|
||||
ItemVarStoreInstancer &instancer;
|
||||
hb_map_t current_glyphs;
|
||||
|
@ -85,7 +87,7 @@ public:
|
|||
funcs (funcs_),
|
||||
data (data_),
|
||||
font (font_),
|
||||
palette_index (palette_),
|
||||
palette (font->face->table.CPAL->get_palette_colors (palette_)),
|
||||
foreground (foreground_),
|
||||
instancer (instancer_)
|
||||
{ }
|
||||
|
@ -99,10 +101,7 @@ public:
|
|||
if (color_index != 0xffff)
|
||||
{
|
||||
if (!funcs->custom_palette_color (data, color_index, &color))
|
||||
{
|
||||
unsigned int clen = 1;
|
||||
hb_ot_color_palette_get_colors (font->face, palette_index, color_index, &clen, &color);
|
||||
}
|
||||
color = palette[color_index];
|
||||
|
||||
*is_foreground = false;
|
||||
}
|
||||
|
|
|
@ -187,6 +187,14 @@ struct CPAL
|
|||
hb_ot_name_id_t get_color_name_id (unsigned int color_index) const
|
||||
{ return v1 ().get_color_name_id (this, color_index, numColors); }
|
||||
|
||||
hb_array_t<const BGRAColor> get_palette_colors (unsigned int palette_index) const
|
||||
{
|
||||
if (unlikely (palette_index >= numPalettes))
|
||||
return hb_array_t<const BGRAColor> ();
|
||||
unsigned int start_index = colorRecordIndicesZ[palette_index];
|
||||
hb_array_t<const BGRAColor> all_colors ((this+colorRecordsZ).arrayZ, numColorRecords);
|
||||
return all_colors.sub_array (start_index, numColors);
|
||||
}
|
||||
unsigned int get_palette_colors (unsigned int palette_index,
|
||||
unsigned int start_offset,
|
||||
unsigned int *color_count, /* IN/OUT. May be NULL. */
|
||||
|
|
Loading…
Add table
Reference in a new issue