Skip to content

Commit 4a7d5e6

Browse files
committed
gles/element: Take src into account
1 parent 475072d commit 4a7d5e6

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/backend/renderer/gles/element.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ impl Element for PixelShaderElement {
8080
}
8181

8282
fn src(&self) -> Rectangle<f64, Buffer> {
83-
self.area
84-
.to_f64()
85-
.to_buffer(1.0, Transform::Normal, &self.area.size.to_f64())
83+
Rectangle::from_size(self.area.size.to_f64().to_buffer(1.0, Transform::Normal))
8684
}
8785

8886
fn geometry(&self, scale: Scale<f64>) -> Rectangle<i32, Physical> {
@@ -110,14 +108,16 @@ impl RenderElement<GlesRenderer> for PixelShaderElement {
110108
fn draw(
111109
&self,
112110
frame: &mut GlesFrame<'_>,
113-
_src: Rectangle<f64, Buffer>,
111+
src: Rectangle<f64, Buffer>,
114112
dst: Rectangle<i32, Physical>,
115113
damage: &[Rectangle<i32, Physical>],
116114
_opaque_regions: &[Rectangle<i32, Physical>],
117115
) -> Result<(), GlesError> {
118116
frame.render_pixel_shader_to(
119117
&self.shader,
118+
src,
120119
dst,
120+
self.area.size.to_buffer(1, Transform::Normal),
121121
Some(damage),
122122
self.alpha,
123123
&self.additional_uniforms,

src/backend/renderer/gles/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2753,10 +2753,13 @@ impl GlesFrame<'_> {
27532753

27542754
/// Render a pixel shader into the current target at a given `dest`-region.
27552755
#[profiling::function]
2756+
#[allow(clippy::too_many_arguments)]
27562757
pub fn render_pixel_shader_to(
27572758
&mut self,
27582759
pixel_shader: &GlesPixelProgram,
2760+
src: Rectangle<f64, BufferCoord>,
27592761
dest: Rectangle<i32, Physical>,
2762+
size: Size<i32, BufferCoord>,
27602763
damage: Option<&[Rectangle<i32, Physical>]>,
27612764
alpha: f32,
27622765
additional_uniforms: &[Uniform<'_>],
@@ -2810,15 +2813,10 @@ impl GlesFrame<'_> {
28102813
}
28112814

28122815
let mut matrix = Matrix3::<f32>::identity();
2813-
let mut tex_matrix = Matrix3::<f32>::identity();
2816+
let tex_matrix = build_texture_mat(src, dest, size, Transform::Normal);
28142817

28152818
// dest position and scale
28162819
matrix = matrix * Matrix3::from_translation(Vector2::new(dest.loc.x as f32, dest.loc.y as f32));
2817-
tex_matrix = tex_matrix
2818-
* Matrix3::from_nonuniform_scale(
2819-
(1.0f64 / dest.size.w as f64) as f32,
2820-
(1.0f64 / dest.size.h as f64) as f32,
2821-
);
28222820

28232821
//apply output transformation
28242822
matrix = self.current_projection * matrix;
@@ -2836,7 +2834,7 @@ impl GlesFrame<'_> {
28362834

28372835
gl.UniformMatrix3fv(program.uniform_matrix, 1, ffi::FALSE, matrix.as_ptr());
28382836
gl.UniformMatrix3fv(program.uniform_tex_matrix, 1, ffi::FALSE, tex_matrix.as_ptr());
2839-
gl.Uniform2f(program.uniform_size, dest.size.w as f32, dest.size.h as f32);
2837+
gl.Uniform2f(program.uniform_size, size.w as f32, size.h as f32);
28402838
gl.Uniform1f(program.uniform_alpha, alpha);
28412839
let tint = if self.renderer.debug_flags.contains(DebugFlags::TINT) {
28422840
1.0f32

0 commit comments

Comments
 (0)