Skip to content

Commit

Permalink
gles/element: Take src into account
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakulix committed Jan 23, 2025
1 parent 475072d commit 4a7d5e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/backend/renderer/gles/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ impl Element for PixelShaderElement {
}

fn src(&self) -> Rectangle<f64, Buffer> {
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<f64>) -> Rectangle<i32, Physical> {
Expand Down Expand Up @@ -110,14 +108,16 @@ impl RenderElement<GlesRenderer> for PixelShaderElement {
fn draw(
&self,
frame: &mut GlesFrame<'_>,
_src: Rectangle<f64, Buffer>,
src: Rectangle<f64, Buffer>,
dst: Rectangle<i32, Physical>,
damage: &[Rectangle<i32, Physical>],
_opaque_regions: &[Rectangle<i32, Physical>],
) -> 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,
Expand Down
12 changes: 5 additions & 7 deletions src/backend/renderer/gles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<f64, BufferCoord>,
dest: Rectangle<i32, Physical>,
size: Size<i32, BufferCoord>,
damage: Option<&[Rectangle<i32, Physical>]>,
alpha: f32,
additional_uniforms: &[Uniform<'_>],
Expand Down Expand Up @@ -2810,15 +2813,10 @@ impl GlesFrame<'_> {
}

let mut matrix = Matrix3::<f32>::identity();
let mut tex_matrix = Matrix3::<f32>::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;
Expand All @@ -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
Expand Down

0 comments on commit 4a7d5e6

Please sign in to comment.