[gtk/wip/otte/gl-hdr: 5/12] gdk: Add a request_hdr argument to begin_frame()




commit 0820828489862fa79d046b20b802841ddb1a1ea4
Author: Benjamin Otte <otte redhat com>
Date:   Sat Oct 2 22:21:23 2021 +0200

    gdk: Add a request_hdr argument to begin_frame()
    
    It's not used by anyone, it's just there.
    
    gdk_draw_context_begin_frame_full() has been added so renderers can
    make use of it.

 gdk/broadway/gdkcairocontext-broadway.c |  1 +
 gdk/broadway/gdkdrawcontext-broadway.c  |  1 +
 gdk/gdkdrawcontext.c                    | 34 ++++++++++++++++++++++++++++++---
 gdk/gdkdrawcontextprivate.h             |  4 ++++
 gdk/gdkglcontext.c                      |  1 +
 gdk/gdkvulkancontext.c                  |  1 +
 gdk/macos/gdkmacoscairocontext.c        |  1 +
 gdk/macos/gdkmacosglcontext.c           |  3 ++-
 gdk/wayland/gdkcairocontext-wayland.c   |  1 +
 gdk/wayland/gdkglcontext-wayland.c      |  3 ++-
 gdk/win32/gdkcairocontext-win32.c       |  1 +
 gdk/win32/gdkglcontext-win32-egl.c      |  8 ++------
 gdk/win32/gdkglcontext-win32-wgl.c      |  3 ++-
 gdk/win32/gdkvulkancontext-win32.c      |  3 ++-
 gdk/x11/gdkcairocontext-x11.c           |  1 +
 gdk/x11/gdkglcontext-egl.c              |  3 ++-
 16 files changed, 55 insertions(+), 14 deletions(-)
