1
0
Fork 0

cogl: Drop Pipeline.set_color_*

Those setters variants makes it very hard to do across project changes
to the
color type. As part of
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3544
I would like to switch from using integers to floats inside CoglColor
which this PR would simplify

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3553>
This commit is contained in:
Bilal Elmoussaoui 2024-01-29 13:56:31 +01:00
parent b00fcbf948
commit 2c613df4eb
31 changed files with 191 additions and 156 deletions

View file

@ -97,6 +97,7 @@
* ClutterActor *actor) * ClutterActor *actor)
* { * {
* MyEffect *self = MY_EFFECT (meta); * MyEffect *self = MY_EFFECT (meta);
* CoglColor color;
* *
* // Clear the previous state // * // Clear the previous state //
* if (self->rect_1) * if (self->rect_1)
@ -120,11 +121,13 @@
* *
* // Create a red material * // Create a red material
* self->rect_1 = cogl_pipeline_new (); * self->rect_1 = cogl_pipeline_new ();
* cogl_pipeline_set_color4f (self->rect_1, 1.0, 0.0, 0.0, 1.0); * cogl_color_init_from_4f (&color, 1.0, 1.0, 1.0, 1.0);
* cogl_pipeline_set_color (self->rect_1, &color);
* *
* // Create a green material * // Create a green material
* self->rect_2 = cogl_pipeline_new (); * self->rect_2 = cogl_pipeline_new ();
* cogl_pipeline_set_color4f (self->rect_2, 0.0, 1.0, 0.0, 1.0); * cogl_color_init_from_4f (&color, 0.0, 1.0, 0.0, 1.0);
* cogl_pipeline_set_color (self->rect_2, &color);
* } * }
* *
* static gboolean * static gboolean

View file

