From 9123aa4e848e4c65ff302321b11566508ac50011 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Thu, 28 Jan 2021 11:17:52 +0300 Subject: [PATCH] cogl/frame-info: Add ZERO_COPY flag Part-of: --- 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 cd6bea004..675b6da45 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 642bf298e..24a100bfa 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 6dfc6f296..62a9bb0ea 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 8bc3d2607..cff5df50c 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; }