cogl: Remove Color.get_*_byte
Helps with https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3544 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3594>
This commit is contained in:
parent
40dde833af
commit
cf0803ab71
@ -251,10 +251,10 @@ clutter_deform_effect_paint_target (ClutterOffscreenEffect *effect,
|
||||
vertex_out->z = vertex.z;
|
||||
vertex_out->s = vertex.tx;
|
||||
vertex_out->t = vertex.ty;
|
||||
vertex_out->r = cogl_color_get_red_byte (&vertex.color);
|
||||
vertex_out->g = cogl_color_get_green_byte (&vertex.color);
|
||||
vertex_out->b = cogl_color_get_blue_byte (&vertex.color);
|
||||
vertex_out->a = cogl_color_get_alpha_byte (&vertex.color);
|
||||
vertex_out->r = cogl_color_get_red (&vertex.color) * 255.0;
|
||||
vertex_out->g = cogl_color_get_green (&vertex.color) * 255.0;
|
||||
vertex_out->b = cogl_color_get_blue (&vertex.color) * 255.0;
|
||||
vertex_out->a = cogl_color_get_alpha (&vertex.color) * 255.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -417,13 +417,12 @@ _cogl_pango_display_list_render (CoglFramebuffer *fb,
|
||||
if (node->color_override)
|
||||
/* Use the override color but preserve the alpha from the
|
||||
draw color */
|
||||
cogl_color_init_from_4ub (&draw_color,
|
||||
cogl_color_get_red_byte (&node->color),
|
||||
cogl_color_get_green_byte (&node->color),
|
||||
cogl_color_get_blue_byte (&node->color),
|
||||
(cogl_color_get_alpha_byte (&node->color) *
|
||||
cogl_color_get_alpha_byte (color) /
|
||||
255));
|
||||
cogl_color_init_from_4f (&draw_color,
|
||||
cogl_color_get_red (&node->color),
|
||||
cogl_color_get_green (&node->color),
|
||||
cogl_color_get_blue (&node->color),
|
||||
(cogl_color_get_alpha (&node->color) *
|
||||
cogl_color_get_alpha (color)));
|
||||
else
|
||||
draw_color = *color;
|
||||
cogl_color_premultiply (&draw_color);
|
||||
|
@ -87,48 +87,24 @@ cogl_color_init_from_4f (CoglColor *color,
|
||||
color->alpha = (alpha * 255);
|
||||
}
|
||||
|
||||
unsigned char
|
||||
cogl_color_get_red_byte (const CoglColor *color)
|
||||
{
|
||||
return color->red;
|
||||
}
|
||||
|
||||
float
|
||||
cogl_color_get_red (const CoglColor *color)
|
||||
{
|
||||
return ((float) color->red / 255.0);
|
||||
}
|
||||
|
||||
unsigned char
|
||||
cogl_color_get_green_byte (const CoglColor *color)
|
||||
{
|
||||
return color->green;
|
||||
}
|
||||
|
||||
float
|
||||
cogl_color_get_green (const CoglColor *color)
|
||||
{
|
||||
return ((float) color->green / 255.0);
|
||||
}
|
||||
|
||||
unsigned char
|
||||
cogl_color_get_blue_byte (const CoglColor *color)
|
||||
{
|
||||
return color->blue;
|
||||
}
|
||||
|
||||
float
|
||||
cogl_color_get_blue (const CoglColor *color)
|
||||
{
|
||||
return ((float) color->blue / 255.0);
|
||||
}
|
||||
|
||||
unsigned char
|
||||
cogl_color_get_alpha_byte (const CoglColor *color)
|
||||
{
|
||||
return color->alpha;
|
||||
}
|
||||
|
||||
float
|
||||
cogl_color_get_alpha (const CoglColor *color)
|
||||
{
|
||||
|
@ -115,54 +115,6 @@ cogl_color_init_from_4f (CoglColor *color,
|
||||
float blue,
|
||||
float alpha);
|
||||
|
||||
/**
|
||||
* cogl_color_get_red_byte:
|
||||
* @color: a #CoglColor
|
||||
*
|
||||
* Retrieves the red channel of @color as a byte value
|
||||
* between 0 and 255
|
||||
*
|
||||
* Return value: the red channel of the passed color
|
||||
*/
|
||||
COGL_EXPORT unsigned char
|
||||
cogl_color_get_red_byte (const CoglColor *color);
|
||||
|
||||
/**
|
||||
* cogl_color_get_green_byte:
|
||||
* @color: a #CoglColor
|
||||
*
|
||||
* Retrieves the green channel of @color as a byte value
|
||||
* between 0 and 255
|
||||
*
|
||||
* Return value: the green channel of the passed color
|
||||
*/
|
||||
COGL_EXPORT unsigned char
|
||||
cogl_color_get_green_byte (const CoglColor *color);
|
||||
|
||||
/**
|
||||
* cogl_color_get_blue_byte:
|
||||
* @color: a #CoglColor
|
||||
*
|
||||
* Retrieves the blue channel of @color as a byte value
|
||||
* between 0 and 255
|
||||
*
|
||||
* Return value: the blue channel of the passed color
|
||||
*/
|
||||
COGL_EXPORT unsigned char
|
||||
cogl_color_get_blue_byte (const CoglColor *color);
|
||||
|
||||
/**
|
||||
* cogl_color_get_alpha_byte:
|
||||
* @color: a #CoglColor
|
||||
*
|
||||
* Retrieves the alpha channel of @color as a byte value
|
||||
* between 0 and 255
|
||||
*
|
||||
* Return value: the alpha channel of the passed color
|
||||
*/
|
||||
COGL_EXPORT unsigned char
|
||||
cogl_color_get_alpha_byte (const CoglColor *color);
|
||||
|
||||
/**
|
||||
* cogl_color_get_red:
|
||||
* @color: a #CoglColor
|
||||
|
@ -187,10 +187,10 @@ dump_pipeline_cb (CoglNode *node, void *user_data)
|
||||
changes = TRUE;
|
||||
g_string_append_printf (changes_label,
|
||||
"\\lcolor=0x%02X%02X%02X%02X\\n",
|
||||
cogl_color_get_red_byte (&pipeline->color),
|
||||
cogl_color_get_green_byte (&pipeline->color),
|
||||
cogl_color_get_blue_byte (&pipeline->color),
|
||||
cogl_color_get_alpha_byte (&pipeline->color));
|
||||
(int) (cogl_color_get_red (&pipeline->color) * 255.0),
|
||||
(int) (cogl_color_get_green (&pipeline->color) * 255.0),
|
||||
(int) (cogl_color_get_blue (&pipeline->color) * 255.0),
|
||||
(int) (cogl_color_get_alpha (&pipeline->color) * 255.0));
|
||||
}
|
||||
|
||||
if (pipeline->differences & COGL_PIPELINE_STATE_BLEND)
|
||||
|
@ -639,14 +639,15 @@ _cogl_pipeline_change_implies_transparency (CoglPipeline *pipeline,
|
||||
if (unknown_color_alpha)
|
||||
return TRUE;
|
||||
|
||||
if ((override_color && cogl_color_get_alpha_byte (override_color) != 0xff))
|
||||
if (override_color &&
|
||||
!G_APPROX_VALUE (cogl_color_get_alpha (override_color), 1.0, FLT_EPSILON))
|
||||
return TRUE;
|
||||
|
||||
if (changes & COGL_PIPELINE_STATE_COLOR)
|
||||
{
|
||||
CoglColor tmp;
|
||||
cogl_pipeline_get_color (pipeline, &tmp);
|
||||
if (cogl_color_get_alpha_byte (&tmp) != 0xff)
|
||||
if (!G_APPROX_VALUE (cogl_color_get_alpha (&tmp), 1.0, FLT_EPSILON))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -89,10 +89,10 @@ test_coglbox_fade_texture (CoglFramebuffer *framebuffer,
|
||||
255,
|
||||
((i ^ (i >> 1)) & 1) ? 0 : 128);
|
||||
cogl_color_premultiply (&cogl_color);
|
||||
vertices[i].r = cogl_color_get_red_byte (&cogl_color);
|
||||
vertices[i].g = cogl_color_get_green_byte (&cogl_color);
|
||||
vertices[i].b = cogl_color_get_blue_byte (&cogl_color);
|
||||
vertices[i].a = cogl_color_get_alpha_byte (&cogl_color);
|
||||
vertices[i].r = cogl_color_get_red (&cogl_color) * 255.0;
|
||||
vertices[i].g = cogl_color_get_green (&cogl_color) * 255.0;
|
||||
vertices[i].b = cogl_color_get_blue (&cogl_color) * 255.0;
|
||||
vertices[i].a = cogl_color_get_alpha (&cogl_color) * 255.0;
|
||||
}
|
||||
|
||||
primitive =
|
||||
|
@ -13,7 +13,7 @@ test_color_hsl (void)
|
||||
CoglColor color;
|
||||
float hue, saturation, luminance;
|
||||
|
||||
cogl_color_init_from_4ub(&color, 108, 198, 78, 255);
|
||||
cogl_color_init_from_4f (&color, 108.0 / 255.0, 198 / 255.0, 78.0 / 255.0, 1.0);
|
||||
cogl_color_to_hsl(&color, &hue, &saturation, &luminance);
|
||||
|
||||
g_assert_cmpfloat_with_epsilon (hue, 105.f, TEST_CASE_EPSILON);
|
||||
@ -21,15 +21,19 @@ test_color_hsl (void)
|
||||
g_assert_cmpfloat_with_epsilon (luminance, 0.541176, TEST_CASE_EPSILON);
|
||||
|
||||
memset(&color, 0, sizeof (CoglColor));
|
||||
cogl_color_init_from_hsl(&color, hue, saturation, luminance);
|
||||
cogl_color_init_from_hsl (&color, hue, saturation, luminance);
|
||||
|
||||
g_assert_cmpint (cogl_color_get_red_byte (&color), ==, 108);
|
||||
g_assert_cmpint (cogl_color_get_green_byte (&color), ==, 198);
|
||||
g_assert_cmpint (cogl_color_get_blue_byte (&color), ==, 78);
|
||||
g_assert_cmpint (cogl_color_get_alpha_byte (&color), ==, 255);
|
||||
g_assert_cmpfloat_with_epsilon (cogl_color_get_red (&color), 108.0 / 255.0,
|
||||
TEST_CASE_EPSILON);
|
||||
g_assert_cmpfloat_with_epsilon (cogl_color_get_green (&color), 198.0 / 255.0,
|
||||
TEST_CASE_EPSILON);
|
||||
g_assert_cmpfloat_with_epsilon (cogl_color_get_blue (&color), 78.0 / 255.0,
|
||||
TEST_CASE_EPSILON);
|
||||
g_assert_cmpfloat_with_epsilon (cogl_color_get_alpha (&color), 1.0,
|
||||
TEST_CASE_EPSILON);
|
||||
|
||||
memset(&color, 0, sizeof (CoglColor));
|
||||
cogl_color_init_from_hsl(&color, hue, 0, luminance);
|
||||
cogl_color_init_from_hsl (&color, hue, 0, luminance);
|
||||
|
||||
g_assert_cmpfloat_with_epsilon (cogl_color_get_red (&color), luminance,
|
||||
TEST_CASE_EPSILON);
|
||||
|
Loading…
Reference in New Issue
Block a user