Merge branch 'transparent-optimizations' into 'master'

snapshot: Handle transparent opacity nodes correctly

See merge request GNOME/gtk!3754
This commit is contained in:
Matthias Clasen 2021-07-15 18:39:48 +00:00
commit b70b058b66
2 changed files with 19 additions and 3 deletions

View File

@ -1373,11 +1373,16 @@ static inline void
gsk_ngl_render_job_visit_color_node (GskNglRenderJob *job,
const GskRenderNode *node)
{
const GdkRGBA *rgba;
guint16 color[4];
GskNglProgram *program;
GskNglCommandBatch *batch;
rgba_to_half (gsk_color_node_get_color (node), color);
rgba = gsk_color_node_get_color (node);
if (gdk_rgba_is_clear (rgba))
return;
rgba_to_half (rgba, color);
/* Avoid switching away from the coloring program for
* rendering a solid color.
@ -2845,7 +2850,12 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
* We tell the shader by setting the color to vec4(-1).
*/
if (force_color || !gsk_text_node_has_color_glyphs (node))
rgba_to_half (color, c);
{
if (gdk_rgba_is_clear (color))
return;
rgba_to_half (color, c);
}
lookup.font = (PangoFont *)font;
lookup.scale = (guint) (text_scale * 1024);

View File

@ -30,6 +30,8 @@
#include "gtkstylecontextprivate.h"
#include "gsktransformprivate.h"
#include "gdk/gdkrgbaprivate.h"
#include "gsk/gskrendernodeprivate.h"
#include "gsk/gskroundedrectprivate.h"
@ -461,8 +463,12 @@ gtk_snapshot_collect_opacity (GtkSnapshot *snapshot,
}
else if (state->data.opacity.opacity == 0.0)
{
GdkRGBA color = GDK_RGBA ("00000000");
graphene_rect_t bounds;
gsk_render_node_get_bounds (node, &bounds);
opacity_node = gsk_color_node_new (&color, &bounds);
gsk_render_node_unref (node);
opacity_node = NULL;
}
else
{