mirror of
https://github.com/brl/mutter.git
synced 2024-11-29 11:30:45 -05:00
backends/native: Refactor onscreen creation into separate function
And use the right size, regarless of view transform. https://bugzilla.gnome.org/show_bug.cgi?id=745079
This commit is contained in:
parent
6ce918661c
commit
8065ff5a37
@ -848,6 +848,43 @@ meta_renderer_native_get_monitor_info_transform (MetaRenderer *renderer,
|
|||||||
monitor_info->outputs[0]->crtc);
|
monitor_info->outputs[0]->crtc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CoglOnscreen *
|
||||||
|
meta_renderer_native_create_onscreen (MetaRendererNative *renderer,
|
||||||
|
CoglContext *context,
|
||||||
|
MetaMonitorTransform transform,
|
||||||
|
gint view_width,
|
||||||
|
gint view_height)
|
||||||
|
{
|
||||||
|
CoglOnscreen *onscreen;
|
||||||
|
gint width, height;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (meta_monitor_transform_is_rotated (transform))
|
||||||
|
{
|
||||||
|
width = view_height;
|
||||||
|
height = view_width;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
width = view_width;
|
||||||
|
height = view_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
onscreen = cogl_onscreen_new (context, width, height);
|
||||||
|
cogl_onscreen_set_swap_throttled (onscreen,
|
||||||
|
_clutter_get_sync_to_vblank ());
|
||||||
|
|
||||||
|
if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (onscreen), &error))
|
||||||
|
{
|
||||||
|
g_warning ("Could not create onscreen: %s", error->message);
|
||||||
|
cogl_object_unref (onscreen);
|
||||||
|
g_error_free (error);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return onscreen;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
meta_renderer_native_set_legacy_view_size (MetaRendererNative *renderer_native,
|
meta_renderer_native_set_legacy_view_size (MetaRendererNative *renderer_native,
|
||||||
MetaRendererView *view,
|
MetaRendererView *view,
|
||||||
@ -1006,13 +1043,11 @@ meta_renderer_native_create_legacy_view (MetaRendererNative *renderer_native)
|
|||||||
MetaBackend *backend = meta_get_backend ();
|
MetaBackend *backend = meta_get_backend ();
|
||||||
MetaMonitorManager *monitor_manager =
|
MetaMonitorManager *monitor_manager =
|
||||||
meta_backend_get_monitor_manager (backend);
|
meta_backend_get_monitor_manager (backend);
|
||||||
CoglOnscreen *onscreen;
|
CoglOnscreen *onscreen = NULL;
|
||||||
CoglFramebuffer *framebuffer;
|
|
||||||
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
||||||
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
|
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
|
||||||
cairo_rectangle_int_t view_layout = { 0 };
|
cairo_rectangle_int_t view_layout = { 0 };
|
||||||
MetaRendererView *view;
|
MetaRendererView *view;
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
if (!monitor_manager)
|
if (!monitor_manager)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1021,22 +1056,20 @@ meta_renderer_native_create_legacy_view (MetaRendererNative *renderer_native)
|
|||||||
&view_layout.width,
|
&view_layout.width,
|
||||||
&view_layout.height);
|
&view_layout.height);
|
||||||
|
|
||||||
onscreen = cogl_onscreen_new (cogl_context,
|
onscreen = meta_renderer_native_create_onscreen (renderer_native,
|
||||||
|
cogl_context,
|
||||||
|
META_MONITOR_TRANSFORM_NORMAL,
|
||||||
view_layout.width,
|
view_layout.width,
|
||||||
view_layout.height);
|
view_layout.height);
|
||||||
cogl_onscreen_set_swap_throttled (onscreen,
|
|
||||||
_clutter_get_sync_to_vblank ());
|
|
||||||
|
|
||||||
framebuffer = COGL_FRAMEBUFFER (onscreen);
|
if (!onscreen)
|
||||||
if (!cogl_framebuffer_allocate (framebuffer, &error))
|
meta_fatal ("Failed to allocate onscreen framebuffer\n");
|
||||||
meta_fatal ("Failed to allocate onscreen framebuffer: %s\n",
|
|
||||||
error->message);
|
|
||||||
|
|
||||||
view = g_object_new (META_TYPE_RENDERER_VIEW,
|
view = g_object_new (META_TYPE_RENDERER_VIEW,
|
||||||
"layout", &view_layout,
|
"layout", &view_layout,
|
||||||
"framebuffer", framebuffer,
|
"framebuffer", onscreen,
|
||||||
NULL);
|
NULL);
|
||||||
cogl_object_unref (framebuffer);
|
cogl_object_unref (onscreen);
|
||||||
|
|
||||||
meta_onscreen_native_set_view (onscreen, view);
|
meta_onscreen_native_set_view (onscreen, view);
|
||||||
|
|
||||||
@ -1051,31 +1084,27 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
|
|||||||
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
||||||
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
|
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
|
||||||
MetaMonitorTransform transform;
|
MetaMonitorTransform transform;
|
||||||
CoglOnscreen *onscreen;
|
CoglOnscreen *onscreen = NULL;
|
||||||
CoglFramebuffer *framebuffer;
|
|
||||||
MetaRendererView *view;
|
MetaRendererView *view;
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
transform = meta_renderer_native_get_monitor_info_transform (renderer,
|
transform = meta_renderer_native_get_monitor_info_transform (renderer,
|
||||||
monitor_info);
|
monitor_info);
|
||||||
onscreen = cogl_onscreen_new (cogl_context,
|
|
||||||
|
onscreen = meta_renderer_native_create_onscreen (META_RENDERER_NATIVE (renderer),
|
||||||
|
cogl_context,
|
||||||
|
transform,
|
||||||
monitor_info->rect.width,
|
monitor_info->rect.width,
|
||||||
monitor_info->rect.height);
|
monitor_info->rect.height);
|
||||||
cogl_onscreen_set_swap_throttled (onscreen,
|
if (!onscreen)
|
||||||
_clutter_get_sync_to_vblank ());
|
meta_fatal ("Failed to allocate onscreen framebuffer\n");
|
||||||
|
|
||||||
framebuffer = COGL_FRAMEBUFFER (onscreen);
|
|
||||||
if (!cogl_framebuffer_allocate (framebuffer, &error))
|
|
||||||
meta_fatal ("Failed to allocate onscreen framebuffer: %s\n",
|
|
||||||
error->message);
|
|
||||||
|
|
||||||
view = g_object_new (META_TYPE_RENDERER_VIEW,
|
view = g_object_new (META_TYPE_RENDERER_VIEW,
|
||||||
"layout", &monitor_info->rect,
|
"layout", &monitor_info->rect,
|
||||||
"framebuffer", framebuffer,
|
"framebuffer", onscreen,
|
||||||
"monitor-info", monitor_info,
|
"monitor-info", monitor_info,
|
||||||
"transform", transform,
|
"transform", transform,
|
||||||
NULL);
|
NULL);
|
||||||
cogl_object_unref (framebuffer);
|
cogl_object_unref (onscreen);
|
||||||
|
|
||||||
meta_onscreen_native_set_view (onscreen, view);
|
meta_onscreen_native_set_view (onscreen, view);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user