clutter/stage-view: Give a stage view a refresh rate

Currently unused, but it's intention is to use as a initial refresh rate
for a with the stage view associated frame clock. It defaults to 60 Hz
if nothing sets it, but the native backend sets it to the associated
CRTCs current mode's refresh rate.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
This commit is contained in:
Jonas Ådahl 2020-04-17 09:18:37 +02:00
parent 2b95ec40c6
commit bb73038a27
3 changed files with 24 additions and 0 deletions

View File

@ -39,6 +39,7 @@ enum
PROP_OFFSCREEN, PROP_OFFSCREEN,
PROP_USE_SHADOWFB, PROP_USE_SHADOWFB,
PROP_SCALE, PROP_SCALE,
PROP_REFRESH_RATE,
PROP_LAST PROP_LAST
}; };
@ -74,6 +75,8 @@ typedef struct _ClutterStageViewPrivate
gboolean has_redraw_clip; gboolean has_redraw_clip;
cairo_region_t *redraw_clip; cairo_region_t *redraw_clip;
float refresh_rate;
guint dirty_viewport : 1; guint dirty_viewport : 1;
guint dirty_projection : 1; guint dirty_projection : 1;
} ClutterStageViewPrivate; } ClutterStageViewPrivate;
@ -1053,6 +1056,9 @@ clutter_stage_view_get_property (GObject *object,
case PROP_SCALE: case PROP_SCALE:
g_value_set_float (value, priv->scale); g_value_set_float (value, priv->scale);
break; break;
case PROP_REFRESH_RATE:
g_value_set_float (value, priv->refresh_rate);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
} }
@ -1093,6 +1099,9 @@ clutter_stage_view_set_property (GObject *object,
case PROP_SCALE: case PROP_SCALE:
priv->scale = g_value_get_float (value); priv->scale = g_value_get_float (value);
break; break;
case PROP_REFRESH_RATE:
priv->refresh_rate = g_value_get_float (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
} }
@ -1147,6 +1156,7 @@ clutter_stage_view_init (ClutterStageView *view)
priv->dirty_viewport = TRUE; priv->dirty_viewport = TRUE;
priv->dirty_projection = TRUE; priv->dirty_projection = TRUE;
priv->scale = 1.0; priv->scale = 1.0;
priv->refresh_rate = 60.0;
} }
static void static void
@ -1225,5 +1235,14 @@ clutter_stage_view_class_init (ClutterStageViewClass *klass)
G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS); G_PARAM_STATIC_STRINGS);
obj_props[PROP_REFRESH_RATE] =
g_param_spec_float ("refresh-rate",
"Refresh rate",
"Update refresh rate",
1.0, G_MAXFLOAT, 60.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, PROP_LAST, obj_props); g_object_class_install_properties (object_class, PROP_LAST, obj_props);
} }

View File

@ -3255,6 +3255,7 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
"offscreen", offscreen, "offscreen", offscreen,
"use-shadowfb", use_shadowfb, "use-shadowfb", use_shadowfb,
"transform", view_transform, "transform", view_transform,
"refresh-rate", crtc_mode_info->refresh_rate,
NULL); NULL);
g_clear_pointer (&offscreen, cogl_object_unref); g_clear_pointer (&offscreen, cogl_object_unref);

View File

@ -191,6 +191,7 @@ meta_renderer_x11_nested_create_view (MetaRenderer *renderer,
CoglOffscreen *fake_onscreen; CoglOffscreen *fake_onscreen;
CoglOffscreen *offscreen; CoglOffscreen *offscreen;
MetaRectangle view_layout; MetaRectangle view_layout;
const MetaCrtcModeInfo *mode_info;
MetaRendererView *view; MetaRendererView *view;
view_transform = calculate_view_transform (monitor_manager, logical_monitor); view_transform = calculate_view_transform (monitor_manager, logical_monitor);
@ -215,11 +216,14 @@ meta_renderer_x11_nested_create_view (MetaRenderer *renderer,
META_ROUNDING_STRATEGY_ROUND, META_ROUNDING_STRATEGY_ROUND,
&view_layout); &view_layout);
mode_info = meta_crtc_mode_get_info (crtc_config->mode);
view = g_object_new (META_TYPE_RENDERER_VIEW, view = g_object_new (META_TYPE_RENDERER_VIEW,
"name", meta_output_get_name (output), "name", meta_output_get_name (output),
"stage", meta_backend_get_stage (backend), "stage", meta_backend_get_stage (backend),
"layout", &view_layout, "layout", &view_layout,
"crtc", crtc, "crtc", crtc,
"refresh-rate", mode_info->refresh_rate,
"framebuffer", COGL_FRAMEBUFFER (fake_onscreen), "framebuffer", COGL_FRAMEBUFFER (fake_onscreen),
"offscreen", COGL_FRAMEBUFFER (offscreen), "offscreen", COGL_FRAMEBUFFER (offscreen),
"transform", view_transform, "transform", view_transform,