diff options
author | Christian Hergert <chergert@redhat.com> | 2022-03-23 20:20:02 -0700 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-04-21 19:15:05 -0400 |
commit | cbd03cda5625ba4a0acfc37395ece2eef1335092 (patch) | |
tree | 801d34ea812b8e3ddfbf2ff9142da482db507771 | |
parent | 018bbd67742d3b9b75eaa22b10f63ed11e0cab2d (diff) | |
download | gtk+-cbd03cda5625ba4a0acfc37395ece2eef1335092.tar.gz |
gdk/gl: handle GL_RGBA/GL_UNSIGNED_NORMALIZED
WebKit's GTK 4 port can give us textures with an internal format of
GL_RGBA with GL_UNSIGNED_NORMALIZED and a bit-depth of 8. This fixes
warnings for every GdkGLTexture created/delivered to the GskGLRenderer.
The format is essentially the same as GL_RGBA8 since it is normalized
between 0.0..1.0 for 8-bit components.
Fixes #4783
-rw-r--r-- | gdk/gdkgltexture.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gdk/gdkgltexture.c b/gdk/gdkgltexture.c index 23bc806c0d..94d877e8a2 100644 --- a/gdk/gdkgltexture.c +++ b/gdk/gdkgltexture.c @@ -365,6 +365,42 @@ gdk_gl_texture_determine_format (GdkGLTexture *self) texture->format = GDK_MEMORY_R32G32B32A32_FLOAT_PREMULTIPLIED; break; + case GL_RGBA: + { + GLint red_size = 0; + GLint green_size = 0; + GLint blue_size = 0; + GLint alpha_size = 0; + GLint red_type = 0; + GLint green_type = 0; + GLint blue_type = 0; + GLint alpha_type = 0; + + glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_RED_TYPE, &red_type); + glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_TYPE, &green_type); + glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_TYPE, &blue_type); + glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_TYPE, &alpha_type); + + glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &red_size); + glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE, &green_size); + glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE, &blue_size); + glGetTexLevelParameteriv (GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &alpha_size); + +#define CHECK_RGBA(rt,gt,bt,at,rs,gs,bs,as) \ + (red_type == rt && green_type == gt && blue_type == bt && alpha_type == at && \ + red_size == rs && green_size == gs && blue_size == bs && alpha_size == as) + + if (CHECK_RGBA (GL_UNSIGNED_NORMALIZED, GL_UNSIGNED_NORMALIZED, GL_UNSIGNED_NORMALIZED, GL_UNSIGNED_NORMALIZED, 8, 8, 8, 8)) + { + texture->format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; + break; + } + +#undef CHECK_RGBA + } + + G_GNUC_FALLTHROUGH; + default: g_warning ("Texture in unexpected format 0x%X (%d). File a bug about adding it to GTK", internal_format, internal_format); /* fallback to the dumbest possible format |