[vlc-commits] opengl: add BGRA texture support
Thomas Guillem
git at videolan.org
Mon Oct 2 10:32:30 CEST 2017
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Oct 2 09:50:32 2017 +0200| [36c90dad5e97a50988574929b9d4cbb1c02a4027] | committer: Thomas Guillem
opengl: add BGRA texture support
Refs #18870
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=36c90dad5e97a50988574929b9d4cbb1c02a4027
---
modules/video_output/opengl/fragment_shaders.c | 33 +++++++++++++++++++++-----
1 file changed, 27 insertions(+), 6 deletions(-)
diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c
index 3d04202568..3462f296c9 100644
--- a/modules/video_output/opengl/fragment_shaders.c
+++ b/modules/video_output/opengl/fragment_shaders.c
@@ -38,6 +38,9 @@
#ifndef GL_R16
# define GL_R16 0x822A
#endif
+#ifndef GL_BGRA
+# define GL_BGRA 0x80E1
+#endif
#ifndef GL_LUMINANCE16
# define GL_LUMINANCE16 0x8042
#endif
@@ -55,8 +58,11 @@ static int GetTexFormatSize(opengl_tex_converter_t *tc, int target,
return -1;
GLint tex_param_size;
+ int mul = 1;
switch (tex_format)
{
+ case GL_BGRA:
+ mul = 4;
case GL_RED:
tex_param_size = GL_TEXTURE_RED_SIZE;
break;
@@ -75,7 +81,7 @@ static int GetTexFormatSize(opengl_tex_converter_t *tc, int target,
tc->vt->GetTexLevelParameteriv(target, 0, tex_param_size, &size);
tc->vt->DeleteTextures(1, &texture);
- return size;
+ return size > 0 ? size * mul : size;
}
static int
@@ -252,13 +258,28 @@ tc_rgb_base_init(opengl_tex_converter_t *tc, GLenum tex_target,
{
(void) tex_target;
- if (chroma != VLC_CODEC_RGB32)
- return VLC_EGENERIC;
tc->tex_count = 1;
- tc->texs[0] = (struct opengl_tex_cfg) {
- { 1, 1 }, { 1, 1 }, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE
- };
+ switch (chroma)
+ {
+ case VLC_CODEC_RGB32:
+ case VLC_CODEC_RGBA:
+ tc->texs[0] = (struct opengl_tex_cfg) {
+ { 1, 1 }, { 1, 1 }, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE
+ };
+ break;
+ case VLC_CODEC_BGRA: {
+ if (GetTexFormatSize(tc, tex_target, GL_BGRA, GL_RGBA,
+ GL_UNSIGNED_BYTE) != 32)
+ return VLC_EGENERIC;
+ tc->texs[0] = (struct opengl_tex_cfg) {
+ { 1, 1 }, { 1, 1 }, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE
+ };
+ break;
+ }
+ default:
+ return VLC_EGENERIC;
+ }
return VLC_SUCCESS;
}
More information about the vlc-commits
mailing list