[mutter] MetaRendererNative: Add helper for getting the next framebuffer id



commit faa96444b586ffee8ed44600eb7759249e6d6b5e
Author: Jonas Ådahl <jadahl gmail com>
Date:   Thu Sep 29 22:33:02 2016 +0800

    MetaRendererNative: Add helper for getting the next framebuffer id
    
    https://bugzilla.gnome.org/show_bug.cgi?id=773629

 src/backends/native/meta-renderer-native.c |   68 ++++++++++++++++++----------
 1 files changed, 44 insertions(+), 24 deletions(-)
---
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index 8c5ea11..21f786f 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -598,10 +598,10 @@ meta_onscreen_native_flip_crtcs (CoglOnscreen *onscreen)
   g_closure_unref (flip_closure);
 }
 
-static void
-meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
-                                               const int    *rectangles,
-                                               int           n_rectangles)
+static gboolean
+gbm_get_next_fb_id (CoglOnscreen   *onscreen,
+                    struct gbm_bo **out_next_bo,
+                    uint32_t       *out_next_fb_id)
 {
   CoglContext *cogl_context = COGL_FRAMEBUFFER (onscreen)->context;
   CoglRenderer *cogl_renderer = cogl_context->display->renderer;
@@ -609,24 +609,15 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
   MetaRendererNative *renderer_native = egl_renderer->platform;
   CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
   MetaOnscreenNative *onscreen_native = egl_onscreen->platform;
-  CoglFrameInfo *frame_info;
   uint32_t handle, stride;
-
-  frame_info = g_queue_peek_tail (&onscreen->pending_frame_infos);
-  frame_info->global_frame_counter = renderer_native->frame_counter;
-
-  g_warn_if_fail (!onscreen_native->pending_queue_swap_notify);
-
-  parent_vtable->onscreen_swap_buffers_with_damage (onscreen,
-                                                    rectangles,
-                                                    n_rectangles);
+  struct gbm_bo *next_bo;
+  uint32_t next_fb_id;
 
   /* Now we need to set the CRTC to whatever is the front buffer */
-  onscreen_native->gbm.next_bo =
-    gbm_surface_lock_front_buffer (onscreen_native->gbm.surface);
+  next_bo = gbm_surface_lock_front_buffer (onscreen_native->gbm.surface);
 
-  stride = gbm_bo_get_stride (onscreen_native->gbm.next_bo);
-  handle = gbm_bo_get_handle (onscreen_native->gbm.next_bo).u32;
+  stride = gbm_bo_get_stride (next_bo);
+  handle = gbm_bo_get_handle (next_bo).u32;
 
   if (drmModeAddFB (renderer_native->kms_fd,
                     cogl_framebuffer_get_width (COGL_FRAMEBUFFER (onscreen)),
@@ -635,16 +626,45 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
                     32, /* bpp */
                     stride,
                     handle,
-                    &onscreen_native->gbm.next_fb_id))
+                    &next_fb_id))
     {
       g_warning ("Failed to create new back buffer handle: %m");
-      gbm_surface_release_buffer (onscreen_native->gbm.surface,
-                                  onscreen_native->gbm.next_bo);
-      onscreen_native->gbm.next_bo = NULL;
-      onscreen_native->gbm.next_fb_id = 0;
-      return;
+      gbm_surface_release_buffer (onscreen_native->gbm.surface, next_bo);
+      return FALSE;
     }
 
+  *out_next_bo = next_bo;
+  *out_next_fb_id = next_fb_id;
+  return TRUE;
+}
+
+static void
+meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen *onscreen,
+                                               const int    *rectangles,
+                                               int           n_rectangles)
+{
+  CoglContext *cogl_context = COGL_FRAMEBUFFER (onscreen)->context;
+  CoglRenderer *cogl_renderer = cogl_context->display->renderer;
+  CoglRendererEGL *egl_renderer = cogl_renderer->winsys;
+  MetaRendererNative *renderer_native = egl_renderer->platform;
+  CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
+  MetaOnscreenNative *onscreen_native = egl_onscreen->platform;
+  CoglFrameInfo *frame_info;
+
+  frame_info = g_queue_peek_tail (&onscreen->pending_frame_infos);
+  frame_info->global_frame_counter = renderer_native->frame_counter;
+
+  g_warn_if_fail (!onscreen_native->pending_queue_swap_notify);
+
+  parent_vtable->onscreen_swap_buffers_with_damage (onscreen,
+                                                    rectangles,
+                                                    n_rectangles);
+
+  if (!gbm_get_next_fb_id (onscreen,
+                           &onscreen_native->gbm.next_bo,
+                           &onscreen_native->gbm.next_fb_id))
+    return;
+
   /* If this is the first framebuffer to be presented then we now setup the
    * crtc modes, else we flip from the previous buffer */
   if (onscreen_native->pending_set_crtc)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]