forge
Explore
Log in

Don't you dare go Hollow

Fix crop + crossfade artifacts

Browse files at this commit

0fcd981b86029ce4a554bf4805221a104a9228a7Ivan MolodetskikhParent: 5c4153e
src/render_helpers/crossfade.rsmodified+6 -0
@@ -36,6 +36,11 @@ impl CrossfadeRenderElement {
3636 let tex_to_geo = texture_to_geo.to_f64().upscale(scale_to);
3737 let combined_geo = tex_from_geo.merge(tex_to_geo);
3838
39+ let size = combined_geo
40+ .size
41+ .to_logical(1.)
42+ .to_buffer(1., Transform::Normal);
43+
3944 let area = Rectangle::from_loc_and_size(
4045 area.loc + combined_geo.loc.to_logical(scale).to_i32_round(),
4146 combined_geo.size.to_logical(scale).to_i32_round(),
@@ -57,6 +62,7 @@ impl CrossfadeRenderElement {
5762 (String::from("tex_to"), texture_to),
5863 ]),
5964 area,
65+ size,
6066 None,
6167 result_alpha,
6268 vec![
src/render_helpers/primary_gpu_pixel_shader_with_textures.rsmodified+15 -8
@@ -9,7 +9,7 @@ use smithay::backend::renderer::gles::{
99 UniformDesc, UniformName,
1010 };
1111 use smithay::backend::renderer::utils::CommitCounter;
12-use smithay::utils::{Buffer, Logical, Physical, Rectangle, Scale, Transform};
12+use smithay::utils::{Buffer, Logical, Physical, Rectangle, Scale, Size};
1313
1414 use super::renderer::AsGlesFrame;
1515 use super::resources::Resources;
@@ -25,6 +25,7 @@ pub struct PrimaryGpuPixelShaderWithTexturesRenderElement {
2525 id: Id,
2626 commit_counter: CommitCounter,
2727 area: Rectangle<i32, Logical>,
28+ size: Size<f64, Buffer>,
2829 opaque_regions: Vec<Rectangle<i32, Logical>>,
2930 alpha: f32,
3031 additional_uniforms: Vec<Uniform<'static>>,
@@ -122,10 +123,12 @@ impl PixelWithTexturesProgram {
122123 }
123124
124125 impl PrimaryGpuPixelShaderWithTexturesRenderElement {
126+ #[allow(clippy::too_many_arguments)]
125127 pub fn new(
126128 shader: PixelWithTexturesProgram,
127129 textures: HashMap<String, GlesTexture>,
128130 area: Rectangle<i32, Logical>,
131+ size: Size<f64, Buffer>,
129132 opaque_regions: Option<Vec<Rectangle<i32, Logical>>>,
130133 alpha: f32,
131134 additional_uniforms: Vec<Uniform<'_>>,
@@ -137,6 +140,7 @@ impl PrimaryGpuPixelShaderWithTexturesRenderElement {
137140 id: Id::new(),
138141 commit_counter: CommitCounter::default(),
139142 area,
143+ size,
140144 opaque_regions: opaque_regions.unwrap_or_default(),
141145 alpha,
142146 additional_uniforms: additional_uniforms
@@ -158,9 +162,7 @@ impl Element for PrimaryGpuPixelShaderWithTexturesRenderElement {
158162 }
159163
160164 fn src(&self) -> Rectangle<f64, Buffer> {
161- self.area
162- .to_f64()
163- .to_buffer(1.0, Transform::Normal, &self.area.size.to_f64())
165+ Rectangle::from_loc_and_size((0., 0.), self.size.to_f64())
164166 }
165167
166168 fn geometry(&self, scale: Scale<f64>) -> Rectangle<i32, Physical> {
@@ -187,7 +189,7 @@ impl RenderElement<GlesRenderer> for PrimaryGpuPixelShaderWithTexturesRenderElem
187189 fn draw(
188190 &self,
189191 frame: &mut GlesFrame<'_>,
190- _src: Rectangle<f64, Buffer>,
192+ src: Rectangle<f64, Buffer>,
191193 dest: Rectangle<i32, Physical>,
192194 damage: &[Rectangle<i32, Physical>],
193195 ) -> Result<(), GlesError> {
@@ -253,10 +255,15 @@ impl RenderElement<GlesRenderer> for PrimaryGpuPixelShaderWithTexturesRenderElem
253255
254256 // dest position and scale
255257 let mut matrix = Mat3::from_translation(Vec2::new(dest.loc.x as f32, dest.loc.y as f32));
258+
259+ let scale = src.size.to_f64() / dest.size.to_f64();
260+ let tex_matrix = Mat3::from_scale(Vec2::new(scale.x as f32, scale.y as f32));
261+ let tex_matrix =
262+ Mat3::from_translation(Vec2::new(src.loc.x as f32, src.loc.y as f32)) * tex_matrix;
256263 let tex_matrix = Mat3::from_scale(Vec2::new(
257- (1.0f64 / dest.size.w as f64) as f32,
258- (1.0f64 / dest.size.h as f64) as f32,
259- ));
264+ (1.0f64 / self.size.w) as f32,
265+ (1.0f64 / self.size.h) as f32,
266+ )) * tex_matrix;
260267
261268 //apply output transformation
262269 matrix = Mat3::from_cols_array(frame.projection()) * matrix;