From abef73bb58aa69ec63ebe2dbaed959da7dec0bb5 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 3 Sep 2010 16:55:12 +0100 Subject: [PATCH] Replace cogl_color_set_from_* with cogl_color_init_from_* The former is not yet "officially" deprecated by the latter, but it's confusing to have them both in the code base. --- clutter/clutter-deform-effect.c | 2 +- clutter/clutter-main.c | 2 +- clutter/clutter-offscreen-effect.c | 2 +- clutter/clutter-page-turn-effect.c | 2 +- clutter/clutter-stage.c | 36 ++++++++++++------------- clutter/clutter-text.c | 10 +++---- clutter/clutter-texture.c | 12 ++++----- clutter/cogl/cogl/cogl-material.c | 4 +-- clutter/cogl/cogl/cogl.c | 6 ++--- clutter/cogl/pango/cogl-pango-display-list.c | 10 +++---- clutter/cogl/pango/cogl-pango-render.c | 10 +++---- doc/cookbook/examples/text-shadow.c | 2 +- doc/cookbook/examples/textures-crossfade-cogl.c | 2 +- doc/cookbook/examples/textures-reflection.c | 4 +-- doc/cookbook/textures.xml | 4 +-- tests/conform/test-cogl-backface-culling.c | 2 +- tests/conform/test-cogl-blend-strings.c | 4 +-- tests/conform/test-cogl-materials.c | 2 +- tests/conform/test-cogl-viewport.c | 2 +- tests/interactive/test-box-layout.c | 2 +- tests/interactive/test-cogl-tex-polygon.c | 10 +++---- 21 files changed, 64 insertions(+), 66 deletions(-) diff --git a/clutter/clutter-deform-effect.c b/clutter/clutter-deform-effect.c index a21e533..0f6f673 100644 --- a/clutter/clutter-deform-effect.c +++ b/clutter/clutter-deform-effect.c @@ -199,7 +199,7 @@ clutter_deform_effect_paint_target (ClutterOffscreenEffect *effect) vertex->y = height * vertex->ty; vertex->z = 0.0f; - cogl_color_set_from_4ub (&vertex->color, 255, 255, 255, opacity); + cogl_color_init_from_4ub (&vertex->color, 255, 255, 255, opacity); _clutter_deform_effect_deform_vertex (self, width, height, vertex); } diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index daa2891..3c8718c 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -680,7 +680,7 @@ _clutter_do_pick (ClutterStage *stage, is_clipped ? "clippped" : "full", x, y); cogl_disable_fog (); - cogl_color_set_from_4ub (&stage_pick_id, 255, 255, 255, 255); + cogl_color_init_from_4ub (&stage_pick_id, 255, 255, 255, 255); CLUTTER_TIMER_START (_clutter_uprof_context, pick_clear); cogl_clear (&stage_pick_id, COGL_BUFFER_BIT_COLOR | diff --git a/clutter/clutter-offscreen-effect.c b/clutter/clutter-offscreen-effect.c index 308edb9..2685afe 100644 --- a/clutter/clutter-offscreen-effect.c +++ b/clutter/clutter-offscreen-effect.c @@ -287,7 +287,7 @@ clutter_offscreen_effect_pre_paint (ClutterEffect *effect) perspective.z_near, perspective.z_far); - cogl_color_set_from_4ub (&transparent, 0, 0, 0, 0); + cogl_color_init_from_4ub (&transparent, 0, 0, 0, 0); cogl_clear (&transparent, COGL_BUFFER_BIT_COLOR | COGL_BUFFER_BIT_DEPTH); diff --git a/clutter/clutter-page-turn-effect.c b/clutter/clutter-page-turn-effect.c index add0c67..d95e614 100644 --- a/clutter/clutter-page-turn-effect.c +++ b/clutter/clutter-page-turn-effect.c @@ -121,7 +121,7 @@ clutter_page_turn_effect_deform_vertex (ClutterDeformEffect *effect, /* Add a gradient that makes it look like lighting and hides the switch * between textures. */ - cogl_color_set_from_4ub (&vertex->color, shade, shade, shade, 0xff); + cogl_color_init_from_4ub (&vertex->color, shade, shade, shade, 0xff); } if (rx > 0) diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index 9ab8279..c4cf053 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -316,11 +316,11 @@ clutter_stage_paint (ClutterActor *self) /* we use the real alpha to clear the stage if :use-alpha is * set; the effect depends entirely on how the Clutter backend */ - cogl_color_set_from_4ub (&stage_color, - priv->color.red, - priv->color.green, - priv->color.blue, - priv->use_alpha ? real_alpha + cogl_color_init_from_4ub (&stage_color, + priv->color.red, + priv->color.green, + priv->color.blue, + priv->use_alpha ? real_alpha : 255); cogl_color_premultiply (&stage_color); @@ -2082,11 +2082,11 @@ clutter_stage_set_use_fog (ClutterStage *stage, * * /* set the fog color to the stage background color */ * clutter_stage_get_color (CLUTTER_STAGE (actor), &stage_color); - * cogl_color_set_from_4ub (&fog_color, - * stage_color.red, - * stage_color.green, - * stage_color.blue, - * stage_color.alpha); + * cogl_color_init_from_4ub (&fog_color, + * stage_color.red, + * stage_color.green, + * stage_color.blue, + * stage_color.alpha); * * /* enable fog */ * cogl_set_fog (&fog_color, @@ -2096,15 +2096,13 @@ clutter_stage_set_use_fog (ClutterStage *stage, * } * ]| * - * Note: The fogging functions only work correctly when the visible actors use - * unmultiplied alpha colors. By default Cogl will premultiply textures - * and cogl_set_source_color will premultiply colors, so unless you - * explicitly load your textures requesting an unmultiplied - * internal_format and use cogl_material_set_color you can only use - * fogging with fully opaque actors. - * - * We can look to improve this in the future when we can depend on - * fragment shaders. + * The fogging functions only work correctly when the visible actors use + * unmultiplied alpha colors. By default Cogl will premultiply textures and + * cogl_set_source_color() will premultiply colors, so unless you explicitly + * load your textures requesting an unmultiplied internal format and use + * cogl_material_set_color() you can only use fogging with fully opaque actors. + * Support for premultiplied colors will improve in the future when we can + * depend on fragment shaders. * * Since: 0.6 */ diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index c428a4e..2d4313e 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -1903,11 +1903,11 @@ clutter_text_paint (ClutterActor *self) CLUTTER_NOTE (PAINT, "painting text (text: '%s')", priv->text); - cogl_color_set_from_4ub (&color, - priv->text_color.red, - priv->text_color.green, - priv->text_color.blue, - real_opacity); + cogl_color_init_from_4ub (&color, + priv->text_color.red, + priv->text_color.green, + priv->text_color.blue, + real_opacity); cogl_pango_render_layout (layout, text_x, 0, &color, 0); if (clip_set) diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index 423d4e1..5cbb18c 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -511,7 +511,7 @@ update_fbo (ClutterActor *self) /* cogl_clear is called to clear the buffers */ - cogl_color_set_from_4ub (&transparent_col, 0, 0, 0, 0); + cogl_color_init_from_4ub (&transparent_col, 0, 0, 0, 0); cogl_clear (&transparent_col, COGL_BUFFER_BIT_COLOR | COGL_BUFFER_BIT_DEPTH); @@ -615,11 +615,11 @@ clutter_texture_pick (ClutterActor *self, if (priv->fbo_handle != COGL_INVALID_HANDLE) update_fbo (self); - cogl_color_set_from_4ub (&pick_color, - color->red, - color->green, - color->blue, - 0xff); + cogl_color_init_from_4ub (&pick_color, + color->red, + color->green, + color->blue, + 0xff); cogl_material_set_layer_combine_constant (priv->pick_material, 0, &pick_color); cogl_material_set_layer (priv->pick_material, 0, diff --git a/clutter/cogl/cogl/cogl-material.c b/clutter/cogl/cogl/cogl-material.c index 2ecf08c..b21f431 100644 --- a/clutter/cogl/cogl/cogl-material.c +++ b/clutter/cogl/cogl/cogl-material.c @@ -3530,7 +3530,7 @@ cogl_material_set_color4ub (CoglMaterial *material, guint8 alpha) { CoglColor color; - cogl_color_set_from_4ub (&color, red, green, blue, alpha); + cogl_color_init_from_4ub (&color, red, green, blue, alpha); cogl_material_set_color (material, &color); } @@ -3542,7 +3542,7 @@ cogl_material_set_color4f (CoglMaterial *material, float alpha) { CoglColor color; - cogl_color_set_from_4f (&color, red, green, blue, alpha); + cogl_color_init_from_4f (&color, red, green, blue, alpha); cogl_material_set_color (material, &color); } diff --git a/clutter/cogl/cogl/cogl.c b/clutter/cogl/cogl/cogl.c index 229acde..6005725 100644 --- a/clutter/cogl/cogl/cogl.c +++ b/clutter/cogl/cogl/cogl.c @@ -1048,7 +1048,7 @@ cogl_set_source_texture (CoglHandle texture_handle) g_return_if_fail (texture_handle != NULL); cogl_material_set_layer (ctx->simple_material, 0, texture_handle); - cogl_color_set_from_4ub (&white, 0xff, 0xff, 0xff, 0xff); + cogl_color_init_from_4ub (&white, 0xff, 0xff, 0xff, 0xff); cogl_material_set_color (ctx->simple_material, &white); cogl_set_source (ctx->simple_material); } @@ -1061,7 +1061,7 @@ cogl_set_source_color4ub (guint8 red, { CoglColor c = { 0, }; - cogl_color_set_from_4ub (&c, red, green, blue, alpha); + cogl_color_init_from_4ub (&c, red, green, blue, alpha); cogl_set_source_color (&c); } @@ -1073,7 +1073,7 @@ cogl_set_source_color4f (float red, { CoglColor c = { 0, }; - cogl_color_set_from_4f (&c, red, green, blue, alpha); + cogl_color_init_from_4f (&c, red, green, blue, alpha); cogl_set_source_color (&c); } diff --git a/clutter/cogl/pango/cogl-pango-display-list.c b/clutter/cogl/pango/cogl-pango-display-list.c index 965418a..180aa41 100644 --- a/clutter/cogl/pango/cogl-pango-display-list.c +++ b/clutter/cogl/pango/cogl-pango-display-list.c @@ -337,11 +337,11 @@ _cogl_pango_display_list_render (CoglPangoDisplayList *dl, if (node->color_override) /* Use the override color but preserve the alpha from the draw color */ - cogl_color_set_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 (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 (color)); else draw_color = *color; cogl_color_premultiply (&draw_color); diff --git a/clutter/cogl/pango/cogl-pango-render.c b/clutter/cogl/pango/cogl-pango-render.c index 5a554a2..6068404 100644 --- a/clutter/cogl/pango/cogl-pango-render.c +++ b/clutter/cogl/pango/cogl-pango-render.c @@ -569,11 +569,11 @@ cogl_pango_renderer_set_color_for_part (PangoRenderer *renderer, { CoglColor color; - cogl_color_set_from_4ub (&color, - pango_color->red >> 8, - pango_color->green >> 8, - pango_color->blue >> 8, - 0xff); + cogl_color_init_from_4ub (&color, + pango_color->red >> 8, + pango_color->green >> 8, + pango_color->blue >> 8, + 0xff); _cogl_pango_display_list_set_color_override (priv->display_list, &color); } diff --git a/doc/cookbook/examples/text-shadow.c b/doc/cookbook/examples/text-shadow.c index ced68b7..3647da9 100644 --- a/doc/cookbook/examples/text-shadow.c +++ b/doc/cookbook/examples/text-shadow.c @@ -27,7 +27,7 @@ _text_paint_cb (ClutterActor *actor) /* Create a #ccc color and premultiply it */ CoglColor color; - cogl_color_set_from_4ub (&color, 0xcc, 0xcc, 0xcc, real_opacity); + cogl_color_init_from_4ub (&color, 0xcc, 0xcc, 0xcc, real_opacity); cogl_color_premultiply (&color); /* Finally, render the Text layout at a given offset using the color */ diff --git a/doc/cookbook/examples/textures-crossfade-cogl.c b/doc/cookbook/examples/textures-crossfade-cogl.c index 671d240..2c129f4 100644 --- a/doc/cookbook/examples/textures-crossfade-cogl.c +++ b/doc/cookbook/examples/textures-crossfade-cogl.c @@ -50,7 +50,7 @@ _update_progress_cb (ClutterTimeline *timeline, * depending on the current progress of the timeline */ CoglColor constant; - cogl_color_set_from_4ub (&constant, 0x00, 0x00, 0x00, 0xff * progress); + cogl_color_init_from_4ub (&constant, 0x00, 0x00, 0x00, 0xff * progress); /* This sets the value of the constant color we use when combining * the two layers diff --git a/doc/cookbook/examples/textures-reflection.c b/doc/cookbook/examples/textures-reflection.c index e94b40b..a5358bd 100644 --- a/doc/cookbook/examples/textures-reflection.c +++ b/doc/cookbook/examples/textures-reflection.c @@ -35,9 +35,9 @@ _clone_paint_cb (ClutterActor *actor) /* figure out the two colors for the reflection: the first is * full color and the second is the same, but at 0 opacity */ - cogl_color_set_from_4f (&color_1, 1.0, 1.0, 1.0, opacity / 255.); + cogl_color_init_from_4f (&color_1, 1.0, 1.0, 1.0, opacity / 255.); cogl_color_premultiply (&color_1); - cogl_color_set_from_4f (&color_2, 1.0, 1.0, 1.0, 0.0); + cogl_color_init_from_4f (&color_2, 1.0, 1.0, 1.0, 0.0); cogl_color_premultiply (&color_2); /* now describe the four vertices of the quad; since it has diff --git a/doc/cookbook/textures.xml b/doc/cookbook/textures.xml index 9a2cd01..b48d85b 100644 --- a/doc/cookbook/textures.xml +++ b/doc/cookbook/textures.xml @@ -677,9 +677,9 @@ _clone_paint_cb (ClutterActor *actor) /* figure out the two colors for the reflection: the first is * full color and the second is the same, but at 0 opacity */ - cogl_color_set_from_4f (&color_1, 1.0, 1.0, 1.0, opacity / 255.); + cogl_color_init_from_4f (&color_1, 1.0, 1.0, 1.0, opacity / 255.); cogl_color_premultiply (&color_1); - cogl_color_set_from_4f (&color_2, 1.0, 1.0, 1.0, 0.0); + cogl_color_init_from_4f (&color_2, 1.0, 1.0, 1.0, 0.0); cogl_color_premultiply (&color_2); /* describe the four vertices of the quad; since it has diff --git a/tests/conform/test-cogl-backface-culling.c b/tests/conform/test-cogl-backface-culling.c index c8c3c47..bcef760 100644 --- a/tests/conform/test-cogl-backface-culling.c +++ b/tests/conform/test-cogl-backface-culling.c @@ -204,7 +204,7 @@ on_paint (ClutterActor *actor, TestState *state) CoglMatrix stage_projection; CoglMatrix stage_modelview; - cogl_color_set_from_4ub (&clr, 0x00, 0x00, 0x00, 0xff); + cogl_color_init_from_4ub (&clr, 0x00, 0x00, 0x00, 0xff); do_test_backface_culling (state); diff --git a/tests/conform/test-cogl-blend-strings.c b/tests/conform/test-cogl-blend-strings.c index 1024d17..ba1be8a 100644 --- a/tests/conform/test-cogl-blend-strings.c +++ b/tests/conform/test-cogl-blend-strings.c @@ -111,7 +111,7 @@ test_blend (TestState *state, blend_string, error->message); } - cogl_color_set_from_4ub (&blend_const_color, Br, Bg, Bb, Ba); + cogl_color_init_from_4ub (&blend_const_color, Br, Bg, Bb, Ba); cogl_material_set_blend_constant (material, &blend_const_color); cogl_set_source (material); @@ -232,7 +232,7 @@ test_tex_combine (TestState *state, combine_string, error->message); } - cogl_color_set_from_4ub (&combine_const_color, Cr, Cg, Cb, Ca); + cogl_color_init_from_4ub (&combine_const_color, Cr, Cg, Cb, Ca); cogl_material_set_layer_combine_constant (material, 1, &combine_const_color); cogl_set_source (material); diff --git a/tests/conform/test-cogl-materials.c b/tests/conform/test-cogl-materials.c index 8ea013f..7e6b8b0 100644 --- a/tests/conform/test-cogl-materials.c +++ b/tests/conform/test-cogl-materials.c @@ -200,7 +200,7 @@ test_invalid_texture_layers_with_constant_colors (TestState *state, /* ignore the fallback texture on the layer and use a constant color instead */ - cogl_color_set_from_4ub (&constant_color, 0, 0, 255, 255); + cogl_color_init_from_4ub (&constant_color, 0, 0, 255, 255); cogl_material_set_layer_combine (material, 0, "RGBA=REPLACE(CONSTANT)", NULL); diff --git a/tests/conform/test-cogl-viewport.c b/tests/conform/test-cogl-viewport.c index e983cab..778bae0 100644 --- a/tests/conform/test-cogl-viewport.c +++ b/tests/conform/test-cogl-viewport.c @@ -82,7 +82,7 @@ on_paint (ClutterActor *actor, void *state) float height; /* for clearing the offscreen framebuffer to black... */ - cogl_color_set_from_4ub (&black, 0x00, 0x00, 0x00, 0xff); + cogl_color_init_from_4ub (&black, 0x00, 0x00, 0x00, 0xff); cogl_get_viewport (saved_viewport); cogl_get_projection_matrix (&saved_projection); diff --git a/tests/interactive/test-box-layout.c b/tests/interactive/test-box-layout.c index 9e31ff6..b05f8b7 100644 --- a/tests/interactive/test-box-layout.c +++ b/tests/interactive/test-box-layout.c @@ -56,7 +56,7 @@ on_paint (ClutterActor *actor, layout = clutter_actor_create_pango_layout (actor, text); pango_layout_get_size (layout, &layout_width, &layout_height); - cogl_color_set_from_4ub (&color, 0, 0, 0, 255); + cogl_color_init_from_4ub (&color, 0, 0, 0, 255); cogl_pango_render_layout (layout, (width - (layout_width / 1024)) / 2, (height - (layout_height / 1024)) / 2, diff --git a/tests/interactive/test-cogl-tex-polygon.c b/tests/interactive/test-cogl-tex-polygon.c index 9b70251..1c3b1be 100644 --- a/tests/interactive/test-cogl-tex-polygon.c +++ b/tests/interactive/test-cogl-tex-polygon.c @@ -114,11 +114,11 @@ test_coglbox_fade_texture (gfloat x1, for (i = 0; i < 4; i++) { - cogl_color_set_from_4ub (&(vertices[i].color), - 255, - 255, - 255, - ((i ^ (i >> 1)) & 1) ? 0 : 128); + cogl_color_init_from_4ub (&(vertices[i].color), + 255, + 255, + 255, + ((i ^ (i >> 1)) & 1) ? 0 : 128); cogl_color_premultiply (&(vertices[i].color)); } -- 2.7.4