Skip to content

Commit

Permalink
Use untransformed texture in MirroringState::new_with_renderer
Browse files Browse the repository at this point in the history
Apply inverse of output transform to mode to get render size, and apply
no transform during rendering. The transform of the output being
mirrored from shouldn't affect the final render.

Fixes issues when source output for mirroring has a transform, and also
fixes issues in #1058
when this code is used for postprocessing, where this resulted in the
same transform being applied twice.
  • Loading branch information
ids1024 committed Jan 28, 2025
1 parent 63995c4 commit 84e7e5e
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/backend/kms/surface/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,25 +159,32 @@ impl MirroringState {
format: Fourcc,
output: &Output,
) -> Result<Self> {
let size = output
.current_mode()
.map(|mode| mode.size)
.unwrap_or_default()
.to_logical(1)
.to_buffer(1, Transform::Normal);
let opaque_regions = vec![Rectangle::from_size(size)];

let texture = Offscreen::<GlesTexture>::create_buffer(renderer, format, size)?;
let transform = output.current_transform();
// Apply inverse of output transform to mode size to get correct size
// for an untransformed render.
let size = output.current_transform().invert().transform_size(
output
.current_mode()
.map(|mode| mode.size)
.unwrap_or_default(),
);
let buffer_size = size.to_logical(1).to_buffer(1, Transform::Normal);
let opaque_regions = vec![Rectangle::from_size(buffer_size)];

let texture = Offscreen::<GlesTexture>::create_buffer(renderer, format, buffer_size)?;
let texture_buffer = TextureRenderBuffer::from_texture(
renderer,
texture,
1,
transform,
Transform::Normal,
Some(opaque_regions),
);

let damage_tracker = OutputDamageTracker::from_output(output);
// Don't use `from_output` to avoid applying output transform
let damage_tracker = OutputDamageTracker::new(
size,
output.current_scale().fractional_scale(),
Transform::Normal,
);

Ok(MirroringState {
texture: texture_buffer,
Expand Down

0 comments on commit 84e7e5e

Please sign in to comment.