diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-09-15 08:26:54 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-09-15 08:28:39 -0400 |
commit | ada6123cad9129921261ddc508ea6fe3cb205afb (patch) | |
tree | db07d5fa00b38d66e040ebe148a2691e51465292 | |
parent | ec6228b3a48950f7104cb26ae8f53ebda06f0868 (diff) | |
download | gtk+-ngl-opacity-fix.tar.gz |
wip: ngl: Try to fix opacity handlingngl-opacity-fix
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
-rw-r--r-- | gsk/ngl/gsknglrenderjob.c | 45 |
1 files 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); } |