Adapt to painting and picking API change

While still leaving them unused, pass around ClutterPaintContext and
ClutterPickContext when painting and picking.

The reason for splitting this change up in two is to make it possible to
bisect easier in between the API change and the change to using the
framebuffer passed around with the temporary contexts.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/827
This commit is contained in:
Jonas Ådahl 2019-11-22 18:35:55 +01:00 committed by Georges Basile Stavracas Neto
parent 73776508b3
commit 988a0e7314
15 changed files with 102 additions and 51 deletions

View File

@ -472,9 +472,9 @@ class ObjInspector extends St.ScrollView {
var RedBorderEffect = GObject.registerClass(
class RedBorderEffect extends Clutter.Effect {
vfunc_paint() {
vfunc_paint(paintContext) {
let actor = this.get_actor();
actor.continue_paint();
actor.continue_paint(paintContext);
let color = new Cogl.Color();
color.init_from_4ub(0xff, 0, 0, 0xc4);

View File

@ -142,8 +142,8 @@ class UserWidgetLabel extends St.Widget {
this._currentLabel.allocate(childBox, flags);
}
vfunc_paint() {
this._currentLabel.paint();
vfunc_paint(paintContext) {
this._currentLabel.paint(paintContext);
}
_updateUser() {

View File

@ -26,7 +26,8 @@ struct _ShellGLSLEffectPrivate
G_DEFINE_TYPE_WITH_PRIVATE (ShellGLSLEffect, shell_glsl_effect, CLUTTER_TYPE_OFFSCREEN_EFFECT);
static gboolean
shell_glsl_effect_pre_paint (ClutterEffect *effect)
shell_glsl_effect_pre_paint (ClutterEffect *effect,
ClutterPaintContext *paint_context)
{
ShellGLSLEffect *self = SHELL_GLSL_EFFECT (effect);
ClutterOffscreenEffect *offscreen_effect = CLUTTER_OFFSCREEN_EFFECT (effect);
@ -51,7 +52,7 @@ shell_glsl_effect_pre_paint (ClutterEffect *effect)
}
parent_class = CLUTTER_EFFECT_CLASS (shell_glsl_effect_parent_class);
success = parent_class->pre_paint (effect);
success = parent_class->pre_paint (effect, paint_context);
if (!success)
return FALSE;
@ -66,7 +67,8 @@ shell_glsl_effect_pre_paint (ClutterEffect *effect)
}
static void
shell_glsl_effect_paint_target (ClutterOffscreenEffect *effect)
shell_glsl_effect_paint_target (ClutterOffscreenEffect *effect,
ClutterPaintContext *paint_context)
{
ShellGLSLEffect *self = SHELL_GLSL_EFFECT (effect);
ShellGLSLEffectPrivate *priv;

View File

@ -76,7 +76,8 @@ G_DEFINE_TYPE (ShellInvertLightnessEffect,
CLUTTER_TYPE_OFFSCREEN_EFFECT);
static gboolean
shell_invert_lightness_effect_pre_paint (ClutterEffect *effect)
shell_invert_lightness_effect_pre_paint (ClutterEffect *effect,
ClutterPaintContext *paint_context)
{
ShellInvertLightnessEffect *self = SHELL_INVERT_LIGHTNESS_EFFECT (effect);
ClutterEffectClass *parent_class;
@ -98,7 +99,7 @@ shell_invert_lightness_effect_pre_paint (ClutterEffect *effect)
parent_class =
CLUTTER_EFFECT_CLASS (shell_invert_lightness_effect_parent_class);
if (parent_class->pre_paint (effect))
if (parent_class->pre_paint (effect, paint_context))
{
ClutterOffscreenEffect *offscreen_effect =
CLUTTER_OFFSCREEN_EFFECT (effect);
@ -117,7 +118,8 @@ shell_invert_lightness_effect_pre_paint (ClutterEffect *effect)
}
static void
shell_invert_lightness_effect_paint_target (ClutterOffscreenEffect *effect)
shell_invert_lightness_effect_paint_target (ClutterOffscreenEffect *effect,
ClutterPaintContext *paint_context)
{
ShellInvertLightnessEffect *self = SHELL_INVERT_LIGHTNESS_EFFECT (effect);
ClutterActor *actor;

View File

@ -477,6 +477,7 @@ recorder_record_frame (ShellRecorder *recorder,
*/
static void
recorder_on_stage_paint (ClutterActor *actor,
ClutterPaintContext *paint_context,
ShellRecorder *recorder)
{
if (recorder->state == RECORDER_STATE_RECORDING)

View File

@ -45,6 +45,10 @@ typedef enum
G_DEFINE_TYPE_WITH_PRIVATE (ShellScreenshot, shell_screenshot, G_TYPE_OBJECT);
static void
grab_screenshot (ClutterActor *stage,
GTask *result);
static void
shell_screenshot_class_init (ShellScreenshotClass *screenshot_class)
{
@ -263,6 +267,21 @@ draw_cursor_image (cairo_surface_t *surface,
g_free (data);
}
static void
on_paint (ClutterActor *actor,
ClutterPaintContext *paint_context,
GTask *result)
{
grab_screenshot (actor, result);
}
static void
on_actors_painted (ClutterActor *actor,
GTask *result)
{
grab_screenshot (actor, result);
}
static void
grab_screenshot (ClutterActor *stage,
GTask *result)
@ -325,7 +344,8 @@ grab_screenshot (ClutterActor *stage,
if (priv->include_cursor)
draw_cursor_image (priv->image, priv->screenshot_area);
g_signal_handlers_disconnect_by_func (stage, grab_screenshot, result);
g_signal_handlers_disconnect_by_func (stage, on_paint, result);
g_signal_handlers_disconnect_by_func (stage, on_actors_painted, result);
task = g_task_new (screenshot, NULL, on_screenshot_written, result);
g_task_run_in_thread (task, write_screenshot_thread);
@ -460,7 +480,7 @@ shell_screenshot_screenshot (ShellScreenshot *screenshot,
{
ClutterActor *stage;
ShellScreenshotPrivate *priv = screenshot->priv;
const char *paint_signal;
gboolean use_paint_signal = FALSE;
GTask *result;
if (priv->stream != NULL) {
@ -483,7 +503,6 @@ shell_screenshot_screenshot (ShellScreenshot *screenshot,
priv->include_cursor = FALSE;
stage = CLUTTER_ACTOR (shell_global_get_stage (priv->global));
paint_signal = "actors-painted";
meta_disable_unredirect_for_display (shell_global_get_display (priv->global));
@ -492,10 +511,21 @@ shell_screenshot_screenshot (ShellScreenshot *screenshot,
if (should_draw_cursor_image (SHELL_SCREENSHOT_SCREEN))
priv->include_cursor = TRUE;
else
paint_signal = "paint";
use_paint_signal = TRUE;
}
g_signal_connect_after (stage, paint_signal, G_CALLBACK (grab_screenshot), result);
if (use_paint_signal)
{
g_signal_connect_after (stage, "paint",
G_CALLBACK (on_paint),
result);
}
else
{
g_signal_connect_after (stage, "actors-painted",
G_CALLBACK (on_actors_painted),
result);
}
clutter_actor_queue_redraw (stage);
}

View File

@ -387,7 +387,8 @@ get_border_paint_offsets (StBoxLayout *self,
static void
st_box_layout_paint (ClutterActor *actor)
st_box_layout_paint (ClutterActor *actor,
ClutterPaintContext *paint_context)
{
StBoxLayout *self = ST_BOX_LAYOUT (actor);
StBoxLayoutPrivate *priv = self->priv;
@ -405,7 +406,7 @@ st_box_layout_paint (ClutterActor *actor)
cogl_framebuffer_translate (fb, (int)x, (int)y, 0);
}
st_widget_paint_background (ST_WIDGET (actor));
st_widget_paint_background (ST_WIDGET (actor), paint_context);
if (x != 0 || y != 0)
{
@ -436,14 +437,15 @@ st_box_layout_paint (ClutterActor *actor)
for (child = clutter_actor_get_first_child (actor);
child != NULL;
child = clutter_actor_get_next_sibling (child))
clutter_actor_paint (child);
clutter_actor_paint (child, paint_context);
if (priv->hadjustment || priv->vadjustment)
cogl_framebuffer_pop_clip (fb);
}
static void
st_box_layout_pick (ClutterActor *actor)
st_box_layout_pick (ClutterActor *actor,
ClutterPickContext *pick_context)
{
StBoxLayout *self = ST_BOX_LAYOUT (actor);
StBoxLayoutPrivate *priv = self->priv;
@ -461,7 +463,7 @@ st_box_layout_pick (ClutterActor *actor)
cogl_framebuffer_translate (fb, (int)x, (int)y, 0);
}
CLUTTER_ACTOR_CLASS (st_box_layout_parent_class)->pick (actor);
CLUTTER_ACTOR_CLASS (st_box_layout_parent_class)->pick (actor, pick_context);
if (x != 0 || y != 0)
{
@ -489,7 +491,7 @@ st_box_layout_pick (ClutterActor *actor)
for (child = clutter_actor_get_first_child (actor);
child != NULL;
child = clutter_actor_get_next_sibling (child))
clutter_actor_pick (child);
clutter_actor_pick (child, pick_context);
if (priv->hadjustment || priv->vadjustment)
cogl_framebuffer_pop_clip (fb);

View File

@ -842,14 +842,15 @@ st_entry_leave_event (ClutterActor *actor,
}
static void
st_entry_paint (ClutterActor *actor)
st_entry_paint (ClutterActor *actor,
ClutterPaintContext *paint_context)
{
StEntryPrivate *priv = ST_ENTRY_PRIV (actor);
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
StShadow *shadow_spec = st_theme_node_get_text_shadow (theme_node);
ClutterActorClass *parent_class;
st_widget_paint_background (ST_WIDGET (actor));
st_widget_paint_background (ST_WIDGET (actor), paint_context);
if (shadow_spec)
{
@ -888,7 +889,7 @@ st_entry_paint (ClutterActor *actor)
* This is needed as we still want to paint children.
*/
parent_class = g_type_class_peek_parent (st_entry_parent_class);
parent_class->paint (actor);
parent_class->paint (actor, paint_context);
}
static void

View File

@ -163,12 +163,13 @@ st_icon_dispose (GObject *gobject)
}
static void
st_icon_paint (ClutterActor *actor)
st_icon_paint (ClutterActor *actor,
ClutterPaintContext *paint_context)
{
StIcon *icon = ST_ICON (actor);
StIconPrivate *priv = icon->priv;
st_widget_paint_background (ST_WIDGET (actor));
st_widget_paint_background (ST_WIDGET (actor), paint_context);
if (priv->icon_texture)
{
@ -186,7 +187,7 @@ st_icon_paint (ClutterActor *actor)
clutter_actor_get_paint_opacity (priv->icon_texture));
}
clutter_actor_paint (priv->icon_texture);
clutter_actor_paint (priv->icon_texture, paint_context);
}
}

View File

@ -191,13 +191,14 @@ st_label_dispose (GObject *object)
}
static void
st_label_paint (ClutterActor *actor)
st_label_paint (ClutterActor *actor,
ClutterPaintContext *paint_context)
{
StLabelPrivate *priv = ST_LABEL (actor)->priv;
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
StShadow *shadow_spec = st_theme_node_get_text_shadow (theme_node);
st_widget_paint_background (ST_WIDGET (actor));
st_widget_paint_background (ST_WIDGET (actor), paint_context);
if (shadow_spec)
{
@ -236,7 +237,7 @@ st_label_paint (ClutterActor *actor)
}
}
clutter_actor_paint (priv->label);
clutter_actor_paint (priv->label, paint_context);
}
static void

View File

@ -432,6 +432,7 @@ _st_create_shadow_pipeline_from_actor (StShadow *shadow_spec,
CoglPipeline *shadow_pipeline = NULL;
float resource_scale;
float width, height;
ClutterPaintContext *paint_context;
g_return_val_if_fail (clutter_actor_has_allocation (actor), NULL);
@ -501,13 +502,17 @@ _st_create_shadow_pipeline_from_actor (StShadow *shadow_spec,
cogl_framebuffer_scale (fb, resource_scale, resource_scale, 1);
clutter_actor_set_opacity_override (actor, 255);
clutter_actor_paint (actor);
clutter_actor_set_opacity_override (actor, -1);
paint_context = clutter_paint_context_new_for_framebuffer (fb);
clutter_actor_paint (actor, paint_context);
clutter_paint_context_destroy (paint_context);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
cogl_pop_framebuffer ();
G_GNUC_END_IGNORE_DEPRECATIONS;
clutter_actor_set_opacity_override (actor, -1);
cogl_object_unref (fb);
shadow_pipeline = _st_create_shadow_pipeline (shadow_spec, buffer,

View File

@ -85,7 +85,8 @@ st_scroll_view_fade_get_static_shader_source (ClutterShaderEffect *effect)
static void
st_scroll_view_fade_paint_target (ClutterOffscreenEffect *effect)
st_scroll_view_fade_paint_target (ClutterOffscreenEffect *effect,
ClutterPaintContext *paint_context)
{
StScrollViewFade *self = ST_SCROLL_VIEW_FADE (effect);
ClutterShaderEffect *shader = CLUTTER_SHADER_EFFECT (effect);
@ -153,7 +154,7 @@ st_scroll_view_fade_paint_target (ClutterOffscreenEffect *effect)
clutter_shader_effect_set_uniform (shader, "fade_area_bottomright", CLUTTER_TYPE_SHADER_FLOAT, 2, fade_area_bottomright);
parent = CLUTTER_OFFSCREEN_EFFECT_CLASS (st_scroll_view_fade_parent_class);
parent->paint_target(effect);
parent->paint_target (effect, paint_context);
}
static void

View File

@ -276,34 +276,36 @@ st_scroll_view_dispose (GObject *object)
}
static void
st_scroll_view_paint (ClutterActor *actor)
st_scroll_view_paint (ClutterActor *actor,
ClutterPaintContext *paint_context)
{
StScrollViewPrivate *priv = ST_SCROLL_VIEW (actor)->priv;
st_widget_paint_background (ST_WIDGET (actor));
st_widget_paint_background (ST_WIDGET (actor), paint_context);
if (priv->child)
clutter_actor_paint (priv->child);
clutter_actor_paint (priv->child, paint_context);
if (priv->hscrollbar_visible)
clutter_actor_paint (priv->hscroll);
clutter_actor_paint (priv->hscroll, paint_context);
if (priv->vscrollbar_visible)
clutter_actor_paint (priv->vscroll);
clutter_actor_paint (priv->vscroll, paint_context);
}
static void
st_scroll_view_pick (ClutterActor *actor)
st_scroll_view_pick (ClutterActor *actor,
ClutterPickContext *pick_context)
{
StScrollViewPrivate *priv = ST_SCROLL_VIEW (actor)->priv;
/* Chain up so we get a bounding box pained (if we are reactive) */
CLUTTER_ACTOR_CLASS (st_scroll_view_parent_class)->pick (actor);
CLUTTER_ACTOR_CLASS (st_scroll_view_parent_class)->pick (actor, pick_context);
if (priv->child)
clutter_actor_pick (priv->child);
clutter_actor_pick (priv->child, pick_context);
if (priv->hscrollbar_visible)
clutter_actor_pick (priv->hscroll);
clutter_actor_pick (priv->hscroll, pick_context);
if (priv->vscrollbar_visible)
clutter_actor_pick (priv->vscroll);
clutter_actor_pick (priv->vscroll, pick_context);
}
static gboolean

View File

@ -403,7 +403,8 @@ st_widget_allocate (ClutterActor *actor,
* painting children.
*/
void
st_widget_paint_background (StWidget *widget)
st_widget_paint_background (StWidget *widget,
ClutterPaintContext *paint_context)
{
StWidgetPrivate *priv = st_widget_get_instance_private (widget);
CoglFramebuffer *framebuffer;
@ -438,12 +439,13 @@ st_widget_paint_background (StWidget *widget)
}
static void
st_widget_paint (ClutterActor *actor)
st_widget_paint (ClutterActor *actor,
ClutterPaintContext *paint_context)
{
st_widget_paint_background (ST_WIDGET (actor));
st_widget_paint_background (ST_WIDGET (actor), paint_context);
/* Chain up so we paint children. */
CLUTTER_ACTOR_CLASS (st_widget_parent_class)->paint (actor);
CLUTTER_ACTOR_CLASS (st_widget_parent_class)->paint (actor, paint_context);
}
static void

View File

@ -133,7 +133,8 @@ StThemeNode * st_widget_get_theme_node (StWidget *widg
StThemeNode * st_widget_peek_theme_node (StWidget *widget);
GList * st_widget_get_focus_chain (StWidget *widget);
void st_widget_paint_background (StWidget *widget);
void st_widget_paint_background (StWidget *widget,
ClutterPaintContext *paint_context);
gboolean st_widget_get_resource_scale (StWidget *widget,
float *resource_scale);