From 60e10511ae9270b15b78421a33a249608a1b6642 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 16 Feb 2024 23:44:34 +0100 Subject: [PATCH] cogl: Remove Color.init_from_4ub Slowly switching to using floats only in CoglColor Helps https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3544 Part-of: --- clutter/clutter/clutter-actor.c | 10 ++--- clutter/clutter/clutter-blur.c | 2 +- clutter/clutter/clutter-deform-effect.c | 2 +- clutter/clutter/clutter-page-turn-effect.c | 6 +-- clutter/clutter/clutter-paint-nodes.c | 42 +++++++++---------- clutter/clutter/clutter-stage.c | 2 +- clutter/clutter/clutter-text.c | 40 +++++++++--------- cogl/cogl-pango/cogl-pango-render.c | 14 +++---- cogl/cogl/cogl-color.c | 15 ------- cogl/cogl/cogl-color.h | 17 -------- cogl/cogl/cogl-pipeline.c | 6 +-- src/backends/meta-screen-cast-stream-src.c | 2 +- src/compositor/meta-shaped-texture.c | 3 +- src/compositor/meta-window-actor.c | 4 +- .../interactive/test-cogl-tex-polygon.c | 10 ++--- src/tests/cogl/conform/test-alpha-test.c | 2 +- src/tests/cogl/conform/test-blend-strings.c | 8 +++- .../cogl/conform/test-just-vertex-shader.c | 4 +- src/tests/cogl/conform/test-layer-remove.c | 10 ++--- .../conform/test-offscreen-texture-formats.c | 8 +++- src/tests/cogl/conform/test-offscreen.c | 2 +- .../test-pipeline-cache-unrefs-texture.c | 2 +- src/tests/cogl/conform/test-viewport.c | 2 +- 23 files changed, 95 insertions(+), 118 deletions(-) diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index a89e329b0..b3897987b 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -3056,11 +3056,11 @@ _clutter_actor_draw_paint_volume_full (ClutterActor *self, n_vertices, (CoglVertexP3 *)line_ends); - cogl_color_init_from_4ub (&cogl_color, - color->red, - color->green, - color->blue, - color->alpha); + cogl_color_init_from_4f (&cogl_color, + color->red / 255.0, + color->green / 255.0, + color->blue / 255.0, + color->alpha / 255.0); cogl_pipeline_set_color (outline, &cogl_color); pipeline_node = clutter_pipeline_node_new (outline); diff --git a/clutter/clutter/clutter-blur.c b/clutter/clutter/clutter-blur.c index 874a84c9e..c6d3ea7f3 100644 --- a/clutter/clutter/clutter-blur.c +++ b/clutter/clutter/clutter-blur.c @@ -313,7 +313,7 @@ apply_blur_pass (BlurPass *pass) { CoglColor transparent; - cogl_color_init_from_4ub (&transparent, 0, 0, 0, 0); + cogl_color_init_from_4f (&transparent, 0.0, 0.0, 0.0, 0.0); cogl_framebuffer_clear (pass->framebuffer, COGL_BUFFER_BIT_COLOR, diff --git a/clutter/clutter/clutter-deform-effect.c b/clutter/clutter/clutter-deform-effect.c index a53d0665b..5f4be0e55 100644 --- a/clutter/clutter/clutter-deform-effect.c +++ b/clutter/clutter/clutter-deform-effect.c @@ -238,7 +238,7 @@ clutter_deform_effect_paint_target (ClutterOffscreenEffect *effect, vertex.y = height * vertex.ty; vertex.z = 0.0f; - cogl_color_init_from_4ub (&vertex.color, 255, 255, 255, opacity); + cogl_color_init_from_4f (&vertex.color, 1.0, 1.0, 1.0, opacity / 255.0); clutter_deform_effect_deform_vertex (self, width, height, diff --git a/clutter/clutter/clutter-page-turn-effect.c b/clutter/clutter/clutter-page-turn-effect.c index cfa6d90f7..0dce24817 100644 --- a/clutter/clutter/clutter-page-turn-effect.c +++ b/clutter/clutter/clutter-page-turn-effect.c @@ -77,7 +77,7 @@ clutter_page_turn_effect_deform_vertex (ClutterDeformEffect *effect, { ClutterPageTurnEffect *self = CLUTTER_PAGE_TURN_EFFECT (effect); gfloat cx, cy, rx, ry, radians, turn_angle; - guint shade; + float shade; if (self->period == 0.0) return; @@ -103,12 +103,12 @@ clutter_page_turn_effect_deform_vertex (ClutterDeformEffect *effect, * ray (i.e. the page crease) */ turn_angle = (rx / self->radius * G_PI_2) - G_PI_2; - shade = (sin (turn_angle) * 96.0f) + 159.0f; + shade = ((sin (turn_angle) * 96.0f) + 159.0f) / 255.0; /* Add a gradient that makes it look like lighting and hides the switch * between textures. */ - cogl_color_init_from_4ub (&vertex->color, shade, shade, shade, 0xff); + cogl_color_init_from_4f (&vertex->color, shade, shade, shade, 1.0); } if (rx > 0) diff --git a/clutter/clutter/clutter-paint-nodes.c b/clutter/clutter/clutter-paint-nodes.c index 24b5f8bec..3384ca617 100644 --- a/clutter/clutter/clutter-paint-nodes.c +++ b/clutter/clutter/clutter-paint-nodes.c @@ -161,11 +161,11 @@ clutter_root_node_new (CoglFramebuffer *framebuffer, res = _clutter_paint_node_create (CLUTTER_TYPE_ROOT_NODE); - cogl_color_init_from_4ub (&res->clear_color, - clear_color->red, - clear_color->green, - clear_color->blue, - clear_color->alpha); + cogl_color_init_from_4f (&res->clear_color, + clear_color->red / 255.0, + clear_color->green / 255.0, + clear_color->blue / 255.0, + clear_color->alpha / 255.0); cogl_color_premultiply (&res->clear_color); res->framebuffer = g_object_ref (framebuffer); @@ -565,11 +565,11 @@ clutter_color_node_new (const ClutterColor *color) { CoglColor cogl_color; - cogl_color_init_from_4ub (&cogl_color, - color->red, - color->green, - color->blue, - color->alpha); + cogl_color_init_from_4f (&cogl_color, + color->red / 255.0, + color->green / 255.0, + color->blue / 255.0, + color->alpha / 255.0); cogl_color_premultiply (&cogl_color); cogl_pipeline_set_color (cnode->pipeline, &cogl_color); @@ -674,15 +674,15 @@ clutter_texture_node_new (CoglTexture *texture, if (color != NULL) { - cogl_color_init_from_4ub (&cogl_color, - color->red, - color->green, - color->blue, - color->alpha); + cogl_color_init_from_4f (&cogl_color, + color->red / 255.0, + color->green / 255.0, + color->blue / 255.0, + color->alpha / 255.0); cogl_color_premultiply (&cogl_color); } else - cogl_color_init_from_4ub (&cogl_color, 255, 255, 255, 255); + cogl_color_init_from_4f (&cogl_color, 1.0, 1.0, 1.0, 1.0); cogl_pipeline_set_color (tnode->pipeline, &cogl_color); @@ -843,11 +843,11 @@ clutter_text_node_new (PangoLayout *layout, if (color != NULL) { - cogl_color_init_from_4ub (&res->color, - color->red, - color->green, - color->blue, - color->alpha); + cogl_color_init_from_4f (&res->color, + color->red / 255.0, + color->green / 255.0, + color->blue / 255.0, + color->alpha / 255.0); } return (ClutterPaintNode *) res; diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index 498408ec3..c13c548dc 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -2702,7 +2702,7 @@ clutter_stage_paint_to_framebuffer (ClutterStage *stage, { CoglColor clear_color; - cogl_color_init_from_4ub (&clear_color, 0, 0, 0, 0); + cogl_color_init_from_4f (&clear_color, 0.0, 0.0, 0.0, 0.0); cogl_framebuffer_clear (framebuffer, COGL_BUFFER_BIT_COLOR, &clear_color); } diff --git a/clutter/clutter/clutter-text.c b/clutter/clutter/clutter-text.c index 9f2b3544b..9fa9cdf54 100644 --- a/clutter/clutter/clutter-text.c +++ b/clutter/clutter/clutter-text.c @@ -1925,11 +1925,11 @@ paint_selection_rectangle (ClutterText *self, else color = &priv->text_color; - cogl_color_init_from_4ub (&cogl_color, - color->red, - color->green, - color->blue, - paint_opacity * color->alpha / 255); + cogl_color_init_from_4f (&cogl_color, + color->red / 255.0, + color->green / 255.0, + color->blue / 255.0, + paint_opacity / 255.0 * color->alpha / 255.0); cogl_color_premultiply (&cogl_color); cogl_pipeline_set_color (color_pipeline, &cogl_color); @@ -1945,11 +1945,11 @@ paint_selection_rectangle (ClutterText *self, else color = &priv->text_color; - cogl_color_init_from_4ub (&cogl_color, - color->red, - color->green, - color->blue, - paint_opacity * color->alpha / 255); + cogl_color_init_from_4f (&cogl_color, + color->red / 255.0, + color->green / 255.0, + color->blue / 255.0, + paint_opacity / 255.0 * color->alpha / 255.0); cogl_pango_show_layout (fb, layout, priv->text_x, 0, &cogl_color); @@ -1982,11 +1982,11 @@ selection_paint (ClutterText *self, color = &priv->text_color; - cogl_color_init_from_4ub (&cogl_color, - color->red, - color->green, - color->blue, - paint_opacity * color->alpha / 255); + cogl_color_init_from_4f (&cogl_color, + color->red / 255.0, + color->green / 255.0, + color->blue / 255.0, + paint_opacity / 255.0 * color->alpha / 255.0); cogl_color_premultiply (&cogl_color); cogl_pipeline_set_color (color_pipeline, &cogl_color); @@ -2753,11 +2753,11 @@ clutter_text_paint (ClutterActor *self, CLUTTER_NOTE (PAINT, "painting text (text: '%s')", clutter_text_buffer_get_text (get_buffer (text))); - cogl_color_init_from_4ub (&color, - priv->text_color.red, - priv->text_color.green, - priv->text_color.blue, - real_opacity); + cogl_color_init_from_4f (&color, + priv->text_color.red / 255.0, + priv->text_color.green / 255.0, + priv->text_color.blue / 255.0, + real_opacity / 255.0); cogl_pango_show_layout (fb, layout, priv->text_x, priv->text_y, &color); selection_paint (text, fb); diff --git a/cogl/cogl-pango/cogl-pango-render.c b/cogl/cogl-pango/cogl-pango-render.c index cbd9d0a63..8b96b2a72 100644 --- a/cogl/cogl-pango/cogl-pango-render.c +++ b/cogl/cogl-pango/cogl-pango-render.c @@ -714,11 +714,11 @@ cogl_pango_renderer_set_color_for_part (PangoRenderer *renderer, { CoglColor color; - cogl_color_init_from_4ub (&color, - pango_color->red >> 8, - pango_color->green >> 8, - pango_color->blue >> 8, - alpha ? alpha >> 8 : 0xff); + cogl_color_init_from_4f (&color, + pango_color->red / 65535.0, + pango_color->green / 65535.0, + pango_color->blue / 65535.0, + alpha ? alpha / 65535.0 : 1.0); _cogl_pango_display_list_set_color_override (priv->display_list, &color); } @@ -901,8 +901,8 @@ cogl_pango_renderer_draw_glyphs (PangoRenderer *renderer, alpha = pango_renderer_get_alpha (renderer, PANGO_RENDER_PART_FOREGROUND); - cogl_color_init_from_4ub (&color, 0xff, 0xff, 0xff, - alpha ? alpha >> 8 : 0xff); + cogl_color_init_from_4f (&color, 1.0, 1.0, 1.0, + alpha ? (alpha >> 8) / 255.0 : 1.0); _cogl_pango_display_list_set_color_override (priv->display_list, &color); } diff --git a/cogl/cogl/cogl-color.c b/cogl/cogl/cogl-color.c index 7ab76d8be..310243a87 100644 --- a/cogl/cogl/cogl-color.c +++ b/cogl/cogl/cogl-color.c @@ -57,21 +57,6 @@ cogl_color_free (CoglColor *color) g_free (color); } -void -cogl_color_init_from_4ub (CoglColor *color, - uint8_t red, - uint8_t green, - uint8_t blue, - uint8_t alpha) -{ - g_return_if_fail (color != NULL); - - color->red = red; - color->green = green; - color->blue = blue; - color->alpha = alpha; -} - void cogl_color_init_from_4f (CoglColor *color, float red, diff --git a/cogl/cogl/cogl-color.h b/cogl/cogl/cogl-color.h index 91fdc9e95..c5526d956 100644 --- a/cogl/cogl/cogl-color.h +++ b/cogl/cogl/cogl-color.h @@ -81,23 +81,6 @@ cogl_color_copy (const CoglColor *color); COGL_EXPORT void cogl_color_free (CoglColor *color); -/** - * cogl_color_init_from_4ub: - * @color: A pointer to a #CoglColor to initialize - * @red: value of the red channel, between 0 and 255 - * @green: value of the green channel, between 0 and 255 - * @blue: value of the blue channel, between 0 and 255 - * @alpha: value of the alpha channel, between 0 and 255 - * - * Sets the values of the passed channels into a #CoglColor. - */ -COGL_EXPORT void -cogl_color_init_from_4ub (CoglColor *color, - uint8_t red, - uint8_t green, - uint8_t blue, - uint8_t alpha); - /** * cogl_color_init_from_4f: * @color: A pointer to a #CoglColor to initialize diff --git a/cogl/cogl/cogl-pipeline.c b/cogl/cogl/cogl-pipeline.c index 5feb5e7de..f5a48b9f4 100644 --- a/cogl/cogl/cogl-pipeline.c +++ b/cogl/cogl/cogl-pipeline.c @@ -194,8 +194,8 @@ create_default_big_state (void) blend_state->blend_equation_alpha = GL_FUNC_ADD; blend_state->blend_src_factor_alpha = GL_ONE; blend_state->blend_dst_factor_alpha = GL_ONE_MINUS_SRC_ALPHA; - cogl_color_init_from_4ub (&blend_state->blend_constant, - 0x00, 0x00, 0x00, 0x00); + cogl_color_init_from_4f (&blend_state->blend_constant, + 0.0, 0.0, 0.0, 0.0); blend_state->blend_src_factor_rgb = GL_ONE; blend_state->blend_dst_factor_rgb = GL_ONE_MINUS_SRC_ALPHA; @@ -229,7 +229,7 @@ _cogl_pipeline_init_default_pipeline (CoglContext *context) pipeline->has_big_state = TRUE; /* Use the same defaults as the GL spec... */ - cogl_color_init_from_4ub (&pipeline->color, 0xff, 0xff, 0xff, 0xff); + cogl_color_init_from_4f (&pipeline->color, 1.0, 1.0, 1.0, 1.0); #ifdef COGL_ENABLE_DEBUG pipeline->static_breadcrumb = "default pipeline"; diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c index f5cf3c251..43a14beda 100644 --- a/src/backends/meta-screen-cast-stream-src.c +++ b/src/backends/meta-screen-cast-stream-src.c @@ -354,7 +354,7 @@ draw_cursor_sprite_via_offscreen (MetaScreenCastStreamSrc *src, &matrix); cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix); - cogl_color_init_from_4ub (&clear_color, 0, 0, 0, 0); + cogl_color_init_from_4f (&clear_color, 0.0, 0.0, 0.0, 0.0); cogl_framebuffer_clear (fb, COGL_BUFFER_BIT_COLOR, &clear_color); cogl_framebuffer_draw_rectangle (fb, pipeline, -1, 1, 1, -1); diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c index 0ccb4c1e9..b47572b2e 100644 --- a/src/compositor/meta-shaped-texture.c +++ b/src/compositor/meta-shaped-texture.c @@ -846,7 +846,8 @@ do_paint_content (MetaShapedTexture *stex, cogl_pipeline_set_layer_filters (blended_pipeline, i, min_filter, mag_filter); } - cogl_color_init_from_4ub (&color, opacity, opacity, opacity, opacity); + cogl_color_init_from_4f (&color, opacity / 255.0, opacity / 255.0, + opacity / 255.0, opacity / 255.0); cogl_pipeline_set_color (blended_pipeline, &color); if (blended_tex_region) diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c index 78546ffd2..b3f028a15 100644 --- a/src/compositor/meta-window-actor.c +++ b/src/compositor/meta-window-actor.c @@ -1448,7 +1448,7 @@ meta_window_actor_blit_to_framebuffer (MetaScreenCastWindow *screen_cast_window, clutter_actor_inhibit_culling (actor); - cogl_color_init_from_4ub (&clear_color, 0, 0, 0, 0); + cogl_color_init_from_4f (&clear_color, 0.0, 0.0, 0.0, 0.0); cogl_framebuffer_clear (framebuffer, COGL_BUFFER_BIT_COLOR, &clear_color); cogl_framebuffer_orthographic (framebuffer, 0, 0, @@ -1606,7 +1606,7 @@ create_framebuffer_from_window_actor (MetaWindowActor *self, return NULL; } - cogl_color_init_from_4ub (&clear_color, 0, 0, 0, 0); + cogl_color_init_from_4f (&clear_color, 0.0, 0.0, 0.0, 0.0); cogl_framebuffer_clear (framebuffer, COGL_BUFFER_BIT_COLOR, &clear_color); cogl_framebuffer_orthographic (framebuffer, 0, 0, clip->width, clip->height, 0, 1.0); diff --git a/src/tests/clutter/interactive/test-cogl-tex-polygon.c b/src/tests/clutter/interactive/test-cogl-tex-polygon.c index 41a5e7502..6cd9f4501 100644 --- a/src/tests/clutter/interactive/test-cogl-tex-polygon.c +++ b/src/tests/clutter/interactive/test-cogl-tex-polygon.c @@ -83,11 +83,11 @@ test_coglbox_fade_texture (CoglFramebuffer *framebuffer, { CoglColor cogl_color; - cogl_color_init_from_4ub (&cogl_color, - 255, - 255, - 255, - ((i ^ (i >> 1)) & 1) ? 0 : 128); + cogl_color_init_from_4f (&cogl_color, + 1.0, + 1.0, + 1.0, + ((i ^ (i >> 1)) & 1) ? 0.0 : 128.0 / 255.0); cogl_color_premultiply (&cogl_color); vertices[i].r = cogl_color_get_red (&cogl_color) * 255.0; vertices[i].g = cogl_color_get_green (&cogl_color) * 255.0; diff --git a/src/tests/cogl/conform/test-alpha-test.c b/src/tests/cogl/conform/test-alpha-test.c index 0f820739e..d01f01093 100644 --- a/src/tests/cogl/conform/test-alpha-test.c +++ b/src/tests/cogl/conform/test-alpha-test.c @@ -37,7 +37,7 @@ test_alpha_test (void) COGL_PIPELINE_ALPHA_FUNC_GEQUAL, 254 / 255.0f /* alpha reference */); - cogl_color_init_from_4ub (&clear_color, 0x00, 0x00, 0xff, 0xff); + cogl_color_init_from_4f (&clear_color, 0.0, 0.0, 1.0, 1.0); cogl_framebuffer_clear (test_fb, COGL_BUFFER_BIT_COLOR, &clear_color); diff --git a/src/tests/cogl/conform/test-blend-strings.c b/src/tests/cogl/conform/test-blend-strings.c index 2f3935cfb..8a3a3597f 100644 --- a/src/tests/cogl/conform/test-blend-strings.c +++ b/src/tests/cogl/conform/test-blend-strings.c @@ -97,7 +97,9 @@ test_blend_paint (TestState *state, return; } - cogl_color_init_from_4ub (&blend_const_color, Br, Bg, Bb, Ba); + cogl_color_init_from_4f (&blend_const_color, + Br / 255.0, Bg / 255.0, + Bb / 255.0, Ba / 255.0); cogl_pipeline_set_blend_constant (pipeline, &blend_const_color); cogl_framebuffer_draw_rectangle (test_fb, @@ -215,7 +217,9 @@ test_tex_combine (TestState *state, combine_string, error->message); } - cogl_color_init_from_4ub (&combine_const_color, Cr, Cg, Cb, Ca); + cogl_color_init_from_4f (&combine_const_color, + Cr / 255.0, Cg / 255.0, + Cb / 255.0, Ca / 255.0); cogl_pipeline_set_layer_combine_constant (pipeline, 1, &combine_const_color); cogl_framebuffer_draw_rectangle (test_fb, diff --git a/src/tests/cogl/conform/test-just-vertex-shader.c b/src/tests/cogl/conform/test-just-vertex-shader.c index 4cb95b67b..f149b025b 100644 --- a/src/tests/cogl/conform/test-just-vertex-shader.c +++ b/src/tests/cogl/conform/test-just-vertex-shader.c @@ -36,11 +36,11 @@ paint (TestState *state) CoglShader *shader; CoglProgram *program; - cogl_color_init_from_4ub (&color, 0, 0, 0, 255); + cogl_color_init_from_4f (&color, 0.0, 0.0, 0.0, 1.0); cogl_framebuffer_clear (test_fb, COGL_BUFFER_BIT_COLOR, &color); /* Set the primary vertex color as red */ - cogl_color_init_from_4ub (&color, 0xff, 0x00, 0x00, 0xff); + cogl_color_init_from_4f (&color, 1.0, 0.0, 0.0, 1.0); cogl_pipeline_set_color (pipeline, &color); /* Override the vertex color in the texture environment with a diff --git a/src/tests/cogl/conform/test-layer-remove.c b/src/tests/cogl/conform/test-layer-remove.c index 8a41476f7..0ee897bea 100644 --- a/src/tests/cogl/conform/test-layer-remove.c +++ b/src/tests/cogl/conform/test-layer-remove.c @@ -11,11 +11,11 @@ create_two_layer_pipeline (void) CoglColor color; /* The pipeline is initially black */ - cogl_color_init_from_4f (&color, 0.0, 0.0, 0.0, 255.0); + cogl_color_init_from_4f (&color, 0.0, 0.0, 0.0, 1.0); cogl_pipeline_set_color (pipeline, &color); /* The first layer adds a full red component */ - cogl_color_init_from_4ub (&color, 255, 0, 0, 255); + cogl_color_init_from_4f (&color, 1.0, 0.0, 0.0, 1.0); cogl_pipeline_set_layer_combine_constant (pipeline, 0, &color); cogl_pipeline_set_layer_combine (pipeline, 0, /* layer_num */ @@ -23,7 +23,7 @@ create_two_layer_pipeline (void) NULL); /* The second layer adds a full green component */ - cogl_color_init_from_4ub (&color, 0, 255, 0, 255); + cogl_color_init_from_4f (&color, 0.0, 1.0, 0.0, 1.0); cogl_pipeline_set_layer_combine_constant (pipeline, 1, &color); cogl_pipeline_set_layer_combine (pipeline, 1, /* layer_num */ @@ -122,7 +122,7 @@ test_layer_remove (void) /* Check that we can modify a layer in a child pipeline */ pipeline0 = create_two_layer_pipeline (); pipeline1 = cogl_pipeline_copy (pipeline0); - cogl_color_init_from_4ub (&color, 0, 0, 255, 255); + cogl_color_init_from_4f (&color, 0.0, 0.0, 1.0, 1.0); cogl_pipeline_set_layer_combine_constant (pipeline1, 0, &color); test_color (pipeline0, 0xffff00ff, pos++); test_color (pipeline1, 0x00ffffff, pos++); @@ -133,7 +133,7 @@ test_layer_remove (void) /* Check that we can modify a layer in a child pipeline but then remove it */ pipeline0 = create_two_layer_pipeline (); pipeline1 = cogl_pipeline_copy (pipeline0); - cogl_color_init_from_4ub (&color, 0, 0, 255, 255); + cogl_color_init_from_4f (&color, 0.0, 0.0, 1.0, 1.0); cogl_pipeline_set_layer_combine_constant (pipeline1, 0, &color); cogl_pipeline_remove_layer (pipeline1, 0); test_color (pipeline0, 0xffff00ff, pos++); diff --git a/src/tests/cogl/conform/test-offscreen-texture-formats.c b/src/tests/cogl/conform/test-offscreen-texture-formats.c index c15194a4d..8706ec39c 100644 --- a/src/tests/cogl/conform/test-offscreen-texture-formats.c +++ b/src/tests/cogl/conform/test-offscreen-texture-formats.c @@ -439,7 +439,9 @@ test_offscreen_texture_formats_store_rgb8 (void) }; int i; - cogl_color_init_from_4ub (&color, red, green, blue, alpha); + cogl_color_init_from_4f (&color, + red / 255.0, green / 255.0, + blue / 255.0, alpha / 255.0); for (i = 0; i < G_N_ELEMENTS (formats); i++) { @@ -810,7 +812,9 @@ test_offscreen_texture_formats_paint_rgb8 (void) }; int i; - cogl_color_init_from_4ub (&color, red, green, blue, alpha); + cogl_color_init_from_4f (&color, + red / 255.0, green / 255.0, + blue / 255.0, alpha / 255.0); for (i = 0; i < G_N_ELEMENTS (formats); i++) { diff --git a/src/tests/cogl/conform/test-offscreen.c b/src/tests/cogl/conform/test-offscreen.c index 51a8bb36d..348ed201f 100644 --- a/src/tests/cogl/conform/test-offscreen.c +++ b/src/tests/cogl/conform/test-offscreen.c @@ -149,7 +149,7 @@ test_flush (TestState *state) offscreen = cogl_offscreen_new_with_texture (tex); framebuffer = COGL_FRAMEBUFFER (offscreen); - cogl_color_init_from_4ub (&clear_color, 0, 0, 0, 255); + cogl_color_init_from_4f (&clear_color, 0.0, 0.0, 0.0, 1.0); cogl_framebuffer_clear (framebuffer, COGL_BUFFER_BIT_COLOR, &clear_color); cogl_framebuffer_draw_rectangle (framebuffer, pipeline, -1, -1, 1, 1); diff --git a/src/tests/cogl/conform/test-pipeline-cache-unrefs-texture.c b/src/tests/cogl/conform/test-pipeline-cache-unrefs-texture.c index c9c3f1980..9d1600e31 100644 --- a/src/tests/cogl/conform/test-pipeline-cache-unrefs-texture.c +++ b/src/tests/cogl/conform/test-pipeline-cache-unrefs-texture.c @@ -69,7 +69,7 @@ test_pipeline_cache_unrefs_texture (void) for (i = 0; i < N_TEXTURES; i++) { CoglColor combine_constant; - cogl_color_init_from_4ub (&combine_constant, i, 0, 0, 255); + cogl_color_init_from_4f (&combine_constant, i / 255.0, 0.0, 0.0, 1.0); cogl_pipeline_set_layer_combine_constant (simple_pipeline, i, &combine_constant); diff --git a/src/tests/cogl/conform/test-viewport.c b/src/tests/cogl/conform/test-viewport.c index 57a709ec8..5071fb50c 100644 --- a/src/tests/cogl/conform/test-viewport.c +++ b/src/tests/cogl/conform/test-viewport.c @@ -84,7 +84,7 @@ on_after_paint (ClutterActor *actor, float height; /* for clearing the offscreen framebuffer to black... */ - cogl_color_init_from_4ub (&black, 0x00, 0x00, 0x00, 0xff); + cogl_color_init_from_4f (&black, 0.0, 0.0, 0.0, 1.0); cogl_get_viewport (saved_viewport); cogl_get_projection_matrix (&saved_projection);