clutter: Introduce paint contexts

When painting, actors rely on semi global state tracked by the state to
get various things needed for painting, such as the current draw
framebuffer. Having state hidden in such ways can be very deceiving as
it's hard to follow changes spread out, and adding more and more state
that should be tracked during a paint gets annoying as they will not
change in isolation but one by one in their own places. To do this
better, introduce a paint context that is passed along in paint calls
that contains the necessary state needed during painting.

The paint context implements a framebuffer stack just as Cogl works,
which is currently needed for offscreen rendering used by clutter.

The same context is passed around for paint nodes, contents and effects
as well.

In this commit, the context is only introduced, but not used. It aims to
replace the Cogl framebuffer stack, and will allow actors to know what
view it is currently painted on.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
This commit is contained in:
Jonas Ådahl
2019-11-13 22:21:58 +01:00
committed by Georges Basile Stavracas Neto
parent 5c986060f0
commit 49c8d42317
69 changed files with 563 additions and 175 deletions

View File

@@ -191,7 +191,9 @@ test_invalid_texture_layers_with_constant_colors (TestState *state,
}
static void
on_paint (ClutterActor *actor, TestState *state)
on_paint (ClutterActor *actor,
ClutterPaintContext *paint_context,
TestState *state)
{
test_invalid_texture_layers (state,
0, 0 /* position */

View File

@@ -99,7 +99,9 @@ make_texture (guchar ref)
}
static void
on_paint (ClutterActor *actor, TestState *state)
on_paint (ClutterActor *actor,
ClutterPaintContext *paint_context,
TestState *state)
{
CoglHandle tex0, tex1;
CoglHandle material;

View File

@@ -15,7 +15,9 @@ static const ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff };
static void
on_paint (ClutterActor *actor, void *state)
on_paint (ClutterActor *actor,
ClutterPaintContext *paint_context,
void *state)
{
float saved_viewport[4];
CoglMatrix saved_projection;

View File

@@ -45,7 +45,9 @@ make_texture (void)
}
static void
on_paint (ClutterActor *actor, TestState *state)
on_paint (ClutterActor *actor,
ClutterPaintContext *paint_context,
TestState *state)
{
CoglHandle tex;
CoglHandle material;

View File

@@ -140,7 +140,9 @@ check_paint (TestState *state, int x, int y, int scale)
#define FRAME_COUNT_UPDATED 8
static void
on_paint (ClutterActor *actor, TestState *state)
on_paint (ClutterActor *actor,
ClutterPaintContext *paint_context,
TestState *state)
{
CoglHandle material;

View File

@@ -96,7 +96,9 @@ validate_result (TestState *state)
}
static void
on_paint (ClutterActor *actor, TestState *state)
on_paint (ClutterActor *actor,
ClutterPaintContext *paint_context,
TestState *state)
{
/* Draw a faded blue triangle */
cogl_vertex_buffer_enable (state->buffer, "gl_Color::blue");

View File

@@ -63,7 +63,9 @@ validate_result (TestState *state)
}
static void
on_paint (ClutterActor *actor, TestState *state)
on_paint (ClutterActor *actor,
ClutterPaintContext *paint_context,
TestState *state)
{
/* Draw a faded blue triangle */
cogl_vertex_buffer_draw (state->buffer,

View File

@@ -66,7 +66,9 @@ assert_rectangle_color_and_black_border (int x,
static void
on_paint (ClutterActor *actor, void *state)
on_paint (ClutterActor *actor,
ClutterPaintContext *paint_context,
void *state)
{
float saved_viewport[4];
CoglMatrix saved_projection;