diff --git a/clutter/clutter/clutter-deform-effect.c b/clutter/clutter/clutter-deform-effect.c index 64b954ba1..a53d0665b 100644 --- a/clutter/clutter/clutter-deform-effect.c +++ b/clutter/clutter/clutter-deform-effect.c @@ -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; } } diff --git a/cogl/cogl-pango/cogl-pango-display-list.c b/cogl/cogl-pango/cogl-pango-display-list.c index 26354124d..60bf0fd17 100644 --- a/cogl/cogl-pango/cogl-pango-display-list.c +++ b/cogl/cogl-pango/cogl-pango-display-list.c @@ -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); diff --git a/cogl/cogl/cogl-color.c b/cogl/cogl/cogl-color.c index bef603786..7ab76d8be 100644 --- a/cogl/cogl/cogl-color.c +++ b/cogl/cogl/cogl-color.c @@ -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) { diff --git a/cogl/cogl/cogl-color.h b/cogl/cogl/cogl-color.h index e6b12d8cf..91fdc9e95 100644 --- a/cogl/cogl/cogl-color.h +++ b/cogl/cogl/cogl-color.h @@ -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 diff --git a/cogl/cogl/cogl-pipeline-debug.c b/cogl/cogl/cogl-pipeline-debug.c index 39a92d48f..ba86df706 100644 --- a/cogl/cogl/cogl-pipeline-debug.c +++ b/cogl/cogl/cogl-pipeline-debug.c @@ -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) diff --git a/cogl/cogl/cogl-pipeline.c b/cogl/cogl/cogl-pipeline.c index 8cfd232e4..5feb5e7de 100644 --- a/cogl/cogl/cogl-pipeline.c +++ b/cogl/cogl/cogl-pipeline.c @@ -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; } diff --git a/src/tests/clutter/interactive/test-cogl-tex-polygon.c b/src/tests/clutter/interactive/test-cogl-tex-polygon.c index 021584672..41a5e7502 100644 --- a/src/tests/clutter/interactive/test-cogl-tex-polygon.c +++ b/src/tests/clutter/interactive/test-cogl-tex-polygon.c @@ -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 = diff --git a/src/tests/cogl/conform/test-color-hsl.c b/src/tests/cogl/conform/test-color-hsl.c index 80a2021b0..6a2826ebb 100644 --- a/src/tests/cogl/conform/test-color-hsl.c +++ b/src/tests/cogl/conform/test-color-hsl.c @@ -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);