From 4a7d5e667d2bdc8a0d5e4bf4c61a820eb08ae230 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Thu, 23 Jan 2025 15:22:27 +0100 Subject: [PATCH] gles/element: Take `src` into account --- src/backend/renderer/gles/element.rs | 8 ++++---- src/backend/renderer/gles/mod.rs | 12 +++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/backend/renderer/gles/element.rs b/src/backend/renderer/gles/element.rs index 6d16fea50c02..d7db1661cffa 100644 --- a/src/backend/renderer/gles/element.rs +++ b/src/backend/renderer/gles/element.rs @@ -80,9 +80,7 @@ impl Element for PixelShaderElement { } fn src(&self) -> Rectangle { - self.area - .to_f64() - .to_buffer(1.0, Transform::Normal, &self.area.size.to_f64()) + Rectangle::from_size(self.area.size.to_f64().to_buffer(1.0, Transform::Normal)) } fn geometry(&self, scale: Scale) -> Rectangle { @@ -110,14 +108,16 @@ impl RenderElement for PixelShaderElement { fn draw( &self, frame: &mut GlesFrame<'_>, - _src: Rectangle, + src: Rectangle, dst: Rectangle, damage: &[Rectangle], _opaque_regions: &[Rectangle], ) -> Result<(), GlesError> { frame.render_pixel_shader_to( &self.shader, + src, dst, + self.area.size.to_buffer(1, Transform::Normal), Some(damage), self.alpha, &self.additional_uniforms, diff --git a/src/backend/renderer/gles/mod.rs b/src/backend/renderer/gles/mod.rs index fdf4e6e8d76e..abbf1f486726 100644 --- a/src/backend/renderer/gles/mod.rs +++ b/src/backend/renderer/gles/mod.rs @@ -2753,10 +2753,13 @@ impl GlesFrame<'_> { /// Render a pixel shader into the current target at a given `dest`-region. #[profiling::function] + #[allow(clippy::too_many_arguments)] pub fn render_pixel_shader_to( &mut self, pixel_shader: &GlesPixelProgram, + src: Rectangle, dest: Rectangle, + size: Size, damage: Option<&[Rectangle]>, alpha: f32, additional_uniforms: &[Uniform<'_>], @@ -2810,15 +2813,10 @@ impl GlesFrame<'_> { } let mut matrix = Matrix3::::identity(); - let mut tex_matrix = Matrix3::::identity(); + let tex_matrix = build_texture_mat(src, dest, size, Transform::Normal); // dest position and scale matrix = matrix * Matrix3::from_translation(Vector2::new(dest.loc.x as f32, dest.loc.y as f32)); - tex_matrix = tex_matrix - * Matrix3::from_nonuniform_scale( - (1.0f64 / dest.size.w as f64) as f32, - (1.0f64 / dest.size.h as f64) as f32, - ); //apply output transformation matrix = self.current_projection * matrix; @@ -2836,7 +2834,7 @@ impl GlesFrame<'_> { gl.UniformMatrix3fv(program.uniform_matrix, 1, ffi::FALSE, matrix.as_ptr()); gl.UniformMatrix3fv(program.uniform_tex_matrix, 1, ffi::FALSE, tex_matrix.as_ptr()); - gl.Uniform2f(program.uniform_size, dest.size.w as f32, dest.size.h as f32); + gl.Uniform2f(program.uniform_size, size.w as f32, size.h as f32); gl.Uniform1f(program.uniform_alpha, alpha); let tint = if self.renderer.debug_flags.contains(DebugFlags::TINT) { 1.0f32