gl: handle B8G8R8 texture data when uploading
authorChristian Hergert <chergert@redhat.com>
Mon, 8 Feb 2021 23:30:58 +0000 (15:30 -0800)
committerChristian Hergert <chergert@redhat.com>
Mon, 8 Feb 2021 23:32:12 +0000 (15:32 -0800)
We do not need to translate this on the CPU when we can instead push it
to the GPU in the same format and allow it to swizzle.

This fixes a huge number of memory allocations found while uploading the
GTK animation in widget-factory.

gdk/gdkglcontext.c

index 5d73080b9bb76d3d4458c819771651f0bff7c6f1..3bc52b74fb34e059b82000f4e9b2e9c31a2391dc 100644 (file)
@@ -271,6 +271,12 @@ gdk_gl_context_upload_texture (GdkGLContext    *context,
           gl_type = GL_UNSIGNED_BYTE;
           bpp = 3;
         }
+      else if (data_format == GDK_MEMORY_B8G8R8)
+        {
+          gl_format = GL_BGR;
+          gl_type = GL_UNSIGNED_BYTE;
+          bpp = 3;
+        }
       else /* Fall-back, convert to cairo-surface-format */
         {
           copy = g_malloc (width * height * 4);