diff --git a/src/backend/renderer/gles2/mod.rs b/src/backend/renderer/gles2/mod.rs index 2cb6486..5e1750e 100644 --- a/src/backend/renderer/gles2/mod.rs +++ b/src/backend/renderer/gles2/mod.rs @@ -373,8 +373,6 @@ impl Gles2Renderer { let programs = [ texture_program(&gl, shaders::FRAGMENT_SHADER_ABGR)?, texture_program(&gl, shaders::FRAGMENT_SHADER_XBGR)?, - texture_program(&gl, shaders::FRAGMENT_SHADER_BGRA)?, - texture_program(&gl, shaders::FRAGMENT_SHADER_BGRX)?, texture_program(&gl, shaders::FRAGMENT_SHADER_EXTERNAL)?, ]; @@ -459,8 +457,8 @@ impl Gles2Renderer { let (gl_format, shader_idx) = match data.format { wl_shm::Format::Abgr8888 => (ffi::RGBA, 0), wl_shm::Format::Xbgr8888 => (ffi::RGBA, 1), - wl_shm::Format::Argb8888 => (ffi::BGRA_EXT, 2), - wl_shm::Format::Xrgb8888 => (ffi::BGRA_EXT, 3), + wl_shm::Format::Argb8888 => (ffi::BGRA_EXT, 0), + wl_shm::Format::Xrgb8888 => (ffi::BGRA_EXT, 1), format => return Err(Gles2Error::UnsupportedPixelFormat(format)), }; @@ -493,7 +491,7 @@ impl Gles2Renderer { width, height, 0, - ffi::RGBA, + gl_format, ffi::UNSIGNED_BYTE as u32, slice.as_ptr() as *const _, ); @@ -551,9 +549,9 @@ impl Gles2Renderer { Gles2Texture(Rc::new(Gles2TextureInternal { texture: tex, texture_kind: match new_buffer.format { - EGLFormat::RGB => 3, - EGLFormat::RGBA => 2, - EGLFormat::External => 4, + EGLFormat::RGB => 1, + EGLFormat::RGBA => 0, + EGLFormat::External => 2, _ => unreachable!("EGLBuffer currenly does not expose multi-planar buffers to us"), }, is_external: new_buffer.format == EGLFormat::External, diff --git a/src/backend/renderer/gles2/shaders.rs b/src/backend/renderer/gles2/shaders.rs index c23f56c..f17ef6c 100644 --- a/src/backend/renderer/gles2/shaders.rs +++ b/src/backend/renderer/gles2/shaders.rs @@ -17,7 +17,7 @@ void main() { } }"#; -pub const FRAGMENT_COUNT: usize = 5; +pub const FRAGMENT_COUNT: usize = 3; pub const FRAGMENT_SHADER_ABGR: &str = r#" #version 100 @@ -26,11 +26,7 @@ uniform sampler2D tex; uniform float alpha; varying vec2 v_tex_coords; void main() { - vec4 color = texture2D(tex, v_tex_coords); - gl_FragColor.r = color.w; - gl_FragColor.g = color.z; - gl_FragColor.b = color.y; - gl_FragColor.a = color.x * alpha; + gl_FragColor = texture2D(tex, v_tex_coords) * alpha; } "#; @@ -41,41 +37,7 @@ uniform sampler2D tex; uniform float alpha; varying vec2 v_tex_coords; void main() { - vec4 color = texture2D(tex, v_tex_coords); - gl_FragColor.r = color.w; - gl_FragColor.g = color.z; - gl_FragColor.b = color.y; - gl_FragColor.a = alpha; -} -"#; - -pub const FRAGMENT_SHADER_BGRA: &str = r#" -#version 100 -precision mediump float; -uniform sampler2D tex; -uniform float alpha; -varying vec2 v_tex_coords; -void main() { - vec4 color = texture2D(tex, v_tex_coords); - gl_FragColor.r = color.z; - gl_FragColor.g = color.y; - gl_FragColor.b = color.x; - gl_FragColor.a = color.w * alpha; -} -"#; - -pub const FRAGMENT_SHADER_BGRX: &str = r#" -#version 100 -precision mediump float; -uniform sampler2D tex; -uniform float alpha; -varying vec2 v_tex_coords; -void main() { - vec4 color = texture2D(tex, v_tex_coords); - gl_FragColor.r = color.z; - gl_FragColor.g = color.y; - gl_FragColor.b = color.x; - gl_FragColor.a = alpha; + gl_FragColor = vec4(texture2D(tex, v_tex_coords).rgb, 1.0) * alpha; } "#;