Minor
This commit is contained in:
parent
44f79b4bf8
commit
37ba2413c1
@ -115,17 +115,17 @@ struct CPAL
|
|||||||
inline bool sanitize (hb_sanitize_context_t *c) const
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
||||||
{
|
{
|
||||||
TRACE_SANITIZE (this);
|
TRACE_SANITIZE (this);
|
||||||
if (unlikely (!(c->check_struct (this) && // it checks colorRecordIndices also
|
if (unlikely (!(c->check_struct (this) && /* it checks colorRecordIndices also
|
||||||
// see #get_size
|
* See #get_size */
|
||||||
(this+colorRecordsZ).sanitize (c, numColorRecords))))
|
(this+colorRecordsZ).sanitize (c, numColorRecords))))
|
||||||
return_trace (false);
|
return_trace (false);
|
||||||
|
|
||||||
// Check for indices sanity so no need for doing it runtime
|
/* Check for indices sanity so no need for doing it runtime */
|
||||||
for (unsigned int i = 0; i < numPalettes; ++i)
|
for (unsigned int i = 0; i < numPalettes; ++i)
|
||||||
if (unlikely (colorRecordIndicesZ[i] + numPaletteEntries > numColorRecords))
|
if (unlikely (colorRecordIndicesZ[i] + numPaletteEntries > numColorRecords))
|
||||||
return_trace (false);
|
return_trace (false);
|
||||||
|
|
||||||
// If version is zero, we are done here; otherwise we need to check tail also
|
/* If version is zero, we are done here; otherwise we need to check tail also */
|
||||||
if (version == 0)
|
if (version == 0)
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ struct CPAL
|
|||||||
if (unlikely (color_index >= numPaletteEntries || palette >= numPalettes))
|
if (unlikely (color_index >= numPaletteEntries || palette >= numPalettes))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// No need for more range check as it is already done on #sanitize
|
/* No need for more range check as it is already done on #sanitize */
|
||||||
const UnsizedArrayOf<BGRAColor>& color_records = this+colorRecordsZ;
|
const UnsizedArrayOf<BGRAColor>& color_records = this+colorRecordsZ;
|
||||||
if (color)
|
if (color)
|
||||||
*color = color_records[colorRecordIndicesZ[palette] + color_index];
|
*color = color_records[colorRecordIndicesZ[palette] + color_index];
|
||||||
|
@ -96,7 +96,7 @@ hb_ot_color_get_palette_count (hb_face_t *face)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* hb_ot_color_get_palette_name_id:
|
* hb_ot_color_get_palette_name_id:
|
||||||
* @face: a font face.
|
* @face: a font face.
|
||||||
* @palette: the index of the color palette whose name is being requested.
|
* @palette: the index of the color palette whose name is being requested.
|
||||||
*
|
*
|
||||||
* Retrieves the name id of a color palette. For example, a color font can
|
* Retrieves the name id of a color palette. For example, a color font can
|
||||||
@ -121,7 +121,7 @@ hb_ot_color_get_palette_name_id (hb_face_t *face, unsigned int palette)
|
|||||||
* @face: a font face.
|
* @face: a font face.
|
||||||
* @palette_entry:
|
* @palette_entry:
|
||||||
*
|
*
|
||||||
* Returns: Name ID associated with an palette entry, e.g. eye color
|
* Returns: Name ID associated with a palette entry, e.g. eye color
|
||||||
*
|
*
|
||||||
* Since: REPLACEME
|
* Since: REPLACEME
|
||||||
*/
|
*/
|
||||||
@ -162,33 +162,36 @@ unsigned int
|
|||||||
hb_ot_color_get_palette_colors (hb_face_t *face,
|
hb_ot_color_get_palette_colors (hb_face_t *face,
|
||||||
unsigned int palette, /* default=0 */
|
unsigned int palette, /* default=0 */
|
||||||
unsigned int start_offset,
|
unsigned int start_offset,
|
||||||
unsigned int *count /* IN/OUT. May be NULL. */,
|
unsigned int *colors_count /* IN/OUT. May be NULL. */,
|
||||||
hb_color_t *colors /* OUT. May be NULL. */)
|
hb_color_t *colors /* OUT. May be NULL. */)
|
||||||
{
|
{
|
||||||
const OT::CPAL& cpal = _get_cpal(face);
|
const OT::CPAL& cpal = _get_cpal(face);
|
||||||
if (unlikely (palette >= cpal.get_palette_count ()))
|
if (unlikely (palette >= cpal.get_palette_count ()))
|
||||||
{
|
{
|
||||||
if (count) *count = 0;
|
if (colors_count) *colors_count = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int num_results = 0;
|
unsigned int num_results = 0;
|
||||||
if (count)
|
if (colors_count)
|
||||||
{
|
{
|
||||||
unsigned int platte_count = MIN<unsigned int>(*count, cpal.get_palette_entries_count () - start_offset);
|
unsigned int platte_count;
|
||||||
|
platte_count = MIN<unsigned int>(*colors_count,
|
||||||
|
cpal.get_palette_entries_count () - start_offset);
|
||||||
for (unsigned int i = 0; i < platte_count; i++)
|
for (unsigned int i = 0; i < platte_count; i++)
|
||||||
{
|
{
|
||||||
if (cpal.get_color_record_argb(start_offset + i, palette, &colors[num_results]))
|
if (cpal.get_color_record_argb(start_offset + i, palette, &colors[num_results]))
|
||||||
++num_results;
|
++num_results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (likely (count)) *count = num_results;
|
if (likely (colors_count)) *colors_count = num_results;
|
||||||
return cpal.get_palette_entries_count ();
|
return cpal.get_palette_entries_count ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hb_ot_color_get_color_layers:
|
* hb_ot_color_get_color_layers:
|
||||||
|
* @face: a font face.
|
||||||
* @gid:
|
* @gid:
|
||||||
* @start_offset:
|
* @start_offset:
|
||||||
* @count: (inout) (optional):
|
* @count: (inout) (optional):
|
||||||
@ -203,8 +206,8 @@ unsigned int
|
|||||||
hb_ot_color_get_color_layers (hb_face_t *face,
|
hb_ot_color_get_color_layers (hb_face_t *face,
|
||||||
hb_codepoint_t gid,
|
hb_codepoint_t gid,
|
||||||
unsigned int start_offset,
|
unsigned int start_offset,
|
||||||
unsigned int *count, /* IN/OUT. May be NULL. */
|
unsigned int *count /* IN/OUT. May be NULL. */,
|
||||||
hb_codepoint_t *gids, /* OUT. May be NULL. */
|
hb_codepoint_t *gids /* OUT. May be NULL. */,
|
||||||
unsigned int *color_indices /* OUT. May be NULL. */)
|
unsigned int *color_indices /* OUT. May be NULL. */)
|
||||||
{
|
{
|
||||||
const OT::COLR& colr = _get_colr (face);
|
const OT::COLR& colr = _get_colr (face);
|
||||||
@ -230,7 +233,7 @@ hb_ot_color_get_color_layers (hb_face_t *face,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* hb_ot_color_get_palette_flags:
|
* hb_ot_color_get_palette_flags:
|
||||||
* @face: a font face
|
* @face: a font face
|
||||||
* @palette: the index of the color palette whose flags are being requested
|
* @palette: the index of the color palette whose flags are being requested
|
||||||
*
|
*
|
||||||
* Returns: the flags for the requested color palette. If @face has no colors,
|
* Returns: the flags for the requested color palette. If @face has no colors,
|
||||||
|
@ -57,16 +57,16 @@ HB_EXTERN unsigned int
|
|||||||
hb_ot_color_get_palette_colors (hb_face_t *face,
|
hb_ot_color_get_palette_colors (hb_face_t *face,
|
||||||
unsigned int palette, /* default=0 */
|
unsigned int palette, /* default=0 */
|
||||||
unsigned int start_offset,
|
unsigned int start_offset,
|
||||||
unsigned int *color_count /* IN/OUT */,
|
unsigned int *color_count /* IN/OUT. May be NULL. */,
|
||||||
hb_color_t *colors /* OUT */);
|
hb_color_t *colors /* OUT. May be NULL. */);
|
||||||
|
|
||||||
HB_EXTERN unsigned int
|
HB_EXTERN unsigned int
|
||||||
hb_ot_color_get_color_layers (hb_face_t *face,
|
hb_ot_color_get_color_layers (hb_face_t *face,
|
||||||
hb_codepoint_t gid,
|
hb_codepoint_t gid,
|
||||||
unsigned int offset,
|
unsigned int start_offset,
|
||||||
unsigned int *count, /* IN/OUT */
|
unsigned int *count /* IN/OUT. May be NULL. */,
|
||||||
hb_codepoint_t *gids, /* OUT */
|
hb_codepoint_t *gids /* OUT. May be NULL. */,
|
||||||
unsigned int *color_indices /* OUT */);
|
unsigned int *color_indices /* OUT. May be NULL. */);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hb_ot_color_palette_flags_t:
|
* hb_ot_color_palette_flags_t:
|
||||||
|
Loading…
Reference in New Issue
Block a user