renderer-native: Move 'backend' field to MetaRenderer

So that it can be used by the generic MetaRenderer class, as well as
other sub types, as well.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/838
This commit is contained in:
Jonas Ådahl 2019-10-01 11:51:53 +02:00
parent 8c1e6ebde0
commit 704fea6323
5 changed files with 109 additions and 85 deletions

View File

@ -48,13 +48,33 @@
#include "backends/meta-backend-private.h"
enum
{
PROP_0,
PROP_BACKEND,
N_PROPS
};
static GParamSpec *obj_props[N_PROPS];
typedef struct _MetaRendererPrivate
{
MetaBackend *backend;
GList *views;
} MetaRendererPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (MetaRenderer, meta_renderer, G_TYPE_OBJECT)
MetaBackend *
meta_renderer_get_backend (MetaRenderer *renderer)
{
MetaRendererPrivate *priv = meta_renderer_get_instance_private (renderer);
return priv->backend;
}
/**
* meta_renderer_create_cogl_renderer:
* @renderer: a #MetaRenderer object
@ -166,6 +186,46 @@ meta_renderer_get_view_from_logical_monitor (MetaRenderer *renderer,
return NULL;
}
static void
meta_renderer_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
MetaRenderer *renderer = META_RENDERER (object);
MetaRendererPrivate *priv = meta_renderer_get_instance_private (renderer);
switch (prop_id)
{
case PROP_BACKEND:
g_value_set_object (value, priv->backend);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
meta_renderer_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
MetaRenderer *renderer = META_RENDERER (object);
MetaRendererPrivate *priv = meta_renderer_get_instance_private (renderer);
switch (prop_id)
{
case PROP_BACKEND:
priv->backend = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
meta_renderer_finalize (GObject *object)
{
@ -188,7 +248,19 @@ meta_renderer_class_init (MetaRendererClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = meta_renderer_get_property;
object_class->set_property = meta_renderer_set_property;
object_class->finalize = meta_renderer_finalize;
klass->rebuild_views = meta_renderer_real_rebuild_views;
obj_props[PROP_BACKEND] =
g_param_spec_object ("backend",
"backend",
"MetaBackend",
META_TYPE_BACKEND,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, obj_props);
}

View File

@ -46,6 +46,8 @@ struct _MetaRendererClass
void (* rebuild_views) (MetaRenderer *renderer);
};
MetaBackend * meta_renderer_get_backend (MetaRenderer *renderer);
CoglRenderer * meta_renderer_create_cogl_renderer (MetaRenderer *renderer);
void meta_renderer_rebuild_views (MetaRenderer *renderer);

View File

@ -83,17 +83,6 @@
#define DRM_FORMAT_INVALID 0
#endif
enum
{
PROP_0,
PROP_BACKEND,
PROP_LAST
};
static GParamSpec *obj_props[PROP_LAST];
typedef enum _MetaSharedFramebufferCopyMode
{
/* Zero-copy: primary GPU exports, secondary GPU imports as KMS FB */
@ -227,7 +216,6 @@ struct _MetaRendererNative
MetaGpuKms *primary_gpu_kms;
MetaBackend *backend;
MetaGles3 *gles3;
gboolean use_modifiers;
@ -353,7 +341,9 @@ get_secondary_gpu_state (CoglOnscreen *onscreen,
static MetaEgl *
meta_renderer_native_get_egl (MetaRendererNative *renderer_native)
{
return meta_backend_get_egl (renderer_native->backend);
MetaRenderer *renderer = META_RENDERER (renderer_native);
return meta_backend_get_egl (meta_renderer_get_backend (renderer));
}
static MetaEgl *
@ -1707,8 +1697,9 @@ meta_onscreen_native_flip_crtcs (CoglOnscreen *onscreen,
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
MetaRendererView *view = onscreen_native->view;
MetaRendererNative *renderer_native = onscreen_native->renderer_native;
MetaRenderer *renderer = META_RENDERER (renderer_native);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (renderer_native->backend);
meta_backend_get_monitor_manager (meta_renderer_get_backend (renderer));
MetaPowerSave power_save_mode;
MetaLogicalMonitor *logical_monitor;
@ -2266,7 +2257,8 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
CoglRendererEGL *cogl_renderer_egl = cogl_renderer->winsys;
MetaRendererNativeGpuData *renderer_gpu_data = cogl_renderer_egl->platform;
MetaRendererNative *renderer_native = renderer_gpu_data->renderer_native;
MetaBackend *backend = renderer_native->backend;
MetaRenderer *renderer = META_RENDERER (renderer_native);
MetaBackend *backend = meta_renderer_get_backend (renderer);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
@ -3002,9 +2994,11 @@ _cogl_winsys_egl_vtable = {
gboolean
meta_renderer_native_supports_mirroring (MetaRendererNative *renderer_native)
{
MetaRenderer *renderer = META_RENDERER (renderer_native);
MetaBackend *backend = meta_renderer_get_backend (renderer);
GList *l;
for (l = meta_backend_get_gpus (renderer_native->backend); l; l = l->next)
for (l = meta_backend_get_gpus (backend); l; l = l->next)
{
MetaGpuKms *gpu_kms = META_GPU_KMS (l->data);
MetaRendererNativeGpuData *renderer_gpu_data;
@ -3252,7 +3246,8 @@ calculate_view_transform (MetaMonitorManager *monitor_manager,
static CoglContext *
cogl_context_from_renderer_native (MetaRendererNative *renderer_native)
{
MetaBackend *backend = renderer_native->backend;
MetaRenderer *renderer = META_RENDERER (renderer_native);
MetaBackend *backend = meta_renderer_get_backend (renderer);
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
return clutter_backend_get_cogl_context (clutter_backend);
@ -3306,7 +3301,7 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
MetaLogicalMonitor *logical_monitor)
{
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer);
MetaBackend *backend = renderer_native->backend;
MetaBackend *backend = meta_renderer_get_backend (renderer);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
CoglContext *cogl_context =
@ -3414,9 +3409,8 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
static void
meta_renderer_native_rebuild_views (MetaRenderer *renderer)
{
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer);
MetaBackendNative *backend_native =
META_BACKEND_NATIVE (renderer_native->backend);
MetaBackend *backend = meta_renderer_get_backend (renderer);
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
MetaKms *kms = meta_backend_native_get_kms (backend_native);
MetaRendererClass *parent_renderer_class =
META_RENDERER_CLASS (meta_renderer_native_parent_class);
@ -3431,7 +3425,8 @@ meta_renderer_native_rebuild_views (MetaRenderer *renderer)
void
meta_renderer_native_finish_frame (MetaRendererNative *renderer_native)
{
MetaBackend *backend = renderer_native->backend;
MetaRenderer *renderer = META_RENDERER (renderer_native);
MetaBackend *backend = meta_renderer_get_backend (renderer);
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
MetaKms *kms = meta_backend_native_get_kms (backend_native);
MetaKmsUpdate *kms_update = NULL;
@ -3442,7 +3437,7 @@ meta_renderer_native_finish_frame (MetaRendererNative *renderer_native)
{
GList *l;
for (l = meta_backend_get_gpus (renderer_native->backend); l; l = l->next)
for (l = meta_backend_get_gpus (backend); l; l = l->next)
{
MetaGpu *gpu = l->data;
GList *k;
@ -3483,49 +3478,6 @@ meta_renderer_native_get_frame_counter (MetaRendererNative *renderer_native)
return renderer_native->frame_counter;
}
static void
meta_renderer_native_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (object);
switch (prop_id)
{
case PROP_BACKEND:
g_value_set_object (value, renderer_native->backend);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
on_gpu_added (MetaBackendNative *backend_native,
MetaGpuKms *gpu_kms,
MetaRendererNative *renderer_native);
static void
meta_renderer_native_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (object);
switch (prop_id)
{
case PROP_BACKEND:
renderer_native->backend = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static gboolean
create_secondary_egl_config (MetaEgl *egl,
MetaRendererNativeMode mode,
@ -3912,7 +3864,10 @@ get_egl_device_display (MetaRendererNative *renderer_native,
static int
count_drm_devices (MetaRendererNative *renderer_native)
{
return g_list_length (meta_backend_get_gpus (renderer_native->backend));
MetaRenderer *renderer = META_RENDERER (renderer_native);
MetaBackend *backend = meta_renderer_get_backend (renderer);
return g_list_length (meta_backend_get_gpus (backend));
}
static MetaRendererNativeGpuData *
@ -4083,8 +4038,9 @@ static void
on_power_save_mode_changed (MetaMonitorManager *monitor_manager,
MetaRendererNative *renderer_native)
{
MetaBackendNative *backend_native =
META_BACKEND_NATIVE (renderer_native->backend);
MetaRenderer *renderer = META_RENDERER (renderer_native);
MetaBackend *backend = meta_renderer_get_backend (renderer);
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
MetaKms *kms = meta_backend_native_get_kms (backend_native);
MetaPowerSave power_save_mode;
@ -4174,7 +4130,8 @@ meta_renderer_native_initable_init (GInitable *initable,
GError **error)
{
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (initable);
MetaBackend *backend = renderer_native->backend;
MetaRenderer *renderer = META_RENDERER (renderer_native);
MetaBackend *backend = meta_renderer_get_backend (renderer);
GList *gpus;
GList *l;
@ -4225,7 +4182,8 @@ static void
meta_renderer_native_constructed (GObject *object)
{
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (object);
MetaBackend *backend = renderer_native->backend;
MetaRenderer *renderer = META_RENDERER (renderer_native);
MetaBackend *backend = meta_renderer_get_backend (renderer);
MetaSettings *settings = meta_backend_get_settings (backend);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
@ -4257,24 +4215,12 @@ meta_renderer_native_class_init (MetaRendererNativeClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
MetaRendererClass *renderer_class = META_RENDERER_CLASS (klass);
object_class->get_property = meta_renderer_native_get_property;
object_class->set_property = meta_renderer_native_set_property;
object_class->finalize = meta_renderer_native_finalize;
object_class->constructed = meta_renderer_native_constructed;
renderer_class->create_cogl_renderer = meta_renderer_native_create_cogl_renderer;
renderer_class->create_view = meta_renderer_native_create_view;
renderer_class->rebuild_views = meta_renderer_native_rebuild_views;
obj_props[PROP_BACKEND] =
g_param_spec_object ("backend",
"backend",
"MetaBackendNative",
META_TYPE_BACKEND_NATIVE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, PROP_LAST, obj_props);
}
MetaRendererNative *

View File

@ -100,7 +100,9 @@ static MetaRenderer *
meta_backend_x11_cm_create_renderer (MetaBackend *backend,
GError **error)
{
return g_object_new (META_TYPE_RENDERER_X11_CM, NULL);
return g_object_new (META_TYPE_RENDERER_X11_CM,
"backend", backend,
NULL);
}
static MetaMonitorManager *

View File

@ -40,7 +40,9 @@ static MetaRenderer *
meta_backend_x11_nested_create_renderer (MetaBackend *backend,
GError **error)
{
return g_object_new (META_TYPE_RENDERER_X11_NESTED, NULL);
return g_object_new (META_TYPE_RENDERER_X11_NESTED,
"backend", backend,
NULL);
}
static MetaMonitorManager *