[gtk/matthiasc/color-profiles] gsk: Add an hdr property to renderers
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/color-profiles] gsk: Add an hdr property to renderers
- Date: Fri, 1 Oct 2021 12:57:30 +0000 (UTC)
commit 8bc28fffa8e30fbdb38801b8f5bf6b311ab1e157
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Oct 1 00:14:03 2021 -0400
gsk: Add an hdr property to renderers
This will let applications tell the renderer that they expect to
feed it with HDR content, in which case the renderer can consider
doing the necessary things to get such content to the screen as
accurately as possible.
The ngl renderer uses the information to choose GL_RGBA16F as
intermediate texture format.
gsk/gskrenderer.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++
gsk/gskrenderer.h | 7 ++++
gsk/ngl/gsknglrenderer.c | 4 +--
3 files changed, 98 insertions(+), 2 deletions(-)
---
diff --git a/gsk/gskrenderer.c b/gsk/gskrenderer.c
index 77fc9a0dfa..ac594e79ae 100644
--- a/gsk/gskrenderer.c
+++ b/gsk/gskrenderer.c
@@ -84,6 +84,7 @@ typedef struct
GskDebugFlags debug_flags;
gboolean is_realized : 1;
+ gboolean is_hdr : 1;
} GskRendererPrivate;
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GskRenderer, gsk_renderer, G_TYPE_OBJECT)
@@ -92,6 +93,7 @@ enum {
PROP_0,
PROP_REALIZED,
PROP_SURFACE,
+ PROP_HDR,
N_PROPS
};
@@ -148,6 +150,26 @@ gsk_renderer_dispose (GObject *gobject)
G_OBJECT_CLASS (gsk_renderer_parent_class)->dispose (gobject);
}
+static void
+gsk_renderer_set_property (GObject *gobject,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GskRenderer *self = GSK_RENDERER (gobject);
+
+ switch (prop_id)
+ {
+ case PROP_HDR:
+ gsk_renderer_set_hdr (self, g_value_get_boolean (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+ break;
+ }
+}
+
static void
gsk_renderer_get_property (GObject *gobject,
guint prop_id,
@@ -167,6 +189,10 @@ gsk_renderer_get_property (GObject *gobject,
g_value_set_object (value, priv->surface);
break;
+ case PROP_HDR:
+ g_value_set_boolean (value, priv->is_hdr);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -184,6 +210,7 @@ gsk_renderer_class_init (GskRendererClass *klass)
klass->render_texture = gsk_renderer_real_render_texture;
gobject_class->get_property = gsk_renderer_get_property;
+ gobject_class->set_property = gsk_renderer_set_property;
gobject_class->dispose = gsk_renderer_dispose;
/**
@@ -210,6 +237,23 @@ gsk_renderer_class_init (GskRendererClass *klass)
GDK_TYPE_SURFACE,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+ /**
+ * GskRenderer:hdr: (attributes org.gtk.Property.get=gsk_renderer_get_hdr
org.gtk.Property.set=gsk_renderer_set_hdr)
+ *
+ * Sets whether this renderer will be used for HDR content.
+ *
+ * The renderer may use this information when deciding what
+ * format to use for intermediate textures.
+ *
+ * Since: 4.6
+ */
+ gsk_renderer_properties[PROP_HDR] =
+ g_param_spec_boolean ("hdr",
+ "HDR",
+ "Whether the renderer will be used for HDR content",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+
g_object_class_install_properties (gobject_class, N_PROPS, gsk_renderer_properties);
}
@@ -684,3 +728,48 @@ gsk_renderer_set_debug_flags (GskRenderer *renderer,
priv->debug_flags = flags;
}
+
+/**
+ * gsk_renderer_set_hdr: (attributes org.gtk.Method.set_property=hdr)
+ * @renderer: a `GskRenderer`
+ * @hdr: whether this renderer will handle HDR content
+ *
+ * Sets whether this renderer will be used for HDR content.
+ *
+ * If this is the case, the renderer may decide to use higher quality
+ * intermediate textures to preserve HDR information during rendering.
+ *
+ * Since: 4.6
+ */
+void
+gsk_renderer_set_hdr (GskRenderer *renderer,
+ gboolean hdr)
+{
+ GskRendererPrivate *priv = gsk_renderer_get_instance_private (renderer);
+
+ g_return_if_fail (GSK_IS_RENDERER (renderer));
+
+ priv->is_hdr = hdr;
+
+ g_object_notify_by_pspec (G_OBJECT (renderer), gsk_renderer_properties[PROP_HDR]);
+}
+
+/**
+ * gsk_renderer_get_hdr: (attributes org.gtk.Method.get_property=hdr)
+ * @renderer: a `GskRenderer`
+ *
+ * Gets whether this renderer is used for HDR content.
+ *
+ * Returns: %TRUE if @renderer is used for HDR content
+ *
+ * Since: 4.6
+ */
+gboolean
+gsk_renderer_get_hdr (GskRenderer *renderer)
+{
+ GskRendererPrivate *priv = gsk_renderer_get_instance_private (renderer);
+
+ g_return_val_if_fail (GSK_IS_RENDERER (renderer), FALSE);
+
+ return priv->is_hdr;
+}
diff --git a/gsk/gskrenderer.h b/gsk/gskrenderer.h
index 70f05a7180..3a520ca164 100644
--- a/gsk/gskrenderer.h
+++ b/gsk/gskrenderer.h
@@ -63,6 +63,13 @@ void gsk_renderer_render (GskRenderer
GskRenderNode *root,
const cairo_region_t *region);
+GDK_AVAILABLE_IN_4_6
+gboolean gsk_renderer_get_hdr (GskRenderer *renderer);
+
+GDK_AVAILABLE_IN_4_6
+void gsk_renderer_set_hdr (GskRenderer *renderer,
+ gboolean hdr);
+
G_END_DECLS
#endif /* __GSK_RENDERER_H__ */
diff --git a/gsk/ngl/gsknglrenderer.c b/gsk/ngl/gsknglrenderer.c
index afe9e761f6..d79f64d7ec 100644
--- a/gsk/ngl/gsknglrenderer.c
+++ b/gsk/ngl/gsknglrenderer.c
@@ -207,7 +207,7 @@ gsk_ngl_renderer_render (GskRenderer *renderer,
render_region = get_render_region (surface, self->context);
gsk_ngl_driver_begin_frame (self->driver, self->command_queue);
- job = gsk_ngl_render_job_new (self->driver, &viewport, scale_factor, render_region, 0, FALSE);
+ job = gsk_ngl_render_job_new (self->driver, &viewport, scale_factor, render_region, 0,
gsk_renderer_get_hdr (renderer));
#ifdef G_ENABLE_DEBUG
if (GSK_RENDERER_DEBUG_CHECK (GSK_RENDERER (self), FALLBACK))
gsk_ngl_render_job_set_debug_fallback (job, TRUE);
@@ -250,7 +250,7 @@ gsk_ngl_renderer_render_texture (GskRenderer *renderer,
&render_target))
{
gsk_ngl_driver_begin_frame (self->driver, self->command_queue);
- job = gsk_ngl_render_job_new (self->driver, viewport, 1, NULL, render_target->framebuffer_id, FALSE);
+ job = gsk_ngl_render_job_new (self->driver, viewport, 1, NULL, render_target->framebuffer_id,
gsk_renderer_get_hdr (renderer));
#ifdef G_ENABLE_DEBUG
if (GSK_RENDERER_DEBUG_CHECK (GSK_RENDERER (self), FALLBACK))
gsk_ngl_render_job_set_debug_fallback (job, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]