surface: Add a hdr metadata field

Allow surfaces to carry HDR metadata for describing the
capabilities of the output it is presented on.

This information is important for gamut or tone mapping,
since the goal is to produce colors that can actually be
presented on the output.

When used in this way, the data is sometimes called the
'target color volume'.
This commit is contained in:
Matthias Clasen 2024-08-12 22:31:36 -04:00
parent fd3ec138b6
commit 04b98f224e
2 changed files with 29 additions and 0 deletions

View File

@ -83,6 +83,7 @@ struct _GdkSurfacePrivate
gpointer widget;
GdkColorState *color_state;
GdkHdrMetadata *hdr_metadata;
};
enum {
@ -3241,3 +3242,26 @@ gdk_surface_set_color_state (GdkSurface *surface,
gdk_surface_invalidate_rect (surface, NULL);
}
GdkHdrMetadata *
gdk_surface_get_hdr_metadata (GdkSurface *surface)
{
GdkSurfacePrivate *priv = gdk_surface_get_instance_private (surface);
return priv->hdr_metadata;
}
void
gdk_surface_set_hdr_metadata (GdkSurface *surface,
GdkHdrMetadata *hdr_metadata)
{
GdkSurfacePrivate *priv = gdk_surface_get_instance_private (surface);
if (gdk_hdr_metadata_equal (priv->hdr_metadata, hdr_metadata))
return;
gdk_hdr_metadata_unref (priv->hdr_metadata);
priv->hdr_metadata = gdk_hdr_metadata_ref (hdr_metadata);
gdk_surface_invalidate_rect (surface, NULL);
}

View File

@ -24,6 +24,7 @@
#include "gdkmemoryformatprivate.h"
#include "gdksurface.h"
#include "gdktoplevel.h"
#include "gdkhdrmetadataprivate.h"
#include <graphene.h>
G_BEGIN_DECLS
@ -358,4 +359,8 @@ GdkColorState * gdk_surface_get_color_state (GdkSurface *surface);
void gdk_surface_set_color_state (GdkSurface *surface,
GdkColorState *color_state);
GdkHdrMetadata * gdk_surface_get_hdr_metadata (GdkSurface *surface);
void gdk_surface_set_hdr_metadata (GdkSurface *surface,
GdkHdrMetadata *hdr_metadata);
G_END_DECLS