[gnome-shell] Adapt to painting and picking API change
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] Adapt to painting and picking API change
- Date: Tue, 3 Dec 2019 19:13:03 +0000 (UTC)
commit 988a0e7314018d490527f1b786d2bba43e48c35a
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Fri Nov 22 18:35:55 2019 +0100
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
js/ui/lookingGlass.js | 4 ++--
js/ui/userWidget.js | 4 ++--
src/shell-glsl-effect.c | 8 +++++---
src/shell-invert-lightness-effect.c | 8 +++++---
src/shell-recorder.c | 5 +++--
src/shell-screenshot.c | 40 ++++++++++++++++++++++++++++++++-----
src/st/st-box-layout.c | 14 +++++++------
src/st/st-entry.c | 7 ++++---
src/st/st-icon.c | 7 ++++---
src/st/st-label.c | 7 ++++---
src/st/st-private.c | 9 +++++++--
src/st/st-scroll-view-fade.c | 5 +++--
src/st/st-scroll-view.c | 22 ++++++++++----------
src/st/st-widget.c | 10 ++++++----
src/st/st-widget.h | 3 ++-
15 files changed, 102 insertions(+), 51 deletions(-)
---
diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js
index 30aa8c2fa2..19a9396d43 100644
--- a/js/ui/lookingGlass.js
+++ b/js/ui/lookingGlass.js
@@ -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);
diff --git a/js/ui/userWidget.js b/js/ui/userWidget.js
index 115f4db6b1..03d4d6388f 100644
--- a/js/ui/userWidget.js
+++ b/js/ui/userWidget.js
@@ -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() {
diff --git a/src/shell-glsl-effect.c b/src/shell-glsl-effect.c
index 1ffe9d0d91..6347dbf9c6 100644
--- a/src/shell-glsl-effect.c
+++ b/src/shell-glsl-effect.c
@@ -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;
diff --git a/src/shell-invert-lightness-effect.c b/src/shell-invert-lightness-effect.c
index b7618dec38..282725b225 100644
--- a/src/shell-invert-lightness-effect.c
+++ b/src/shell-invert-lightness-effect.c
@@ -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;
diff --git a/src/shell-recorder.c b/src/shell-recorder.c
index 43600ebbd0..1a318175e6 100644
--- a/src/shell-recorder.c
+++ b/src/shell-recorder.c
@@ -476,8 +476,9 @@ recorder_record_frame (ShellRecorder *recorder,
* by clutter before glSwapBuffers() makes it visible to the user.
*/
static void
-recorder_on_stage_paint (ClutterActor *actor,
- ShellRecorder *recorder)
+recorder_on_stage_paint (ClutterActor *actor,
+ ClutterPaintContext *paint_context,
+ ShellRecorder *recorder)
{
if (recorder->state == RECORDER_STATE_RECORDING)
recorder_record_frame (recorder, FALSE);
diff --git a/src/shell-screenshot.c b/src/shell-screenshot.c
index 4af51c698d..de95b8a729 100644
--- a/src/shell-screenshot.c
+++ b/src/shell-screenshot.c
@@ -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);
}
diff --git a/src/st/st-box-layout.c b/src/st/st-box-layout.c
index 0f02a478be..66b17b185b 100644
--- a/src/st/st-box-layout.c
+++ b/src/st/st-box-layout.c
@@ -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);
diff --git a/src/st/st-entry.c b/src/st/st-entry.c
index eb8609887b..9c45fbd654 100644
--- a/src/st/st-entry.c
+++ b/src/st/st-entry.c
@@ -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
diff --git a/src/st/st-icon.c b/src/st/st-icon.c
index 4ef2876201..fc6aa51238 100644
--- a/src/st/st-icon.c
+++ b/src/st/st-icon.c
@@ -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);
}
}
diff --git a/src/st/st-label.c b/src/st/st-label.c
index 64127c964b..42816ffdf2 100644
--- a/src/st/st-label.c
+++ b/src/st/st-label.c
@@ -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
diff --git a/src/st/st-private.c b/src/st/st-private.c
index a9ca90644b..fd2cc39b1d 100644
--- a/src/st/st-private.c
+++ b/src/st/st-private.c
@@ -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,
diff --git a/src/st/st-scroll-view-fade.c b/src/st/st-scroll-view-fade.c
index e288e695a7..8d473d3adf 100644
--- a/src/st/st-scroll-view-fade.c
+++ b/src/st/st-scroll-view-fade.c
@@ -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
diff --git a/src/st/st-scroll-view.c b/src/st/st-scroll-view.c
index 79af3ca13a..04169b1a2f 100644
--- a/src/st/st-scroll-view.c
+++ b/src/st/st-scroll-view.c
@@ -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
diff --git a/src/st/st-widget.c b/src/st/st-widget.c
index 23787073da..dd11f8ad11 100644
--- a/src/st/st-widget.c
+++ b/src/st/st-widget.c
@@ -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
diff --git a/src/st/st-widget.h b/src/st/st-widget.h
index 9b6efd559d..82fd7d0b44 100644
--- a/src/st/st-widget.h
+++ b/src/st/st-widget.h
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]