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_USE_SHADOWFB,
PROP_SCALE,
PROP_REFRESH_RATE,
PROP_LAST
};
@ -74,6 +75,8 @@ typedef struct _ClutterStageViewPrivate
gboolean has_redraw_clip;
cairo_region_t *redraw_clip;
float refresh_rate;
guint dirty_viewport : 1;
guint dirty_projection : 1;
} ClutterStageViewPrivate;
@ -1053,6 +1056,9 @@ clutter_stage_view_get_property (GObject *object,
case PROP_SCALE:
g_value_set_float (value, priv->scale);
break;
case PROP_REFRESH_RATE:
g_value_set_float (value, priv->refresh_rate);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@ -1093,6 +1099,9 @@ clutter_stage_view_set_property (GObject *object,
case PROP_SCALE:
priv->scale = g_value_get_float (value);
break;
case PROP_REFRESH_RATE:
priv->refresh_rate = g_value_get_float (value);
break;
default:
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_projection = TRUE;
priv->scale = 1.0;
priv->refresh_rate = 60.0;
}
static void
@ -1225,5 +1235,14 @@ clutter_stage_view_class_init (ClutterStageViewClass *klass)
G_PARAM_CONSTRUCT |
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);
}

View File

@ -3255,6 +3255,7 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
"offscreen", offscreen,
"use-shadowfb", use_shadowfb,
"transform", view_transform,
"refresh-rate", crtc_mode_info->refresh_rate,
NULL);
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 *offscreen;
MetaRectangle view_layout;
const MetaCrtcModeInfo *mode_info;
MetaRendererView *view;
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,
&view_layout);
mode_info = meta_crtc_mode_get_info (crtc_config->mode);
view = g_object_new (META_TYPE_RENDERER_VIEW,
"name", meta_output_get_name (output),
"stage", meta_backend_get_stage (backend),
"layout", &view_layout,
"crtc", crtc,
"refresh-rate", mode_info->refresh_rate,
"framebuffer", COGL_FRAMEBUFFER (fake_onscreen),
"offscreen", COGL_FRAMEBUFFER (offscreen),
"transform", view_transform,