Introduce MetaRenderer

MetaRenderer is meant to be the object responsible for rendering the
scene graph. It will contain the logic related to the cogl winsys
backend, the clutter backend, and the clutter stage window.

https://bugzilla.gnome.org/show_bug.cgi?id=768976
This commit is contained in:
Jonas Ådahl 2016-05-07 23:07:46 +08:00
parent 2facf26568
commit a54042e938
11 changed files with 296 additions and 0 deletions

View File

@ -104,6 +104,8 @@ libmutter_la_SOURCES = \
backends/meta-pointer-constraint.h \ backends/meta-pointer-constraint.h \
backends/meta-stage.h \ backends/meta-stage.h \
backends/meta-stage.c \ backends/meta-stage.c \
backends/meta-renderer.c \
backends/meta-renderer.h \
backends/edid-parse.c \ backends/edid-parse.c \
backends/edid.h \ backends/edid.h \
backends/x11/meta-backend-x11.c \ backends/x11/meta-backend-x11.c \
@ -122,6 +124,8 @@ libmutter_la_SOURCES = \
backends/x11/meta-input-settings-x11.h \ backends/x11/meta-input-settings-x11.h \
backends/x11/meta-monitor-manager-xrandr.c \ backends/x11/meta-monitor-manager-xrandr.c \
backends/x11/meta-monitor-manager-xrandr.h \ backends/x11/meta-monitor-manager-xrandr.h \
backends/x11/meta-renderer-x11.c \
backends/x11/meta-renderer-x11.h \
core/meta-accel-parse.c \ core/meta-accel-parse.c \
core/meta-accel-parse.h \ core/meta-accel-parse.h \
meta/barrier.h \ meta/barrier.h \
@ -344,6 +348,8 @@ libmutter_la_SOURCES += \
backends/native/meta-monitor-manager-kms.h \ backends/native/meta-monitor-manager-kms.h \
backends/native/meta-launcher.c \ backends/native/meta-launcher.c \
backends/native/meta-launcher.h \ backends/native/meta-launcher.h \
backends/native/meta-renderer-native.c \
backends/native/meta-renderer-native.h \
backends/native/dbus-utils.c \ backends/native/dbus-utils.c \
backends/native/dbus-utils.h \ backends/native/dbus-utils.h \
$(NULL) $(NULL)

View File

