Add three macros for separating color channels
This commit is contained in:
parent
0e33467e52
commit
e8a6f5b803
|
@ -151,10 +151,10 @@ static void colr_cpal_rendering (hb_face_t *face, cairo_font_face_t *cairo_face)
|
||||||
uint32_t color = 0xFF;
|
uint32_t color = 0xFF;
|
||||||
if (color_indices[layer] != 0xFFFF)
|
if (color_indices[layer] != 0xFFFF)
|
||||||
color = colors[color_indices[layer]];
|
color = colors[color_indices[layer]];
|
||||||
int alpha = color & 0xFF;
|
int alpha = hb_ot_color_get_alpha (color);
|
||||||
int r = (color >> 8) & 0xFF;
|
int r = hb_ot_color_get_red (color);
|
||||||
int g = (color >> 16) & 0xFF;
|
int g = hb_ot_color_get_green (color);
|
||||||
int b = (color >> 24) & 0xFF;
|
int b = hb_ot_color_get_blue (color);
|
||||||
cairo_set_source_rgba (cr, r / 255., g / 255., b / 255., alpha);
|
cairo_set_source_rgba (cr, r / 255., g / 255., b / 255., alpha);
|
||||||
|
|
||||||
cairo_glyph_t glyph;
|
cairo_glyph_t glyph;
|
||||||
|
|
|
@ -201,7 +201,6 @@ hb_ot_color_get_color_layers (hb_face_t *face,
|
||||||
if (count)
|
if (count)
|
||||||
{
|
{
|
||||||
unsigned int layer_count = MIN<unsigned int>(*count, num_layers - start_offset);
|
unsigned int layer_count = MIN<unsigned int>(*count, num_layers - start_offset);
|
||||||
printf ("%d ", *count);
|
|
||||||
for (unsigned int i = 0; i < layer_count; i++)
|
for (unsigned int i = 0; i < layer_count; i++)
|
||||||
{
|
{
|
||||||
if (colr.get_layer_record (start_layer_index + start_offset + i,
|
if (colr.get_layer_record (start_layer_index + start_offset + i,
|
||||||
|
|
|
@ -49,6 +49,11 @@ HB_BEGIN_DECLS
|
||||||
*/
|
*/
|
||||||
typedef uint32_t hb_ot_color_t;
|
typedef uint32_t hb_ot_color_t;
|
||||||
|
|
||||||
|
#define hb_ot_color_get_alpha(color) (color & 0xFF)
|
||||||
|
#define hb_ot_color_get_red(color) ((color >> 8) & 0xFF)
|
||||||
|
#define hb_ot_color_get_green(color) ((color >> 16) & 0xFF)
|
||||||
|
#define hb_ot_color_get_blue(color) ((color >> 24) & 0xFF)
|
||||||
|
|
||||||
HB_EXTERN hb_bool_t
|
HB_EXTERN hb_bool_t
|
||||||
hb_ot_color_has_cpal_data (hb_face_t *face);
|
hb_ot_color_has_cpal_data (hb_face_t *face);
|
||||||
|
|
||||||
|
|
|
@ -102,19 +102,19 @@ static hb_face_t *cpal_v1 = NULL;
|
||||||
const hb_ot_color_t *_colors = (colors); \
|
const hb_ot_color_t *_colors = (colors); \
|
||||||
const size_t _i = (i); \
|
const size_t _i = (i); \
|
||||||
const uint8_t red = (r), green = (g), blue = (b), alpha = (a); \
|
const uint8_t red = (r), green = (g), blue = (b), alpha = (a); \
|
||||||
if ((_colors[_i] >> 16 & 0xff) != red) { \
|
if (hb_ot_color_get_red (_colors[_i]) != red) { \
|
||||||
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||||
"colors[" #i "]", _colors[_i], "==", red, 'x'); \
|
"colors[" #i "]", _colors[_i], "==", red, 'x'); \
|
||||||
} \
|
} \
|
||||||
if ((_colors[_i] >> 8 & 0xff) != green) { \
|
if (hb_ot_color_get_green (_colors[_i]) != green) { \
|
||||||
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||||
"colors[" #i "]", _colors[_i], "==", green, 'x'); \
|
"colors[" #i "]", _colors[_i], "==", green, 'x'); \
|
||||||
} \
|
} \
|
||||||
if ((_colors[_i] & 0xff) != blue) { \
|
if (hb_ot_color_get_blue (_colors[_i]) != blue) { \
|
||||||
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||||
"colors[" #i "]", colors[_i], "==", blue, 'x'); \
|
"colors[" #i "]", colors[_i], "==", blue, 'x'); \
|
||||||
} \
|
} \
|
||||||
if ((_colors[_i] >> 24 & 0xff) != alpha) { \
|
if (hb_ot_color_get_alpha (_colors[_i]) != alpha) { \
|
||||||
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||||
"colors[" #i "]", _colors[_i], "==", alpha, 'x'); \
|
"colors[" #i "]", _colors[_i], "==", alpha, 'x'); \
|
||||||
} \
|
} \
|
||||||
|
|
Loading…
Reference in New Issue