From 40dde833af13703590da22923109ecb9e26f0e0f Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 16 Feb 2024 22:44:37 +0100 Subject: [PATCH] cogl: Remove Color.get_*_float They are exactly the same as the get_* variants Part-of: --- cogl/cogl/cogl-color.c | 24 ----------- cogl/cogl/cogl-color.h | 48 ---------------------- cogl/cogl/cogl-framebuffer.c | 8 ++-- cogl/cogl/cogl-pipeline-layer-state.c | 8 ++-- cogl/cogl/driver/gl/cogl-pipeline-opengl.c | 20 ++++----- src/tests/cogl/conform/test-color-hsl.c | 8 ++-- 6 files changed, 20 insertions(+), 96 deletions(-) diff --git a/cogl/cogl/cogl-color.c b/cogl/cogl/cogl-color.c index 6014f1d1a..bef603786 100644 --- a/cogl/cogl/cogl-color.c +++ b/cogl/cogl/cogl-color.c @@ -93,12 +93,6 @@ cogl_color_get_red_byte (const CoglColor *color) return color->red; } -float -cogl_color_get_red_float (const CoglColor *color) -{ - return (float) color->red / 255.0; -} - float cogl_color_get_red (const CoglColor *color) { @@ -111,12 +105,6 @@ cogl_color_get_green_byte (const CoglColor *color) return color->green; } -float -cogl_color_get_green_float (const CoglColor *color) -{ - return (float) color->green / 255.0; -} - float cogl_color_get_green (const CoglColor *color) { @@ -129,12 +117,6 @@ cogl_color_get_blue_byte (const CoglColor *color) return color->blue; } -float -cogl_color_get_blue_float (const CoglColor *color) -{ - return (float) color->blue / 255.0; -} - float cogl_color_get_blue (const CoglColor *color) { @@ -147,12 +129,6 @@ cogl_color_get_alpha_byte (const CoglColor *color) return color->alpha; } -float -cogl_color_get_alpha_float (const CoglColor *color) -{ - return (float) color->alpha / 255.0; -} - float cogl_color_get_alpha (const CoglColor *color) { diff --git a/cogl/cogl/cogl-color.h b/cogl/cogl/cogl-color.h index 4f1479efd..e6b12d8cf 100644 --- a/cogl/cogl/cogl-color.h +++ b/cogl/cogl/cogl-color.h @@ -163,54 +163,6 @@ cogl_color_get_blue_byte (const CoglColor *color); COGL_EXPORT unsigned char cogl_color_get_alpha_byte (const CoglColor *color); -/** - * cogl_color_get_red_float: - * @color: a #CoglColor - * - * Retrieves the red channel of @color as a floating point - * value between 0.0 and 1.0 - * - * Return value: the red channel of the passed color - */ -COGL_EXPORT float -cogl_color_get_red_float (const CoglColor *color); - -/** - * cogl_color_get_green_float: - * @color: a #CoglColor - * - * Retrieves the green channel of @color as a floating point - * value between 0.0 and 1.0 - * - * Return value: the green channel of the passed color - */ -COGL_EXPORT float -cogl_color_get_green_float (const CoglColor *color); - -/** - * cogl_color_get_blue_float: - * @color: a #CoglColor - * - * Retrieves the blue channel of @color as a floating point - * value between 0.0 and 1.0 - * - * Return value: the blue channel of the passed color - */ -COGL_EXPORT float -cogl_color_get_blue_float (const CoglColor *color); - -/** - * cogl_color_get_alpha_float: - * @color: a #CoglColor - * - * Retrieves the alpha channel of @color as a floating point - * value between 0.0 and 1.0 - * - * Return value: the alpha channel of the passed color - */ -COGL_EXPORT float -cogl_color_get_alpha_float (const CoglColor *color); - /** * cogl_color_get_red: * @color: a #CoglColor diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c index aa43fd1aa..269c49d26 100644 --- a/cogl/cogl/cogl-framebuffer.c +++ b/cogl/cogl/cogl-framebuffer.c @@ -645,10 +645,10 @@ cogl_framebuffer_clear (CoglFramebuffer *framebuffer, const CoglColor *color) { cogl_framebuffer_clear4f (framebuffer, buffers, - cogl_color_get_red_float (color), - cogl_color_get_green_float (color), - cogl_color_get_blue_float (color), - cogl_color_get_alpha_float (color)); + cogl_color_get_red (color), + cogl_color_get_green (color), + cogl_color_get_blue (color), + cogl_color_get_alpha (color)); } /* We will lazily allocate framebuffers if necessary when querying diff --git a/cogl/cogl/cogl-pipeline-layer-state.c b/cogl/cogl/cogl-pipeline-layer-state.c index c6625566e..88a6dc8ab 100644 --- a/cogl/cogl/cogl-pipeline-layer-state.c +++ b/cogl/cogl/cogl-pipeline-layer-state.c @@ -1029,10 +1029,10 @@ cogl_pipeline_set_layer_combine_constant (CoglPipeline *pipeline, * state we want to change */ authority = _cogl_pipeline_layer_get_authority (layer, state); - color_as_floats[0] = cogl_color_get_red_float (constant_color); - color_as_floats[1] = cogl_color_get_green_float (constant_color); - color_as_floats[2] = cogl_color_get_blue_float (constant_color); - color_as_floats[3] = cogl_color_get_alpha_float (constant_color); + color_as_floats[0] = cogl_color_get_red (constant_color); + color_as_floats[1] = cogl_color_get_green (constant_color); + color_as_floats[2] = cogl_color_get_blue (constant_color); + color_as_floats[3] = cogl_color_get_alpha (constant_color); if (memcmp (authority->big_state->texture_combine_constant, color_as_floats, sizeof (float) * 4) == 0) diff --git a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c index a07c6a50b..3deef74f7 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c @@ -321,14 +321,10 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state ( blend_factor_uses_constant (blend_state->blend_dst_factor_rgb) || blend_factor_uses_constant (blend_state->blend_dst_factor_alpha)) { - float red = - cogl_color_get_red_float (&blend_state->blend_constant); - float green = - cogl_color_get_green_float (&blend_state->blend_constant); - float blue = - cogl_color_get_blue_float (&blend_state->blend_constant); - float alpha = - cogl_color_get_alpha_float (&blend_state->blend_constant); + float red = cogl_color_get_red (&blend_state->blend_constant); + float green = cogl_color_get_green (&blend_state->blend_constant); + float blue = cogl_color_get_blue (&blend_state->blend_constant); + float alpha = cogl_color_get_alpha (&blend_state->blend_constant); GE (ctx, glBlendColor (red, green, blue, alpha)); @@ -1117,10 +1113,10 @@ done: if (attribute != -1) GE (ctx, glVertexAttrib4f (attribute, - cogl_color_get_red_float (&authority->color), - cogl_color_get_green_float (&authority->color), - cogl_color_get_blue_float (&authority->color), - cogl_color_get_alpha_float (&authority->color))); + cogl_color_get_red (&authority->color), + cogl_color_get_green (&authority->color), + cogl_color_get_blue (&authority->color), + cogl_color_get_alpha (&authority->color))); } /* Give the progend a chance to update any uniforms that might not diff --git a/src/tests/cogl/conform/test-color-hsl.c b/src/tests/cogl/conform/test-color-hsl.c index 4c422ddb1..80a2021b0 100644 --- a/src/tests/cogl/conform/test-color-hsl.c +++ b/src/tests/cogl/conform/test-color-hsl.c @@ -31,13 +31,13 @@ test_color_hsl (void) memset(&color, 0, sizeof (CoglColor)); cogl_color_init_from_hsl(&color, hue, 0, luminance); - g_assert_cmpfloat_with_epsilon (cogl_color_get_red_float (&color), luminance, + g_assert_cmpfloat_with_epsilon (cogl_color_get_red (&color), luminance, TEST_CASE_EPSILON); - g_assert_cmpfloat_with_epsilon (cogl_color_get_green_float (&color), luminance, + g_assert_cmpfloat_with_epsilon (cogl_color_get_green (&color), luminance, TEST_CASE_EPSILON); - g_assert_cmpfloat_with_epsilon (cogl_color_get_blue_float (&color), luminance, + g_assert_cmpfloat_with_epsilon (cogl_color_get_blue (&color), luminance, TEST_CASE_EPSILON); - g_assert_cmpfloat_with_epsilon (cogl_color_get_alpha_float (&color), 1.0, + g_assert_cmpfloat_with_epsilon (cogl_color_get_alpha (&color), 1.0, TEST_CASE_EPSILON); if (cogl_test_verbose ())