---
diff --git a/gdk/broadway/gdkcairocontext-broadway.c b/gdk/broadway/gdkcairocontext-broadway.c
index bc45b5094a..46fdbaf637 100644
--- a/gdk/broadway/gdkcairocontext-broadway.c
+++ b/gdk/broadway/gdkcairocontext-broadway.c
@@ -34,6 +34,7 @@ gdk_broadway_cairo_context_dispose (GObject *object)
 
 static void
 gdk_broadway_cairo_context_begin_frame (GdkDrawContext *draw_context,
+                                        gboolean        request_hdr,
                                         cairo_region_t *region)
 {
   GdkBroadwayCairoContext *self = GDK_BROADWAY_CAIRO_CONTEXT (draw_context);
diff --git a/gdk/broadway/gdkdrawcontext-broadway.c b/gdk/broadway/gdkdrawcontext-broadway.c
index 473488396a..660976bff5 100644
--- a/gdk/broadway/gdkdrawcontext-broadway.c
+++ b/gdk/broadway/gdkdrawcontext-broadway.c
@@ -34,6 +34,7 @@ gdk_broadway_draw_context_dispose (GObject *object)
 
 static void
 gdk_broadway_draw_context_begin_frame (GdkDrawContext *draw_context,
+                                       gboolean        request_hdr,
                                        cairo_region_t *region)
 {
   GdkBroadwayDrawContext *self = GDK_BROADWAY_DRAW_CONTEXT (draw_context);
diff --git a/gdk/gdkdrawcontext.c b/gdk/gdkdrawcontext.c
index fdd6fc9c9d..1515917b07 100644
--- a/gdk/gdkdrawcontext.c
+++ b/gdk/gdkdrawcontext.c
@@ -307,11 +307,39 @@ void
 gdk_draw_context_begin_frame (GdkDrawContext       *context,
                               const cairo_region_t *region)
 {
-  GdkDrawContextPrivate *priv = gdk_draw_context_get_instance_private (context);
-
   g_return_if_fail (GDK_IS_DRAW_CONTEXT (context));
   g_return_if_fail (region != NULL);
 
+  gdk_draw_context_begin_frame_full (context, FALSE, region);
+}
+
+/*
+ * @request_hdr: %TRUE to request high dynamic range.
+ *
+ * If HDR is requested, GDK will see about providing a rendering target
+ * that supports high dynamic range. Typically this means a target supporting
+ * 16bit floating point pixels, but that is not guaranteed.
+ *
+ * This is only a request and if the GDK backend does not support HDR rendering
+ * or does not consider it worthwhile, it may choose to not honor the request.
+ * It may also choose to provide HDR even if it was not requested.
+ * Typically the steps undertaken by a backend are:
+ * 1. Check if HDR is supported by this drawing backend.
+ * 2. Check if the compositor supports HDR.
+ * 3. Check if the compositor prefers SDR. This is usually the case when the attached
+ *    monitors do not support HDR content or when the system is resource constrained.
+ * In either of those cases, the context will usually choose to not honor the request.
+ *
+ * The rendering code must be able to deal with HDR and SDR content, no matter if HDR
+ * was requested. The request is only a hint and GDK is free to choose.
+ */
+void
+gdk_draw_context_begin_frame_full (GdkDrawContext       *context,
+                                   gboolean              request_hdr,
+                                   const cairo_region_t *region)
+{
+  GdkDrawContextPrivate *priv = gdk_draw_context_get_instance_private (context);
+
   if (GDK_SURFACE_DESTROYED (priv->surface))
     return;
 
@@ -336,7 +364,7 @@ gdk_draw_context_begin_frame (GdkDrawContext       *context,
   priv->frame_region = cairo_region_copy (region);
   priv->surface->paint_context = g_object_ref (context);
 
-  GDK_DRAW_CONTEXT_GET_CLASS (context)->begin_frame (context, priv->frame_region);
+  GDK_DRAW_CONTEXT_GET_CLASS (context)->begin_frame (context, request_hdr, priv->frame_region);
 }
 
 #ifdef HAVE_SYSPROF
diff --git a/gdk/gdkdrawcontextprivate.h b/gdk/gdkdrawcontextprivate.h
index 8ae1d0e8f8..0171876d9d 100644
--- a/gdk/gdkdrawcontextprivate.h
+++ b/gdk/gdkdrawcontextprivate.h
@@ -41,6 +41,7 @@ struct _GdkDrawContextClass
   GObjectClass parent_class;
 
   void                  (* begin_frame)                         (GdkDrawContext         *context,
+                                                                 gboolean                request_hdr,
                                                                  cairo_region_t         *update_area);
   void                  (* end_frame)                           (GdkDrawContext         *context,
                                                                  cairo_region_t         *painted);
@@ -49,6 +50,9 @@ struct _GdkDrawContextClass
 
 void                    gdk_draw_context_surface_resized        (GdkDrawContext         *context);
 
+void                    gdk_draw_context_begin_frame_full       (GdkDrawContext         *context,
+                                                                 gboolean                request_hdr,
+                                                                 const cairo_region_t   *region);
 G_END_DECLS
 
 #endif /* __GDK__DRAW_CONTEXT_PRIVATE__ */
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index a692a4f5ef..19150361fa 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -374,6 +374,7 @@ gdk_gl_context_real_is_shared (GdkGLContext *self,
 
 static void
 gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context,
+                                 gboolean        request_hdr,
                                  cairo_region_t *region)
 {
   GdkGLContext *context = GDK_GL_CONTEXT (draw_context);
diff --git a/gdk/gdkvulkancontext.c b/gdk/gdkvulkancontext.c
index c3f54bbb7c..2466c317b8 100644
--- a/gdk/gdkvulkancontext.c
+++ b/gdk/gdkvulkancontext.c
@@ -425,6 +425,7 @@ device_supports_incremental_present (VkPhysicalDevice device)
 
 static void
 gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
+                                gboolean        request_hdr,
                                 cairo_region_t *region)
 {
   GdkVulkanContext *context = GDK_VULKAN_CONTEXT (draw_context);
diff --git a/gdk/macos/gdkmacoscairocontext.c b/gdk/macos/gdkmacoscairocontext.c
index d33f195e5c..7a195ab063 100644
--- a/gdk/macos/gdkmacoscairocontext.c
+++ b/gdk/macos/gdkmacoscairocontext.c
@@ -82,6 +82,7 @@ _gdk_macos_cairo_context_cairo_create (GdkCairoContext *cairo_context)
 
 static void
 _gdk_macos_cairo_context_begin_frame (GdkDrawContext *draw_context,
+                                      gboolean        request_hdr,
                                       cairo_region_t *region)
 {
   GdkMacosCairoContext *self = (GdkMacosCairoContext *)draw_context;
diff --git a/gdk/macos/gdkmacosglcontext.c b/gdk/macos/gdkmacosglcontext.c
index 77391b9eaa..967648626c 100644
--- a/gdk/macos/gdkmacosglcontext.c
+++ b/gdk/macos/gdkmacosglcontext.c
@@ -291,6 +291,7 @@ opaque_region_covers_surface (GdkMacosGLContext *self)
 
 static void
 gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
+                                  gboolean        request_hdr,
                                   cairo_region_t *painted)
 {
   GdkMacosGLContext *self = (GdkMacosGLContext *)context;
@@ -344,7 +345,7 @@ gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
       [self->gl_context update];
     }
 
-  GDK_DRAW_CONTEXT_CLASS (gdk_macos_gl_context_parent_class)->begin_frame (context, painted);
+  GDK_DRAW_CONTEXT_CLASS (gdk_macos_gl_context_parent_class)->begin_frame (context, request_hdr, painted);
 
   if (!self->is_attached)
     {
diff --git a/gdk/wayland/gdkcairocontext-wayland.c b/gdk/wayland/gdkcairocontext-wayland.c
index 4ce7134327..e06eaa1096 100644
--- a/gdk/wayland/gdkcairocontext-wayland.c
+++ b/gdk/wayland/gdkcairocontext-wayland.c
@@ -144,6 +144,7 @@ gdk_wayland_cairo_context_create_surface (GdkWaylandCairoContext *self)
 
 static void
 gdk_wayland_cairo_context_begin_frame (GdkDrawContext *draw_context,
+                                       gboolean        request_hdr,
                                        cairo_region_t *region)
 {
   GdkWaylandCairoContext *self = GDK_WAYLAND_CAIRO_CONTEXT (draw_context);
diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c
index 834cbc8510..e256277add 100644
--- a/gdk/wayland/gdkglcontext-wayland.c
+++ b/gdk/wayland/gdkglcontext-wayland.c
@@ -282,9 +282,10 @@ gdk_wayland_gl_context_make_current (GdkGLContext *context,
 
 static void
 gdk_wayland_gl_context_begin_frame (GdkDrawContext *draw_context,
+                                    gboolean        request_hdr,
                                     cairo_region_t *region)
 {
-  GDK_DRAW_CONTEXT_CLASS (gdk_wayland_gl_context_parent_class)->begin_frame (draw_context, region);
+  GDK_DRAW_CONTEXT_CLASS (gdk_wayland_gl_context_parent_class)->begin_frame (draw_context, request_hdr, 
region);
 
   glDrawBuffers (1, (GLenum[1]) { GL_BACK });
 }
diff --git a/gdk/win32/gdkcairocontext-win32.c b/gdk/win32/gdkcairocontext-win32.c
index 0f9dbbca1a..65aef46b48 100644
--- a/gdk/win32/gdkcairocontext-win32.c
+++ b/gdk/win32/gdkcairocontext-win32.c
@@ -53,6 +53,7 @@ create_cairo_surface_for_surface (GdkSurface *surface,
 
 static void
 gdk_win32_cairo_context_begin_frame (GdkDrawContext *draw_context,
+                                     gboolean        request_hdr,
                                      cairo_region_t *region)
 {
   GdkWin32CairoContext *self = GDK_WIN32_CAIRO_CONTEXT (draw_context);
diff --git a/gdk/win32/gdkglcontext-win32-egl.c b/gdk/win32/gdkglcontext-win32-egl.c
index 0b30a8b481..8d6bef9e17 100644
--- a/gdk/win32/gdkglcontext-win32-egl.c
+++ b/gdk/win32/gdkglcontext-win32-egl.c
@@ -471,16 +471,12 @@ gdk_win32_gl_context_egl_make_current (GdkGLContext *context,
 
 static void
 gdk_win32_gl_context_egl_begin_frame (GdkDrawContext *draw_context,
+                                      gboolean        request_hdr,
                                       cairo_region_t *update_area)
 {
-  GdkGLContext *context = GDK_GL_CONTEXT (draw_context);
-  GdkSurface *surface;
-
-  surface = gdk_gl_context_get_surface (context);
-
   gdk_win32_surface_handle_queued_move_resize (draw_context);
 
-  GDK_DRAW_CONTEXT_CLASS (gdk_win32_gl_context_egl_parent_class)->begin_frame (draw_context, update_area);
+  GDK_DRAW_CONTEXT_CLASS (gdk_win32_gl_context_egl_parent_class)->begin_frame (draw_context, request_hdr, 
update_area);
 }
 
 static void
diff --git a/gdk/win32/gdkglcontext-win32-wgl.c b/gdk/win32/gdkglcontext-win32-wgl.c
index 73ced98673..9f9bc257a3 100644
--- a/gdk/win32/gdkglcontext-win32-wgl.c
+++ b/gdk/win32/gdkglcontext-win32-wgl.c
@@ -118,11 +118,12 @@ gdk_win32_gl_context_wgl_end_frame (GdkDrawContext *draw_context,
 
 static void
 gdk_win32_gl_context_wgl_begin_frame (GdkDrawContext *draw_context,
+                                      gboolean        request_hdr,
                                       cairo_region_t *update_area)
 {
   gdk_win32_surface_handle_queued_move_resize (draw_context);
 
-  GDK_DRAW_CONTEXT_CLASS (gdk_win32_gl_context_wgl_parent_class)->begin_frame (draw_context, update_area);
+  GDK_DRAW_CONTEXT_CLASS (gdk_win32_gl_context_wgl_parent_class)->begin_frame (draw_context, request_hdr, 
update_area);
 }
 
 static int
diff --git a/gdk/win32/gdkvulkancontext-win32.c b/gdk/win32/gdkvulkancontext-win32.c
index 478299c31e..d82cb15d27 100644
--- a/gdk/win32/gdkvulkancontext-win32.c
+++ b/gdk/win32/gdkvulkancontext-win32.c
@@ -68,11 +68,12 @@ gdk_win32_vulkan_context_create_surface (GdkVulkanContext *context,
 
 static void
 gdk_win32_vulkan_context_begin_frame (GdkDrawContext *draw_context,
+                                      gboolean        request_hdr,
                                       cairo_region_t *update_area)
 {
   gdk_win32_surface_handle_queued_move_resize (draw_context);
 
-  GDK_DRAW_CONTEXT_CLASS (gdk_win32_vulkan_context_parent_class)->begin_frame (draw_context, update_area);
+  GDK_DRAW_CONTEXT_CLASS (gdk_win32_vulkan_context_parent_class)->begin_frame (draw_context, request_hdr, 
update_area);
 }
 
 static void
diff --git a/gdk/x11/gdkcairocontext-x11.c b/gdk/x11/gdkcairocontext-x11.c
index 36bf1ae0ba..e6accbb6ad 100644
--- a/gdk/x11/gdkcairocontext-x11.c
+++ b/gdk/x11/gdkcairocontext-x11.c
@@ -55,6 +55,7 @@ create_cairo_surface_for_surface (GdkSurface *surface)
 
 static void
 gdk_x11_cairo_context_begin_frame (GdkDrawContext *draw_context,
+                                   gboolean        request_hdr,
                                    cairo_region_t *region)
 {
   GdkX11CairoContext *self = GDK_X11_CAIRO_CONTEXT (draw_context);
diff --git a/gdk/x11/gdkglcontext-egl.c b/gdk/x11/gdkglcontext-egl.c
index 6f3330d654..f83784f36e 100644
--- a/gdk/x11/gdkglcontext-egl.c
+++ b/gdk/x11/gdkglcontext-egl.c
@@ -313,9 +313,10 @@ gdk_x11_surface_destroy_egl_surface (GdkX11Surface *self)
 
 static void
 gdk_x11_gl_context_egl_begin_frame (GdkDrawContext *draw_context,
+                                    gboolean        request_hdr,
                                     cairo_region_t *region)
 {
-  GDK_DRAW_CONTEXT_CLASS (gdk_x11_gl_context_egl_parent_class)->begin_frame (draw_context, region);
+  GDK_DRAW_CONTEXT_CLASS (gdk_x11_gl_context_egl_parent_class)->begin_frame (draw_context, request_hdr, 
region);
 
   glDrawBuffers (1, (GLenum[1]) { GL_BACK });
 }


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