From 1b33a5a3a78dd34e76442316d82e402bfb5a7aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Mon, 20 Apr 2020 21:10:23 +0200 Subject: [PATCH] clutter/paint-context: Add paint flag A paint flag affects a paint operation in ways defined by the flags. Currently no flags are defined, so no semantical changes are defined yet. Eventually a flag aiming to avoid painting of cursors is going to be added, so that screen cast streams can decide whether to include a cursor or not. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1207 --- .../clutter/clutter-paint-context-private.h | 3 ++- clutter/clutter/clutter-paint-context.c | 19 +++++++++++++++++-- clutter/clutter/clutter-paint-context.h | 11 ++++++++++- clutter/clutter/clutter-stage.c | 3 ++- src/compositor/meta-shaped-texture.c | 3 ++- src/compositor/meta-window-actor.c | 8 ++++++-- 6 files changed, 39 insertions(+), 8 deletions(-) diff --git a/clutter/clutter/clutter-paint-context-private.h b/clutter/clutter/clutter-paint-context-private.h index a825c8ffd..1e6f3fa00 100644 --- a/clutter/clutter/clutter-paint-context-private.h +++ b/clutter/clutter/clutter-paint-context-private.h @@ -21,7 +21,8 @@ #include "clutter-paint-context.h" ClutterPaintContext * clutter_paint_context_new_for_view (ClutterStageView *view, - const cairo_region_t *redraw_clip); + const cairo_region_t *redraw_clip, + ClutterPaintFlag paint_flags); gboolean clutter_paint_context_is_drawing_off_stage (ClutterPaintContext *paint_context); diff --git a/clutter/clutter/clutter-paint-context.c b/clutter/clutter/clutter-paint-context.c index d0d334951..4d5639e88 100644 --- a/clutter/clutter/clutter-paint-context.c +++ b/clutter/clutter/clutter-paint-context.c @@ -23,6 +23,8 @@ struct _ClutterPaintContext { grefcount ref_count; + ClutterPaintFlag paint_flags; + GList *framebuffers; ClutterStageView *view; @@ -36,7 +38,8 @@ G_DEFINE_BOXED_TYPE (ClutterPaintContext, clutter_paint_context, ClutterPaintContext * clutter_paint_context_new_for_view (ClutterStageView *view, - const cairo_region_t *redraw_clip) + const cairo_region_t *redraw_clip, + ClutterPaintFlag paint_flags) { ClutterPaintContext *paint_context; CoglFramebuffer *framebuffer; @@ -45,6 +48,7 @@ clutter_paint_context_new_for_view (ClutterStageView *view, g_ref_count_init (&paint_context->ref_count); paint_context->view = view; paint_context->redraw_clip = cairo_region_copy (redraw_clip); + paint_context->paint_flags = paint_flags; framebuffer = clutter_stage_view_get_framebuffer (view); clutter_paint_context_push_framebuffer (paint_context, framebuffer); @@ -56,12 +60,14 @@ clutter_paint_context_new_for_view (ClutterStageView *view, * clutter_paint_context_new_for_framebuffer: (skip) */ ClutterPaintContext * -clutter_paint_context_new_for_framebuffer (CoglFramebuffer *framebuffer) +clutter_paint_context_new_for_framebuffer (CoglFramebuffer *framebuffer, + ClutterPaintFlag paint_flags) { ClutterPaintContext *paint_context; paint_context = g_new0 (ClutterPaintContext, 1); g_ref_count_init (&paint_context->ref_count); + paint_context->paint_flags = paint_flags; clutter_paint_context_push_framebuffer (paint_context, framebuffer); @@ -170,3 +176,12 @@ clutter_paint_context_is_drawing_off_stage (ClutterPaintContext *paint_context) return !paint_context->view; } + +/** + * clutter_paint_context_get_paint_flags: (skip) + */ +ClutterPaintFlag +clutter_paint_context_get_paint_flags (ClutterPaintContext *paint_context) +{ + return paint_context->paint_flags; +} diff --git a/clutter/clutter/clutter-paint-context.h b/clutter/clutter/clutter-paint-context.h index c54f95c03..6b0bb0859 100644 --- a/clutter/clutter/clutter-paint-context.h +++ b/clutter/clutter/clutter-paint-context.h @@ -29,13 +29,19 @@ typedef struct _ClutterPaintContext ClutterPaintContext; +typedef enum _ClutterPaintFlag +{ + CLUTTER_PAINT_FLAG_NONE = 0, +} ClutterPaintFlag; + #define CLUTTER_TYPE_PAINT_CONTEXT (clutter_paint_context_get_type ()) CLUTTER_EXPORT GType clutter_paint_context_get_type (void); CLUTTER_EXPORT -ClutterPaintContext * clutter_paint_context_new_for_framebuffer (CoglFramebuffer *framebuffer); +ClutterPaintContext * clutter_paint_context_new_for_framebuffer (CoglFramebuffer *framebuffer, + ClutterPaintFlag paint_flags); CLUTTER_EXPORT ClutterPaintContext * clutter_paint_context_ref (ClutterPaintContext *paint_context); @@ -62,4 +68,7 @@ void clutter_paint_context_pop_framebuffer (ClutterPaintContext *paint_context); CLUTTER_EXPORT const cairo_region_t * clutter_paint_context_get_redraw_clip (ClutterPaintContext *paint_context); +CLUTTER_EXPORT +ClutterPaintFlag clutter_paint_context_get_paint_flags (ClutterPaintContext *paint_context); + #endif /* CLUTTER_PAINT_CONTEXT_H */ diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index e1e3e6e77..a7afaf802 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -924,7 +924,8 @@ clutter_stage_do_paint_view (ClutterStage *stage, ClutterPaintContext *paint_context; cairo_rectangle_int_t clip_rect; - paint_context = clutter_paint_context_new_for_view (view, redraw_clip); + paint_context = clutter_paint_context_new_for_view (view, redraw_clip, + CLUTTER_PAINT_FLAG_NONE); cairo_region_get_extents (redraw_clip, &clip_rect); setup_view_for_pick_or_paint (stage, view, &clip_rect); diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c index 79bb61c8f..e0c31e866 100644 --- a/src/compositor/meta-shaped-texture.c +++ b/src/compositor/meta-shaped-texture.c @@ -1270,7 +1270,8 @@ get_image_via_offscreen (MetaShapedTexture *stex, root_node = clutter_root_node_new (fb, &clear_color, COGL_BUFFER_BIT_COLOR); clutter_paint_node_set_static_name (root_node, "MetaShapedTexture.offscreen"); - paint_context = clutter_paint_context_new_for_framebuffer (fb); + paint_context = + clutter_paint_context_new_for_framebuffer (fb, CLUTTER_PAINT_FLAG_NONE); do_paint_content (stex, root_node, paint_context, stex->texture, diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c index 31e0cb607..cd47e5244 100644 --- a/src/compositor/meta-window-actor.c +++ b/src/compositor/meta-window-actor.c @@ -1321,7 +1321,9 @@ meta_window_actor_blit_to_framebuffer (MetaScreenCastWindow *screen_cast_window, cogl_framebuffer_scale (framebuffer, resource_scale, resource_scale, 1); cogl_framebuffer_translate (framebuffer, -x, -y, 0); - paint_context = clutter_paint_context_new_for_framebuffer (framebuffer); + paint_context = + clutter_paint_context_new_for_framebuffer (framebuffer, + CLUTTER_PAINT_FLAG_NONE); clutter_actor_paint (actor, paint_context); clutter_paint_context_destroy (paint_context); @@ -1479,7 +1481,9 @@ meta_window_actor_get_image (MetaWindowActor *self, cogl_framebuffer_scale (framebuffer, resource_scale, resource_scale, 1); cogl_framebuffer_translate (framebuffer, -x, -y, 0); - paint_context = clutter_paint_context_new_for_framebuffer (framebuffer); + paint_context = + clutter_paint_context_new_for_framebuffer (framebuffer, + CLUTTER_PAINT_FLAG_NONE); clutter_actor_paint (actor, paint_context); clutter_paint_context_destroy (paint_context);