@ -424,15 +424,15 @@ clutter_offscreen_effect_real_paint_target (ClutterOffscreenEffect *effect,
ClutterOffscreenEffectPrivate *priv = ClutterOffscreenEffectPrivate *priv =
clutter_offscreen_effect_get_instance_private (effect); clutter_offscreen_effect_get_instance_private (effect);
ClutterPaintNode *pipeline_node; ClutterPaintNode *pipeline_node;
guint8 paint_opacity; float paint_opacity;
CoglColor color;
paint_opacity = clutter_actor_get_paint_opacity (priv->actor); paint_opacity = clutter_actor_get_paint_opacity (priv->actor) / 255.0;
cogl_pipeline_set_color4ub (priv->pipeline, cogl_color_init_from_4f (&color,
paint_opacity, paint_opacity, paint_opacity,
paint_opacity, paint_opacity, paint_opacity);
paint_opacity, cogl_pipeline_set_color (priv->pipeline, &color);
paint_opacity);
pipeline_node = clutter_pipeline_node_new (priv->pipeline); pipeline_node = clutter_pipeline_node_new (priv->pipeline);
clutter_paint_node_set_static_name (pipeline_node, clutter_paint_node_set_static_name (pipeline_node,

View file

@ -344,9 +344,10 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_RECTANGLES))) if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_RECTANGLES)))
{ {
static CoglPipeline *outline = NULL; static CoglPipeline *outline = NULL;
uint8_t color_intensity; float color_intensity;
int i; int i;
CoglAttribute *loop_attributes[1]; CoglAttribute *loop_attributes[1];
CoglColor color;
if (outline == NULL) if (outline == NULL)
outline = cogl_pipeline_new (ctx); outline = cogl_pipeline_new (ctx);
@ -358,15 +359,16 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
in the order 0xff, 0xcc, 0x99, and 0x66. This gives a total in the order 0xff, 0xcc, 0x99, and 0x66. This gives a total
of 24 colours. If there are more than 24 batches on the stage of 24 colours. If there are more than 24 batches on the stage
then it will wrap around */ then it will wrap around */
color_intensity = 0xff - 0x33 * (ctx->journal_rectangles_color >> 3); color_intensity = (0xff - 0x33 * (ctx->journal_rectangles_color >> 3) ) / 255.0;
cogl_pipeline_set_color4ub (outline, cogl_color_init_from_4f (&color,
(ctx->journal_rectangles_color & 1) ? (ctx->journal_rectangles_color & 1) ?
color_intensity : 0, color_intensity : 0.0,
(ctx->journal_rectangles_color & 2) ? (ctx->journal_rectangles_color & 2) ?
color_intensity : 0, color_intensity : 0.0,
(ctx->journal_rectangles_color & 4) ? (ctx->journal_rectangles_color & 4) ?
color_intensity : 0, color_intensity : 0.0,
0xff); 1.0);
cogl_pipeline_set_color (outline, &color);
loop_attributes[0] = attributes[0]; /* we just want the position */ loop_attributes[0] = attributes[0]; /* we just want the position */
for (i = 0; i < batch_len; i++) for (i = 0; i < batch_len; i++)

View file

@ -368,30 +368,6 @@ cogl_pipeline_set_color (CoglPipeline *pipeline,
pipeline->dirty_real_blend_enable = TRUE; pipeline->dirty_real_blend_enable = TRUE;
} }
void
cogl_pipeline_set_color4ub (CoglPipeline *pipeline,
uint8_t red,
uint8_t green,
uint8_t blue,
uint8_t alpha)
{
CoglColor color;
cogl_color_init_from_4ub (&color, red, green, blue, alpha);
cogl_pipeline_set_color (pipeline, &color);
}
void
cogl_pipeline_set_color4f (CoglPipeline *pipeline,
float red,
float green,
float blue,
float alpha)
{
CoglColor color;
cogl_color_init_from_4f (&color, red, green, blue, alpha);
cogl_pipeline_set_color (pipeline, &color);
}
static void static void
_cogl_pipeline_set_alpha_test_function (CoglPipeline *pipeline, _cogl_pipeline_set_alpha_test_function (CoglPipeline *pipeline,
CoglPipelineAlphaFunc alpha_func) CoglPipelineAlphaFunc alpha_func)

View file

@ -59,44 +59,6 @@ COGL_EXPORT void
cogl_pipeline_set_color (CoglPipeline *pipeline, cogl_pipeline_set_color (CoglPipeline *pipeline,
const CoglColor *color); const CoglColor *color);
/**
* cogl_pipeline_set_color4ub:
* @pipeline: A #CoglPipeline object
* @red: The red component
* @green: The green component
* @blue: The blue component
* @alpha: The alpha component
*
* Sets the basic color of the pipeline, used when no lighting is enabled.
*
* The default value is (0xff, 0xff, 0xff, 0xff)
*/
COGL_EXPORT void
cogl_pipeline_set_color4ub (CoglPipeline *pipeline,
uint8_t red,
uint8_t green,
uint8_t blue,
uint8_t alpha);
/**
* cogl_pipeline_set_color4f:
* @pipeline: A #CoglPipeline object
* @red: The red component
* @green: The green component
* @blue: The blue component
* @alpha: The alpha component
*
* Sets the basic color of the pipeline, used when no lighting is enabled.
*
* The default value is (1.0, 1.0, 1.0, 1.0)
*/
COGL_EXPORT void
cogl_pipeline_set_color4f (CoglPipeline *pipeline,
float red,
float green,
float blue,
float alpha);
/** /**
* cogl_pipeline_get_color: * cogl_pipeline_get_color:
* @pipeline: A #CoglPipeline object * @pipeline: A #CoglPipeline object

View file

@ -140,6 +140,7 @@ paint_damage_region (ClutterStageWindow *stage_window,
CoglFramebuffer *framebuffer = clutter_stage_view_get_framebuffer (view); CoglFramebuffer *framebuffer = clutter_stage_view_get_framebuffer (view);
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer); CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
static CoglPipeline *overlay_blue = NULL; static CoglPipeline *overlay_blue = NULL;
CoglColor blue_color, red_color;
MetaStageImpl *stage_impl = META_STAGE_IMPL (stage_window); MetaStageImpl *stage_impl = META_STAGE_IMPL (stage_window);
ClutterActor *actor = CLUTTER_ACTOR (stage_impl->wrapper); ClutterActor *actor = CLUTTER_ACTOR (stage_impl->wrapper);
graphene_matrix_t transform; graphene_matrix_t transform;
@ -156,7 +157,8 @@ paint_damage_region (ClutterStageWindow *stage_window,
if (G_UNLIKELY (overlay_blue == NULL)) if (G_UNLIKELY (overlay_blue == NULL))
{ {
overlay_blue = cogl_pipeline_new (ctx); overlay_blue = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (overlay_blue, 0x00, 0x00, 0x33, 0x33); cogl_color_init_from_4f (&blue_color, 0.0, 0.0, 0.2, 0.2);
cogl_pipeline_set_color (overlay_blue, &blue_color);
} }
n_rects = mtk_region_num_rectangles (swap_region); n_rects = mtk_region_num_rectangles (swap_region);
@ -182,7 +184,8 @@ paint_damage_region (ClutterStageWindow *stage_window,
if (G_UNLIKELY (overlay_red == NULL)) if (G_UNLIKELY (overlay_red == NULL))
{ {
overlay_red = cogl_pipeline_new (ctx); overlay_red = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (overlay_red, 0x33, 0x00, 0x00, 0x33); cogl_color_init_from_4f (&red_color, 0.2, 0.0, 0.0, 0.2);
cogl_pipeline_set_color (overlay_red, &red_color);
} }
n_rects = mtk_region_num_rectangles (queued_redraw_clip); n_rects = mtk_region_num_rectangles (queued_redraw_clip);

View file

@ -398,6 +398,7 @@ setup_pipeline (MetaBackgroundContent *self,
float color_component; float color_component;
CoglFramebuffer *fb; CoglFramebuffer *fb;
CoglPipelineFilter min_filter, mag_filter; CoglPipelineFilter min_filter, mag_filter;
CoglColor color;
opacity = clutter_actor_get_paint_opacity (actor); opacity = clutter_actor_get_paint_opacity (actor);
if (opacity < 255) if (opacity < 255)
@ -538,11 +539,12 @@ setup_pipeline (MetaBackgroundContent *self,
else else
color_component = opacity / 255.; color_component = opacity / 255.;
cogl_pipeline_set_color4f (self->pipeline, cogl_color_init_from_4f (&color,
color_component, color_component,
color_component, color_component,
color_component, color_component,
opacity / 255.); opacity / 255.);
cogl_pipeline_set_color (self->pipeline, &color);
fb = clutter_paint_context_get_framebuffer (paint_context); fb = clutter_paint_context_get_framebuffer (paint_context);
if (meta_actor_painting_untransformed (fb, if (meta_actor_painting_untransformed (fb,

View file

@ -857,13 +857,16 @@ meta_background_get_texture (MetaBackground *self,
{ {
CoglPipeline *pipeline = create_pipeline (PIPELINE_REPLACE); CoglPipeline *pipeline = create_pipeline (PIPELINE_REPLACE);
int mipmap_level; int mipmap_level;
CoglColor color;
mipmap_level = get_best_mipmap_level (texture2, mipmap_level = get_best_mipmap_level (texture2,
texture_width, texture_width,
texture_height); texture_height);
cogl_pipeline_set_color4f (pipeline, cogl_color_init_from_4f (&color,
self->blend_factor, self->blend_factor, self->blend_factor, self->blend_factor); self->blend_factor, self->blend_factor,
self->blend_factor, self->blend_factor);
cogl_pipeline_set_color (pipeline, &color);
cogl_pipeline_set_layer_texture (pipeline, 0, texture2); cogl_pipeline_set_layer_texture (pipeline, 0, texture2);
cogl_pipeline_set_layer_wrap_mode (pipeline, 0, get_wrap_mode (self->style)); cogl_pipeline_set_layer_wrap_mode (pipeline, 0, get_wrap_mode (self->style));
cogl_pipeline_set_layer_max_mipmap_level (pipeline, 0, mipmap_level); cogl_pipeline_set_layer_max_mipmap_level (pipeline, 0, mipmap_level);
@ -886,16 +889,16 @@ meta_background_get_texture (MetaBackground *self,
{ {
CoglPipeline *pipeline = create_pipeline (PIPELINE_ADD); CoglPipeline *pipeline = create_pipeline (PIPELINE_ADD);
int mipmap_level; int mipmap_level;
CoglColor color;
mipmap_level = get_best_mipmap_level (texture1, mipmap_level = get_best_mipmap_level (texture1,
texture_width, texture_width,
texture_height); texture_height);
cogl_pipeline_set_color4f (pipeline, cogl_color_init_from_4f (&color,
(1 - self->blend_factor), (1 - self->blend_factor), (1 - self->blend_factor),
(1 - self->blend_factor), (1 - self->blend_factor), (1 - self->blend_factor));
(1 - self->blend_factor), cogl_pipeline_set_color (pipeline, &color);
(1 - self->blend_factor));
cogl_pipeline_set_layer_texture (pipeline, 0, texture1); cogl_pipeline_set_layer_texture (pipeline, 0, texture1);
cogl_pipeline_set_layer_wrap_mode (pipeline, 0, get_wrap_mode (self->style)); cogl_pipeline_set_layer_wrap_mode (pipeline, 0, get_wrap_mode (self->style));
cogl_pipeline_set_layer_max_mipmap_level (pipeline, 0, mipmap_level); cogl_pipeline_set_layer_max_mipmap_level (pipeline, 0, mipmap_level);

View file

@ -202,6 +202,7 @@ meta_shadow_paint (MetaShadow *shadow,
MtkRegion *clip, MtkRegion *clip,
gboolean clip_strictly) gboolean clip_strictly)
{ {
CoglColor color;
float texture_width = cogl_texture_get_width (shadow->texture); float texture_width = cogl_texture_get_width (shadow->texture);
float texture_height = cogl_texture_get_height (shadow->texture); float texture_height = cogl_texture_get_height (shadow->texture);
int i, j; int i, j;
@ -214,8 +215,10 @@ meta_shadow_paint (MetaShadow *shadow,
if (clip && mtk_region_is_empty (clip)) if (clip && mtk_region_is_empty (clip))
return; return;
cogl_pipeline_set_color4ub (shadow->pipeline, cogl_color_init_from_4f (&color,
opacity, opacity, opacity, opacity); opacity / 255.0, opacity / 255.0,
opacity / 255.0, opacity / 255.0);
cogl_pipeline_set_color (shadow->pipeline, &color);
if (shadow->scale_width) if (shadow->scale_width)
{ {

View file

@ -488,13 +488,15 @@ static CoglPipeline *
get_opaque_overlay_pipeline (CoglContext *ctx) get_opaque_overlay_pipeline (CoglContext *ctx)
{ {
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglColor color;
pipeline = cogl_context_get_named_pipeline (ctx, pipeline = cogl_context_get_named_pipeline (ctx,
&opaque_overlay_pipeline_key); &opaque_overlay_pipeline_key);
if (!pipeline) if (!pipeline)
{ {
pipeline = cogl_pipeline_new (ctx); pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, 0x00, 0x33, 0x00, 0x33); cogl_color_init_from_4f (&color, 0.0, 0.2, 0.0, 0.2);
cogl_pipeline_set_color (pipeline, &color);
cogl_context_set_named_pipeline (ctx, cogl_context_set_named_pipeline (ctx,
&opaque_overlay_pipeline_key, &opaque_overlay_pipeline_key,
@ -508,13 +510,15 @@ static CoglPipeline *
get_blended_overlay_pipeline (CoglContext *ctx) get_blended_overlay_pipeline (CoglContext *ctx)
{ {
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglColor color;
pipeline = cogl_context_get_named_pipeline (ctx, pipeline = cogl_context_get_named_pipeline (ctx,
&blended_overlay_pipeline_key); &blended_overlay_pipeline_key);
if (!pipeline) if (!pipeline)
{ {
pipeline = cogl_pipeline_new (ctx); pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, 0x33, 0x00, 0x33, 0x33); cogl_color_init_from_4f (&color, 0.2, 0.0, 0.2, 0.2);
cogl_pipeline_set_color (pipeline, &color);
cogl_context_set_named_pipeline (ctx, cogl_context_set_named_pipeline (ctx,
&blended_overlay_pipeline_key, &blended_overlay_pipeline_key,

View file

@ -45,6 +45,7 @@ foo_actor_paint (ClutterActor *actor,
ClutterActorBox allocation; ClutterActorBox allocation;
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglFramebuffer *framebuffer; CoglFramebuffer *framebuffer;
CoglColor color;
foo_actor->last_paint_opacity = clutter_actor_get_paint_opacity (actor); foo_actor->last_paint_opacity = clutter_actor_get_paint_opacity (actor);
foo_actor->paint_count++; foo_actor->paint_count++;
@ -53,9 +54,9 @@ foo_actor_paint (ClutterActor *actor,
/* Paint a red rectangle with the right opacity */ /* Paint a red rectangle with the right opacity */
pipeline = cogl_pipeline_new (ctx); pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, cogl_color_init_from_4f (&color, 1.0, 0.0, 0.0,
255, 0, 0, foo_actor->last_paint_opacity / 255.);
foo_actor->last_paint_opacity); cogl_pipeline_set_color (pipeline, &color);
framebuffer = clutter_paint_context_get_framebuffer (paint_context); framebuffer = clutter_paint_context_get_framebuffer (paint_context);
cogl_framebuffer_draw_rectangle (framebuffer, cogl_framebuffer_draw_rectangle (framebuffer,

View file

@ -142,10 +142,12 @@ key_group_paint (ClutterActor *actor,
ClutterActor *child; ClutterActor *child;
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglFramebuffer *framebuffer; CoglFramebuffer *framebuffer;
CoglColor color;
gint i = 0; gint i = 0;
pipeline = cogl_pipeline_new (ctx); pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, 255, 255, 0, 224); cogl_color_init_from_4f (&color, 1.0, 1.0, 0.0, 224. / 255. );
cogl_pipeline_set_color (pipeline, &color);
framebuffer = clutter_paint_context_get_framebuffer (paint_context); framebuffer = clutter_paint_context_get_framebuffer (paint_context);

View file

@ -173,6 +173,7 @@ key_group_paint (ClutterActor *actor,
if (i == self->selected_index) if (i == self->selected_index)
{ {
ClutterActorBox box = { 0, }; ClutterActorBox box = { 0, };
CoglColor color;
clutter_actor_get_allocation_box (child, &box); clutter_actor_get_allocation_box (child, &box);
@ -181,7 +182,8 @@ key_group_paint (ClutterActor *actor,
box.x2 += 2; box.x2 += 2;
box.y2 += 2; box.y2 += 2;
cogl_pipeline_set_color4ub (pipeline, 255, 255, 0, 224); cogl_color_init_from_4f (&color, 1.0, 1.0, 0.0, 224.0 / 255.0);
cogl_pipeline_set_color (pipeline, &color);
cogl_framebuffer_draw_rectangle (framebuffer, pipeline, cogl_framebuffer_draw_rectangle (framebuffer, pipeline,
box.x1, box.y1, box.x2, box.y2); box.x1, box.y1, box.x2, box.y2);

View file

@ -49,9 +49,11 @@ test_coglbox_paint (ClutterActor *self,
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer); CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
gfloat texcoords[4] = { 0, 0, 1, 1 }; gfloat texcoords[4] = { 0, 0, 1, 1 };
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglColor color;
pipeline = cogl_pipeline_new (ctx); pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, 0x66, 0x66, 0xdd, 0xff); cogl_color_init_from_4f (&color, 0.4, 0.4, 221.0 / 255.0, 1.0);
cogl_pipeline_set_color (pipeline, &color);
cogl_framebuffer_draw_rectangle (framebuffer, pipeline, 0, 0, 400, 400); cogl_framebuffer_draw_rectangle (framebuffer, pipeline, 0, 0, 400, 400);
g_object_unref (pipeline); g_object_unref (pipeline);
@ -65,17 +67,23 @@ test_coglbox_paint (ClutterActor *self,
g_object_unref (pipeline); g_object_unref (pipeline);
pipeline = cogl_pipeline_new (ctx); pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, 0xff, 0, 0, 0xff);
cogl_color_init_from_4f (&color, 1.0, 0.0, 0.0, 1.0);
cogl_pipeline_set_color (pipeline, &color);
cogl_framebuffer_draw_rectangle (coglbox->framebuffer, pipeline, cogl_framebuffer_draw_rectangle (coglbox->framebuffer, pipeline,
20, 20, 20 + 100, 20 + 100); 20, 20, 20 + 100, 20 + 100);
cogl_pipeline_set_color4ub (pipeline, 0, 0xff, 0, 0xff); cogl_color_init_from_4f (&color, 0.0, 1.0, 0.0, 1.0);
cogl_pipeline_set_color (pipeline, &color);
cogl_framebuffer_draw_rectangle (coglbox->framebuffer, pipeline, cogl_framebuffer_draw_rectangle (coglbox->framebuffer, pipeline,
80, 80, 80 + 100, 80 + 100); 80, 80, 80 + 100, 80 + 100);
g_object_unref (pipeline); g_object_unref (pipeline);
pipeline = cogl_pipeline_new (ctx); pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, 0x88, 0x88, 0x88, 0x88); cogl_color_init_from_4f (&color,
136.0 / 255.0, 136.0 / 255.0,
136.0 / 255.0, 136.0 / 255.0);
cogl_pipeline_set_color (pipeline, &color);
cogl_pipeline_set_layer_texture (pipeline, 0, coglbox->texture_id); cogl_pipeline_set_layer_texture (pipeline, 0, coglbox->texture_id);
cogl_framebuffer_draw_textured_rectangle (framebuffer, pipeline, cogl_framebuffer_draw_textured_rectangle (framebuffer, pipeline,
100, 100, 100, 100,

View file

@ -48,6 +48,7 @@ test_coglbox_paint (ClutterActor *self,
clutter_paint_context_get_framebuffer (paint_context); clutter_paint_context_get_framebuffer (paint_context);
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer); CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglColor color;
gfloat texcoords[4] = { 0.0f, 0.0f, 1.0f, 1.0f }; gfloat texcoords[4] = { 0.0f, 0.0f, 1.0f, 1.0f };
gfloat angle; gfloat angle;
gfloat frac; gfloat frac;
@ -71,7 +72,8 @@ test_coglbox_paint (ClutterActor *self,
cogl_framebuffer_push_matrix (framebuffer); cogl_framebuffer_push_matrix (framebuffer);
pipeline = cogl_pipeline_new (ctx); pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, 0x66, 0x66, 0xdd, 0xff); cogl_color_init_from_4f (&color, 0.4, 0.4, 221.0 / 255.0, 1.0);
cogl_pipeline_set_color (pipeline, &color);
cogl_framebuffer_draw_rectangle (framebuffer, pipeline, 0, 0, 400, 400); cogl_framebuffer_draw_rectangle (framebuffer, pipeline, 0, 0, 400, 400);
g_object_unref (pipeline); g_object_unref (pipeline);

View file

@ -32,6 +32,7 @@ test_rectangles (TestState *state,
int x; int x;
int y; int y;
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglColor color;
/* Should the rectangles be randomly positioned/colored/rotated? /* Should the rectangles be randomly positioned/colored/rotated?
* *
@ -61,14 +62,16 @@ test_rectangles (TestState *state,
{ {
for (x = 0; x < STAGE_WIDTH; x += RECT_WIDTH) for (x = 0; x < STAGE_WIDTH; x += RECT_WIDTH)
{ {
cogl_framebuffer_push_matrix (framebuffer); cogl_color_init_from_4f (&color,
cogl_framebuffer_translate (framebuffer, x, y, 0);
cogl_framebuffer_rotate (framebuffer, 45, 0, 0, 1);
cogl_pipeline_set_color4f (pipeline,
1, 1,
(1.0f / STAGE_WIDTH) * y, (1.0f / STAGE_WIDTH) * y,
(1.0f / STAGE_HEIGHT) * x, (1.0f / STAGE_HEIGHT) * x,
1); 1);
cogl_framebuffer_push_matrix (framebuffer);
cogl_framebuffer_translate (framebuffer, x, y, 0);
cogl_framebuffer_rotate (framebuffer, 45, 0, 0, 1);
cogl_pipeline_set_color (pipeline, &color);
cogl_framebuffer_draw_rectangle (framebuffer, pipeline, cogl_framebuffer_draw_rectangle (framebuffer, pipeline,
0, 0, RECT_WIDTH, RECT_HEIGHT); 0, 0, RECT_WIDTH, RECT_HEIGHT);
cogl_framebuffer_pop_matrix (framebuffer); cogl_framebuffer_pop_matrix (framebuffer);
@ -82,11 +85,12 @@ test_rectangles (TestState *state,
cogl_framebuffer_push_matrix (framebuffer); cogl_framebuffer_push_matrix (framebuffer);
cogl_framebuffer_translate (framebuffer, x, y, 0); cogl_framebuffer_translate (framebuffer, x, y, 0);
cogl_framebuffer_rotate (framebuffer, 0, 0, 0, 1); cogl_framebuffer_rotate (framebuffer, 0, 0, 0, 1);
cogl_pipeline_set_color4f (pipeline, cogl_color_init_from_4f (&color,
1, 1,
(1.0f / STAGE_WIDTH) * x, (1.0f / STAGE_WIDTH) * x,
(1.0f / STAGE_HEIGHT) * y, (1.0f / STAGE_HEIGHT) * y,
(1.0f / STAGE_WIDTH) * x); (1.0f / STAGE_WIDTH) * x);
cogl_pipeline_set_color (pipeline, &color);
cogl_framebuffer_draw_rectangle (framebuffer, pipeline, cogl_framebuffer_draw_rectangle (framebuffer, pipeline,
0, 0, RECT_WIDTH, RECT_HEIGHT); 0, 0, RECT_WIDTH, RECT_HEIGHT);
cogl_framebuffer_pop_matrix (framebuffer); cogl_framebuffer_pop_matrix (framebuffer);

View file

@ -48,6 +48,7 @@ paint_test_backface_culling (TestState *state,
{ {
int draw_num; int draw_num;
CoglPipeline *base_pipeline = cogl_pipeline_new (test_ctx); CoglPipeline *base_pipeline = cogl_pipeline_new (test_ctx);
CoglColor color;
cogl_framebuffer_orthographic (framebuffer, cogl_framebuffer_orthographic (framebuffer,
0, 0, 0, 0,
@ -114,7 +115,10 @@ paint_test_backface_culling (TestState *state,
/* If the texture is sliced then cogl_polygon doesn't work so /* If the texture is sliced then cogl_polygon doesn't work so
we'll just use a solid color instead */ we'll just use a solid color instead */
if (cogl_texture_is_sliced (state->texture)) if (cogl_texture_is_sliced (state->texture))
cogl_pipeline_set_color4ub (pipeline, 255, 0, 0, 255); {
cogl_color_init_from_4f (&color, 1.0, 0.0, 0.0, 1.0);
cogl_pipeline_set_color (pipeline, &color);
}
/* Draw a front-facing polygon */ /* Draw a front-facing polygon */
verts[0].x = x1; verts[0].y = y2; verts[0].x = x1; verts[0].y = y2;

View file

@ -50,7 +50,7 @@ test_blend_paint (TestState *state,
uint8_t Bg = MASK_GREEN (blend_constant); uint8_t Bg = MASK_GREEN (blend_constant);
uint8_t Bb = MASK_BLUE (blend_constant); uint8_t Bb = MASK_BLUE (blend_constant);
uint8_t Ba = MASK_ALPHA (blend_constant); uint8_t Ba = MASK_ALPHA (blend_constant);
CoglColor blend_const_color; CoglColor blend_const_color, pipeline_color;
CoglPipeline *pipeline; CoglPipeline *pipeline;
gboolean status; gboolean status;
@ -60,7 +60,10 @@ test_blend_paint (TestState *state,
/* First write out the destination color without any blending... */ /* First write out the destination color without any blending... */
pipeline = cogl_pipeline_new (test_ctx); pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, Dr, Dg, Db, Da); cogl_color_init_from_4f (&pipeline_color,
Dr / 255.0, Dg / 255.0,
Db / 255.0, Da / 255.0);
cogl_pipeline_set_color (pipeline, &pipeline_color);
cogl_pipeline_set_blend (pipeline, "RGBA = ADD (SRC_COLOR, 0)", NULL); cogl_pipeline_set_blend (pipeline, "RGBA = ADD (SRC_COLOR, 0)", NULL);
cogl_framebuffer_draw_rectangle (test_fb, cogl_framebuffer_draw_rectangle (test_fb,
pipeline, pipeline,
@ -75,7 +78,10 @@ test_blend_paint (TestState *state,
*/ */
pipeline = cogl_pipeline_new (test_ctx); pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, Sr, Sg, Sb, Sa); cogl_color_init_from_4f (&pipeline_color,
Sr / 255.0, Sg / 255.0,
Sb / 255.0, Sa / 255.0);
cogl_pipeline_set_color (pipeline, &pipeline_color);
status = cogl_pipeline_set_blend (pipeline, blend_string, &error); status = cogl_pipeline_set_blend (pipeline, blend_string, &error);
if (!status) if (!status)
@ -174,7 +180,7 @@ test_tex_combine (TestState *state,
uint8_t Cg = MASK_GREEN (combine_constant); uint8_t Cg = MASK_GREEN (combine_constant);
uint8_t Cb = MASK_BLUE (combine_constant); uint8_t Cb = MASK_BLUE (combine_constant);
uint8_t Ca = MASK_ALPHA (combine_constant); uint8_t Ca = MASK_ALPHA (combine_constant);
CoglColor combine_const_color; CoglColor combine_const_color, pipeline_color;
CoglPipeline *pipeline; CoglPipeline *pipeline;
gboolean status; gboolean status;
@ -188,7 +194,10 @@ test_tex_combine (TestState *state,
pipeline = cogl_pipeline_new (test_ctx); pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, 0x80, 0x80, 0x80, 0x80); cogl_color_init_from_4f (&pipeline_color,
128.0 / 255.0, 128.0 / 255.0,
128.0 / 255.0, 128.0 / 255.0);
cogl_pipeline_set_color (pipeline, &pipeline_color);
cogl_pipeline_set_blend (pipeline, "RGBA = ADD (SRC_COLOR, 0)", NULL); cogl_pipeline_set_blend (pipeline, "RGBA = ADD (SRC_COLOR, 0)", NULL);
cogl_pipeline_set_layer_texture (pipeline, 0, tex0); cogl_pipeline_set_layer_texture (pipeline, 0, tex0);

View file

@ -173,6 +173,7 @@ test_short_verts (TestState *state, int offset_x, int offset_y)
CoglPipeline *pipeline, *pipeline2; CoglPipeline *pipeline, *pipeline2;
CoglSnippet *snippet; CoglSnippet *snippet;
CoglPrimitive *primitive; CoglPrimitive *primitive;
CoglColor color;
static const ShortVert short_verts[] = static const ShortVert short_verts[] =
{ {
@ -184,7 +185,8 @@ test_short_verts (TestState *state, int offset_x, int offset_y)
pipeline = cogl_pipeline_copy (state->pipeline); pipeline = cogl_pipeline_copy (state->pipeline);
cogl_pipeline_set_color4ub (pipeline, 255, 0, 0, 255); cogl_color_init_from_4f (&color, 1.0, 0.0, 0.0, 1.0);
cogl_pipeline_set_color (pipeline, &color);
buffer = cogl_attribute_buffer_new (test_ctx, buffer = cogl_attribute_buffer_new (test_ctx,
sizeof (short_verts), short_verts); sizeof (short_verts), short_verts);

View file

@ -46,6 +46,7 @@ draw_rectangle (TestState *state,
uint8_t Ca = MASK_ALPHA (rect_state->color); uint8_t Ca = MASK_ALPHA (rect_state->color);
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglDepthState depth_state; CoglDepthState depth_state;
CoglColor color;
cogl_depth_state_init (&depth_state); cogl_depth_state_init (&depth_state);
cogl_depth_state_set_test_enabled (&depth_state, rect_state->test_enable); cogl_depth_state_set_test_enabled (&depth_state, rect_state->test_enable);
@ -62,10 +63,13 @@ draw_rectangle (TestState *state,
return FALSE; return FALSE;
} }
cogl_color_init_from_4f (&color,
Cr / 255.0, Cg / 255.0,
Cb / 255.0, Ca / 255.0);
cogl_pipeline_set_color (pipeline, &color);
if (!legacy_mode) if (!legacy_mode)
{ {
cogl_pipeline_set_color4ub (pipeline, Cr, Cg, Cb, Ca);
cogl_framebuffer_set_depth_write_enabled (test_fb, cogl_framebuffer_set_depth_write_enabled (test_fb,
rect_state->fb_write_enable); rect_state->fb_write_enable);
cogl_framebuffer_push_matrix (test_fb); cogl_framebuffer_push_matrix (test_fb);
@ -85,7 +89,6 @@ draw_rectangle (TestState *state,
legacy_pipeline = cogl_pipeline_new (test_ctx); legacy_pipeline = cogl_pipeline_new (test_ctx);
cogl_framebuffer_push_matrix (test_fb); cogl_framebuffer_push_matrix (test_fb);
cogl_pipeline_set_color4ub (pipeline, Cr, Cg, Cb, Ca);
cogl_framebuffer_translate (test_fb, 0, 0, rect_state->depth); cogl_framebuffer_translate (test_fb, 0, 0, rect_state->depth);
cogl_framebuffer_draw_rectangle (test_fb, cogl_framebuffer_draw_rectangle (test_fb,
pipeline, pipeline,

View file

@ -11,6 +11,7 @@ test_journal_unref_flush (void)
CoglTexture *texture; CoglTexture *texture;
CoglOffscreen *offscreen; CoglOffscreen *offscreen;
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglColor color;
const int width = 1; const int width = 1;
const int height = 1; const int height = 1;
const int stride = width * 4; const int stride = width * 4;
@ -26,7 +27,8 @@ test_journal_unref_flush (void)
g_object_add_weak_pointer (G_OBJECT (offscreen), (gpointer *) &offscreen); g_object_add_weak_pointer (G_OBJECT (offscreen), (gpointer *) &offscreen);
pipeline = cogl_pipeline_new (test_ctx); pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, 0x33, 0x33, 0x33, 0x33); cogl_color_init_from_4f (&color, 0.2, 0.2, 0.2, 0.2);
cogl_pipeline_set_color (pipeline, &color);
cogl_framebuffer_draw_rectangle (COGL_FRAMEBUFFER (offscreen), cogl_framebuffer_draw_rectangle (COGL_FRAMEBUFFER (offscreen),
pipeline, pipeline,
-1, -1, 1, 1); -1, -1, 1, 1);

View file

@ -11,7 +11,8 @@ create_two_layer_pipeline (void)
CoglColor color; CoglColor color;
/* The pipeline is initially black */ /* The pipeline is initially black */
cogl_pipeline_set_color4ub (pipeline, 0, 0, 0, 255); cogl_color_init_from_4f (&color, 0.0, 0.0, 0.0, 255.0);
cogl_pipeline_set_color (pipeline, &color);
/* The first layer adds a full red component */ /* The first layer adds a full red component */
cogl_color_init_from_4ub (&color, 255, 0, 0, 255); cogl_color_init_from_4ub (&color, 255, 0, 0, 255);

View file

@ -105,6 +105,7 @@ on_paint (ClutterActor *actor,
{ {
CoglTexture *tex0, *tex1; CoglTexture *tex0, *tex1;
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglColor color;
gboolean status; gboolean status;
GError *error = NULL; GError *error = NULL;
float tex_coords[] = { float tex_coords[] = {
@ -118,7 +119,10 @@ on_paint (ClutterActor *actor,
pipeline = cogl_pipeline_new (); pipeline = cogl_pipeline_new ();
/* An arbitrary color which should be replaced by the first texture layer */ /* An arbitrary color which should be replaced by the first texture layer */
cogl_pipeline_set_color4ub (pipeline, 0x80, 0x80, 0x80, 0x80); cogl_color_init_from_4f (&color,
128.0 / 255.0, 128.0 / 255.0,
128.0 / 255.0, 128.0 / 255.0);
cogl_pipeline_set_color (pipeline, &color);
cogl_pipekine_set_blend (pipeline, "RGBA = ADD (SRC_COLOR, 0)", NULL); cogl_pipekine_set_blend (pipeline, "RGBA = ADD (SRC_COLOR, 0)", NULL);
cogl_pipeline_set_layer_texture (pipeline, 0, tex0); cogl_pipeline_set_layer_texture (pipeline, 0, tex0);

View file

@ -45,6 +45,7 @@ test_paint (TestState *state)
CoglFramebuffer *framebuffer; CoglFramebuffer *framebuffer;
CoglPipeline *opaque_pipeline; CoglPipeline *opaque_pipeline;
CoglPipeline *texture_pipeline; CoglPipeline *texture_pipeline;
CoglColor color;
tex = cogl_texture_2d_new_with_size (test_ctx, tex = cogl_texture_2d_new_with_size (test_ctx,
state->fb_width, state->fb_width,
@ -74,19 +75,24 @@ test_paint (TestState *state)
opaque_pipeline = cogl_pipeline_new (test_ctx); opaque_pipeline = cogl_pipeline_new (test_ctx);
/* red, top left */ /* red, top left */
cogl_pipeline_set_color4ub (opaque_pipeline, 0xff, 0x00, 0x00, 0xff); cogl_color_init_from_4f (&color, 1.0, 0.0, 0.0, 1.0);
cogl_pipeline_set_color (opaque_pipeline, &color);
cogl_framebuffer_draw_rectangle (framebuffer, opaque_pipeline, cogl_framebuffer_draw_rectangle (framebuffer, opaque_pipeline,
-0.5, 0.5, 0, 0); -0.5, 0.5, 0, 0);
/* green, top right */ /* green, top right */
cogl_pipeline_set_color4ub (opaque_pipeline, 0x00, 0xff, 0x00, 0xff); /* red, top left */
cogl_color_init_from_4f (&color, 0.0, 1.0, 0.0, 1.0);
cogl_pipeline_set_color (opaque_pipeline, &color);
cogl_framebuffer_draw_rectangle (framebuffer, opaque_pipeline, cogl_framebuffer_draw_rectangle (framebuffer, opaque_pipeline,
0, 0.5, 0.5, 0); 0, 0.5, 0.5, 0);
/* blue, bottom left */ /* blue, bottom left */
cogl_pipeline_set_color4ub (opaque_pipeline, 0x00, 0x00, 0xff, 0xff); cogl_color_init_from_4f (&color, 0.0, 0.0, 1.0, 1.0);
cogl_pipeline_set_color (opaque_pipeline, &color);
cogl_framebuffer_draw_rectangle (framebuffer, opaque_pipeline, cogl_framebuffer_draw_rectangle (framebuffer, opaque_pipeline,
-0.5, 0, 0, -0.5); -0.5, 0, 0, -0.5);
/* white, bottom right */ /* white, bottom right */
cogl_pipeline_set_color4ub (opaque_pipeline, 0xff, 0xff, 0xff, 0xff); cogl_color_init_from_4f (&color, 1.0, 1.0, 1.0, 1.0);
cogl_pipeline_set_color (opaque_pipeline, &color);
cogl_framebuffer_draw_rectangle (framebuffer, opaque_pipeline, cogl_framebuffer_draw_rectangle (framebuffer, opaque_pipeline,
0, 0, 0.5, -0.5); 0, 0, 0.5, -0.5);
@ -124,11 +130,12 @@ test_flush (TestState *state)
CoglTexture *tex; CoglTexture *tex;
CoglOffscreen *offscreen; CoglOffscreen *offscreen;
CoglFramebuffer *framebuffer; CoglFramebuffer *framebuffer;
CoglColor clear_color; CoglColor clear_color, pipeline_color;
int i; int i;
pipeline = cogl_pipeline_new (test_ctx); pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, 255, 0, 0, 255); cogl_color_init_from_4f (&pipeline_color, 1.0, 0.0, 0.0, 1.0);
cogl_pipeline_set_color (pipeline, &pipeline_color);
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {

View file

@ -13,6 +13,7 @@ test_pipeline_shader_state (void)
CoglPipeline *draw_pipeline; CoglPipeline *draw_pipeline;
CoglTexture *tex; CoglTexture *tex;
CoglSnippet *snippet; CoglSnippet *snippet;
CoglColor color;
float width = cogl_framebuffer_get_width (test_fb); float width = cogl_framebuffer_get_width (test_fb);
float height = cogl_framebuffer_get_height (test_fb); float height = cogl_framebuffer_get_height (test_fb);
@ -35,7 +36,8 @@ test_pipeline_shader_state (void)
base_pipeline = cogl_pipeline_new (test_ctx); base_pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_layer_texture (base_pipeline, 1, tex); cogl_pipeline_set_layer_texture (base_pipeline, 1, tex);
cogl_pipeline_set_color4f (base_pipeline, 1, 0, 0, 1); cogl_color_init_from_4f (&color, 1.0, 0.0, 0.0, 1.0);
cogl_pipeline_set_color (base_pipeline, &color);
/* Derive a pipeline from the template, making a change that affects /* Derive a pipeline from the template, making a change that affects

View file

@ -105,6 +105,7 @@ do_test (const char *attribute_name,
int fb_height = cogl_framebuffer_get_height (test_fb); int fb_height = cogl_framebuffer_get_height (test_fb);
CoglPrimitive *primitive; CoglPrimitive *primitive;
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglColor color;
int i; int i;
cogl_framebuffer_orthographic (test_fb, cogl_framebuffer_orthographic (test_fb,
@ -119,7 +120,8 @@ do_test (const char *attribute_name,
primitive = create_primitive (attribute_name); primitive = create_primitive (attribute_name);
pipeline = cogl_pipeline_new (test_ctx); pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, 0x00, 0xff, 0x00, 0xff); cogl_color_init_from_4f (&color, 0.0, 1.0, 0.0, 1.0);
cogl_pipeline_set_color (pipeline, &color);
cogl_pipeline_set_per_vertex_point_size (pipeline, TRUE, NULL); cogl_pipeline_set_per_vertex_point_size (pipeline, TRUE, NULL);
if (pipeline_setup_func) if (pipeline_setup_func)
pipeline_setup_func (pipeline); pipeline_setup_func (pipeline);

View file

@ -50,9 +50,11 @@ test_point_size (void)
{ {
int fb_width = cogl_framebuffer_get_width (test_fb); int fb_width = cogl_framebuffer_get_width (test_fb);
int fb_height = cogl_framebuffer_get_height (test_fb); int fb_height = cogl_framebuffer_get_height (test_fb);
CoglColor color;
int point_size; int point_size;
int x_pos; int x_pos;
cogl_color_init_from_4f (&color, 0.0, 1.0, 0.0, 1.0);
cogl_framebuffer_orthographic (test_fb, cogl_framebuffer_orthographic (test_fb,
0, 0, /* x_1, y_1 */ 0, 0, /* x_1, y_1 */
fb_width, /* x_2 */ fb_width, /* x_2 */
@ -79,7 +81,7 @@ test_point_size (void)
&point); &point);
cogl_pipeline_set_point_size (pipeline, point_size); cogl_pipeline_set_point_size (pipeline, point_size);
cogl_pipeline_set_color4ub (pipeline, 0, 255, 0, 255); cogl_pipeline_set_color (pipeline, &color);
cogl_primitive_draw (prim, test_fb, pipeline); cogl_primitive_draw (prim, test_fb, pipeline);
g_object_unref (prim); g_object_unref (prim);

View file

@ -55,9 +55,10 @@ create_primitives (CoglPrimitive *primitives[2])
static CoglPipeline * static CoglPipeline *
create_pipeline (void) create_pipeline (void)
{ {
CoglColor color;
CoglPipeline *pipeline = cogl_pipeline_new (test_ctx); CoglPipeline *pipeline = cogl_pipeline_new (test_ctx);
cogl_color_init_from_4f (&color, 0.0, 1.0, 0.0, 1.0);
cogl_pipeline_set_color4ub (pipeline, 0, 255, 0, 255); cogl_pipeline_set_color (pipeline, &color);
return pipeline; return pipeline;
} }

View file

@ -157,6 +157,7 @@ test_paint (TestState *state)
{ {
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglTexture *tex; CoglTexture *tex;
CoglColor color;
uint8_t tex_data[6]; uint8_t tex_data[6];
int i; int i;
@ -177,11 +178,12 @@ test_paint (TestState *state)
6, /* rowstride */ 6, /* rowstride */
tex_data); tex_data);
pipeline = cogl_pipeline_new (test_ctx); pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, cogl_color_init_from_4f (&color,
(PRIM_COLOR >> 24) & 0xff, ((PRIM_COLOR >> 24) & 0xff) / 255.0,
(PRIM_COLOR >> 16) & 0xff, ((PRIM_COLOR >> 16) & 0xff) / 255.0,
(PRIM_COLOR >> 8) & 0xff, ((PRIM_COLOR >> 8) & 0xff) / 255.0,
(PRIM_COLOR >> 0) & 0xff); ((PRIM_COLOR >> 0) & 0xff) / 255.0);
cogl_pipeline_set_color (pipeline, &color);
cogl_pipeline_set_layer_texture (pipeline, 0, tex); cogl_pipeline_set_layer_texture (pipeline, 0, tex);
g_object_unref (tex); g_object_unref (tex);

View file

@ -47,11 +47,13 @@ simple_fragment_snippet (TestState *state)
{ {
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglSnippet *snippet; CoglSnippet *snippet;
CoglColor color;
/* Simple fragment snippet */ /* Simple fragment snippet */
pipeline = cogl_pipeline_new (test_ctx); pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, 255, 0, 0, 255); cogl_color_init_from_4f (&color, 1.0, 0.0, 0.0, 1.0);
cogl_pipeline_set_color (pipeline, &color);
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT, snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,
NULL, /* declarations */ NULL, /* declarations */
@ -71,11 +73,13 @@ simple_vertex_snippet (TestState *state)
{ {
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglSnippet *snippet; CoglSnippet *snippet;
CoglColor color;
/* Simple vertex snippet */ /* Simple vertex snippet */
pipeline = cogl_pipeline_new (test_ctx); pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, 255, 0, 0, 255); cogl_color_init_from_4f (&color, 1.0, 0.0, 0.0, 1.0);
cogl_pipeline_set_color (pipeline, &color);
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_VERTEX, snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_VERTEX,
NULL, NULL,
@ -95,6 +99,7 @@ shared_uniform (TestState *state)
{ {
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglSnippet *snippet; CoglSnippet *snippet;
CoglColor color;
int location; int location;
/* Snippets sharing a uniform across the vertex and fragment /* Snippets sharing a uniform across the vertex and fragment
@ -104,7 +109,9 @@ shared_uniform (TestState *state)
location = cogl_pipeline_get_uniform_location (pipeline, "a_value"); location = cogl_pipeline_get_uniform_location (pipeline, "a_value");
cogl_pipeline_set_uniform_1f (pipeline, location, 0.25f); cogl_pipeline_set_uniform_1f (pipeline, location, 0.25f);
cogl_pipeline_set_color4ub (pipeline, 255, 0, 0, 255); cogl_color_init_from_4f (&color, 1.0, 0.0, 0.0, 1.0);
cogl_pipeline_set_color (pipeline, &color);
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_VERTEX, snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_VERTEX,
"uniform float a_value;", "uniform float a_value;",
@ -131,13 +138,15 @@ lots_snippets (TestState *state)
{ {
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglSnippet *snippet; CoglSnippet *snippet;
CoglColor color;
int location; int location;
int i; int i;
/* Lots of snippets on one pipeline */ /* Lots of snippets on one pipeline */
pipeline = cogl_pipeline_new (test_ctx); pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, 0, 0, 0, 255); cogl_color_init_from_4f (&color, 0.0, 0.0, 0.0, 1.0);
cogl_pipeline_set_color (pipeline, &color);
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {
@ -175,12 +184,14 @@ shared_variable_pre_post (TestState *state)
{ {
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglSnippet *snippet; CoglSnippet *snippet;
CoglColor color;
/* Test that the pre string can declare variables used by the post /* Test that the pre string can declare variables used by the post
string */ string */
pipeline = cogl_pipeline_new (test_ctx); pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, 255, 255, 255, 255); cogl_color_init_from_4f (&color, 1.0, 1.0, 1.0, 1.0);
cogl_pipeline_set_color (pipeline, &color);
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT, snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,
NULL, /* declarations */ NULL, /* declarations */
@ -489,6 +500,7 @@ test_vertex_transform_hook (TestState *state)
{ {
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglSnippet *snippet; CoglSnippet *snippet;
CoglColor color;
graphene_matrix_t identity_matrix; graphene_matrix_t identity_matrix;
graphene_matrix_t matrix; graphene_matrix_t matrix;
float v[16]; float v[16];
@ -500,7 +512,8 @@ test_vertex_transform_hook (TestState *state)
pipeline = cogl_pipeline_new (test_ctx); pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, 255, 0, 255, 255); cogl_color_init_from_4f (&color, 1.0, 0.0, 1.0, 1.0);
cogl_pipeline_set_color (pipeline, &color);
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_VERTEX_TRANSFORM, snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_VERTEX_TRANSFORM,
"uniform mat4 pmat;", "uniform mat4 pmat;",
@ -642,6 +655,7 @@ test_snippet_order (TestState *state)
{ {
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglSnippet *snippet; CoglSnippet *snippet;
CoglColor color;
/* Verify that the snippets are executed in the right order. We'll /* Verify that the snippets are executed in the right order. We'll
replace the r component of the color in the pre sections of the replace the r component of the color in the pre sections of the
@ -652,7 +666,8 @@ test_snippet_order (TestState *state)
component from the first */ component from the first */
pipeline = cogl_pipeline_new (test_ctx); pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_color4ub (pipeline, 0, 0, 0, 255); cogl_color_init_from_4f (&color, 0.0, 0.0, 0.0, 1.0);
cogl_pipeline_set_color (pipeline, &color);
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT, snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,
NULL, NULL,

View file

@ -7,6 +7,7 @@ static void
test_pipeline_opengl_blend_enable (void) test_pipeline_opengl_blend_enable (void)
{ {
CoglPipeline *pipeline; CoglPipeline *pipeline;
CoglColor color;
pipeline = cogl_pipeline_new (test_ctx); pipeline = cogl_pipeline_new (test_ctx);
@ -20,7 +21,8 @@ test_pipeline_opengl_blend_enable (void)
* disabled */ * disabled */
g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 0); g_assert_cmpint (test_ctx->gl_blend_enable_cache, ==, 0);
cogl_pipeline_set_color4f (pipeline, 0, 0, 0, 0); cogl_color_init_from_4f (&color, 0.0, 0.0, 0.0, 0.0);
cogl_pipeline_set_color (pipeline, &color);
cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 1, 1); cogl_framebuffer_draw_rectangle (test_fb, pipeline, 0, 0, 1, 1);
_cogl_framebuffer_flush_journal (test_fb); _cogl_framebuffer_flush_journal (test_fb);