This commit fixes a performance issue on X11 systems in regards to drawing on an...
authorhenry <henry.riehl@btinternet.com>
Wed, 31 May 2023 22:05:19 +0000 (23:05 +0100)
committerSimon McVittie <smcv@debian.org>
Wed, 8 Nov 2023 16:30:21 +0000 (16:30 +0000)
This commit fixes a performance issue on X11 systems making use of the gdk_cairo_draw_from_gl() function in regards
to drawing on an OpenGL surface in GTK/GDK. Specifically, this fix removes the slow X11 codepath that was used when
executing the gdk_cairo_draw_from_gl() function because it was completely uneeded. I tested the before and after on
Flutter and GTK apps making use of the OpenGL rendering and can confirm that there is no behaviour and visual
difference. This change is also specific to drawings that make use of textures. The render buffer code path has
been left completely unmodified.

Bug: https://gitlab.gnome.org/GNOME/gtk/-/issues/4704
Origin: 3.24.39, commit:7237f5d0eb5ec2f1411a28b9394ff4c4472f4d8b

Gbp-Pq: Name This-commit-fixes-a-performance-issue-on-X11-systems-in-r.patch

gdk/gdkgl.c

index 666b5e81335a53e93678a3d9c46ff7d409c8c9bb..86b169039a8d7921117debc2f72f467c78c20ebd 100644 (file)
@@ -392,11 +392,7 @@ gdk_cairo_draw_from_gl (cairo_t              *cr,
   else if (source_type == GL_TEXTURE)
     {
       glBindTexture (GL_TEXTURE_2D, source);
-
-      if (gdk_gl_context_get_use_es (paint_context))
-        alpha_size = 1;
-      else
-        glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE,  &alpha_size);
+      glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE,  &alpha_size);
     }
   else
     {
@@ -540,30 +536,6 @@ gdk_cairo_draw_from_gl (cairo_t              *cr,
       /* Translate to impl coords */
       cairo_region_translate (clip_region, dx, dy);
 
-      if (alpha_size != 0)
-        {
-          cairo_region_t *opaque_region, *blend_region;
-
-          opaque_region = cairo_region_copy (clip_region);
-          cairo_region_subtract (opaque_region, impl_window->current_paint.flushed_region);
-          cairo_region_subtract (opaque_region, impl_window->current_paint.need_blend_region);
-
-          if (!cairo_region_is_empty (opaque_region))
-            gdk_gl_texture_from_surface (impl_window->current_paint.surface,
-                                         opaque_region);
-
-          blend_region = cairo_region_copy (clip_region);
-          cairo_region_intersect (blend_region, impl_window->current_paint.need_blend_region);
-
-          glEnable (GL_BLEND);
-          if (!cairo_region_is_empty (blend_region))
-            gdk_gl_texture_from_surface (impl_window->current_paint.surface,
-                                         blend_region);
-
-          cairo_region_destroy (opaque_region);
-          cairo_region_destroy (blend_region);
-        }
-
       glBindTexture (GL_TEXTURE_2D, source);
 
       if (gdk_gl_context_get_use_es (paint_context))