[gtk/ngl-opacity-fix] wip: ngl: Try to fix opacity handling




commit ada6123cad9129921261ddc508ea6fe3cb205afb
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Sep 15 08:26:54 2021 -0400

    wip: ngl: Try to fix opacity handling
    
    We can't put alpha in place before doing the offscreen
    rendering, or it will affect that rendering, in addition
    to being applied by the blit.
    
    I wonder if we should stop carrying around alpha as
    global state altogether. What is that needed for?
    
    This needs investigation of cases where we can avoid
    the offscreen.
    
    Fixes: #4261

 gsk/ngl/gsknglrenderjob.c | 45 +++++++++++++++++++--------------------------
 1 file changed, 19 insertions(+), 26 deletions(-)
---
diff --git a/gsk/ngl/gsknglrenderjob.c b/gsk/ngl/gsknglrenderjob.c
index 4b04310e66..7931f6daad 100644
--- a/gsk/ngl/gsknglrenderjob.c
+++ b/gsk/ngl/gsknglrenderjob.c
@@ -2778,37 +2778,30 @@ gsk_ngl_render_job_visit_opacity_node (GskNglRenderJob     *job,
 
   if (!ALPHA_IS_CLEAR (new_alpha))
     {
-      float prev_alpha = gsk_ngl_render_job_set_alpha (job, new_alpha);
+      GskNglRenderOffscreen offscreen = {0};
 
-      if (gsk_render_node_get_node_type (child) == GSK_CONTAINER_NODE)
-        {
-          GskNglRenderOffscreen offscreen = {0};
+      offscreen.bounds = &child->bounds;
+      offscreen.force_offscreen = TRUE;
+      offscreen.reset_clip = TRUE;
 
-          offscreen.bounds = &child->bounds;
-          offscreen.force_offscreen = TRUE;
-          offscreen.reset_clip = TRUE;
+      /* The semantics of an opacity node mandate that when, e.g., two
+       * color nodes overlap, there may not be any blending between them.
+       */
+      if (!gsk_ngl_render_job_visit_node_with_offscreen (job, child, &offscreen))
+        return;
 
-          /* The semantics of an opacity node mandate that when, e.g., two
-           * color nodes overlap, there may not be any blending between them.
-           */
-          if (!gsk_ngl_render_job_visit_node_with_offscreen (job, child, &offscreen))
-            return;
+      g_assert (offscreen.texture_id);
 
-          g_assert (offscreen.texture_id);
+      float prev_alpha = gsk_ngl_render_job_set_alpha (job, new_alpha);
 
-          gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
-          gsk_ngl_program_set_uniform_texture (job->current_program,
-                                               UNIFORM_SHARED_SOURCE, 0,
-                                               GL_TEXTURE_2D,
-                                               GL_TEXTURE0,
-                                               offscreen.texture_id);
-          gsk_ngl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
-          gsk_ngl_render_job_end_draw (job);
-        }
-      else
-        {
-          gsk_ngl_render_job_visit_node (job, child);
-        }
+      gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, blit));
+      gsk_ngl_program_set_uniform_texture (job->current_program,
+                                           UNIFORM_SHARED_SOURCE, 0,
+                                           GL_TEXTURE_2D,
+                                           GL_TEXTURE0,
+                                           offscreen.texture_id);
+      gsk_ngl_render_job_draw_offscreen (job, &node->bounds, &offscreen);
+      gsk_ngl_render_job_end_draw (job);
 
       gsk_ngl_render_job_set_alpha (job, prev_alpha);
     }


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