[gtk/wip/matthiasc/gsk-hdr: 3/6] gsk: Add hdr rendernode api




commit 3303fb2bc067a51a6517a9312f3500c580798ae1
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Oct 1 16:23:12 2021 -0400

    gsk: Add hdr rendernode api
    
    Add private api to find out if the content
    of a render node should be considered HDR.
    
    The information is collected at creation time,
    so there is no tree-walking involved when we
    are using this information in the renderer.
    
    Currently, this comes down to whether there are
    any texture nodes with HDR textures in the subtree.
    In the future, we may want to allow marking gradient
    nodes as HDR as well.

 gsk/gskrendernode.c        |  5 +++++
 gsk/gskrendernodeimpl.c    | 31 ++++++++++++++++++++++++++++++-
 gsk/gskrendernodeprivate.h |  3 +++
 3 files changed, 38 insertions(+), 1 deletion(-)
---
diff --git a/gsk/gskrendernode.c b/gsk/gskrendernode.c
index 9c4332fe01..175b9399ad 100644
--- a/gsk/gskrendernode.c
+++ b/gsk/gskrendernode.c
@@ -725,3 +725,8 @@ gsk_value_dup_render_node (const GValue *value)
   return gsk_render_node_ref (value->data[0].v_pointer);
 }
 
+gboolean
+gsk_render_node_is_hdr (const GskRenderNode *node)
+{
+  return node->is_hdr;
+}
diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c
index fd2a9e5d44..dd4d8932c6 100644
--- a/gsk/gskrendernodeimpl.c
+++ b/gsk/gskrendernodeimpl.c
@@ -1560,6 +1560,8 @@ gsk_texture_node_new (GdkTexture            *texture,
   self->texture = g_object_ref (texture);
   graphene_rect_init_from_rect (&node->bounds, bounds);
 
+  node->is_hdr = gdk_texture_is_hdr (texture);
+
   return node;
 }
 
@@ -2730,11 +2732,13 @@ gsk_container_node_new (GskRenderNode **children,
 
       self->children[0] = gsk_render_node_ref (children[0]);
       graphene_rect_init_from_rect (&bounds, &(children[0]->bounds));
+      node->is_hdr = gsk_render_node_is_hdr (children[0]);
 
       for (guint i = 1; i < n_children; i++)
         {
           self->children[i] = gsk_render_node_ref (children[i]);
           graphene_rect_union (&bounds, &(children[i]->bounds), &bounds);
+          node->is_hdr |= gsk_render_node_is_hdr (children[i]);
         }
 
       graphene_rect_init_from_rect (&node->bounds, &bounds);
@@ -2965,6 +2969,8 @@ gsk_transform_node_new (GskRenderNode *child,
                                   &child->bounds,
                                   &node->bounds);
 
+  node->is_hdr = gsk_render_node_is_hdr (child);
+
   return node;
 }
 
@@ -3100,6 +3106,8 @@ gsk_opacity_node_new (GskRenderNode *child,
 
   graphene_rect_init_from_rect (&node->bounds, &child->bounds);
 
+  node->is_hdr = gsk_render_node_is_hdr (child);
+
   return node;
 }
 
@@ -3302,6 +3310,8 @@ gsk_color_matrix_node_new (GskRenderNode           *child,
 
   graphene_rect_init_from_rect (&node->bounds, &child->bounds);
 
+  node->is_hdr = gsk_render_node_is_hdr (child);
+
   return node;
 }
 
@@ -3451,6 +3461,8 @@ gsk_repeat_node_new (const graphene_rect_t *bounds,
   else
     graphene_rect_init_from_rect (&self->child_bounds, &child->bounds);
 
+  node->is_hdr = gsk_render_node_is_hdr (child);
+
   return node;
 }
 
@@ -3582,6 +3594,8 @@ gsk_clip_node_new (GskRenderNode         *child,
 
   graphene_rect_intersection (&self->clip, &child->bounds, &node->bounds);
 
+  node->is_hdr = gsk_render_node_is_hdr (child);
+
   return node;
 }
 
@@ -3713,6 +3727,8 @@ gsk_rounded_clip_node_new (GskRenderNode         *child,
 
   graphene_rect_intersection (&self->clip.bounds, &child->bounds, &node->bounds);
 
+  node->is_hdr = gsk_render_node_is_hdr (child);
+
   return node;
 }
 
@@ -3932,6 +3948,8 @@ gsk_shadow_node_new (GskRenderNode   *child,
 
   gsk_shadow_node_get_bounds (self, &node->bounds);
 
+  node->is_hdr = gsk_render_node_is_hdr (child);
+
   return node;
 }
 
@@ -4125,6 +4143,8 @@ gsk_blend_node_new (GskRenderNode *bottom,
 
   graphene_rect_union (&bottom->bounds, &top->bounds, &node->bounds);
 
+  node->is_hdr = gsk_render_node_is_hdr (bottom) || gsk_render_node_is_hdr (top);
+
   return node;
 }
 
@@ -4273,6 +4293,8 @@ gsk_cross_fade_node_new (GskRenderNode *start,
 
   graphene_rect_union (&start->bounds, &end->bounds, &node->bounds);
 
+  node->is_hdr = gsk_render_node_is_hdr (start) || gsk_render_node_is_hdr (end);
+
   return node;
 }
 
@@ -4864,6 +4886,8 @@ gsk_blur_node_new (GskRenderNode *child,
                        - clip_radius,
                        - clip_radius);
 
+  node->is_hdr = gsk_render_node_is_hdr (child);
+
   return node;
 }
 
@@ -4986,6 +5010,8 @@ gsk_debug_node_new (GskRenderNode *child,
 
   graphene_rect_init_from_rect (&node->bounds, &child->bounds);
 
+  node->is_hdr = gsk_render_node_is_hdr (child);
+
   return node;
 }
 
@@ -5150,7 +5176,10 @@ gsk_gl_shader_node_new (GskGLShader           *shader,
     {
       self->children = g_malloc_n (n_children, sizeof (GskRenderNode *));
       for (guint i = 0; i < n_children; i++)
-        self->children[i] = gsk_render_node_ref (children[i]);
+        {
+          self->children[i] = gsk_render_node_ref (children[i]);
+          node->is_hdr |= gsk_render_node_is_hdr (children[i]);
+        }
     }
 
   return node;
diff --git a/gsk/gskrendernodeprivate.h b/gsk/gskrendernodeprivate.h
index ac20813b65..9c9bb5b372 100644
--- a/gsk/gskrendernodeprivate.h
+++ b/gsk/gskrendernodeprivate.h
@@ -27,6 +27,8 @@ struct _GskRenderNode
   gatomicrefcount ref_count;
 
   graphene_rect_t bounds;
+
+  guint is_hdr : 1;
 };
 
 struct _GskRenderNodeClass
@@ -109,6 +111,7 @@ GskRenderNode ** gsk_container_node_get_children        (const GskRenderNode *no
 void             gsk_transform_node_get_translate       (const GskRenderNode *node,
                                                          float               *dx,
                                                          float               *dy);
+gboolean       gsk_render_node_is_hdr                   (const GskRenderNode *node);
 
 
 G_END_DECLS


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