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.
This commit is contained in:
Benjamin Otte 2021-10-02 22:21:23 +02:00
parent bc7c0d05f8
commit 7ede468849
16 changed files with 55 additions and 14 deletions

View File

@ -34,6 +34,7 @@ gdk_broadway_cairo_context_dispose (GObject *object)
static void static void
gdk_broadway_cairo_context_begin_frame (GdkDrawContext *draw_context, gdk_broadway_cairo_context_begin_frame (GdkDrawContext *draw_context,
gboolean request_hdr,
cairo_region_t *region) cairo_region_t *region)
{ {
GdkBroadwayCairoContext *self = GDK_BROADWAY_CAIRO_CONTEXT (draw_context); GdkBroadwayCairoContext *self = GDK_BROADWAY_CAIRO_CONTEXT (draw_context);

View File

@ -34,6 +34,7 @@ gdk_broadway_draw_context_dispose (GObject *object)
static void static void
gdk_broadway_draw_context_begin_frame (GdkDrawContext *draw_context, gdk_broadway_draw_context_begin_frame (GdkDrawContext *draw_context,
gboolean request_hdr,
cairo_region_t *region) cairo_region_t *region)
{ {
GdkBroadwayDrawContext *self = GDK_BROADWAY_DRAW_CONTEXT (draw_context); GdkBroadwayDrawContext *self = GDK_BROADWAY_DRAW_CONTEXT (draw_context);

View File

@ -307,11 +307,39 @@ void
gdk_draw_context_begin_frame (GdkDrawContext *context, gdk_draw_context_begin_frame (GdkDrawContext *context,
const cairo_region_t *region) 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 (GDK_IS_DRAW_CONTEXT (context));
g_return_if_fail (region != NULL); 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)) if (GDK_SURFACE_DESTROYED (priv->surface))
return; return;
@ -336,7 +364,7 @@ gdk_draw_context_begin_frame (GdkDrawContext *context,
priv->frame_region = cairo_region_copy (region); priv->frame_region = cairo_region_copy (region);
priv->surface->paint_context = g_object_ref (context); 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 #ifdef HAVE_SYSPROF

View File

@ -41,6 +41,7 @@ struct _GdkDrawContextClass
GObjectClass parent_class; GObjectClass parent_class;
void (* begin_frame) (GdkDrawContext *context, void (* begin_frame) (GdkDrawContext *context,
gboolean request_hdr,
cairo_region_t *update_area); cairo_region_t *update_area);
void (* end_frame) (GdkDrawContext *context, void (* end_frame) (GdkDrawContext *context,
cairo_region_t *painted); cairo_region_t *painted);
@ -49,6 +50,9 @@ struct _GdkDrawContextClass
void gdk_draw_context_surface_resized (GdkDrawContext *context); 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 G_END_DECLS
#endif /* __GDK__DRAW_CONTEXT_PRIVATE__ */ #endif /* __GDK__DRAW_CONTEXT_PRIVATE__ */

View File

@ -629,6 +629,7 @@ gdk_gl_context_real_make_current (GdkGLContext *context,
static void static void
gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context, gdk_gl_context_real_begin_frame (GdkDrawContext *draw_context,
gboolean request_hdr,
cairo_region_t *region) cairo_region_t *region)
{ {
GdkGLContext *context = GDK_GL_CONTEXT (draw_context); GdkGLContext *context = GDK_GL_CONTEXT (draw_context);

View File

@ -425,6 +425,7 @@ device_supports_incremental_present (VkPhysicalDevice device)
static void static void
gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context, gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
gboolean request_hdr,
cairo_region_t *region) cairo_region_t *region)
{ {
GdkVulkanContext *context = GDK_VULKAN_CONTEXT (draw_context); GdkVulkanContext *context = GDK_VULKAN_CONTEXT (draw_context);

View File

@ -82,6 +82,7 @@ _gdk_macos_cairo_context_cairo_create (GdkCairoContext *cairo_context)
static void static void
_gdk_macos_cairo_context_begin_frame (GdkDrawContext *draw_context, _gdk_macos_cairo_context_begin_frame (GdkDrawContext *draw_context,
gboolean request_hdr,
cairo_region_t *region) cairo_region_t *region)
{ {
GdkMacosCairoContext *self = (GdkMacosCairoContext *)draw_context; GdkMacosCairoContext *self = (GdkMacosCairoContext *)draw_context;

View File

@ -291,6 +291,7 @@ opaque_region_covers_surface (GdkMacosGLContext *self)
static void static void
gdk_macos_gl_context_begin_frame (GdkDrawContext *context, gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
gboolean request_hdr,
cairo_region_t *painted) cairo_region_t *painted)
{ {
GdkMacosGLContext *self = (GdkMacosGLContext *)context; GdkMacosGLContext *self = (GdkMacosGLContext *)context;
@ -344,7 +345,7 @@ gdk_macos_gl_context_begin_frame (GdkDrawContext *context,
[self->gl_context update]; [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) if (!self->is_attached)
{ {

View File

@ -144,6 +144,7 @@ gdk_wayland_cairo_context_create_surface (GdkWaylandCairoContext *self)
static void static void
gdk_wayland_cairo_context_begin_frame (GdkDrawContext *draw_context, gdk_wayland_cairo_context_begin_frame (GdkDrawContext *draw_context,
gboolean request_hdr,
cairo_region_t *region) cairo_region_t *region)
{ {
GdkWaylandCairoContext *self = GDK_WAYLAND_CAIRO_CONTEXT (draw_context); GdkWaylandCairoContext *self = GDK_WAYLAND_CAIRO_CONTEXT (draw_context);

View File

@ -47,11 +47,12 @@ G_DEFINE_TYPE (GdkWaylandGLContext, gdk_wayland_gl_context, GDK_TYPE_GL_CONTEXT)
static void static void
gdk_wayland_gl_context_begin_frame (GdkDrawContext *draw_context, gdk_wayland_gl_context_begin_frame (GdkDrawContext *draw_context,
gboolean request_hdr,
cairo_region_t *region) cairo_region_t *region)
{ {
gdk_wayland_surface_ensure_wl_egl_window (gdk_draw_context_get_surface (draw_context)); gdk_wayland_surface_ensure_wl_egl_window (gdk_draw_context_get_surface (draw_context));
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 }); glDrawBuffers (1, (GLenum[1]) { GL_BACK });
} }

View File

@ -53,6 +53,7 @@ create_cairo_surface_for_surface (GdkSurface *surface,
static void static void
gdk_win32_cairo_context_begin_frame (GdkDrawContext *draw_context, gdk_win32_cairo_context_begin_frame (GdkDrawContext *draw_context,
gboolean request_hdr,
cairo_region_t *region) cairo_region_t *region)
{ {
GdkWin32CairoContext *self = GDK_WIN32_CAIRO_CONTEXT (draw_context); GdkWin32CairoContext *self = GDK_WIN32_CAIRO_CONTEXT (draw_context);

View File

@ -471,16 +471,12 @@ gdk_win32_gl_context_egl_make_current (GdkGLContext *context,
static void static void
gdk_win32_gl_context_egl_begin_frame (GdkDrawContext *draw_context, gdk_win32_gl_context_egl_begin_frame (GdkDrawContext *draw_context,
gboolean request_hdr,
cairo_region_t *update_area) 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_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 static void

View File

@ -118,11 +118,12 @@ gdk_win32_gl_context_wgl_end_frame (GdkDrawContext *draw_context,
static void static void
gdk_win32_gl_context_wgl_begin_frame (GdkDrawContext *draw_context, gdk_win32_gl_context_wgl_begin_frame (GdkDrawContext *draw_context,
gboolean request_hdr,
cairo_region_t *update_area) cairo_region_t *update_area)
{ {
gdk_win32_surface_handle_queued_move_resize (draw_context); 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 static int

View File

@ -68,11 +68,12 @@ gdk_win32_vulkan_context_create_surface (GdkVulkanContext *context,
static void static void
gdk_win32_vulkan_context_begin_frame (GdkDrawContext *draw_context, gdk_win32_vulkan_context_begin_frame (GdkDrawContext *draw_context,
gboolean request_hdr,
cairo_region_t *update_area) cairo_region_t *update_area)
{ {
gdk_win32_surface_handle_queued_move_resize (draw_context); 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 static void

View File

@ -55,6 +55,7 @@ create_cairo_surface_for_surface (GdkSurface *surface)
static void static void
gdk_x11_cairo_context_begin_frame (GdkDrawContext *draw_context, gdk_x11_cairo_context_begin_frame (GdkDrawContext *draw_context,
gboolean request_hdr,
cairo_region_t *region) cairo_region_t *region)
{ {
GdkX11CairoContext *self = GDK_X11_CAIRO_CONTEXT (draw_context); GdkX11CairoContext *self = GDK_X11_CAIRO_CONTEXT (draw_context);

View File

@ -61,9 +61,10 @@ gdk_x11_display_get_egl_display (GdkDisplay *display)
static void static void
gdk_x11_gl_context_egl_begin_frame (GdkDrawContext *draw_context, gdk_x11_gl_context_egl_begin_frame (GdkDrawContext *draw_context,
gboolean request_hdr,
cairo_region_t *region) 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 }); glDrawBuffers (1, (GLenum[1]) { GL_BACK });
} }