[mutter] cogl/frame-info: Add ZERO_COPY flag



commit 9123aa4e848e4c65ff302321b11566508ac50011
Author: Ivan Molodetskikh <yalterz gmail com>
Date:   Thu Jan 28 11:17:52 2021 +0300

    cogl/frame-info: Add ZERO_COPY flag
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>

 cogl/cogl/cogl-frame-info-private.h | 8 ++++++++
 cogl/cogl/cogl-frame-info.c         | 6 ++++++
 cogl/cogl/cogl-frame-info.h         | 3 +++
 cogl/cogl/cogl-onscreen.c           | 1 +
 4 files changed, 18 insertions(+)
---
diff --git a/cogl/cogl/cogl-frame-info-private.h b/cogl/cogl/cogl-frame-info-private.h
index cd6bea004c..675b6da450 100644
--- a/cogl/cogl/cogl-frame-info-private.h
+++ b/cogl/cogl/cogl-frame-info-private.h
@@ -40,6 +40,14 @@ typedef enum _CoglFrameInfoFlag
   COGL_FRAME_INFO_FLAG_SYMBOLIC = 1 << 0,
   /* presentation_time timestamp was provided by the hardware */
   COGL_FRAME_INFO_FLAG_HW_CLOCK = 1 << 1,
+  /*
+   * The presentation of this frame was done zero-copy. This means the buffer
+   * from the client was given to display hardware as is, without copying it.
+   * Compositing with OpenGL counts as copying, even if textured directly from
+   * the client buffer. Possible zero-copy cases include direct scanout of a
+   * fullscreen surface and a surface on a hardware overlay.
+   */
+  COGL_FRAME_INFO_FLAG_ZERO_COPY = 1 << 2,
 } CoglFrameInfoFlag;
 
 struct _CoglFrameInfo
diff --git a/cogl/cogl/cogl-frame-info.c b/cogl/cogl/cogl-frame-info.c
index 642bf298ef..24a100bfa7 100644
--- a/cogl/cogl/cogl-frame-info.c
+++ b/cogl/cogl/cogl-frame-info.c
@@ -95,6 +95,12 @@ cogl_frame_info_is_hw_clock (CoglFrameInfo *info)
   return !!(info->flags & COGL_FRAME_INFO_FLAG_HW_CLOCK);
 }
 
+gboolean
+cogl_frame_info_is_zero_copy (CoglFrameInfo *info)
+{
+  return !!(info->flags & COGL_FRAME_INFO_FLAG_ZERO_COPY);
+}
+
 unsigned int
 cogl_frame_info_get_sequence (CoglFrameInfo *info)
 {
diff --git a/cogl/cogl/cogl-frame-info.h b/cogl/cogl/cogl-frame-info.h
index 6dfc6f2962..62a9bb0eab 100644
--- a/cogl/cogl/cogl-frame-info.h
+++ b/cogl/cogl/cogl-frame-info.h
@@ -141,6 +141,9 @@ gboolean cogl_frame_info_get_is_symbolic (CoglFrameInfo *info);
 COGL_EXPORT
 gboolean cogl_frame_info_is_hw_clock (CoglFrameInfo *info);
 
+COGL_EXPORT
+gboolean cogl_frame_info_is_zero_copy (CoglFrameInfo *info);
+
 COGL_EXPORT
 unsigned int cogl_frame_info_get_sequence (CoglFrameInfo *info);
 
diff --git a/cogl/cogl/cogl-onscreen.c b/cogl/cogl/cogl-onscreen.c
index 8bc3d2607e..cff5df50c5 100644
--- a/cogl/cogl/cogl-onscreen.c
+++ b/cogl/cogl/cogl-onscreen.c
@@ -458,6 +458,7 @@ cogl_onscreen_direct_scanout (CoglOnscreen   *onscreen,
       return FALSE;
     }
 
+  info->flags |= COGL_FRAME_INFO_FLAG_ZERO_COPY;
   priv->frame_counter++;
   return TRUE;
 }


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