st: Fix a bunch of cogl deprecations

This commit is contained in:
Florian Müllner 2015-09-26 04:20:22 +02:00
parent 9acdb8012c
commit 882f5fa79e
4 changed files with 100 additions and 79 deletions

View File

@ -1376,7 +1376,8 @@ st_theme_node_load_background_image (StThemeNode *node)
node->background_material = _st_create_texture_pipeline (node->background_texture);
if (node->background_repeat)
cogl_material_set_layer_wrap_mode (node->background_material, 0, COGL_MATERIAL_WRAP_MODE_REPEAT);
cogl_pipeline_set_layer_wrap_mode (node->background_material, 0,
COGL_PIPELINE_WRAP_MODE_REPEAT);
if (background_image_shadow_spec)
{
@ -1578,16 +1579,18 @@ paint_material_with_opacity (CoglHandle material,
ClutterActorBox *coords,
guint8 paint_opacity)
{
cogl_material_set_color4ub (material,
CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
cogl_pipeline_set_color4ub (material,
paint_opacity, paint_opacity, paint_opacity, paint_opacity);
cogl_set_source (material);
if (coords)
cogl_rectangle_with_texture_coords (box->x1, box->y1, box->x2, box->y2,
coords->x1, coords->y1, coords->x2, coords->y2);
cogl_framebuffer_draw_textured_rectangle (fb, material,
box->x1, box->y1, box->x2, box->y2,
coords->x1, coords->y1, coords->x2, coords->y2);
else
cogl_rectangle (box->x1, box->y1, box->x2, box->y2);
cogl_framebuffer_draw_rectangle (fb, material,
box->x1, box->y1, box->x2, box->y2);
}
static void
@ -1596,6 +1599,7 @@ st_theme_node_paint_borders (StThemeNodePaintState *state,
guint8 paint_opacity)
{
StThemeNode *node = state->node;
CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
float width, height;
guint border_width[4];
guint border_radius[4];
@ -1702,32 +1706,39 @@ st_theme_node_paint_borders (StThemeNodePaintState *state,
if (state->corner_material[corner_id] == COGL_INVALID_HANDLE)
continue;
cogl_material_set_color4ub (state->corner_material[corner_id],
cogl_pipeline_set_color4ub (state->corner_material[corner_id],
paint_opacity, paint_opacity,
paint_opacity, paint_opacity);
cogl_set_source (state->corner_material[corner_id]);
switch (corner_id)
{
case ST_CORNER_TOPLEFT:
cogl_rectangle_with_texture_coords (0, 0,
max_width_radius[ST_CORNER_TOPLEFT], max_width_radius[ST_CORNER_TOPLEFT],
0, 0, 0.5, 0.5);
cogl_framebuffer_draw_textured_rectangle (fb,
state->corner_material[corner_id], 0, 0,
max_width_radius[ST_CORNER_TOPLEFT], max_width_radius[ST_CORNER_TOPLEFT],
0, 0, 0.5, 0.5);
break;
case ST_CORNER_TOPRIGHT:
cogl_rectangle_with_texture_coords (width - max_width_radius[ST_CORNER_TOPRIGHT], 0,
width, max_width_radius[ST_CORNER_TOPRIGHT],
0.5, 0, 1, 0.5);
cogl_framebuffer_draw_textured_rectangle (fb,
state->corner_material[corner_id],
width - max_width_radius[ST_CORNER_TOPRIGHT], 0,
width, max_width_radius[ST_CORNER_TOPRIGHT],
0.5, 0, 1, 0.5);
break;
case ST_CORNER_BOTTOMRIGHT:
cogl_rectangle_with_texture_coords (width - max_width_radius[ST_CORNER_BOTTOMRIGHT], height - max_width_radius[ST_CORNER_BOTTOMRIGHT],
width, height,
0.5, 0.5, 1, 1);
cogl_framebuffer_draw_textured_rectangle (fb,
state->corner_material[corner_id],
width - max_width_radius[ST_CORNER_BOTTOMRIGHT],
height - max_width_radius[ST_CORNER_BOTTOMRIGHT],
width, height,
0.5, 0.5, 1, 1);
break;
case ST_CORNER_BOTTOMLEFT:
cogl_rectangle_with_texture_coords (0, height - max_width_radius[ST_CORNER_BOTTOMLEFT],
max_width_radius[ST_CORNER_BOTTOMLEFT], height,
0, 0.5, 0.5, 1);
cogl_framebuffer_draw_textured_rectangle (fb,
state->corner_material[corner_id],
0, height - max_width_radius[ST_CORNER_BOTTOMLEFT],
max_width_radius[ST_CORNER_BOTTOMLEFT], height,
0, 0.5, 0.5, 1);
break;
default:
g_assert_not_reached();
@ -1868,6 +1879,7 @@ st_theme_node_paint_sliced_shadow (StThemeNodePaintState *state,
guint8 paint_opacity)
{
StThemeNode *node = state->node;
CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
guint border_radius[4];
CoglColor color;
StShadow *box_shadow_spec;
@ -1969,16 +1981,14 @@ st_theme_node_paint_sliced_shadow (StThemeNodePaintState *state,
right += xoffset;
/* Setup pipeline */
cogl_color_set_from_4ub (&color,
box_shadow_spec->color.red * paint_opacity / 255,
box_shadow_spec->color.green * paint_opacity / 255,
box_shadow_spec->color.blue * paint_opacity / 255,
box_shadow_spec->color.alpha * paint_opacity / 255);
cogl_color_init_from_4ub (&color,
box_shadow_spec->color.red * paint_opacity / 255,
box_shadow_spec->color.green * paint_opacity / 255,
box_shadow_spec->color.blue * paint_opacity / 255,
box_shadow_spec->color.alpha * paint_opacity / 255);
cogl_color_premultiply (&color);
cogl_material_set_layer_combine_constant (state->box_shadow_material, 0, &color);
cogl_set_source (state->box_shadow_material);
cogl_pipeline_set_layer_combine_constant (state->box_shadow_material, 0, &color);
idx = 0;
@ -2106,7 +2116,8 @@ st_theme_node_paint_sliced_shadow (StThemeNodePaintState *state,
}
}
cogl_rectangles_with_texture_coords (rectangles, idx / 8);
cogl_framebuffer_draw_textured_rectangles (fb, state->box_shadow_material,
rectangles, idx / 8);
#if 0
/* Visual feedback on shadow's 9-slice and orignal offscreen buffer,
@ -2186,19 +2197,18 @@ st_theme_node_prerender_shadow (StThemeNodePaintState *state)
state->box_shadow_height,
COGL_TEXTURE_NO_SLICING,
COGL_PIXEL_FORMAT_ANY);
offscreen = cogl_offscreen_new_to_texture (buffer);
offscreen = cogl_offscreen_new_with_texture (buffer);
if (offscreen != COGL_INVALID_HANDLE)
{
ClutterActorBox box = { 0, 0, state->box_shadow_width, state->box_shadow_height};
CoglColor clear_color;
cogl_framebuffer_orthographic (offscreen, 0, 0,
state->box_shadow_width,
state->box_shadow_height, 0, 1.0);
cogl_framebuffer_clear4f (offscreen, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 0);
cogl_push_framebuffer (offscreen);
cogl_ortho (0, state->box_shadow_width, state->box_shadow_height, 0, 0, 1.0);
cogl_color_set_from_4ub (&clear_color, 0, 0, 0, 0);
cogl_clear (&clear_color, COGL_BUFFER_BIT_COLOR);
st_theme_node_paint_borders (state, &box, 0xFF);
cogl_pop_framebuffer ();
cogl_handle_unref (offscreen);
@ -2215,6 +2225,7 @@ st_theme_node_paint_sliced_border_image (StThemeNode *node,
float height,
guint8 paint_opacity)
{
CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
gfloat ex, ey;
gfloat tx1, ty1, tx2, ty2;
gint border_left, border_right, border_top, border_bottom;
@ -2245,11 +2256,9 @@ st_theme_node_paint_sliced_border_image (StThemeNode *node,
ey = border_bottom; /* FIXME ? */
material = node->border_slices_material;
cogl_material_set_color4ub (material,
cogl_pipeline_set_color4ub (material,
paint_opacity, paint_opacity, paint_opacity, paint_opacity);
cogl_set_source (material);
{
float rectangles[] =
{
@ -2299,7 +2308,7 @@ st_theme_node_paint_sliced_border_image (StThemeNode *node,
1.0, 1.0
};
cogl_rectangles_with_texture_coords (rectangles, 9);
cogl_framebuffer_draw_textured_rectangles (fb, material, rectangles, 9);
}
}
@ -2513,6 +2522,7 @@ st_theme_node_paint (StThemeNode *node,
{
ClutterActorBox background_box;
ClutterActorBox texture_coords;
CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
gboolean has_visible_outline;
/* If the node doesn't have an opaque or repeating background or
@ -2524,7 +2534,9 @@ st_theme_node_paint (StThemeNode *node,
get_background_position (node, &allocation, &background_box, &texture_coords);
if (has_visible_outline || node->background_repeat)
cogl_clip_push_rectangle (allocation.x1, allocation.y1, allocation.x2, allocation.y2);
cogl_framebuffer_push_rectangle_clip (fb,
allocation.x1, allocation.y1,
allocation.x2, allocation.y2);
/* CSS based drop shadows
*
@ -2551,7 +2563,7 @@ st_theme_node_paint (StThemeNode *node,
paint_opacity);
if (has_visible_outline || node->background_repeat)
cogl_clip_pop ();
cogl_framebuffer_pop_clip (fb);
}
}

View File

@ -107,11 +107,11 @@ struct _StThemeNode {
int box_shadow_min_width;
int box_shadow_min_height;
CoglHandle border_slices_texture;
CoglHandle border_slices_material;
CoglHandle background_texture;
CoglHandle background_material;
CoglHandle background_shadow_material;
CoglPipeline *border_slices_texture;
CoglPipeline *border_slices_material;
CoglPipeline *background_texture;
CoglPipeline *background_material;
CoglPipeline *background_shadow_material;
StThemeNodePaintState cached_state;
};

View File

@ -240,7 +240,6 @@ setup_framebuffers (StThemeNodeTransition *transition,
const ClutterActorBox *allocation)
{
StThemeNodeTransitionPrivate *priv = transition->priv;
CoglColor clear_color = { 0, 0, 0, 0 };
guint width, height;
/* template material to avoid unnecessary shader compilation */
@ -269,11 +268,11 @@ setup_framebuffers (StThemeNodeTransition *transition,
if (priv->old_offscreen)
cogl_handle_unref (priv->old_offscreen);
priv->old_offscreen = cogl_offscreen_new_to_texture (priv->old_texture);
priv->old_offscreen = cogl_offscreen_new_with_texture (priv->old_texture);
if (priv->new_offscreen)
cogl_handle_unref (priv->new_offscreen);
priv->new_offscreen = cogl_offscreen_new_to_texture (priv->new_texture);
priv->new_offscreen = cogl_offscreen_new_with_texture (priv->new_texture);
g_return_val_if_fail (priv->old_offscreen != COGL_INVALID_HANDLE, FALSE);
g_return_val_if_fail (priv->new_offscreen != COGL_INVALID_HANDLE, FALSE);
@ -282,40 +281,49 @@ setup_framebuffers (StThemeNodeTransition *transition,
{
if (G_UNLIKELY (material_template == COGL_INVALID_HANDLE))
{
material_template = cogl_material_new ();
CoglContext *ctx =
clutter_backend_get_cogl_context (clutter_get_default_backend ());
material_template = cogl_pipeline_new (ctx);
cogl_material_set_layer_combine (material_template, 0,
cogl_pipeline_set_layer_combine (material_template, 0,
"RGBA = REPLACE (TEXTURE)",
NULL);
cogl_material_set_layer_combine (material_template, 1,
cogl_pipeline_set_layer_combine (material_template, 1,
"RGBA = INTERPOLATE (PREVIOUS, "
"TEXTURE, "
"CONSTANT[A])",
NULL);
cogl_material_set_layer_combine (material_template, 2,
cogl_pipeline_set_layer_combine (material_template, 2,
"RGBA = MODULATE (PREVIOUS, "
"PRIMARY)",
NULL);
}
priv->material = cogl_material_copy (material_template);
priv->material = cogl_pipeline_copy (material_template);
}
cogl_material_set_layer (priv->material, 0, priv->new_texture);
cogl_material_set_layer (priv->material, 1, priv->old_texture);
cogl_pipeline_set_layer_texture (priv->material, 0, priv->new_texture);
cogl_pipeline_set_layer_texture (priv->material, 1, priv->old_texture);
cogl_framebuffer_clear4f (priv->old_offscreen, COGL_BUFFER_BIT_COLOR,
0, 0, 0, 0);
cogl_framebuffer_orthographic (priv->old_offscreen,
priv->offscreen_box.x1,
priv->offscreen_box.y1,
priv->offscreen_box.x2,
priv->offscreen_box.y2, 0.0, 1.0);
cogl_push_framebuffer (priv->old_offscreen);
cogl_clear (&clear_color, COGL_BUFFER_BIT_COLOR);
cogl_ortho (priv->offscreen_box.x1, priv->offscreen_box.x2,
priv->offscreen_box.y2, priv->offscreen_box.y1,
0.0, 1.0);
st_theme_node_paint (priv->old_theme_node, &priv->old_paint_state, allocation, 255);
cogl_pop_framebuffer ();
cogl_framebuffer_clear4f (priv->new_offscreen, COGL_BUFFER_BIT_COLOR,
0, 0, 0, 0);
cogl_framebuffer_orthographic (priv->new_offscreen,
priv->offscreen_box.x1,
priv->offscreen_box.y1,
priv->offscreen_box.x2,
priv->offscreen_box.y2, 0.0, 1.0);
cogl_push_framebuffer (priv->new_offscreen);
cogl_clear (&clear_color, COGL_BUFFER_BIT_COLOR);
cogl_ortho (priv->offscreen_box.x1, priv->offscreen_box.x2,
priv->offscreen_box.y2, priv->offscreen_box.y1,
0.0, 1.0);
st_theme_node_paint (priv->new_theme_node, &priv->new_paint_state, allocation, 255);
cogl_pop_framebuffer ();
@ -328,6 +336,7 @@ st_theme_node_transition_paint (StThemeNodeTransition *transition,
guint8 paint_opacity)
{
StThemeNodeTransitionPrivate *priv = transition->priv;
CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
CoglColor constant;
float tex_coords[] = {
@ -352,20 +361,20 @@ st_theme_node_transition_paint (StThemeNodeTransition *transition,
return;
}
cogl_color_set_from_4f (&constant, 0., 0., 0.,
clutter_timeline_get_progress (priv->timeline));
cogl_material_set_layer_combine_constant (priv->material, 1, &constant);
cogl_color_init_from_4f (&constant, 0., 0., 0.,
clutter_timeline_get_progress (priv->timeline));
cogl_pipeline_set_layer_combine_constant (priv->material, 1, &constant);
cogl_material_set_color4ub (priv->material,
cogl_pipeline_set_color4ub (priv->material,
paint_opacity, paint_opacity,
paint_opacity, paint_opacity);
cogl_set_source (priv->material);
cogl_rectangle_with_multitexture_coords (priv->offscreen_box.x1,
priv->offscreen_box.y1,
priv->offscreen_box.x2,
priv->offscreen_box.y2,
tex_coords, 8);
cogl_framebuffer_draw_multitextured_rectangle (fb, priv->material,
priv->offscreen_box.x1,
priv->offscreen_box.y1,
priv->offscreen_box.x2,
priv->offscreen_box.y2,
tex_coords, 8);
}
static void

View File

@ -104,9 +104,9 @@ struct _StThemeNodePaintState {
float box_shadow_width;
float box_shadow_height;
CoglHandle box_shadow_material;
CoglHandle prerendered_texture;
CoglHandle prerendered_material;
CoglPipeline *box_shadow_material;
CoglPipeline *prerendered_texture;
CoglPipeline *prerendered_material;
CoglHandle corner_material[4];
};