theme-node: Pass an explicit framebuffer to paint()

This allows us to paint to an offscreen buffer without using the
deprecated cogl_push_framebuffer/cogl_pop_framebuffer functions.
This commit is contained in:
Florian Müllner 2015-09-26 05:44:56 +02:00
parent 113a854048
commit 48a54e8ac4
4 changed files with 20 additions and 18 deletions

View File

@ -1282,6 +1282,7 @@ st_theme_node_prerender_background (StThemeNode *node,
} }
static void st_theme_node_paint_borders (StThemeNodePaintState *state, static void st_theme_node_paint_borders (StThemeNodePaintState *state,
CoglFramebuffer *framebuffer,
const ClutterActorBox *box, const ClutterActorBox *box,
guint8 paint_opacity); guint8 paint_opacity);
@ -1595,11 +1596,11 @@ paint_material_with_opacity (CoglHandle material,
static void static void
st_theme_node_paint_borders (StThemeNodePaintState *state, st_theme_node_paint_borders (StThemeNodePaintState *state,
CoglFramebuffer *framebuffer,
const ClutterActorBox *box, const ClutterActorBox *box,
guint8 paint_opacity) guint8 paint_opacity)
{ {
StThemeNode *node = state->node; StThemeNode *node = state->node;
CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
float width, height; float width, height;
guint border_width[4]; guint border_width[4];
guint border_radius[4]; guint border_radius[4];
@ -1713,20 +1714,20 @@ st_theme_node_paint_borders (StThemeNodePaintState *state,
switch (corner_id) switch (corner_id)
{ {
case ST_CORNER_TOPLEFT: case ST_CORNER_TOPLEFT:
cogl_framebuffer_draw_textured_rectangle (fb, cogl_framebuffer_draw_textured_rectangle (framebuffer,
state->corner_material[corner_id], 0, 0, state->corner_material[corner_id], 0, 0,
max_width_radius[ST_CORNER_TOPLEFT], max_width_radius[ST_CORNER_TOPLEFT], max_width_radius[ST_CORNER_TOPLEFT], max_width_radius[ST_CORNER_TOPLEFT],
0, 0, 0.5, 0.5); 0, 0, 0.5, 0.5);
break; break;
case ST_CORNER_TOPRIGHT: case ST_CORNER_TOPRIGHT:
cogl_framebuffer_draw_textured_rectangle (fb, cogl_framebuffer_draw_textured_rectangle (framebuffer,
state->corner_material[corner_id], state->corner_material[corner_id],
width - max_width_radius[ST_CORNER_TOPRIGHT], 0, width - max_width_radius[ST_CORNER_TOPRIGHT], 0,
width, max_width_radius[ST_CORNER_TOPRIGHT], width, max_width_radius[ST_CORNER_TOPRIGHT],
0.5, 0, 1, 0.5); 0.5, 0, 1, 0.5);
break; break;
case ST_CORNER_BOTTOMRIGHT: case ST_CORNER_BOTTOMRIGHT:
cogl_framebuffer_draw_textured_rectangle (fb, cogl_framebuffer_draw_textured_rectangle (framebuffer,
state->corner_material[corner_id], state->corner_material[corner_id],
width - max_width_radius[ST_CORNER_BOTTOMRIGHT], width - max_width_radius[ST_CORNER_BOTTOMRIGHT],
height - max_width_radius[ST_CORNER_BOTTOMRIGHT], height - max_width_radius[ST_CORNER_BOTTOMRIGHT],
@ -1734,7 +1735,7 @@ st_theme_node_paint_borders (StThemeNodePaintState *state,
0.5, 0.5, 1, 1); 0.5, 0.5, 1, 1);
break; break;
case ST_CORNER_BOTTOMLEFT: case ST_CORNER_BOTTOMLEFT:
cogl_framebuffer_draw_textured_rectangle (fb, cogl_framebuffer_draw_textured_rectangle (framebuffer,
state->corner_material[corner_id], state->corner_material[corner_id],
0, height - max_width_radius[ST_CORNER_BOTTOMLEFT], 0, height - max_width_radius[ST_CORNER_BOTTOMLEFT],
max_width_radius[ST_CORNER_BOTTOMLEFT], height, max_width_radius[ST_CORNER_BOTTOMLEFT], height,
@ -2208,9 +2209,7 @@ st_theme_node_prerender_shadow (StThemeNodePaintState *state)
state->box_shadow_height, 0, 1.0); state->box_shadow_height, 0, 1.0);
cogl_framebuffer_clear4f (offscreen, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 0); cogl_framebuffer_clear4f (offscreen, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 0);
cogl_push_framebuffer (offscreen); st_theme_node_paint_borders (state, offscreen, &box, 0xFF);
st_theme_node_paint_borders (state, &box, 0xFF);
cogl_pop_framebuffer ();
cogl_handle_unref (offscreen); cogl_handle_unref (offscreen);
state->box_shadow_pipeline = _st_create_shadow_pipeline (st_theme_node_get_box_shadow (node), state->box_shadow_pipeline = _st_create_shadow_pipeline (st_theme_node_get_box_shadow (node),
@ -2411,6 +2410,7 @@ st_theme_node_needs_new_box_shadow_for_size (StThemeNodePaintState *state,
void void
st_theme_node_paint (StThemeNode *node, st_theme_node_paint (StThemeNode *node,
StThemeNodePaintState *state, StThemeNodePaintState *state,
CoglFramebuffer *framebuffer,
const ClutterActorBox *box, const ClutterActorBox *box,
guint8 paint_opacity) guint8 paint_opacity)
{ {
@ -2512,7 +2512,7 @@ st_theme_node_paint (StThemeNode *node,
} }
else else
{ {
st_theme_node_paint_borders (state, box, paint_opacity); st_theme_node_paint_borders (state, framebuffer, box, paint_opacity);
} }
st_theme_node_paint_outline (node, box, paint_opacity); st_theme_node_paint_outline (node, box, paint_opacity);
@ -2522,7 +2522,6 @@ st_theme_node_paint (StThemeNode *node,
{ {
ClutterActorBox background_box; ClutterActorBox background_box;
ClutterActorBox texture_coords; ClutterActorBox texture_coords;
CoglFramebuffer *fb = cogl_get_draw_framebuffer ();
gboolean has_visible_outline; gboolean has_visible_outline;
/* If the node doesn't have an opaque or repeating background or /* If the node doesn't have an opaque or repeating background or
@ -2534,7 +2533,7 @@ st_theme_node_paint (StThemeNode *node,
get_background_position (node, &allocation, &background_box, &texture_coords); get_background_position (node, &allocation, &background_box, &texture_coords);
if (has_visible_outline || node->background_repeat) if (has_visible_outline || node->background_repeat)
cogl_framebuffer_push_rectangle_clip (fb, cogl_framebuffer_push_rectangle_clip (framebuffer,
allocation.x1, allocation.y1, allocation.x1, allocation.y1,
allocation.x2, allocation.y2); allocation.x2, allocation.y2);
@ -2563,7 +2562,7 @@ st_theme_node_paint (StThemeNode *node,
paint_opacity); paint_opacity);
if (has_visible_outline || node->background_repeat) if (has_visible_outline || node->background_repeat)
cogl_framebuffer_pop_clip (fb); cogl_framebuffer_pop_clip (framebuffer);
} }
} }

View File

@ -312,9 +312,8 @@ setup_framebuffers (StThemeNodeTransition *transition,
priv->offscreen_box.x2, priv->offscreen_box.x2,
priv->offscreen_box.y2, 0.0, 1.0); priv->offscreen_box.y2, 0.0, 1.0);
cogl_push_framebuffer (priv->old_offscreen); st_theme_node_paint (priv->old_theme_node, &priv->old_paint_state,
st_theme_node_paint (priv->old_theme_node, &priv->old_paint_state, allocation, 255); priv->old_offscreen, allocation, 255);
cogl_pop_framebuffer ();
cogl_framebuffer_clear4f (priv->new_offscreen, COGL_BUFFER_BIT_COLOR, cogl_framebuffer_clear4f (priv->new_offscreen, COGL_BUFFER_BIT_COLOR,
0, 0, 0, 0); 0, 0, 0, 0);
@ -323,9 +322,8 @@ setup_framebuffers (StThemeNodeTransition *transition,
priv->offscreen_box.y1, priv->offscreen_box.y1,
priv->offscreen_box.x2, priv->offscreen_box.x2,
priv->offscreen_box.y2, 0.0, 1.0); priv->offscreen_box.y2, 0.0, 1.0);
cogl_push_framebuffer (priv->new_offscreen); st_theme_node_paint (priv->new_theme_node, &priv->new_paint_state,
st_theme_node_paint (priv->new_theme_node, &priv->new_paint_state, allocation, 255); priv->new_offscreen, allocation, 255);
cogl_pop_framebuffer ();
return TRUE; return TRUE;
} }

View File

@ -268,8 +268,12 @@ gboolean st_theme_node_geometry_equal (StThemeNode *node,
gboolean st_theme_node_paint_equal (StThemeNode *node, gboolean st_theme_node_paint_equal (StThemeNode *node,
StThemeNode *other); StThemeNode *other);
/**
* st_theme_node_paint: (skip)
*/
void st_theme_node_paint (StThemeNode *node, void st_theme_node_paint (StThemeNode *node,
StThemeNodePaintState *state, StThemeNodePaintState *state,
CoglFramebuffer *framebuffer,
const ClutterActorBox *box, const ClutterActorBox *box,
guint8 paint_opacity); guint8 paint_opacity);

View File

@ -456,6 +456,7 @@ st_widget_paint_background (StWidget *widget)
else else
st_theme_node_paint (theme_node, st_theme_node_paint (theme_node,
current_paint_state (widget), current_paint_state (widget),
cogl_get_draw_framebuffer (),
&allocation, &allocation,
opacity); opacity);
} }