mirror of
https://github.com/brl/mutter.git
synced 2024-11-24 17:10:40 -05:00
backends/native: Stop supporting stage views being disabled
Get rid of some technical dept by removing the support in the native backend for drawing the the whole stage to one large framebuffer. Previously the only way to disable stage views was to set the MUTTER_STAGE_VIEWS environment variable to 0; doing that now will cause the native backend to fail to initialize. https://bugzilla.gnome.org/show_bug.cgi?id=785381
This commit is contained in:
parent
3244ed37a9
commit
70edc7dda4
@ -67,7 +67,15 @@ struct _MetaBackendNativePrivate
|
||||
};
|
||||
typedef struct _MetaBackendNativePrivate MetaBackendNativePrivate;
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (MetaBackendNative, meta_backend_native, META_TYPE_BACKEND);
|
||||
static GInitableIface *initable_parent_iface;
|
||||
|
||||
static void
|
||||
initable_iface_init (GInitableIface *initable_iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (MetaBackendNative, meta_backend_native, META_TYPE_BACKEND,
|
||||
G_ADD_PRIVATE (MetaBackendNative)
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
|
||||
initable_iface_init))
|
||||
|
||||
static void
|
||||
meta_backend_native_finalize (GObject *object)
|
||||
@ -556,14 +564,34 @@ meta_backend_native_update_screen_size (MetaBackend *backend,
|
||||
ClutterActor *stage = meta_backend_get_stage (backend);
|
||||
|
||||
stage_native = meta_clutter_backend_native_get_stage_native (clutter_backend);
|
||||
if (meta_is_stage_views_enabled ())
|
||||
meta_stage_native_rebuild_views (stage_native);
|
||||
else
|
||||
meta_stage_native_legacy_set_size (stage_native, width, height);
|
||||
meta_stage_native_rebuild_views (stage_native);
|
||||
|
||||
clutter_actor_set_size (stage, width, height);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_backend_native_initable_init (GInitable *initable,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
if (!meta_is_stage_views_enabled ())
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"The native backend requires stage views");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return initable_parent_iface->init (initable, cancellable, error);
|
||||
}
|
||||
|
||||
static void
|
||||
initable_iface_init (GInitableIface *initable_iface)
|
||||
{
|
||||
initable_parent_iface = g_type_interface_peek_parent (initable_iface);
|
||||
|
||||
initable_iface->init = meta_backend_native_initable_init;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_backend_native_class_init (MetaBackendNativeClass *klass)
|
||||
{
|
||||
|
@ -1624,96 +1624,6 @@ meta_renderer_native_create_offscreen (MetaRendererNative *renderer,
|
||||
return fb;
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_renderer_native_set_legacy_view_size (MetaRendererNative *renderer_native,
|
||||
MetaRendererView *view,
|
||||
int width,
|
||||
int height,
|
||||
GError **error)
|
||||
{
|
||||
ClutterBackend *clutter_backend = clutter_get_default_backend ();
|
||||
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
|
||||
CoglDisplay *cogl_display = cogl_context_get_display (cogl_context);
|
||||
CoglRendererEGL *cogl_renderer_egl = cogl_display->renderer->winsys;
|
||||
ClutterStageView *stage_view = CLUTTER_STAGE_VIEW (view);
|
||||
cairo_rectangle_int_t view_layout;
|
||||
|
||||
clutter_stage_view_get_layout (stage_view, &view_layout);
|
||||
|
||||
if (width != view_layout.width || height != view_layout.height)
|
||||
{
|
||||
CoglFramebuffer *framebuffer =
|
||||
clutter_stage_view_get_onscreen (stage_view);
|
||||
CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
|
||||
CoglOnscreenEGL *onscreen_egl = onscreen->winsys;
|
||||
MetaOnscreenNative *onscreen_native = onscreen_egl->platform;
|
||||
MetaGpuKms *gpu_kms = onscreen_native->gpu_kms;
|
||||
CoglDisplayEGL *cogl_display_egl = cogl_display->winsys;
|
||||
struct gbm_surface *new_surface;
|
||||
EGLSurface new_egl_surface;
|
||||
cairo_rectangle_int_t view_layout;
|
||||
|
||||
/*
|
||||
* Ensure we don't have any pending flips that will want
|
||||
* to swap the current buffer.
|
||||
*/
|
||||
while (onscreen_native->gbm.next_fb_id != 0)
|
||||
meta_gpu_kms_wait_for_flip (gpu_kms, NULL);
|
||||
|
||||
/* Need to drop the GBM surface and create a new one */
|
||||
|
||||
if (!meta_renderer_native_create_surface_gbm (onscreen_native,
|
||||
width, height,
|
||||
&new_surface,
|
||||
&new_egl_surface,
|
||||
error))
|
||||
return FALSE;
|
||||
|
||||
if (onscreen_egl->egl_surface)
|
||||
{
|
||||
_cogl_winsys_egl_make_current (cogl_display,
|
||||
cogl_display_egl->dummy_surface,
|
||||
cogl_display_egl->dummy_surface,
|
||||
cogl_display_egl->egl_context);
|
||||
eglDestroySurface (cogl_renderer_egl->edpy,
|
||||
onscreen_egl->egl_surface);
|
||||
}
|
||||
|
||||
/*
|
||||
* Release the current buffer and destroy the associated surface. The
|
||||
* kernel will deal with keeping the actual buffer alive until its no
|
||||
* longer used.
|
||||
*/
|
||||
free_current_bo (onscreen);
|
||||
g_clear_pointer (&onscreen_native->gbm.surface, gbm_surface_destroy);
|
||||
|
||||
/*
|
||||
* Update the active gbm and egl surfaces and make sure they they are
|
||||
* used for drawing the coming frame.
|
||||
*/
|
||||
onscreen_native->gbm.surface = new_surface;
|
||||
onscreen_egl->egl_surface = new_egl_surface;
|
||||
_cogl_winsys_egl_make_current (cogl_display,
|
||||
onscreen_egl->egl_surface,
|
||||
onscreen_egl->egl_surface,
|
||||
cogl_display_egl->egl_context);
|
||||
|
||||
view_layout = (cairo_rectangle_int_t) {
|
||||
.width = width,
|
||||
.height = height
|
||||
};
|
||||
g_object_set (G_OBJECT (view),
|
||||
"layout", &view_layout,
|
||||
NULL);
|
||||
|
||||
_cogl_framebuffer_winsys_update_size (framebuffer, width, height);
|
||||
}
|
||||
|
||||
meta_renderer_native_queue_modes_reset (renderer_native);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static const CoglWinsysVtable *
|
||||
get_native_cogl_winsys_vtable (CoglRenderer *cogl_renderer)
|
||||
{
|
||||
@ -1772,58 +1682,6 @@ meta_onscreen_native_set_view (CoglOnscreen *onscreen,
|
||||
onscreen_native->view = view;
|
||||
}
|
||||
|
||||
MetaRendererView *
|
||||
meta_renderer_native_create_legacy_view (MetaRendererNative *renderer_native)
|
||||
{
|
||||
MetaMonitorManagerKms *monitor_manager_kms =
|
||||
renderer_native->monitor_manager_kms;
|
||||
MetaMonitorManager *monitor_manager =
|
||||
META_MONITOR_MANAGER (monitor_manager_kms);
|
||||
MetaGpuKms *primary_gpu =
|
||||
meta_monitor_manager_kms_get_primary_gpu (monitor_manager_kms);
|
||||
MetaBackend *backend = meta_monitor_manager_get_backend (monitor_manager);
|
||||
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
||||
CoglContext *cogl_context =
|
||||
clutter_backend_get_cogl_context (clutter_backend);
|
||||
cairo_rectangle_int_t view_layout = { 0 };
|
||||
CoglOnscreen *onscreen;
|
||||
MetaRendererView *view;
|
||||
GError *error = NULL;
|
||||
|
||||
meta_monitor_manager_get_screen_size (monitor_manager,
|
||||
&view_layout.width,
|
||||
&view_layout.height);
|
||||
|
||||
onscreen = meta_renderer_native_create_onscreen (primary_gpu,
|
||||
cogl_context,
|
||||
META_MONITOR_TRANSFORM_NORMAL,
|
||||
view_layout.width,
|
||||
view_layout.height);
|
||||
|
||||
if (!onscreen)
|
||||
meta_fatal ("Failed to allocate onscreen framebuffer\n");
|
||||
|
||||
view = g_object_new (META_TYPE_RENDERER_VIEW,
|
||||
"layout", &view_layout,
|
||||
"framebuffer", onscreen,
|
||||
NULL);
|
||||
|
||||
meta_onscreen_native_set_view (onscreen, view);
|
||||
|
||||
if (!meta_onscreen_native_allocate (onscreen, &error))
|
||||
{
|
||||
g_warning ("Could not create onscreen: %s", error->message);
|
||||
cogl_object_unref (onscreen);
|
||||
g_object_unref (view);
|
||||
g_error_free (error);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cogl_object_unref (onscreen);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
static MetaMonitorTransform
|
||||
calculate_view_transform (MetaMonitorManager *monitor_manager,
|
||||
MetaLogicalMonitor *logical_monitor)
|
||||
|
@ -38,19 +38,12 @@ struct _MetaStageNative
|
||||
{
|
||||
ClutterStageCogl parent;
|
||||
|
||||
CoglOnscreen *pending_onscreen;
|
||||
CoglClosure *frame_closure;
|
||||
|
||||
int64_t presented_frame_counter_sync;
|
||||
int64_t presented_frame_counter_complete;
|
||||
|
||||
gboolean pending_resize;
|
||||
int pending_width;
|
||||
int pending_height;
|
||||
};
|
||||
|
||||
static ClutterStageWindowIface *clutter_stage_window_parent_iface = NULL;
|
||||
|
||||
static void
|
||||
clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
|
||||
|
||||
@ -59,20 +52,6 @@ G_DEFINE_TYPE_WITH_CODE (MetaStageNative, meta_stage_native,
|
||||
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_STAGE_WINDOW,
|
||||
clutter_stage_window_iface_init))
|
||||
|
||||
static MetaRendererView *
|
||||
get_legacy_view (MetaRenderer *renderer)
|
||||
{
|
||||
GList *views;
|
||||
|
||||
views = meta_renderer_get_views (renderer);
|
||||
g_assert (g_list_length (views) <= 1);
|
||||
|
||||
if (views)
|
||||
return views->data;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
frame_cb (CoglOnscreen *onscreen,
|
||||
CoglFrameEvent frame_event,
|
||||
@ -164,26 +143,6 @@ meta_stage_native_rebuild_views (MetaStageNative *stage_native)
|
||||
ensure_frame_callbacks (stage_native);
|
||||
}
|
||||
|
||||
void
|
||||
meta_stage_native_legacy_set_size (MetaStageNative *stage_native,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
stage_native->pending_resize = TRUE;
|
||||
stage_native->pending_width = width;
|
||||
stage_native->pending_height = height;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_stage_native_unrealize (ClutterStageWindow *stage_window)
|
||||
{
|
||||
MetaStageNative *stage_native = META_STAGE_NATIVE (stage_window);
|
||||
|
||||
clutter_stage_window_parent_iface->unrealize (stage_window);
|
||||
|
||||
g_clear_pointer (&stage_native->pending_onscreen, cogl_object_unref);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_stage_native_can_clip_redraws (ClutterStageWindow *stage_window)
|
||||
{
|
||||
@ -217,37 +176,12 @@ meta_stage_native_get_geometry (ClutterStageWindow *stage_window,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_legacy_view (ClutterStageWindow *stage_window)
|
||||
{
|
||||
MetaStageNative *stage_native = META_STAGE_NATIVE (stage_window);
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaRenderer *renderer = meta_backend_get_renderer (backend);
|
||||
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer);
|
||||
MetaRendererView *legacy_view;
|
||||
|
||||
legacy_view = get_legacy_view (renderer);
|
||||
if (legacy_view)
|
||||
return;
|
||||
|
||||
legacy_view = meta_renderer_native_create_legacy_view (renderer_native);
|
||||
if (!legacy_view)
|
||||
return;
|
||||
|
||||
meta_renderer_set_legacy_view (renderer, legacy_view);
|
||||
|
||||
ensure_frame_callback (stage_native, CLUTTER_STAGE_VIEW (legacy_view));
|
||||
}
|
||||
|
||||
static GList *
|
||||
meta_stage_native_get_views (ClutterStageWindow *stage_window)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaRenderer *renderer = meta_backend_get_renderer (backend);
|
||||
|
||||
if (!meta_is_stage_views_enabled ())
|
||||
ensure_legacy_view (stage_window);
|
||||
|
||||
return meta_renderer_get_views (renderer);
|
||||
}
|
||||
|
||||
@ -261,46 +195,6 @@ meta_stage_native_get_frame_counter (ClutterStageWindow *stage_window)
|
||||
return meta_renderer_native_get_frame_counter (renderer_native);
|
||||
}
|
||||
|
||||
static void
|
||||
maybe_resize_legacy_view (MetaStageNative *stage_native)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaRenderer *renderer = meta_backend_get_renderer (backend);
|
||||
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer);
|
||||
MetaRendererView *legacy_view;
|
||||
int width = stage_native->pending_width;
|
||||
int height = stage_native->pending_height;
|
||||
GError *error = NULL;
|
||||
|
||||
if (!stage_native->pending_resize)
|
||||
return;
|
||||
stage_native->pending_resize = FALSE;
|
||||
|
||||
legacy_view = get_legacy_view (renderer);
|
||||
if (!legacy_view)
|
||||
return;
|
||||
|
||||
if (!meta_renderer_native_set_legacy_view_size (renderer_native,
|
||||
legacy_view,
|
||||
width, height,
|
||||
&error))
|
||||
{
|
||||
meta_warning ("Applying display configuration failed: %s\n",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_stage_native_redraw (ClutterStageWindow *stage_window)
|
||||
{
|
||||
MetaStageNative *stage_native = META_STAGE_NATIVE (stage_window);
|
||||
|
||||
maybe_resize_legacy_view (stage_native);
|
||||
|
||||
clutter_stage_window_parent_iface->redraw (stage_window);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_stage_native_finish_frame (ClutterStageWindow *stage_window)
|
||||
{
|
||||
@ -327,13 +221,9 @@ meta_stage_native_class_init (MetaStageNativeClass *klass)
|
||||
static void
|
||||
clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
|
||||
{
|
||||
clutter_stage_window_parent_iface = g_type_interface_peek_parent (iface);
|
||||
|
||||
iface->unrealize = meta_stage_native_unrealize;
|
||||
iface->can_clip_redraws = meta_stage_native_can_clip_redraws;
|
||||
iface->get_geometry = meta_stage_native_get_geometry;
|
||||
iface->get_views = meta_stage_native_get_views;
|
||||
iface->get_frame_counter = meta_stage_native_get_frame_counter;
|
||||
iface->redraw = meta_stage_native_redraw;
|
||||
iface->finish_frame = meta_stage_native_finish_frame;
|
||||
}
|
||||
|
@ -33,8 +33,4 @@ G_DECLARE_FINAL_TYPE (MetaStageNative, meta_stage_native,
|
||||
|
||||
void meta_stage_native_rebuild_views (MetaStageNative *stage_native);
|
||||
|
||||
void meta_stage_native_legacy_set_size (MetaStageNative *stage_native,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
#endif /* META_STAGE_NATIVE_H */
|
||||
|
Loading…
Reference in New Issue
Block a user