@ -35,6 +35,7 @@
#include "meta-cursor-renderer.h" #include "meta-cursor-renderer.h"
#include "meta-monitor-manager-private.h" #include "meta-monitor-manager-private.h"
#include "backends/meta-pointer-constraint.h" #include "backends/meta-pointer-constraint.h"
#include "backends/meta-renderer.h"
#include "core/util-private.h" #include "core/util-private.h"
#define DEFAULT_XKB_RULES_FILE "evdev" #define DEFAULT_XKB_RULES_FILE "evdev"
@ -69,6 +70,7 @@ struct _MetaBackendClass
int device_id); int device_id);
MetaMonitorManager * (* create_monitor_manager) (MetaBackend *backend); MetaMonitorManager * (* create_monitor_manager) (MetaBackend *backend);
MetaCursorRenderer * (* create_cursor_renderer) (MetaBackend *backend); MetaCursorRenderer * (* create_cursor_renderer) (MetaBackend *backend);
MetaRenderer * (* create_renderer) (MetaBackend *backend);
gboolean (* grab_device) (MetaBackend *backend, gboolean (* grab_device) (MetaBackend *backend,
int device_id, int device_id,
@ -108,6 +110,7 @@ MetaIdleMonitor * meta_backend_get_idle_monitor (MetaBackend *backend,
int device_id); int device_id);
MetaMonitorManager * meta_backend_get_monitor_manager (MetaBackend *backend); MetaMonitorManager * meta_backend_get_monitor_manager (MetaBackend *backend);
MetaCursorRenderer * meta_backend_get_cursor_renderer (MetaBackend *backend); MetaCursorRenderer * meta_backend_get_cursor_renderer (MetaBackend *backend);
MetaRenderer * meta_backend_get_renderer (MetaBackend *backend);
gboolean meta_backend_grab_device (MetaBackend *backend, gboolean meta_backend_grab_device (MetaBackend *backend,
int device_id, int device_id,

View File

@ -63,6 +63,7 @@ struct _MetaBackendPrivate
MetaMonitorManager *monitor_manager; MetaMonitorManager *monitor_manager;
MetaCursorRenderer *cursor_renderer; MetaCursorRenderer *cursor_renderer;
MetaInputSettings *input_settings; MetaInputSettings *input_settings;
MetaRenderer *renderer;
ClutterBackend *clutter_backend; ClutterBackend *clutter_backend;
ClutterActor *stage; ClutterActor *stage;
@ -371,11 +372,21 @@ meta_backend_real_get_relative_motion_deltas (MetaBackend *backend,
return FALSE; return FALSE;
} }
static void
meta_backend_constructed (GObject *object)
{
MetaBackend *backend = META_BACKEND (object);
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
priv->renderer = META_BACKEND_GET_CLASS (backend)->create_renderer (backend);
}
static void static void
meta_backend_class_init (MetaBackendClass *klass) meta_backend_class_init (MetaBackendClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = meta_backend_constructed;
object_class->finalize = meta_backend_finalize; object_class->finalize = meta_backend_finalize;
klass->post_init = meta_backend_real_post_init; klass->post_init = meta_backend_real_post_init;
@ -450,6 +461,16 @@ meta_backend_get_cursor_renderer (MetaBackend *backend)
return priv->cursor_renderer; return priv->cursor_renderer;
} }
/**
* meta_backend_get_renderer: (skip)
*/
MetaRenderer * meta_backend_get_renderer (MetaBackend *backend)
{
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
return priv->renderer;
}
/** /**
* meta_backend_grab_device: (skip) * meta_backend_grab_device: (skip)
*/ */

View File

@ -0,0 +1,41 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2016 Red Hat
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written by:
* Jonas Ådahl <jadahl@gmail.com>
*/
#include "config.h"
#include <glib-object.h>
#include "backends/meta-renderer.h"
G_DEFINE_TYPE (MetaRenderer, meta_renderer, G_TYPE_OBJECT)
static void
meta_renderer_init (MetaRenderer *renderer)
{
}
static void
meta_renderer_class_init (MetaRendererClass *klass)
{
}

View File

@ -0,0 +1,38 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2016 Red Hat
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written by:
* Jonas Ådahl <jadahl@gmail.com>
*/
#ifndef META_RENDERER_H
#define META_RENDERER_H
#include <glib-object.h>
#define META_TYPE_RENDERER (meta_renderer_get_type ())
G_DECLARE_DERIVABLE_TYPE (MetaRenderer, meta_renderer, META, RENDERER, GObject)
struct _MetaRendererClass
{
GObjectClass parent_class;
};
#endif /* META_RENDERER_H */

View File

@ -39,6 +39,7 @@
#include "backends/meta-cursor-tracker-private.h" #include "backends/meta-cursor-tracker-private.h"
#include "backends/meta-pointer-constraint.h" #include "backends/meta-pointer-constraint.h"
#include "backends/native/meta-clutter-backend-native.h" #include "backends/native/meta-clutter-backend-native.h"
#include "backends/native/meta-renderer-native.h"
#include <stdlib.h> #include <stdlib.h>
@ -280,6 +281,12 @@ meta_backend_native_create_cursor_renderer (MetaBackend *backend)
return g_object_new (META_TYPE_CURSOR_RENDERER_NATIVE, NULL); return g_object_new (META_TYPE_CURSOR_RENDERER_NATIVE, NULL);
} }
static MetaRenderer *
meta_backend_native_create_renderer (MetaBackend *backend)
{
return g_object_new (META_TYPE_RENDERER_NATIVE, NULL);
}
static void static void
meta_backend_native_warp_pointer (MetaBackend *backend, meta_backend_native_warp_pointer (MetaBackend *backend,
int x, int x,
@ -371,6 +378,7 @@ meta_backend_native_class_init (MetaBackendNativeClass *klass)
backend_class->create_idle_monitor = meta_backend_native_create_idle_monitor; backend_class->create_idle_monitor = meta_backend_native_create_idle_monitor;
backend_class->create_monitor_manager = meta_backend_native_create_monitor_manager; backend_class->create_monitor_manager = meta_backend_native_create_monitor_manager;
backend_class->create_cursor_renderer = meta_backend_native_create_cursor_renderer; backend_class->create_cursor_renderer = meta_backend_native_create_cursor_renderer;
backend_class->create_renderer = meta_backend_native_create_renderer;
backend_class->warp_pointer = meta_backend_native_warp_pointer; backend_class->warp_pointer = meta_backend_native_warp_pointer;
backend_class->set_keymap = meta_backend_native_set_keymap; backend_class->set_keymap = meta_backend_native_set_keymap;

View File

@ -0,0 +1,51 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2016 Red Hat
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Written by:
* Jonas Ådahl <jadahl@gmail.com>
*/
#include "config.h"
#include <glib-object.h>
#include "backends/native/meta-renderer-native.h"
struct _MetaRendererNative
{
MetaRenderer parent;
};
G_DEFINE_TYPE (MetaRendererNative, meta_renderer_native, META_TYPE_RENDERER)
static void
meta_renderer_native_init (MetaRendererNative *renderer_native)
{
}
static void
meta_renderer_native_class_init (MetaRendererNativeClass *klass)
{
}

View File

@ -0,0 +1,37 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2016 Red Hat
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written by:
* Jonas Ådahl <jadahl@gmail.com>
*/
#ifndef META_RENDERER_NATIVE_H
#define META_RENDERER_NATIVE_H
#include <glib-object.h>
#include "backends/meta-renderer.h"
#define META_TYPE_RENDERER_NATIVE (meta_renderer_native_get_type ())
G_DECLARE_FINAL_TYPE (MetaRendererNative, meta_renderer_native,
META, RENDERER_NATIVE,
MetaRenderer)
#endif /* META_RENDERER_NATIVE_H */

View File

@ -43,6 +43,7 @@
#include "backends/meta-monitor-manager-dummy.h" #include "backends/meta-monitor-manager-dummy.h"
#include "backends/x11/nested/meta-cursor-renderer-x11-nested.h" #include "backends/x11/nested/meta-cursor-renderer-x11-nested.h"
#include "backends/x11/meta-clutter-backend-x11.h" #include "backends/x11/meta-clutter-backend-x11.h"
#include "backends/x11/meta-renderer-x11.h"
#include "meta-cursor-renderer-x11.h" #include "meta-cursor-renderer-x11.h"
#ifdef HAVE_WAYLAND #ifdef HAVE_WAYLAND
#include "wayland/meta-wayland.h" #include "wayland/meta-wayland.h"
@ -552,6 +553,12 @@ meta_backend_x11_create_cursor_renderer (MetaBackend *backend)
} }
} }
static MetaRenderer *
meta_backend_x11_create_renderer (MetaBackend *backend)
{
return g_object_new (META_TYPE_RENDERER_X11, NULL);
}
static gboolean static gboolean
meta_backend_x11_grab_device (MetaBackend *backend, meta_backend_x11_grab_device (MetaBackend *backend,
int device_id, int device_id,
@ -878,6 +885,7 @@ meta_backend_x11_class_init (MetaBackendX11Class *klass)
backend_class->create_idle_monitor = meta_backend_x11_create_idle_monitor; backend_class->create_idle_monitor = meta_backend_x11_create_idle_monitor;
backend_class->create_monitor_manager = meta_backend_x11_create_monitor_manager; backend_class->create_monitor_manager = meta_backend_x11_create_monitor_manager;
backend_class->create_cursor_renderer = meta_backend_x11_create_cursor_renderer; backend_class->create_cursor_renderer = meta_backend_x11_create_cursor_renderer;
backend_class->create_renderer = meta_backend_x11_create_renderer;
backend_class->grab_device = meta_backend_x11_grab_device; backend_class->grab_device = meta_backend_x11_grab_device;
backend_class->ungrab_device = meta_backend_x11_ungrab_device; backend_class->ungrab_device = meta_backend_x11_ungrab_device;
backend_class->warp_pointer = meta_backend_x11_warp_pointer; backend_class->warp_pointer = meta_backend_x11_warp_pointer;

View File

@ -0,0 +1,46 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2016 Red Hat
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written by:
* Jonas Ådahl <jadahl@gmail.com>
*/
#include "config.h"
#include <glib-object.h>
#include "backends/x11/meta-renderer-x11.h"
struct _MetaRendererX11
{
MetaRenderer parent;
};
G_DEFINE_TYPE (MetaRendererX11, meta_renderer_x11, META_TYPE_RENDERER)
static void
meta_renderer_x11_init (MetaRendererX11 *renderer_x11)
{
}
static void
meta_renderer_x11_class_init (MetaRendererX11Class *klass)
{
}

View File

@ -0,0 +1,37 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2016 Red Hat
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written by:
* Jonas Ådahl <jadahl@gmail.com>
*/
#ifndef META_RENDERER_X11_H
#define META_RENDERER_X11_H
#include <glib-object.h>
#include "backends/meta-renderer.h"
#define META_TYPE_RENDERER_X11 (meta_renderer_x11_get_type ())
G_DECLARE_FINAL_TYPE (MetaRendererX11, meta_renderer_x11,
META, RENDERER_X11,
MetaRenderer)
#endif /* META_RENDERER_X11_H */