[mutter/wip/garnacho/wayland-emulated-output-transform: 10/13] backends/native: Refactor onscreen creation into separate function
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/garnacho/wayland-emulated-output-transform: 10/13] backends/native: Refactor onscreen creation into separate function
- Date: Mon, 1 Aug 2016 11:36:14 +0000 (UTC)
commit c042870886b31905f2eac356c9547a377b5654e9
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Aug 1 03:47:11 2016 +0200
backends/native: Refactor onscreen creation into separate function
And use the right size, regarless of view transform.
src/backends/native/meta-renderer-native.c | 87 ++++++++++++++++++++--------
1 files changed, 63 insertions(+), 24 deletions(-)
---
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index b101d3f..48a5dba 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -871,6 +871,43 @@ meta_renderer_native_get_monitor_info_transform (MetaRenderer *renderer,
monitor_info->outputs[0]->crtc);
}
+static gboolean
+meta_renderer_native_create_onscreen (MetaRendererNative *renderer,
+ CoglContext *context,
+ MetaMonitorTransform transform,
+ gint view_width,
+ gint view_height,
+ CoglOnscreen **onscreen,
+ GError **error)
+{
+ CoglOnscreen *new_onscreen;
+ gint width, height;
+
+ if (meta_monitor_transform_is_rotated (transform))
+ {
+ width = view_height;
+ height = view_width;
+ }
+ else
+ {
+ width = view_width;
+ height = view_height;
+ }
+
+ new_onscreen = cogl_onscreen_new (context, width, height);
+ cogl_onscreen_set_swap_throttled (new_onscreen,
+ _clutter_get_sync_to_vblank ());
+
+ if (!cogl_framebuffer_allocate (COGL_FRAMEBUFFER (new_onscreen), error))
+ {
+ cogl_object_unref (new_onscreen);
+ return FALSE;
+ }
+
+ *onscreen = new_onscreen;
+ return TRUE;
+}
+
gboolean
meta_renderer_native_set_legacy_view_size (MetaRendererNative *renderer_native,
MetaRendererView *view,
@@ -1037,7 +1074,6 @@ meta_renderer_native_create_legacy_view (MetaRendererNative *renderer_native)
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
CoglOnscreen *onscreen;
- CoglFramebuffer *framebuffer;
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 };
@@ -1053,23 +1089,25 @@ meta_renderer_native_create_legacy_view (MetaRendererNative *renderer_native)
&view_layout.width,
&view_layout.height);
- onscreen = cogl_onscreen_new (cogl_context,
- view_layout.width,
- view_layout.height);
- cogl_onscreen_set_swap_throttled (onscreen,
- _clutter_get_sync_to_vblank ());
- framebuffer = COGL_FRAMEBUFFER (onscreen);
- if (!cogl_framebuffer_allocate (framebuffer, &error))
- meta_fatal ("Failed to allocate onscreen framebuffer: %s\n",
- error->message);
+ if (!meta_renderer_native_create_onscreen (renderer_native,
+ cogl_context,
+ transform,
+ view_layout.width,
+ view_layout.height,
+ &onscreen,
+ &error))
+ {
+ meta_fatal ("Failed to allocate onscreen framebuffer: %s\n",
+ error->message);
+ }
view = g_object_new (META_TYPE_RENDERER_VIEW,
"layout", &view_layout,
- "framebuffer", framebuffer,
+ "framebuffer", onscreen,
"transform", transform,
NULL);
- cogl_object_unref (framebuffer);
+ cogl_object_unref (onscreen);
meta_onscreen_native_set_view (onscreen, view);
@@ -1085,30 +1123,31 @@ meta_renderer_native_create_view (MetaRenderer *renderer,
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
MetaMonitorTransform transform;
CoglOnscreen *onscreen;
- CoglFramebuffer *framebuffer;
MetaRendererView *view;
GError *error = NULL;
transform = meta_renderer_native_get_monitor_info_transform (renderer,
monitor_info);
- onscreen = cogl_onscreen_new (cogl_context,
- monitor_info->rect.width,
- monitor_info->rect.height);
- cogl_onscreen_set_swap_throttled (onscreen,
- _clutter_get_sync_to_vblank ());
- framebuffer = COGL_FRAMEBUFFER (onscreen);
- if (!cogl_framebuffer_allocate (framebuffer, &error))
- meta_fatal ("Failed to allocate onscreen framebuffer: %s\n",
- error->message);
+ if (!meta_renderer_native_create_onscreen (META_RENDERER_NATIVE (renderer),
+ cogl_context,
+ transform,
+ monitor_info->rect.width,
+ monitor_info->rect.height,
+ &onscreen,
+ &error))
+ {
+ meta_fatal ("Failed to allocate onscreen framebuffer: %s\n",
+ error->message);
+ }
view = g_object_new (META_TYPE_RENDERER_VIEW,
"layout", &monitor_info->rect,
- "framebuffer", framebuffer,
+ "framebuffer", onscreen,
"monitor-info", monitor_info,
"transform", transform,
NULL);
- cogl_object_unref (framebuffer);
+ cogl_object_unref (onscreen);
meta_onscreen_native_set_view (onscreen, view);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]