update wlxcapture, dont rotate screen if pre-rotated

This commit is contained in:
galister
2024-02-05 03:11:19 +01:00
parent 74257f4c42
commit 0383596724
2 changed files with 17 additions and 8 deletions

2
Cargo.lock generated
View File

@@ -4175,7 +4175,7 @@ dependencies = [
[[package]] [[package]]
name = "wlx-capture" name = "wlx-capture"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/galister/wlx-capture#e7e5217414b716e433fe2d00d8674b46fc10effb" source = "git+https://github.com/galister/wlx-capture#b49ec2b5fec204fbd192c21ceb66a2a29bebdf62"
dependencies = [ dependencies = [
"ashpd", "ashpd",
"drm-fourcc", "drm-fourcc",

View File

@@ -276,8 +276,7 @@ impl OverlayRenderer for ScreenRenderer {
.create_command_buffer(CommandBufferUsage::OneTimeSubmit); .create_command_buffer(CommandBufferUsage::OneTimeSubmit);
let format = fourcc_to_vk(frame.format.fourcc); let format = fourcc_to_vk(frame.format.fourcc);
let len = frame.format.width as usize * frame.format.height as usize; let data = unsafe { slice::from_raw_parts(frame.ptr as *const u8, frame.size) };
let data = unsafe { slice::from_raw_parts(frame.ptr as *const u8, len) };
let image = let image =
upload.texture2d(frame.format.width, frame.format.height, format, &data); upload.texture2d(frame.format.width, frame.format.height, format, &data);
@@ -364,11 +363,21 @@ where
let axis = Vec3::new(0., 0., 1.); let axis = Vec3::new(0., 0., 1.);
let angle = match output.transform { let logical_ratio = output.logical_size.0 as f32 / output.logical_size.1 as f32;
Transform::_90 | Transform::Flipped90 => PI / 2., let physical_ratio = output.size.0 as f32 / output.size.1 as f32;
Transform::_180 | Transform::Flipped180 => PI,
Transform::_270 | Transform::Flipped270 => -PI / 2., let logical_rotated =
_ => 0., logical_ratio > 1. && physical_ratio < 1. || logical_ratio < 1. && physical_ratio > 1.;
let angle = if logical_rotated {
0.
} else {
match output.transform {
Transform::_90 | Transform::Flipped90 => PI / 2.,
Transform::_180 | Transform::Flipped180 => PI,
Transform::_270 | Transform::Flipped270 => -PI / 2.,
_ => 0.,
}
}; };
let interaction_transform = if output.size.0 >= output.size.1 { let interaction_transform = if output.size.0 >= output.size.1 {