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 {
36 let tex_to_geo = texture_to_geo.to_f64().upscale(scale_to);36 let tex_to_geo = texture_to_geo.to_f64().upscale(scale_to);
37 let combined_geo = tex_from_geo.merge(tex_to_geo);37 let combined_geo = tex_from_geo.merge(tex_to_geo);
38 38
39+ let size = combined_geo
40+ .size
41+ .to_logical(1.)
42+ .to_buffer(1., Transform::Normal);
43+
39 let area = Rectangle::from_loc_and_size(44 let area = Rectangle::from_loc_and_size(
40 area.loc + combined_geo.loc.to_logical(scale).to_i32_round(),45 area.loc + combined_geo.loc.to_logical(scale).to_i32_round(),
41 combined_geo.size.to_logical(scale).to_i32_round(),46 combined_geo.size.to_logical(scale).to_i32_round(),
@@ -57,6 +62,7 @@ impl CrossfadeRenderElement {
57 (String::from("tex_to"), texture_to),62 (String::from("tex_to"), texture_to),
58 ]),63 ]),
59 area,64 area,
65+ size,
60 None,66 None,
61 result_alpha,67 result_alpha,
62 vec![68 vec![
src/render_helpers/primary_gpu_pixel_shader_with_textures.rsmodified+15 -8
@@ -9,7 +9,7 @@ use smithay::backend::renderer::gles::{
9 UniformDesc, UniformName,9 UniformDesc, UniformName,
10 };10 };
11 use smithay::backend::renderer::utils::CommitCounter;11 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};
13 13
14 use super::renderer::AsGlesFrame;14 use super::renderer::AsGlesFrame;
15 use super::resources::Resources;15 use super::resources::Resources;
@@ -25,6 +25,7 @@ pub struct PrimaryGpuPixelShaderWithTexturesRenderElement {
25 id: Id,25 id: Id,
26 commit_counter: CommitCounter,26 commit_counter: CommitCounter,
27 area: Rectangle<i32, Logical>,27 area: Rectangle<i32, Logical>,
28+ size: Size<f64, Buffer>,
28 opaque_regions: Vec<Rectangle<i32, Logical>>,29 opaque_regions: Vec<Rectangle<i32, Logical>>,
29 alpha: f32,30 alpha: f32,
30 additional_uniforms: Vec<Uniform<'static>>,31 additional_uniforms: Vec<Uniform<'static>>,
@@ -122,10 +123,12 @@ impl PixelWithTexturesProgram {
122 }123 }
123 124
124 impl PrimaryGpuPixelShaderWithTexturesRenderElement {125 impl PrimaryGpuPixelShaderWithTexturesRenderElement {
126+ #[allow(clippy::too_many_arguments)]
125 pub fn new(127 pub fn new(
126 shader: PixelWithTexturesProgram,128 shader: PixelWithTexturesProgram,
127 textures: HashMap<String, GlesTexture>,129 textures: HashMap<String, GlesTexture>,
128 area: Rectangle<i32, Logical>,130 area: Rectangle<i32, Logical>,
131+ size: Size<f64, Buffer>,
129 opaque_regions: Option<Vec<Rectangle<i32, Logical>>>,132 opaque_regions: Option<Vec<Rectangle<i32, Logical>>>,
130 alpha: f32,133 alpha: f32,
131 additional_uniforms: Vec<Uniform<'_>>,134 additional_uniforms: Vec<Uniform<'_>>,
@@ -137,6 +140,7 @@ impl PrimaryGpuPixelShaderWithTexturesRenderElement {
137 id: Id::new(),140 id: Id::new(),
138 commit_counter: CommitCounter::default(),141 commit_counter: CommitCounter::default(),
139 area,142 area,
143+ size,
140 opaque_regions: opaque_regions.unwrap_or_default(),144 opaque_regions: opaque_regions.unwrap_or_default(),
141 alpha,145 alpha,
142 additional_uniforms: additional_uniforms146 additional_uniforms: additional_uniforms
@@ -158,9 +162,7 @@ impl Element for PrimaryGpuPixelShaderWithTexturesRenderElement {
158 }162 }
159 163
160 fn src(&self) -> Rectangle<f64, Buffer> {164 fn src(&self) -> Rectangle<f64, Buffer> {
161- self.area165+ Rectangle::from_loc_and_size((0., 0.), self.size.to_f64())
162- .to_f64()
163- .to_buffer(1.0, Transform::Normal, &self.area.size.to_f64())
164 }166 }
165 167
166 fn geometry(&self, scale: Scale<f64>) -> Rectangle<i32, Physical> {168 fn geometry(&self, scale: Scale<f64>) -> Rectangle<i32, Physical> {
@@ -187,7 +189,7 @@ impl RenderElement<GlesRenderer> for PrimaryGpuPixelShaderWithTexturesRenderElem
187 fn draw(189 fn draw(
188 &self,190 &self,
189 frame: &mut GlesFrame<'_>,191 frame: &mut GlesFrame<'_>,
190- _src: Rectangle<f64, Buffer>,192+ src: Rectangle<f64, Buffer>,
191 dest: Rectangle<i32, Physical>,193 dest: Rectangle<i32, Physical>,
192 damage: &[Rectangle<i32, Physical>],194 damage: &[Rectangle<i32, Physical>],
193 ) -> Result<(), GlesError> {195 ) -> Result<(), GlesError> {
@@ -253,10 +255,15 @@ impl RenderElement<GlesRenderer> for PrimaryGpuPixelShaderWithTexturesRenderElem
253 255
254 // dest position and scale256 // dest position and scale
255 let mut matrix = Mat3::from_translation(Vec2::new(dest.loc.x as f32, dest.loc.y as f32));257 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;
256 let tex_matrix = Mat3::from_scale(Vec2::new(263 let tex_matrix = Mat3::from_scale(Vec2::new(
257- (1.0f64 / dest.size.w as f64) as f32,264+ (1.0f64 / self.size.w) as f32,
258- (1.0f64 / dest.size.h as f64) as f32,265+ (1.0f64 / self.size.h) as f32,
259- ));266+ )) * tex_matrix;
260 267
261 //apply output transformation268 //apply output transformation
262 matrix = Mat3::from_cols_array(frame.projection()) * matrix;269 matrix = Mat3::from_cols_array(frame.projection()) * matrix;