clutter, core: Stop using the Cogl framebuffer stack

The Cogl framebuffer stack is going away; replace all its uses by the
framebuffer stack carried by the paint context.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
This commit is contained in:
Jonas Ådahl
2019-11-22 11:41:04 +01:00
committed by Georges Basile Stavracas Neto
parent 549f60fe49
commit 3f65837e0d
29 changed files with 105 additions and 79 deletions

View File

@ -119,14 +119,18 @@ meta_overlay_set (MetaOverlay *overlay,
}
static void
meta_overlay_paint (MetaOverlay *overlay)
meta_overlay_paint (MetaOverlay *overlay,
ClutterPaintContext *paint_context)
{
CoglFramebuffer *framebuffer;
if (!overlay->enabled)
return;
g_assert (meta_is_wayland_compositor ());
cogl_framebuffer_draw_rectangle (cogl_get_draw_framebuffer (),
framebuffer = clutter_paint_context_get_framebuffer (paint_context);
cogl_framebuffer_draw_rectangle (framebuffer,
overlay->pipeline,
overlay->current_rect.origin.x,
overlay->current_rect.origin.y,
@ -198,7 +202,7 @@ meta_stage_paint (ClutterActor *actor,
g_signal_emit (stage, signals[ACTORS_PAINTED], 0);
for (l = stage->overlays; l; l = l->next)
meta_overlay_paint (l->data);
meta_overlay_paint (l->data, paint_context);
notify_watchers_for_mode (stage, stage->current_view,
META_STAGE_WATCH_AFTER_OVERLAY_PAINT);

View File

@ -337,6 +337,7 @@ make_pipeline (PipelineFlags pipeline_flags)
static void
setup_pipeline (MetaBackgroundActor *self,
ClutterPaintContext *paint_context,
cairo_rectangle_int_t *actor_pixel_rect)
{
PipelineFlags pipeline_flags = 0;
@ -436,7 +437,7 @@ setup_pipeline (MetaBackgroundActor *self,
color_component,
opacity / 255.);
fb = cogl_get_draw_framebuffer ();
fb = clutter_paint_context_get_framebuffer (paint_context);
if (!self->force_bilinear &&
meta_actor_painting_untransformed (fb,
actor_pixel_rect->width,
@ -526,14 +527,14 @@ meta_background_actor_paint (ClutterActor *actor,
actor_pixel_rect.width = actor_box.x2 - actor_box.x1;
actor_pixel_rect.height = actor_box.y2 - actor_box.y1;
setup_pipeline (self, &actor_pixel_rect);
setup_pipeline (self, paint_context, &actor_pixel_rect);
set_glsl_parameters (self, &actor_pixel_rect);
/* Limit to how many separate rectangles we'll draw; beyond this just
* fall back and draw the whole thing */
#define MAX_RECTS 64
fb = cogl_get_draw_framebuffer ();
fb = clutter_paint_context_get_framebuffer (paint_context);
/* Now figure out what to actually paint.
*/

View File

@ -512,12 +512,12 @@ texture_is_idle_and_not_mipmapped (gpointer user_data)
}
static void
do_paint_content (MetaShapedTexture *stex,
ClutterPaintNode *root_node,
CoglTexture *paint_tex,
ClutterActorBox *alloc,
uint8_t opacity)
do_paint_content (MetaShapedTexture *stex,
ClutterPaintNode *root_node,
ClutterPaintContext *paint_context,
CoglTexture *paint_tex,
ClutterActorBox *alloc,
uint8_t opacity)
{
int dst_width, dst_height;
cairo_rectangle_int_t content_rect;
@ -550,7 +550,7 @@ do_paint_content (MetaShapedTexture *stex,
framebuffer = clutter_paint_node_get_framebuffer (root_node);
if (!framebuffer)
framebuffer = cogl_get_draw_framebuffer ();
framebuffer = clutter_paint_context_get_framebuffer (paint_context);
if (meta_actor_painting_untransformed (framebuffer,
dst_width, dst_height,
NULL, NULL))
@ -680,7 +680,8 @@ do_paint_content (MetaShapedTexture *stex,
}
static CoglTexture *
select_texture_for_paint (MetaShapedTexture *stex)
select_texture_for_paint (MetaShapedTexture *stex,
ClutterPaintContext *paint_context)
{
CoglTexture *texture = NULL;
int64_t now;
@ -696,7 +697,10 @@ select_texture_for_paint (MetaShapedTexture *stex)
if (age >= MIN_MIPMAP_AGE_USEC ||
stex->fast_updates < MIN_FAST_UPDATES_BEFORE_UNMIPMAP)
texture = meta_texture_tower_get_paint_texture (stex->paint_tower);
{
texture = meta_texture_tower_get_paint_texture (stex->paint_tower,
paint_context);
}
}
if (!texture)
@ -745,14 +749,14 @@ meta_shaped_texture_paint_content (ClutterContent *content,
* Setting the texture quality to high without SGIS_generate_mipmap
* support for TFP textures will result in fallbacks to XGetImage.
*/
paint_tex = select_texture_for_paint (stex);
paint_tex = select_texture_for_paint (stex, paint_context);
if (!paint_tex)
return;
opacity = clutter_actor_get_paint_opacity (actor);
clutter_actor_get_content_box (actor, &alloc);
do_paint_content (stex, root_node, paint_tex, &alloc, opacity);
do_paint_content (stex, root_node, paint_context, paint_tex, &alloc, opacity);
}
static gboolean
@ -1242,7 +1246,7 @@ get_image_via_offscreen (MetaShapedTexture *stex,
paint_context = clutter_paint_context_new_for_framebuffer (fb);
do_paint_content (stex, root_node,
do_paint_content (stex, root_node, paint_context,
stex->texture,
&(ClutterActorBox) {
0, 0,

View File

@ -243,7 +243,9 @@ meta_texture_tower_update_area (MetaTextureTower *tower,
* Meta.
*/
static int
get_paint_level (int width, int height)
get_paint_level (ClutterPaintContext *paint_context,
int width,
int height)
{
CoglFramebuffer *framebuffer;
CoglMatrix projection, modelview, pm;
@ -272,7 +274,7 @@ get_paint_level (int width, int height)
* (w_c) (w_o) (1)
*/
framebuffer = cogl_get_draw_framebuffer ();
framebuffer = clutter_paint_context_get_framebuffer (paint_context);
cogl_framebuffer_get_projection_matrix (framebuffer, &projection);
cogl_framebuffer_get_modelview_matrix (framebuffer, &modelview);
@ -419,6 +421,7 @@ texture_tower_revalidate (MetaTextureTower *tower,
/**
* meta_texture_tower_get_paint_texture:
* @tower: a #MetaTextureTower
* @paint_context: a #ClutterPaintContext
*
* Gets the texture from the tower that best matches the current
* rendering scale. (On the assumption here the texture is going to
@ -430,7 +433,8 @@ texture_tower_revalidate (MetaTextureTower *tower,
* %NULL if no base texture has yet been set.
*/
CoglTexture *
meta_texture_tower_get_paint_texture (MetaTextureTower *tower)
meta_texture_tower_get_paint_texture (MetaTextureTower *tower,
ClutterPaintContext *paint_context)
{
int texture_width, texture_height;
int level;
@ -443,7 +447,7 @@ meta_texture_tower_get_paint_texture (MetaTextureTower *tower)
texture_width = cogl_texture_get_width (tower->textures[0]);
texture_height = cogl_texture_get_height (tower->textures[0]);
level = get_paint_level(texture_width, texture_height);
level = get_paint_level (paint_context, texture_width, texture_height);
if (level < 0) /* singular paint matrix, scaled to nothing */
return NULL;
level = MIN (level, tower->n_levels - 1);

View File

@ -60,7 +60,8 @@ void meta_texture_tower_update_area (MetaTextureTower *tower,
int y,
int width,
int height);
CoglTexture *meta_texture_tower_get_paint_texture (MetaTextureTower *tower);
CoglTexture *meta_texture_tower_get_paint_texture (MetaTextureTower *tower,
ClutterPaintContext *paint_context);
G_END_DECLS

View File

@ -1168,6 +1168,7 @@ meta_window_actor_x11_paint (ClutterActor *actor,
MetaShadowParams params;
cairo_rectangle_int_t shape_bounds;
cairo_region_t *clip = actor_x11->shadow_clip;
CoglFramebuffer *framebuffer;
get_shape_bounds (actor_x11, &shape_bounds);
get_shadow_params (actor_x11, appears_focused, &params);
@ -1188,8 +1189,9 @@ meta_window_actor_x11_paint (ClutterActor *actor,
cairo_region_subtract (clip, frame_bounds);
}
framebuffer = clutter_paint_context_get_framebuffer (paint_context);
meta_shadow_paint (shadow,
cogl_get_draw_framebuffer (),
framebuffer,
params.x_offset + shape_bounds.x,
params.y_offset + shape_bounds.y,
shape_bounds.width,

View File

@ -1403,8 +1403,6 @@ meta_window_actor_get_image (MetaWindowActor *self,
cogl_color_init_from_4ub (&clear_color, 0, 0, 0, 0);
clutter_actor_get_position (actor, &x, &y);
cogl_push_framebuffer (framebuffer);
cogl_framebuffer_clear (framebuffer, COGL_BUFFER_BIT_COLOR, &clear_color);
cogl_framebuffer_orthographic (framebuffer, 0, 0, width, height, 0, 1.0);
cogl_framebuffer_scale (framebuffer, resource_scale, resource_scale, 1);
@ -1414,8 +1412,6 @@ meta_window_actor_get_image (MetaWindowActor *self,
clutter_actor_paint (actor, paint_context);
clutter_paint_context_destroy (paint_context);
cogl_pop_framebuffer ();
if (clip)
{
meta_rectangle_scale_double (clip, resource_scale,

View File

@ -83,7 +83,7 @@ meta_window_group_paint (ClutterActor *actor,
{
CoglFramebuffer *fb;
fb = cogl_get_draw_framebuffer ();
fb = clutter_paint_context_get_framebuffer (paint_context);
if (!meta_actor_painting_untransformed (fb,
screen_width,
screen_height,

View File

@ -58,7 +58,7 @@ foo_actor_paint (ClutterActor *actor,
255, 0, 0,
foo_actor->last_paint_opacity);
framebuffer = cogl_get_draw_framebuffer ();
framebuffer = clutter_paint_context_get_framebuffer (paint_context);
cogl_framebuffer_draw_rectangle (framebuffer,
pipeline,
allocation.x1,

View File

@ -147,7 +147,7 @@ key_group_paint (ClutterActor *actor,
pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_color4ub (pipeline, 255, 255, 0, 224);
framebuffer = cogl_get_draw_framebuffer ();
framebuffer = clutter_paint_context_get_framebuffer (paint_context);
clutter_actor_iter_init (&iter, actor);
while (clutter_actor_iter_next (&iter, &child))

View File

@ -157,7 +157,8 @@ key_group_paint (ClutterActor *actor,
ClutterActorIter iter;
ClutterActor *child;
gint i = 0;
CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer ();
CoglFramebuffer *framebuffer =
clutter_paint_context_get_framebuffer (paint_context);
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
CoglPipeline *pipeline;

View File

@ -87,7 +87,8 @@ test_coglbox_paint (ClutterActor *self,
ClutterPaintContext *paint_context)
{
TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (self);
CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer ();
CoglFramebuffer *framebuffer =
clutter_paint_context_get_framebuffer (paint_context);
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
gfloat texcoords[4] = { 0, 0, 1, 1 };
CoglPipeline *pipeline;

View File

@ -99,7 +99,8 @@ paint_cb (ClutterActor *stage,
ClutterPaintContext *paint_context,
Data *data)
{
CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer ();
CoglFramebuffer *framebuffer =
clutter_paint_context_get_framebuffer (paint_context);
CoglMatrix old_matrix, new_matrix;
int i;
float diff_time;

View File

@ -87,7 +87,8 @@ test_coglbox_paint (ClutterActor *self,
{
TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (self);
CoglPipeline *pipeline;
CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer ();
CoglFramebuffer *framebuffer =
clutter_paint_context_get_framebuffer (paint_context);
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
gfloat texcoords[4] = { 0.0, 0.0, 1.0, 1.0 };

View File

@ -197,7 +197,8 @@ test_coglbox_paint (ClutterActor *self,
: priv->not_sliced_tex;
int tex_width = cogl_texture_get_width (tex_handle);
int tex_height = cogl_texture_get_height (tex_handle);
CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer ();
CoglFramebuffer *framebuffer =
clutter_paint_context_get_framebuffer (paint_context);
CoglHandle material = cogl_material_new ();
cogl_material_set_layer (material, 0, tex_handle);

View File

@ -87,7 +87,8 @@ test_coglbox_paint (ClutterActor *self,
ClutterPaintContext *paint_context)
{
TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (self);
CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer ();
CoglFramebuffer *framebuffer =
clutter_paint_context_get_framebuffer (paint_context);
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
CoglPipeline *pipeline;
gfloat texcoords[4] = { 0.0f, 0.0f, 1.0f, 1.0f };

View File

@ -148,7 +148,8 @@ hand_pre_paint (ClutterActor *actor,
ClutterPaintContext *paint_context,
gpointer user_data)
{
CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer ();
CoglFramebuffer *framebuffer =
clutter_paint_context_get_framebuffer (paint_context);
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
CoglPipeline *pipeline;
SuperOH *oh = user_data;
@ -176,7 +177,8 @@ hand_post_paint (ClutterActor *actor,
ClutterPaintContext *paint_context,
gpointer user_data)
{
CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer ();
CoglFramebuffer *framebuffer =
clutter_paint_context_get_framebuffer (paint_context);
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
CoglPipeline *pipeline;
SuperOH *oh = user_data;

View File

@ -27,14 +27,17 @@ typedef struct _TestState
int current_test;
} TestState;
typedef void (*TestCallback) (TestState *state);
typedef void (*TestCallback) (TestState *state,
ClutterPaintContext *paint_context);
static void
test_rectangles (TestState *state)
test_rectangles (TestState *state,
ClutterPaintContext *paint_context)
{
#define RECT_WIDTH 5
#define RECT_HEIGHT 5
CoglFramebuffer *framebuffer = cogl_get_draw_framebuffer ();
CoglFramebuffer *framebuffer =
clutter_paint_context_get_framebuffer (paint_context);
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
int x;
int y;
@ -111,7 +114,7 @@ on_paint (ClutterActor *actor,
ClutterPaintContext *paint_context,
TestState *state)
{
tests[state->current_test] (state);
tests[state->current_test] (state, paint_context);
}
static gboolean