memoryformat: Check for BGRA support

Check for whether the GL context we are using
supports uploads with GL_BGRA before returning
that memory format.

Fixes: #6171
This commit is contained in:
Matthias Clasen 2023-10-19 11:52:47 -04:00
parent b95d8ebdd3
commit 583ad47b03

View File

@ -20,7 +20,7 @@
#include "config.h"
#include "gdkmemoryformatprivate.h"
#include "gdkglcontext.h"
#include "gdkglcontextprivate.h"
#include "gsk/gl/fp16private.h"
@ -353,7 +353,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
4,
G_ALIGNOF (guchar),
GDK_MEMORY_U8,
{ 0, 0, G_MAXUINT, G_MAXUINT },
{ 0, 0, 0, 0 },
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
b8g8r8a8_premultiplied_to_float,
b8g8r8a8_premultiplied_from_float,
@ -383,7 +383,7 @@ static const GdkMemoryFormatDescription memory_formats[] = {
4,
G_ALIGNOF (guchar),
GDK_MEMORY_U8,
{ 0, 0, G_MAXUINT, G_MAXUINT },
{ 0, 0, 0, 0 },
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA } },
b8g8r8a8_to_float,
b8g8r8a8_from_float,
@ -758,6 +758,9 @@ gdk_memory_format_gl_format (GdkMemoryFormat format,
(memory_formats[format].min_gl_version.gles_major == gl_major &&
memory_formats[format].min_gl_version.gles_minor > gl_minor))
return FALSE;
if (*out_format == GL_BGRA && !gdk_gl_context_has_bgra (context))
return FALSE;
}
else
{